Merge remote-tracking branch 'origin/3.0' into fix/mnode
This commit is contained in:
commit
1e41ba8c14
127
Jenkinsfile2
127
Jenkinsfile2
|
@ -33,16 +33,17 @@ def abort_previous(){
|
||||||
milestone(buildNumber)
|
milestone(buildNumber)
|
||||||
}
|
}
|
||||||
def pre_test(){
|
def pre_test(){
|
||||||
sh 'hostname'
|
|
||||||
sh '''
|
sh '''
|
||||||
|
hostname
|
||||||
date
|
date
|
||||||
sudo rmtaos || echo "taosd has not installed"
|
|
||||||
'''
|
'''
|
||||||
sh '''
|
sh '''
|
||||||
killall -9 taosd ||echo "no taosd running"
|
cd ${WK}
|
||||||
killall -9 gdb || echo "no gdb running"
|
git reset --hard
|
||||||
killall -9 python3.8 || echo "no python program running"
|
git fetch || git fetch
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
|
git reset --hard
|
||||||
|
git fetch || git fetch
|
||||||
'''
|
'''
|
||||||
script {
|
script {
|
||||||
if (env.CHANGE_TARGET == 'master') {
|
if (env.CHANGE_TARGET == 'master') {
|
||||||
|
@ -81,10 +82,10 @@ def pre_test(){
|
||||||
git pull >/dev/null
|
git pull >/dev/null
|
||||||
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||||
git checkout -qf FETCH_HEAD
|
git checkout -qf FETCH_HEAD
|
||||||
git log|head -n20
|
git log -5
|
||||||
cd ${WK}
|
cd ${WK}
|
||||||
git pull >/dev/null
|
git pull >/dev/null
|
||||||
git log|head -n20
|
git log -5
|
||||||
'''
|
'''
|
||||||
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
||||||
sh '''
|
sh '''
|
||||||
|
@ -92,10 +93,10 @@ def pre_test(){
|
||||||
git pull >/dev/null
|
git pull >/dev/null
|
||||||
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||||
git checkout -qf FETCH_HEAD
|
git checkout -qf FETCH_HEAD
|
||||||
git log|head -n20
|
git log -5
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
git pull >/dev/null
|
git pull >/dev/null
|
||||||
git log|head -n20
|
git log -5
|
||||||
'''
|
'''
|
||||||
} else {
|
} else {
|
||||||
sh '''
|
sh '''
|
||||||
|
@ -106,21 +107,10 @@ def pre_test(){
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
'''
|
'''
|
||||||
sh '''
|
|
||||||
cd ${WK}
|
|
||||||
export TZ=Asia/Harbin
|
|
||||||
date
|
|
||||||
rm -rf debug
|
|
||||||
mkdir debug
|
|
||||||
cd debug
|
|
||||||
cmake .. > /dev/null
|
|
||||||
make -j4> /dev/null
|
|
||||||
'''
|
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WKPY}
|
cd ${WKPY}
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git pull
|
git pull
|
||||||
pip3 install .
|
|
||||||
'''
|
'''
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -131,12 +121,14 @@ def pre_test_win(){
|
||||||
time /t
|
time /t
|
||||||
taskkill /f /t /im python.exe
|
taskkill /f /t /im python.exe
|
||||||
taskkill /f /t /im bash.exe
|
taskkill /f /t /im bash.exe
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDengine
|
rd /s /Q C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\debug
|
||||||
rd /s /Q C:\\workspace\\%EXECUTOR_NUMBER%\\TDengine\\debug
|
|
||||||
exit 0
|
exit 0
|
||||||
'''
|
'''
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDengine
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
|
git reset --hard
|
||||||
|
git fetch || git fetch
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git fetch || git fetch
|
git fetch || git fetch
|
||||||
git checkout -f
|
git checkout -f
|
||||||
|
@ -144,39 +136,73 @@ def pre_test_win(){
|
||||||
script {
|
script {
|
||||||
if (env.CHANGE_TARGET == 'master') {
|
if (env.CHANGE_TARGET == 'master') {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDengine
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
|
git checkout master
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git checkout master
|
git checkout master
|
||||||
'''
|
'''
|
||||||
} else if(env.CHANGE_TARGET == '2.0') {
|
} else if(env.CHANGE_TARGET == '2.0') {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDengine
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
|
git checkout 2.0
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git checkout 2.0
|
git checkout 2.0
|
||||||
'''
|
'''
|
||||||
} else if(env.CHANGE_TARGET == '3.0') {
|
} else if(env.CHANGE_TARGET == '3.0') {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDengine
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
|
git checkout 3.0
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git checkout 3.0
|
git checkout 3.0
|
||||||
'''
|
'''
|
||||||
} else {
|
} else {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDengine
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
|
git checkout develop
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
git checkout develop
|
git checkout develop
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
script {
|
||||||
|
if (env.CHANGE_URL =~ /\/TDengine\//) {
|
||||||
bat '''
|
bat '''
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDengine
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
git branch
|
git pull
|
||||||
git pull || git pull
|
git log -5
|
||||||
git fetch origin +refs/pull/%CHANGE_ID%/merge
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
|
git pull
|
||||||
|
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||||
git checkout -qf FETCH_HEAD
|
git checkout -qf FETCH_HEAD
|
||||||
|
git log -5
|
||||||
|
'''
|
||||||
|
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
||||||
|
bat '''
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
|
git pull
|
||||||
|
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||||
|
git checkout -qf FETCH_HEAD
|
||||||
|
git log -5
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
|
git pull
|
||||||
|
git log -5
|
||||||
|
'''
|
||||||
|
} else {
|
||||||
|
sh '''
|
||||||
|
echo "unmatched reposiotry ${CHANGE_URL}"
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bat '''
|
||||||
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal\\community
|
||||||
|
git submodule update --init --recursive
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
def pre_test_build_win() {
|
def pre_test_build_win() {
|
||||||
bat '''
|
bat '''
|
||||||
echo "building ..."
|
echo "building ..."
|
||||||
time /t
|
time /t
|
||||||
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDengine
|
cd C:\\workspace\\%EXECUTOR_NUMBER%\\TDinternal
|
||||||
mkdir debug
|
mkdir debug
|
||||||
cd debug
|
cd debug
|
||||||
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" x64
|
call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" x64
|
||||||
|
@ -192,6 +218,7 @@ pipeline {
|
||||||
agent none
|
agent none
|
||||||
options { skipDefaultCheckout() }
|
options { skipDefaultCheckout() }
|
||||||
environment{
|
environment{
|
||||||
|
WKDIR = '/var/lib/jenkins/workspace'
|
||||||
WK = '/var/lib/jenkins/workspace/TDinternal'
|
WK = '/var/lib/jenkins/workspace/TDinternal'
|
||||||
WKC = '/var/lib/jenkins/workspace/TDinternal/community'
|
WKC = '/var/lib/jenkins/workspace/TDinternal/community'
|
||||||
WKPY = '/var/lib/jenkins/workspace/taos-connector-python'
|
WKPY = '/var/lib/jenkins/workspace/taos-connector-python'
|
||||||
|
@ -206,40 +233,24 @@ pipeline {
|
||||||
changeRequest()
|
changeRequest()
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
timeout(time: 45, unit: 'MINUTES'){
|
timeout(time: 40, unit: 'MINUTES'){
|
||||||
pre_test()
|
pre_test()
|
||||||
script {
|
script {
|
||||||
if (env.CHANGE_URL =~ /\/TDengine\//) {
|
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WK}/debug
|
cd ${WKC}/tests/parallel_test
|
||||||
ctest -VV
|
date
|
||||||
|
time ./container_build.sh -w ${WKDIR} -t 8 -e
|
||||||
|
rm -f /tmp/cases.task
|
||||||
|
./collect_cases.sh -e
|
||||||
'''
|
'''
|
||||||
sh '''
|
sh '''
|
||||||
export LD_LIBRARY_PATH=${WK}/debug/build/lib
|
cd ${WKC}/tests/parallel_test
|
||||||
cd ${WKC}/tests/system-test
|
export DEFAULT_RETRY_TIME=2
|
||||||
./fulltest.sh
|
date
|
||||||
'''
|
timeout 2100 time ./run.sh -e -m /home/m.json -t /tmp/cases.task -b ${BRANCH_NAME} -l ${WKDIR}/log -o 480
|
||||||
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
|
||||||
sh '''
|
|
||||||
cd ${WKC}/debug
|
|
||||||
ctest -VV
|
|
||||||
'''
|
|
||||||
sh '''
|
|
||||||
export LD_LIBRARY_PATH=${WKC}/debug/build/lib
|
|
||||||
cd ${WKC}/tests/system-test
|
|
||||||
./fulltest.sh
|
|
||||||
'''
|
|
||||||
} else {
|
|
||||||
sh '''
|
|
||||||
echo "unmatched reposiotry ${CHANGE_URL}"
|
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sh '''
|
|
||||||
cd ${WKC}/tests
|
|
||||||
./test-all.sh b1fq
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,7 +365,7 @@ if(${BUILD_ADDR2LINE})
|
||||||
if(HAVE_LIBELF_H OR HAVE_LIBELF_LIBELF_H)
|
if(HAVE_LIBELF_H OR HAVE_LIBELF_LIBELF_H)
|
||||||
target_link_libraries(libdwarf PUBLIC libelf)
|
target_link_libraries(libdwarf PUBLIC libelf)
|
||||||
endif()
|
endif()
|
||||||
target_include_directories(libdwarf SYSTEM PUBLIC "libdwarf/src/lib/libdwarf" ${CMAKE_BINARY_DIR}/contrib)
|
target_include_directories(libdwarf SYSTEM PUBLIC "libdwarf/src/lib/libdwarf" ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
file(READ "addr2line/addr2line.c" ADDR2LINE_CONTENT)
|
file(READ "addr2line/addr2line.c" ADDR2LINE_CONTENT)
|
||||||
string(REPLACE "static int" "int" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
string(REPLACE "static int" "int" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
||||||
string(REPLACE "static void" "void" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
string(REPLACE "static void" "void" ADDR2LINE_CONTENT "${ADDR2LINE_CONTENT}")
|
||||||
|
|
|
@ -61,7 +61,7 @@ int32_t init_env() {
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes =
|
pRes =
|
||||||
taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)");
|
taos_query(pConn, "create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int)");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -106,8 +106,8 @@ int32_t create_topic() {
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
/*pRes = taos_query(pConn, "create topic topic_ctb_column as abc1");*/
|
pRes = taos_query(pConn, "create topic topic_ctb_column as abc1");
|
||||||
pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1, c2, c3 from st1");
|
/*pRes = taos_query(pConn, "create topic topic_ctb_column as select ts, c1, c2, c3 from st1");*/
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes));
|
printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -204,7 +204,6 @@ typedef struct {
|
||||||
const char* key;
|
const char* key;
|
||||||
int32_t keyLen;
|
int32_t keyLen;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
int16_t length;
|
|
||||||
union{
|
union{
|
||||||
const char* value;
|
const char* value;
|
||||||
int64_t i;
|
int64_t i;
|
||||||
|
@ -212,7 +211,7 @@ typedef struct {
|
||||||
double d;
|
double d;
|
||||||
float f;
|
float f;
|
||||||
};
|
};
|
||||||
int32_t valueLen;
|
int32_t length;
|
||||||
} SSmlKv;
|
} SSmlKv;
|
||||||
|
|
||||||
#define QUERY_ASC_FORWARD_STEP 1
|
#define QUERY_ASC_FORWARD_STEP 1
|
||||||
|
|
|
@ -173,6 +173,7 @@ typedef struct SqlFunctionCtx {
|
||||||
SInputColumnInfoData input;
|
SInputColumnInfoData input;
|
||||||
SResultDataInfo resDataInfo;
|
SResultDataInfo resDataInfo;
|
||||||
uint32_t order; // data block scanner order: asc|desc
|
uint32_t order; // data block scanner order: asc|desc
|
||||||
|
uint8_t scanFlag; // record current running step, default: 0
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
int32_t startRow; // start row index
|
int32_t startRow; // start row index
|
||||||
int32_t size; // handled processed row number
|
int32_t size; // handled processed row number
|
||||||
|
@ -183,7 +184,6 @@ typedef struct SqlFunctionCtx {
|
||||||
bool hasNull; // null value exist in current block, TODO remove it
|
bool hasNull; // null value exist in current block, TODO remove it
|
||||||
bool requireNull; // require null in some function, TODO remove it
|
bool requireNull; // require null in some function, TODO remove it
|
||||||
int32_t columnIndex; // TODO remove it
|
int32_t columnIndex; // TODO remove it
|
||||||
uint8_t currentStage; // record current running step, default: 0
|
|
||||||
bool isAggSet;
|
bool isAggSet;
|
||||||
int64_t startTs; // timestamp range of current query when function is executed on a specific data block, TODO remove it
|
int64_t startTs; // timestamp range of current query when function is executed on a specific data block, TODO remove it
|
||||||
bool stableQuery;
|
bool stableQuery;
|
||||||
|
|
|
@ -22,17 +22,12 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#define tjsonGetNumberValue(pJson, pName, val, code) \
|
||||||
#define tjsonGetNumberValue(pJson, pName, val) -1
|
do { \
|
||||||
#else
|
|
||||||
#define tjsonGetNumberValue(pJson, pName, val) \
|
|
||||||
({ \
|
|
||||||
uint64_t _tmp = 0; \
|
uint64_t _tmp = 0; \
|
||||||
int32_t _code = tjsonGetUBigIntValue(pJson, pName, &_tmp); \
|
code = tjsonGetUBigIntValue(pJson, pName, &_tmp); \
|
||||||
val = _tmp; \
|
val = _tmp; \
|
||||||
_code; \
|
} while (0)
|
||||||
})
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef void SJson;
|
typedef void SJson;
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ typedef struct SStmtBindInfo {
|
||||||
int8_t tbType;
|
int8_t tbType;
|
||||||
bool tagsCached;
|
bool tagsCached;
|
||||||
void* boundTags;
|
void* boundTags;
|
||||||
char tbName[TSDB_TABLE_FNAME_LEN];;
|
char tbName[TSDB_TABLE_FNAME_LEN];
|
||||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
char stbFName[TSDB_TABLE_FNAME_LEN];
|
char stbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
SName sname;
|
SName sname;
|
||||||
|
@ -71,7 +71,6 @@ typedef struct SStmtBindInfo {
|
||||||
|
|
||||||
typedef struct SStmtExecInfo {
|
typedef struct SStmtExecInfo {
|
||||||
int32_t affectedRows;
|
int32_t affectedRows;
|
||||||
bool emptyRes;
|
|
||||||
SRequestObj* pRequest;
|
SRequestObj* pRequest;
|
||||||
SHashObj* pVgHash;
|
SHashObj* pVgHash;
|
||||||
SHashObj* pBlockHash;
|
SHashObj* pBlockHash;
|
||||||
|
@ -87,7 +86,6 @@ typedef struct SStmtSQLInfo {
|
||||||
char* sqlStr;
|
char* sqlStr;
|
||||||
int32_t sqlLen;
|
int32_t sqlLen;
|
||||||
SArray* nodeList;
|
SArray* nodeList;
|
||||||
SQueryPlan* pQueryPlan;
|
|
||||||
SStmtQueryResInfo queryRes;
|
SStmtQueryResInfo queryRes;
|
||||||
bool autoCreateTbl;
|
bool autoCreateTbl;
|
||||||
} SStmtSQLInfo;
|
} SStmtSQLInfo;
|
||||||
|
|
|
@ -103,7 +103,7 @@ typedef struct {
|
||||||
SHashObj *tagHash; // elements are <key, index in tags>
|
SHashObj *tagHash; // elements are <key, index in tags>
|
||||||
|
|
||||||
SArray *cols;
|
SArray *cols;
|
||||||
SHashObj *fieldHash;
|
SHashObj *colHash;
|
||||||
|
|
||||||
STableMeta *tableMeta;
|
STableMeta *tableMeta;
|
||||||
} SSmlSTableMeta;
|
} SSmlSTableMeta;
|
||||||
|
@ -180,6 +180,7 @@ static inline bool smlCheckDuplicateKey(const char *key, int32_t keyLen, SHashOb
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlBuildInvalidDataMsg(SSmlMsgBuf* pBuf, const char *msg1, const char *msg2) {
|
static int32_t smlBuildInvalidDataMsg(SSmlMsgBuf* pBuf, const char *msg1, const char *msg2) {
|
||||||
|
memset(pBuf->buf, 0 , pBuf->len);
|
||||||
if(msg1) strncat(pBuf->buf, msg1, pBuf->len);
|
if(msg1) strncat(pBuf->buf, msg1, pBuf->len);
|
||||||
int32_t left = pBuf->len - strlen(pBuf->buf);
|
int32_t left = pBuf->len - strlen(pBuf->buf);
|
||||||
if(left > 2 && msg2) {
|
if(left > 2 && msg2) {
|
||||||
|
@ -189,47 +190,39 @@ static int32_t smlBuildInvalidDataMsg(SSmlMsgBuf* pBuf, const char *msg1, const
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlGenerateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, SArray* dbAttrArray, bool isTag, char sTableName[],
|
static int32_t smlGenerateSchemaAction(SSchema* colField, SHashObj* colHash, SSmlKv* kv, bool isTag,
|
||||||
SSchemaAction* action, bool* actionNeeded, SSmlHandle* info) {
|
SSchemaAction* action, bool* actionNeeded, SSmlHandle* info) {
|
||||||
// char fieldName[TSDB_COL_NAME_LEN] = {0};
|
uint16_t *index = (uint16_t *)taosHashGet(colHash, kv->key, kv->keyLen);
|
||||||
// strcpy(fieldName, pointColField->name);
|
if (index) {
|
||||||
//
|
if (colField[*index].type != kv->type) {
|
||||||
// size_t* pDbIndex = taosHashGet(dbAttrHash, fieldName, strlen(fieldName));
|
uError("SML:0x%"PRIx64" point type and db type mismatch. key: %s. point type: %d, db type: %d", info->id, kv->key,
|
||||||
// if (pDbIndex) {
|
colField[*index].type, kv->type);
|
||||||
// SSchema* dbAttr = taosArrayGet(dbAttrArray, *pDbIndex);
|
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
// assert(strcasecmp(dbAttr->name, pointColField->name) == 0);
|
}
|
||||||
// if (pointColField->type != dbAttr->type) {
|
|
||||||
// uError("SML:0x%"PRIx64" point type and db type mismatch. key: %s. point type: %d, db type: %d", info->id, pointColField->name,
|
if ((colField[*index].type == TSDB_DATA_TYPE_VARCHAR && (colField[*index].bytes - VARSTR_HEADER_SIZE) < kv->length) ||
|
||||||
// pointColField->type, dbAttr->type);
|
(colField[*index].type == TSDB_DATA_TYPE_NCHAR &&((colField[*index].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE < kv->length))) {
|
||||||
// return TSDB_CODE_TSC_INVALID_VALUE;
|
if (isTag) {
|
||||||
// }
|
action->action = SCHEMA_ACTION_CHANGE_TAG_SIZE;
|
||||||
//
|
} else {
|
||||||
// if (IS_VAR_DATA_TYPE(pointColField->type) && (pointColField->bytes > dbAttr->bytes)) {
|
action->action = SCHEMA_ACTION_CHANGE_COLUMN_SIZE;
|
||||||
// if (isTag) {
|
}
|
||||||
// action->action = SCHEMA_ACTION_CHANGE_TAG_SIZE;
|
action->alterSTable.field = kv;
|
||||||
// } else {
|
*actionNeeded = true;
|
||||||
// action->action = SCHEMA_ACTION_CHANGE_COLUMN_SIZE;
|
}
|
||||||
// }
|
} else {
|
||||||
// memset(&action->alterSTable, 0, sizeof(SAlterSTableActionInfo));
|
if (isTag) {
|
||||||
// memcpy(action->alterSTable.sTableName, sTableName, TSDB_TABLE_NAME_LEN);
|
action->action = SCHEMA_ACTION_ADD_TAG;
|
||||||
// action->alterSTable.field = pointColField;
|
} else {
|
||||||
// *actionNeeded = true;
|
action->action = SCHEMA_ACTION_ADD_COLUMN;
|
||||||
// }
|
}
|
||||||
// } else {
|
action->alterSTable.field = kv;
|
||||||
// if (isTag) {
|
*actionNeeded = true;
|
||||||
// action->action = SCHEMA_ACTION_ADD_TAG;
|
}
|
||||||
// } else {
|
if (*actionNeeded) {
|
||||||
// action->action = SCHEMA_ACTION_ADD_COLUMN;
|
uDebug("SML:0x%" PRIx64 " generate schema action. column name: %s, action: %d", info->id, colField->name,
|
||||||
// }
|
action->action);
|
||||||
// memset(&action->alterSTable, 0, sizeof(SAlterSTableActionInfo));
|
}
|
||||||
// memcpy(action->alterSTable.sTableName, sTableName, TSDB_TABLE_NAME_LEN);
|
|
||||||
// action->alterSTable.field = pointColField;
|
|
||||||
// *actionNeeded = true;
|
|
||||||
// }
|
|
||||||
// if (*actionNeeded) {
|
|
||||||
// uDebug("SML:0x%" PRIx64 " generate schema action. column name: %s, action: %d", info->id, fieldName,
|
|
||||||
// action->action);
|
|
||||||
// }
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +231,7 @@ static int32_t smlBuildColumnDescription(SSmlKv* field, char* buf, int32_t bufSi
|
||||||
char tname[TSDB_TABLE_NAME_LEN] = {0};
|
char tname[TSDB_TABLE_NAME_LEN] = {0};
|
||||||
memcpy(tname, field->key, field->keyLen);
|
memcpy(tname, field->key, field->keyLen);
|
||||||
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
|
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t bytes = field->valueLen; // todo
|
int32_t bytes = field->length; // todo
|
||||||
int out = snprintf(buf, bufSize,"`%s` %s(%d)",
|
int out = snprintf(buf, bufSize,"`%s` %s(%d)",
|
||||||
tname, tDataTypes[field->type].name, bytes);
|
tname, tDataTypes[field->type].name, bytes);
|
||||||
*outBytes = out;
|
*outBytes = out;
|
||||||
|
@ -259,7 +252,7 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
|
||||||
uDebug("SML:0x%"PRIx64" apply schema action. action: %d", info->id, action->action);
|
uDebug("SML:0x%"PRIx64" apply schema action. action: %d", info->id, action->action);
|
||||||
switch (action->action) {
|
switch (action->action) {
|
||||||
case SCHEMA_ACTION_ADD_COLUMN: {
|
case SCHEMA_ACTION_ADD_COLUMN: {
|
||||||
int n = sprintf(result, "alter stable %s add column ", action->alterSTable.sTableName);
|
int n = sprintf(result, "alter stable `%s` add column ", action->alterSTable.sTableName);
|
||||||
smlBuildColumnDescription(action->alterSTable.field, result+n, capacity-n, &outBytes);
|
smlBuildColumnDescription(action->alterSTable.field, result+n, capacity-n, &outBytes);
|
||||||
TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery
|
TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery
|
||||||
code = taos_errno(res);
|
code = taos_errno(res);
|
||||||
|
@ -282,7 +275,7 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SCHEMA_ACTION_ADD_TAG: {
|
case SCHEMA_ACTION_ADD_TAG: {
|
||||||
int n = sprintf(result, "alter stable %s add tag ", action->alterSTable.sTableName);
|
int n = sprintf(result, "alter stable `%s` add tag ", action->alterSTable.sTableName);
|
||||||
smlBuildColumnDescription(action->alterSTable.field,
|
smlBuildColumnDescription(action->alterSTable.field,
|
||||||
result+n, capacity-n, &outBytes);
|
result+n, capacity-n, &outBytes);
|
||||||
TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery
|
TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery
|
||||||
|
@ -306,7 +299,7 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: {
|
case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: {
|
||||||
int n = sprintf(result, "alter stable %s modify column ", action->alterSTable.sTableName);
|
int n = sprintf(result, "alter stable `%s` modify column ", action->alterSTable.sTableName);
|
||||||
smlBuildColumnDescription(action->alterSTable.field, result+n,
|
smlBuildColumnDescription(action->alterSTable.field, result+n,
|
||||||
capacity-n, &outBytes);
|
capacity-n, &outBytes);
|
||||||
TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery
|
TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery
|
||||||
|
@ -329,7 +322,7 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SCHEMA_ACTION_CHANGE_TAG_SIZE: {
|
case SCHEMA_ACTION_CHANGE_TAG_SIZE: {
|
||||||
int n = sprintf(result, "alter stable %s modify tag ", action->alterSTable.sTableName);
|
int n = sprintf(result, "alter stable `%s` modify tag ", action->alterSTable.sTableName);
|
||||||
smlBuildColumnDescription(action->alterSTable.field, result+n,
|
smlBuildColumnDescription(action->alterSTable.field, result+n,
|
||||||
capacity-n, &outBytes);
|
capacity-n, &outBytes);
|
||||||
TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery
|
TAOS_RES* res = taos_query(info->taos, result); //TODO async doAsyncQuery
|
||||||
|
@ -408,6 +401,25 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t smlProcessSchemaAction(SSmlHandle* info, SSchema* schemaField, SHashObj* schemaHash, SArray *cols, SSchemaAction* action, bool isTag){
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
for (int j = 0; j < taosArrayGetSize(cols); ++j) {
|
||||||
|
SSmlKv* kv = (SSmlKv*)taosArrayGetP(cols, j);
|
||||||
|
bool actionNeeded = false;
|
||||||
|
code = smlGenerateSchemaAction(schemaField, schemaHash, kv, isTag, action, &actionNeeded, info);
|
||||||
|
if(code != TSDB_CODE_SUCCESS){
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
if (actionNeeded) {
|
||||||
|
code = smlApplySchemaAction(info, action);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t smlModifyDBSchemas(SSmlHandle* info) {
|
static int32_t smlModifyDBSchemas(SSmlHandle* info) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -427,27 +439,50 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) {
|
||||||
code = catalogGetSTableMeta(info->pCatalog, info->taos->pAppInfo->pTransporter, &ep, &pName, &pTableMeta);
|
code = catalogGetSTableMeta(info->pCatalog, info->taos->pAppInfo->pTransporter, &ep, &pName, &pTableMeta);
|
||||||
|
|
||||||
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_INVALID_STB) {
|
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_INVALID_STB) {
|
||||||
SSchemaAction schemaAction = { SCHEMA_ACTION_CREATE_STABLE, 0};
|
SSchemaAction schemaAction = { .action = SCHEMA_ACTION_CREATE_STABLE, .createSTable = {0}};
|
||||||
memcpy(schemaAction.createSTable.sTableName, superTable, superTableLen);
|
memcpy(schemaAction.createSTable.sTableName, superTable, superTableLen);
|
||||||
schemaAction.createSTable.tags = sTableData->tags;
|
schemaAction.createSTable.tags = sTableData->tags;
|
||||||
schemaAction.createSTable.fields = sTableData->cols;
|
schemaAction.createSTable.fields = sTableData->cols;
|
||||||
code = smlApplySchemaAction(info, &schemaAction);
|
code = smlApplySchemaAction(info, &schemaAction);
|
||||||
if (code != 0) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%"PRIx64" smlApplySchemaAction failed. can not create %s", info->id, schemaAction.createSTable.sTableName);
|
uError("SML:0x%"PRIx64" smlApplySchemaAction failed. can not create %s", info->id, schemaAction.createSTable.sTableName);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = catalogGetSTableMeta(info->pCatalog, info->taos->pAppInfo->pTransporter, &ep, &pName, &pTableMeta);
|
|
||||||
if (code != 0) {
|
|
||||||
uError("SML:0x%"PRIx64" catalogGetSTableMeta failed. super table name %s", info->id, schemaAction.createSTable.sTableName);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
info->cost.numOfCreateSTables++;
|
info->cost.numOfCreateSTables++;
|
||||||
}else if (code == TSDB_CODE_SUCCESS) {
|
}else if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
SHashObj *hashTmp = taosHashInit(pTableMeta->tableInfo.numOfTags, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
|
for(uint16_t i = pTableMeta->tableInfo.numOfColumns; i < pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags; i++){
|
||||||
|
taosHashPut(hashTmp, pTableMeta->schema[i].name, strlen(pTableMeta->schema[i].name), &i, SHORT_BYTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSchemaAction schemaAction = {.alterSTable = {0}};
|
||||||
|
memcpy(schemaAction.createSTable.sTableName, superTable, superTableLen);
|
||||||
|
code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->tags, &schemaAction, true);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosHashCleanup(hashTmp);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosHashClear(hashTmp);
|
||||||
|
for(uint16_t i = 0; i < pTableMeta->tableInfo.numOfColumns; i++){
|
||||||
|
taosHashPut(hashTmp, pTableMeta->schema[i].name, strlen(pTableMeta->schema[i].name), &i, SHORT_BYTES);
|
||||||
|
}
|
||||||
|
code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->cols, &schemaAction, false);
|
||||||
|
taosHashCleanup(hashTmp);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
uError("SML:0x%"PRIx64" load table meta error: %s", info->id, tstrerror(code));
|
uError("SML:0x%"PRIx64" load table meta error: %s", info->id, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
if(pTableMeta) taosMemoryFree(pTableMeta);
|
||||||
|
|
||||||
|
code = catalogGetSTableMeta(info->pCatalog, info->taos->pAppInfo->pTransporter, &ep, &pName, &pTableMeta);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
uError("SML:0x%"PRIx64" catalogGetSTableMeta failed. super table name %s", info->id, (char*)superTable);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
sTableData->tableMeta = pTableMeta;
|
sTableData->tableMeta = pTableMeta;
|
||||||
|
|
||||||
tableMetaSml = (SSmlSTableMeta**)taosHashIterate(info->superTables, tableMetaSml);
|
tableMetaSml = (SSmlSTableMeta**)taosHashIterate(info->superTables, tableMetaSml);
|
||||||
|
@ -507,7 +542,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) {
|
||||||
|
|
||||||
static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){
|
static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){
|
||||||
const char *pVal = kvVal->value;
|
const char *pVal = kvVal->value;
|
||||||
int32_t len = kvVal->valueLen;
|
int32_t len = kvVal->length;
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
double result = strtod(pVal, &endptr);
|
double result = strtod(pVal, &endptr);
|
||||||
if(pVal == endptr){
|
if(pVal == endptr){
|
||||||
|
@ -591,7 +626,7 @@ static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){
|
||||||
|
|
||||||
static bool smlParseBool(SSmlKv *kvVal) {
|
static bool smlParseBool(SSmlKv *kvVal) {
|
||||||
const char *pVal = kvVal->value;
|
const char *pVal = kvVal->value;
|
||||||
int32_t len = kvVal->valueLen;
|
int32_t len = kvVal->length;
|
||||||
if ((len == 1) && pVal[0] == 't') {
|
if ((len == 1) && pVal[0] == 't') {
|
||||||
kvVal->i = true;
|
kvVal->i = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -690,7 +725,7 @@ static int8_t smlGetTsTypeByLen(int32_t len) {
|
||||||
if (len == TSDB_TIME_PRECISION_SEC_DIGITS) {
|
if (len == TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
return TSDB_TIME_PRECISION_SECONDS;
|
return TSDB_TIME_PRECISION_SECONDS;
|
||||||
} else if (len == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
} else if (len == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
return TSDB_TIME_PRECISION_MILLI_DIGITS;
|
return TSDB_TIME_PRECISION_MILLI;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -756,9 +791,12 @@ static int32_t smlParseTS(SSmlHandle* info, const char* data, int32_t len, SArra
|
||||||
int64_t ts = 0;
|
int64_t ts = 0;
|
||||||
if(info->protocol == TSDB_SML_LINE_PROTOCOL){
|
if(info->protocol == TSDB_SML_LINE_PROTOCOL){
|
||||||
ts = smlParseInfluxTime(info, data, len);
|
ts = smlParseInfluxTime(info, data, len);
|
||||||
}else{
|
}else if(info->protocol == TSDB_SML_TELNET_PROTOCOL){
|
||||||
ts = smlParseOpenTsdbTime(info, data, len);
|
ts = smlParseOpenTsdbTime(info, data, len);
|
||||||
|
}else{
|
||||||
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ts == -1) return TSDB_CODE_TSC_INVALID_TIME_STAMP;
|
if(ts == -1) return TSDB_CODE_TSC_INVALID_TIME_STAMP;
|
||||||
|
|
||||||
// add ts to
|
// add ts to
|
||||||
|
@ -778,18 +816,16 @@ static int32_t smlParseTS(SSmlHandle* info, const char* data, int32_t len, SArra
|
||||||
|
|
||||||
static bool smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
|
static bool smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
|
||||||
//binary
|
//binary
|
||||||
if (smlIsBinary(pVal->value, pVal->valueLen)) {
|
if (smlIsBinary(pVal->value, pVal->length)) {
|
||||||
pVal->type = TSDB_DATA_TYPE_BINARY;
|
pVal->type = TSDB_DATA_TYPE_BINARY;
|
||||||
pVal->valueLen -= BINARY_ADD_LEN;
|
pVal->length -= BINARY_ADD_LEN;
|
||||||
pVal->length = pVal->valueLen;
|
|
||||||
pVal->value += (BINARY_ADD_LEN - 1);
|
pVal->value += (BINARY_ADD_LEN - 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//nchar
|
//nchar
|
||||||
if (smlIsNchar(pVal->value, pVal->valueLen)) {
|
if (smlIsNchar(pVal->value, pVal->length)) {
|
||||||
pVal->type = TSDB_DATA_TYPE_NCHAR;
|
pVal->type = TSDB_DATA_TYPE_NCHAR;
|
||||||
pVal->valueLen -= NCHAR_ADD_LEN;
|
pVal->length -= NCHAR_ADD_LEN;
|
||||||
pVal->length = pVal->valueLen;
|
|
||||||
pVal->value += (NCHAR_ADD_LEN - 1);
|
pVal->value += (NCHAR_ADD_LEN - 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -953,8 +989,8 @@ static int32_t smlParseTelnetTags(const char* data, int32_t len, SArray *cols, S
|
||||||
kv->key = key;
|
kv->key = key;
|
||||||
kv->keyLen = keyLen;
|
kv->keyLen = keyLen;
|
||||||
kv->value = value;
|
kv->value = value;
|
||||||
kv->valueLen = valueLen;
|
kv->length = valueLen;
|
||||||
kv->type = TSDB_DATA_TYPE_NCHAR;
|
kv->type = TSDB_DATA_TYPE_NCHAR; //todo
|
||||||
|
|
||||||
if(cols) taosArrayPush(cols, &kv);
|
if(cols) taosArrayPush(cols, &kv);
|
||||||
}
|
}
|
||||||
|
@ -1002,7 +1038,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char* sql, SSmlTable
|
||||||
kv->key = VALUE;
|
kv->key = VALUE;
|
||||||
kv->keyLen = VALUE_LEN;
|
kv->keyLen = VALUE_LEN;
|
||||||
kv->value = value;
|
kv->value = value;
|
||||||
kv->valueLen = valueLen;
|
kv->length = valueLen;
|
||||||
if(!smlParseValue(kv, &info->msgBuf) || kv->type == TSDB_DATA_TYPE_BINARY
|
if(!smlParseValue(kv, &info->msgBuf) || kv->type == TSDB_DATA_TYPE_BINARY
|
||||||
|| kv->type == TSDB_DATA_TYPE_NCHAR || kv->type == TSDB_DATA_TYPE_BOOL){
|
|| kv->type == TSDB_DATA_TYPE_NCHAR || kv->type == TSDB_DATA_TYPE_BOOL){
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
|
@ -1028,7 +1064,7 @@ static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, bool is
|
||||||
kv->key = TAG;
|
kv->key = TAG;
|
||||||
kv->keyLen = TAG_LEN;
|
kv->keyLen = TAG_LEN;
|
||||||
kv->value = TAG;
|
kv->value = TAG;
|
||||||
kv->valueLen = TAG_LEN;
|
kv->length = TAG_LEN;
|
||||||
kv->type = TSDB_DATA_TYPE_NCHAR;
|
kv->type = TSDB_DATA_TYPE_NCHAR;
|
||||||
if(cols) taosArrayPush(cols, &kv);
|
if(cols) taosArrayPush(cols, &kv);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1086,7 +1122,7 @@ static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, bool is
|
||||||
kv->key = key;
|
kv->key = key;
|
||||||
kv->keyLen = keyLen;
|
kv->keyLen = keyLen;
|
||||||
kv->value = value;
|
kv->value = value;
|
||||||
kv->valueLen = valueLen;
|
kv->length = valueLen;
|
||||||
if(isTag){
|
if(isTag){
|
||||||
kv->type = TSDB_DATA_TYPE_NCHAR;
|
kv->type = TSDB_DATA_TYPE_NCHAR;
|
||||||
}else{
|
}else{
|
||||||
|
@ -1142,73 +1178,40 @@ static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, bool is
|
||||||
// return TSDB_CODE_SUCCESS;
|
// return TSDB_CODE_SUCCESS;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
static bool smlUpdateMeta(SSmlSTableMeta* tableMeta, SArray *tags, SArray *cols, SSmlMsgBuf *msg){
|
static bool smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols, SSmlMsgBuf *msg){
|
||||||
if(tags){
|
for (int i = 0; i < taosArrayGetSize(cols); ++i) { //jump timestamp
|
||||||
for (int i = 0; i < taosArrayGetSize(tags); ++i) {
|
|
||||||
SSmlKv *kv = (SSmlKv *)taosArrayGetP(tags, i);
|
|
||||||
ASSERT(kv->type == TSDB_DATA_TYPE_NCHAR);
|
|
||||||
|
|
||||||
uint8_t *index = (uint8_t *)taosHashGet(tableMeta->tagHash, kv->key, kv->keyLen);
|
|
||||||
if(index){
|
|
||||||
SSmlKv **value = (SSmlKv **)taosArrayGet(tableMeta->tags, *index);
|
|
||||||
ASSERT((*value)->type == TSDB_DATA_TYPE_NCHAR);
|
|
||||||
if(kv->valueLen > (*value)->valueLen){ // tags type is nchar
|
|
||||||
*value = kv;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
size_t tmp = taosArrayGetSize(tableMeta->tags);
|
|
||||||
ASSERT(tmp <= UINT8_MAX);
|
|
||||||
uint8_t size = tmp;
|
|
||||||
taosArrayPush(tableMeta->tags, &kv);
|
|
||||||
taosHashPut(tableMeta->tagHash, kv->key, kv->keyLen, &size, CHAR_BYTES);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cols){
|
|
||||||
for (int i = 1; i < taosArrayGetSize(cols); ++i) { //jump timestamp
|
|
||||||
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
||||||
|
|
||||||
int16_t *index = (int16_t *)taosHashGet(tableMeta->fieldHash, kv->key, kv->keyLen);
|
int16_t *index = (int16_t *)taosHashGet(metaHash, kv->key, kv->keyLen);
|
||||||
if(index){
|
if(index){
|
||||||
SSmlKv **value = (SSmlKv **)taosArrayGet(tableMeta->cols, *index);
|
SSmlKv **value = (SSmlKv **)taosArrayGet(metaArray, *index);
|
||||||
if(kv->type != (*value)->type){
|
if(kv->type != (*value)->type){
|
||||||
smlBuildInvalidDataMsg(msg, "the type is not the same like before", kv->key);
|
smlBuildInvalidDataMsg(msg, "the type is not the same like before", kv->key);
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
if(IS_VAR_DATA_TYPE(kv->type)){ // update string len, if bigger
|
if(IS_VAR_DATA_TYPE(kv->type)){ // update string len, if bigger
|
||||||
if(kv->valueLen > (*value)->valueLen){
|
if(kv->length > (*value)->length){
|
||||||
*value = kv;
|
*value = kv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
size_t tmp = taosArrayGetSize(tableMeta->cols);
|
size_t tmp = taosArrayGetSize(metaArray);
|
||||||
ASSERT(tmp <= INT16_MAX);
|
ASSERT(tmp <= INT16_MAX);
|
||||||
int16_t size = tmp;
|
int16_t size = tmp;
|
||||||
taosArrayPush(tableMeta->cols, &kv);
|
taosArrayPush(metaArray, &kv);
|
||||||
taosHashPut(tableMeta->fieldHash, kv->key, kv->keyLen, &size, SHORT_BYTES);
|
taosHashPut(metaHash, kv->key, kv->keyLen, &size, SHORT_BYTES);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void smlInsertMeta(SSmlSTableMeta* tableMeta, SArray *tags, SArray *cols){
|
static void smlInsertMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols){
|
||||||
if(tags){
|
|
||||||
for (uint8_t i = 0; i < taosArrayGetSize(tags); ++i) {
|
|
||||||
SSmlKv *kv = (SSmlKv *)taosArrayGetP(tags, i);
|
|
||||||
taosArrayPush(tableMeta->tags, &kv);
|
|
||||||
taosHashPut(tableMeta->tagHash, kv->key, kv->keyLen, &i, CHAR_BYTES);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cols){
|
|
||||||
for (int16_t i = 0; i < taosArrayGetSize(cols); ++i) {
|
for (int16_t i = 0; i < taosArrayGetSize(cols); ++i) {
|
||||||
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
||||||
taosArrayPush(tableMeta->cols, &kv);
|
taosArrayPush(metaArray, &kv);
|
||||||
taosHashPut(tableMeta->fieldHash, kv->key, kv->keyLen, &i, SHORT_BYTES);
|
taosHashPut(metaHash, kv->key, kv->keyLen, &i, SHORT_BYTES);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1236,12 +1239,16 @@ cleanup:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void smlDestroyTableInfo(SSmlTableInfo *tag, bool format){
|
static void smlDestroyTableInfo(SSmlHandle* info, SSmlTableInfo *tag){
|
||||||
if(format){
|
if(info->dataFormat){
|
||||||
for(size_t i = 0; i < taosArrayGetSize(tag->cols); i++){
|
for(size_t i = 0; i < taosArrayGetSize(tag->cols); i++){
|
||||||
SArray *kvArray = (SArray *)taosArrayGetP(tag->cols, i);
|
SArray *kvArray = (SArray *)taosArrayGetP(tag->cols, i);
|
||||||
for (int j = 0; j < taosArrayGetSize(kvArray); ++j) {
|
for (int j = 0; j < taosArrayGetSize(kvArray); ++j) {
|
||||||
void *p = taosArrayGetP(kvArray, j);
|
SSmlKv *p = (SSmlKv *)taosArrayGetP(kvArray, j);
|
||||||
|
if(info->protocol == TSDB_SML_JSON_PROTOCOL &&
|
||||||
|
(p->type == TSDB_DATA_TYPE_NCHAR || p->type == TSDB_DATA_TYPE_BINARY)){
|
||||||
|
taosMemoryFree((void*)p->value);
|
||||||
|
}
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
}
|
}
|
||||||
taosArrayDestroy(kvArray);
|
taosArrayDestroy(kvArray);
|
||||||
|
@ -1257,6 +1264,19 @@ static void smlDestroyTableInfo(SSmlTableInfo *tag, bool format){
|
||||||
taosHashCleanup(kvHash);
|
taosHashCleanup(kvHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for(size_t i = 0; i < taosArrayGetSize(tag->tags); i++){
|
||||||
|
SSmlKv *p = (SSmlKv *)taosArrayGetP(tag->tags, i);
|
||||||
|
if(info->protocol == TSDB_SML_JSON_PROTOCOL){
|
||||||
|
taosMemoryFree((void*)p->key);
|
||||||
|
if(p->type == TSDB_DATA_TYPE_NCHAR || p->type == TSDB_DATA_TYPE_BINARY){
|
||||||
|
taosMemoryFree((void*)p->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taosMemoryFree(p);
|
||||||
|
}
|
||||||
|
if(info->protocol == TSDB_SML_JSON_PROTOCOL && tag->sTableName){
|
||||||
|
taosMemoryFree((void*)tag->sTableName);
|
||||||
|
}
|
||||||
taosArrayDestroy(tag->cols);
|
taosArrayDestroy(tag->cols);
|
||||||
taosArrayDestroy(tag->tags);
|
taosArrayDestroy(tag->tags);
|
||||||
taosMemoryFree(tag);
|
taosMemoryFree(tag);
|
||||||
|
@ -1293,8 +1313,8 @@ static SSmlSTableMeta* smlBuildSTableMeta(){
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
meta->fieldHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
meta->colHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
if (meta->fieldHash == NULL) {
|
if (meta->colHash == NULL) {
|
||||||
uError("SML:smlBuildSTableMeta failed to allocate memory");
|
uError("SML:smlBuildSTableMeta failed to allocate memory");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -1319,7 +1339,7 @@ cleanup:
|
||||||
|
|
||||||
static void smlDestroySTableMeta(SSmlSTableMeta *meta){
|
static void smlDestroySTableMeta(SSmlSTableMeta *meta){
|
||||||
taosHashCleanup(meta->tagHash);
|
taosHashCleanup(meta->tagHash);
|
||||||
taosHashCleanup(meta->fieldHash);
|
taosHashCleanup(meta->colHash);
|
||||||
taosArrayDestroy(meta->tags);
|
taosArrayDestroy(meta->tags);
|
||||||
taosArrayDestroy(meta->cols);
|
taosArrayDestroy(meta->cols);
|
||||||
taosMemoryFree(meta->tableMeta);
|
taosMemoryFree(meta->tableMeta);
|
||||||
|
@ -1341,7 +1361,7 @@ static void smlDestroyInfo(SSmlHandle* info){
|
||||||
// destroy info->childTables
|
// destroy info->childTables
|
||||||
void** p1 = (void**)taosHashIterate(info->childTables, NULL);
|
void** p1 = (void**)taosHashIterate(info->childTables, NULL);
|
||||||
while (p1) {
|
while (p1) {
|
||||||
smlDestroyTableInfo((SSmlTableInfo*)(*p1), info->dataFormat);
|
smlDestroyTableInfo(info, (SSmlTableInfo*)(*p1));
|
||||||
p1 = (void**)taosHashIterate(info->childTables, p1);
|
p1 = (void**)taosHashIterate(info->childTables, p1);
|
||||||
}
|
}
|
||||||
taosHashCleanup(info->childTables);
|
taosHashCleanup(info->childTables);
|
||||||
|
@ -1357,7 +1377,9 @@ static void smlDestroyInfo(SSmlHandle* info){
|
||||||
// destroy info->pVgHash
|
// destroy info->pVgHash
|
||||||
taosHashCleanup(info->pVgHash);
|
taosHashCleanup(info->pVgHash);
|
||||||
taosHashCleanup(info->dumplicateKey);
|
taosHashCleanup(info->dumplicateKey);
|
||||||
|
if(!info->dataFormat){
|
||||||
|
taosArrayDestroy(info->colsContainer);
|
||||||
|
}
|
||||||
taosMemoryFreeClear(info);
|
taosMemoryFreeClear(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1682,8 +1704,7 @@ static int32_t smlConvertJSONString(SSmlKv *pVal, char* typeStr, cJSON *value) {
|
||||||
return TSDB_CODE_TSC_INVALID_JSON_TYPE;
|
return TSDB_CODE_TSC_INVALID_JSON_TYPE;
|
||||||
}
|
}
|
||||||
pVal->length = (int16_t)strlen(value->valuestring);
|
pVal->length = (int16_t)strlen(value->valuestring);
|
||||||
pVal->valueLen = pVal->length;
|
return smlJsonCreateSring(&pVal->value, value->valuestring, pVal->length);
|
||||||
return smlJsonCreateSring(&pVal->value, value->valuestring, pVal->valueLen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlParseValueFromJSONObj(cJSON *root, SSmlKv *kv) {
|
static int32_t smlParseValueFromJSONObj(cJSON *root, SSmlKv *kv) {
|
||||||
|
@ -1754,7 +1775,7 @@ static int32_t smlParseValueFromJSON(cJSON *root, SSmlKv *kv) {
|
||||||
* user configured parameter tsDefaultJSONStrType
|
* user configured parameter tsDefaultJSONStrType
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *tsDefaultJSONStrType = "binary"; //todo
|
char *tsDefaultJSONStrType = "nchar"; //todo
|
||||||
smlConvertJSONString(kv, tsDefaultJSONStrType, root);
|
smlConvertJSONString(kv, tsDefaultJSONStrType, root);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1985,8 +2006,8 @@ static int32_t smlParseInfluxLine(SSmlHandle* info, const char* sql) {
|
||||||
|
|
||||||
(*oneTable)->sTableName = elements.measure;
|
(*oneTable)->sTableName = elements.measure;
|
||||||
(*oneTable)->sTableNameLen = elements.measureLen;
|
(*oneTable)->sTableNameLen = elements.measureLen;
|
||||||
RandTableName rName = {.tags=(*oneTable)->tags, .sTableName=(*oneTable)->sTableName, .sTableNameLen=(uint8_t)(*oneTable)->sTableNameLen,
|
RandTableName rName = { (*oneTable)->tags, (*oneTable)->sTableName, (uint8_t)(*oneTable)->sTableNameLen,
|
||||||
.childTableName=(*oneTable)->childTableName};
|
(*oneTable)->childTableName, 0 };
|
||||||
|
|
||||||
buildChildTableName(&rName);
|
buildChildTableName(&rName);
|
||||||
(*oneTable)->uid = rName.uid;
|
(*oneTable)->uid = rName.uid;
|
||||||
|
@ -1994,14 +2015,18 @@ static int32_t smlParseInfluxLine(SSmlHandle* info, const char* sql) {
|
||||||
|
|
||||||
SSmlSTableMeta** tableMeta = (SSmlSTableMeta**)taosHashGet(info->superTables, elements.measure, elements.measureLen);
|
SSmlSTableMeta** tableMeta = (SSmlSTableMeta**)taosHashGet(info->superTables, elements.measure, elements.measureLen);
|
||||||
if(tableMeta){ // update meta
|
if(tableMeta){ // update meta
|
||||||
ret = smlUpdateMeta(*tableMeta, hasTable ? NULL : (*oneTable)->tags, cols, &info->msgBuf);
|
ret = smlUpdateMeta((*tableMeta)->colHash, (*tableMeta)->cols, cols, &info->msgBuf);
|
||||||
|
if(!hasTable && ret){
|
||||||
|
ret = smlUpdateMeta((*tableMeta)->tagHash, (*tableMeta)->tags, (*oneTable)->tags, &info->msgBuf);
|
||||||
|
}
|
||||||
if(!ret){
|
if(!ret){
|
||||||
uError("SML:0x%"PRIx64" smlUpdateMeta failed", info->id);
|
uError("SML:0x%"PRIx64" smlUpdateMeta failed", info->id);
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
SSmlSTableMeta *meta = smlBuildSTableMeta();
|
SSmlSTableMeta *meta = smlBuildSTableMeta();
|
||||||
smlInsertMeta(meta, (*oneTable)->tags, cols);
|
smlInsertMeta(meta->tagHash, meta->tags, (*oneTable)->tags);
|
||||||
|
smlInsertMeta(meta->colHash, meta->cols, cols);
|
||||||
taosHashPut(info->superTables, elements.measure, elements.measureLen, &meta, POINTER_BYTES);
|
taosHashPut(info->superTables, elements.measure, elements.measureLen, &meta, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2026,15 +2051,15 @@ static int32_t smlParseTelnetLine(SSmlHandle* info, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(info->protocol == TSDB_SML_TELNET_PROTOCOL){
|
if(info->protocol == TSDB_SML_TELNET_PROTOCOL){
|
||||||
smlParseTelnetString(info, (const char*)data, tinfo, cols);
|
ret = smlParseTelnetString(info, (const char*)data, tinfo, cols);
|
||||||
}else if(info->protocol == TSDB_SML_JSON_PROTOCOL){
|
}else if(info->protocol == TSDB_SML_JSON_PROTOCOL){
|
||||||
smlParseJSONString(info, (cJSON *)data, tinfo, cols);
|
ret = smlParseJSONString(info, (cJSON *)data, tinfo, cols);
|
||||||
}else{
|
}else{
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
if(ret != TSDB_CODE_SUCCESS){
|
if(ret != TSDB_CODE_SUCCESS){
|
||||||
uError("SML:0x%"PRIx64" smlParseTelnetLine failed", info->id);
|
uError("SML:0x%"PRIx64" smlParseTelnetLine failed", info->id);
|
||||||
smlDestroyTableInfo(tinfo, true);
|
smlDestroyTableInfo(info, tinfo);
|
||||||
taosArrayDestroy(cols);
|
taosArrayDestroy(cols);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2045,8 +2070,8 @@ static int32_t smlParseTelnetLine(SSmlHandle* info, void *data) {
|
||||||
}
|
}
|
||||||
taosHashClear(info->dumplicateKey);
|
taosHashClear(info->dumplicateKey);
|
||||||
|
|
||||||
RandTableName rName = {.tags=tinfo->tags, .sTableName=tinfo->sTableName, .sTableNameLen=(uint8_t)tinfo->sTableNameLen,
|
RandTableName rName = { tinfo->tags, tinfo->sTableName, (uint8_t)tinfo->sTableNameLen,
|
||||||
.childTableName=tinfo->childTableName};
|
tinfo->childTableName, 0 };
|
||||||
buildChildTableName(&rName);
|
buildChildTableName(&rName);
|
||||||
tinfo->uid = rName.uid;
|
tinfo->uid = rName.uid;
|
||||||
|
|
||||||
|
@ -2057,20 +2082,24 @@ static int32_t smlParseTelnetLine(SSmlHandle* info, void *data) {
|
||||||
oneTable = &tinfo;
|
oneTable = &tinfo;
|
||||||
hasTable = false;
|
hasTable = false;
|
||||||
}else{
|
}else{
|
||||||
smlDestroyTableInfo(tinfo, true);
|
smlDestroyTableInfo(info, tinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush((*oneTable)->cols, &cols);
|
taosArrayPush((*oneTable)->cols, &cols);
|
||||||
SSmlSTableMeta** tableMeta = (SSmlSTableMeta** )taosHashGet(info->superTables, (*oneTable)->sTableName, (*oneTable)->sTableNameLen);
|
SSmlSTableMeta** tableMeta = (SSmlSTableMeta** )taosHashGet(info->superTables, (*oneTable)->sTableName, (*oneTable)->sTableNameLen);
|
||||||
if(tableMeta){ // update meta
|
if(tableMeta){ // update meta
|
||||||
ret = smlUpdateMeta(*tableMeta, hasTable ? NULL : (*oneTable)->tags, cols, &info->msgBuf);
|
ret = smlUpdateMeta((*tableMeta)->colHash, (*tableMeta)->cols, cols, &info->msgBuf);
|
||||||
|
if(!hasTable && ret){
|
||||||
|
ret = smlUpdateMeta((*tableMeta)->tagHash, (*tableMeta)->tags, (*oneTable)->tags, &info->msgBuf);
|
||||||
|
}
|
||||||
if(!ret){
|
if(!ret){
|
||||||
uError("SML:0x%"PRIx64" smlUpdateMeta failed", info->id);
|
uError("SML:0x%"PRIx64" smlUpdateMeta failed", info->id);
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
SSmlSTableMeta *meta = smlBuildSTableMeta();
|
SSmlSTableMeta *meta = smlBuildSTableMeta();
|
||||||
smlInsertMeta(meta, (*oneTable)->tags, cols);
|
smlInsertMeta(meta->tagHash, meta->tags, (*oneTable)->tags);
|
||||||
|
smlInsertMeta(meta->colHash, meta->cols, cols);
|
||||||
taosHashPut(info->superTables, (*oneTable)->sTableName, (*oneTable)->sTableNameLen, &meta, POINTER_BYTES);
|
taosHashPut(info->superTables, (*oneTable)->sTableName, (*oneTable)->sTableNameLen, &meta, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,6 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pStmt->exec.autoCreateTbl = false;
|
pStmt->exec.autoCreateTbl = false;
|
||||||
pStmt->exec.emptyRes = false;
|
|
||||||
|
|
||||||
if (keepTable) {
|
if (keepTable) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -298,7 +297,6 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
|
||||||
taosMemoryFree(pStmt->sql.queryRes.userFields);
|
taosMemoryFree(pStmt->sql.queryRes.userFields);
|
||||||
taosMemoryFree(pStmt->sql.sqlStr);
|
taosMemoryFree(pStmt->sql.sqlStr);
|
||||||
qDestroyQuery(pStmt->sql.pQuery);
|
qDestroyQuery(pStmt->sql.pQuery);
|
||||||
qDestroyQueryPlan(pStmt->sql.pQueryPlan);
|
|
||||||
taosArrayDestroy(pStmt->sql.nodeList);
|
taosArrayDestroy(pStmt->sql.nodeList);
|
||||||
|
|
||||||
void* pIter = taosHashIterate(pStmt->sql.pTableCache, NULL);
|
void* pIter = taosHashIterate(pStmt->sql.pTableCache, NULL);
|
||||||
|
@ -599,6 +597,8 @@ int32_t stmtFetchColFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD** fiel
|
||||||
int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_BIND));
|
||||||
|
|
||||||
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
|
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
|
||||||
STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
|
STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
|
||||||
pStmt->bInfo.needParse = false;
|
pStmt->bInfo.needParse = false;
|
||||||
|
@ -617,19 +617,40 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
||||||
STMT_ERR_RET(stmtParseSql(pStmt));
|
STMT_ERR_RET(stmtParseSql(pStmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_BIND));
|
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||||
if (NULL == pStmt->sql.pQueryPlan) {
|
STMT_ERR_RET(qStmtBindParams(pStmt->sql.pQuery, bind, colIdx, pStmt->exec.pRequest->requestId));
|
||||||
STMT_ERR_RET(getQueryPlan(pStmt->exec.pRequest, pStmt->sql.pQuery, &pStmt->sql.nodeList));
|
|
||||||
pStmt->sql.pQueryPlan = pStmt->exec.pRequest->body.pDag;
|
SParseContext ctx = {.requestId = pStmt->exec.pRequest->requestId,
|
||||||
pStmt->exec.pRequest->body.pDag = NULL;
|
.acctId = pStmt->taos->acctId,
|
||||||
STMT_ERR_RET(stmtBackupQueryFields(pStmt));
|
.db = pStmt->exec.pRequest->pDb,
|
||||||
} else {
|
.topicQuery = false,
|
||||||
STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
|
.pSql = pStmt->sql.sqlStr,
|
||||||
|
.sqlLen = pStmt->sql.sqlLen,
|
||||||
|
.pMsg = pStmt->exec.pRequest->msgBuf,
|
||||||
|
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||||
|
.pTransporter = pStmt->taos->pAppInfo->pTransporter,
|
||||||
|
.pStmtCb = NULL,
|
||||||
|
.pUser = pStmt->taos->user};
|
||||||
|
ctx.mgmtEpSet = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp);
|
||||||
|
STMT_ERR_RET(catalogGetHandle(pStmt->taos->pAppInfo->clusterId, &ctx.pCatalog));
|
||||||
|
|
||||||
|
STMT_ERR_RET(qStmtParseQuerySql(&ctx, pStmt->sql.pQuery));
|
||||||
|
|
||||||
|
if (pStmt->sql.pQuery->haveResultSet) {
|
||||||
|
setResSchemaInfo(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->pResSchema, pStmt->sql.pQuery->numOfResCols);
|
||||||
|
setResPrecision(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
STMT_RET(qStmtBindParam(pStmt->sql.pQueryPlan, bind, colIdx, pStmt->exec.pRequest->requestId, &pStmt->exec.emptyRes));
|
TSWAP(pStmt->exec.pRequest->dbList, pStmt->sql.pQuery->pDbList);
|
||||||
|
TSWAP(pStmt->exec.pRequest->tableList, pStmt->sql.pQuery->pTableList);
|
||||||
|
|
||||||
|
//if (STMT_TYPE_QUERY == pStmt->sql.queryRes) {
|
||||||
|
// STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
|
||||||
|
//}
|
||||||
|
|
||||||
|
//STMT_ERR_RET(stmtBackupQueryFields(pStmt));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableDataBlocks **pDataBlock = (STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
STableDataBlocks **pDataBlock = (STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||||
|
@ -736,11 +757,7 @@ int stmtExec(TAOS_STMT *stmt) {
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE));
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||||
if (pStmt->exec.emptyRes) {
|
launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, TSDB_CODE_SUCCESS, true, NULL);
|
||||||
pStmt->exec.pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
|
|
||||||
} else {
|
|
||||||
scheduleQuery(pStmt->exec.pRequest, pStmt->sql.pQueryPlan, pStmt->sql.nodeList, NULL);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
STMT_ERR_RET(qBuildStmtOutput(pStmt->sql.pQuery, pStmt->exec.pVgHash, pStmt->exec.pBlockHash));
|
STMT_ERR_RET(qBuildStmtOutput(pStmt->sql.pQuery, pStmt->exec.pVgHash, pStmt->exec.pBlockHash));
|
||||||
launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, TSDB_CODE_SUCCESS, true, (autoCreateTbl ? (void**)&pRsp : NULL));
|
launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, TSDB_CODE_SUCCESS, true, (autoCreateTbl ? (void**)&pRsp : NULL));
|
||||||
|
@ -839,16 +856,7 @@ int stmtGetParamNum(TAOS_STMT* stmt, int* nums) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||||
if (NULL == pStmt->sql.pQueryPlan) {
|
*nums = taosArrayGetSize(pStmt->sql.pQuery->pPlaceholderValues);
|
||||||
STMT_ERR_RET(getQueryPlan(pStmt->exec.pRequest, pStmt->sql.pQuery, &pStmt->sql.nodeList));
|
|
||||||
pStmt->sql.pQueryPlan = pStmt->exec.pRequest->body.pDag;
|
|
||||||
pStmt->exec.pRequest->body.pDag = NULL;
|
|
||||||
STMT_ERR_RET(stmtBackupQueryFields(pStmt));
|
|
||||||
} else {
|
|
||||||
STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
|
|
||||||
}
|
|
||||||
|
|
||||||
*nums = taosArrayGetSize(pStmt->sql.pQueryPlan->pPlaceholderValues);
|
|
||||||
} else {
|
} else {
|
||||||
STMT_ERR_RET(stmtFetchColFields(stmt, nums, NULL));
|
STMT_ERR_RET(stmtFetchColFields(stmt, nums, NULL));
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,6 +185,7 @@ typedef struct {
|
||||||
int32_t async;
|
int32_t async;
|
||||||
tsem_t rspSem;
|
tsem_t rspSem;
|
||||||
tmq_resp_err_t rspErr;
|
tmq_resp_err_t rspErr;
|
||||||
|
SArray* offsets;
|
||||||
} SMqCommitCbParam;
|
} SMqCommitCbParam;
|
||||||
|
|
||||||
tmq_conf_t* tmq_conf_new() {
|
tmq_conf_t* tmq_conf_new() {
|
||||||
|
@ -246,10 +247,13 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
|
||||||
if (strcmp(key, "msg.with.table.name") == 0) {
|
if (strcmp(key, "msg.with.table.name") == 0) {
|
||||||
if (strcmp(value, "true") == 0) {
|
if (strcmp(value, "true") == 0) {
|
||||||
conf->withTbName = 1;
|
conf->withTbName = 1;
|
||||||
|
return TMQ_CONF_OK;
|
||||||
} else if (strcmp(value, "false") == 0) {
|
} else if (strcmp(value, "false") == 0) {
|
||||||
conf->withTbName = 0;
|
conf->withTbName = 0;
|
||||||
|
return TMQ_CONF_OK;
|
||||||
} else if (strcmp(value, "none") == 0) {
|
} else if (strcmp(value, "none") == 0) {
|
||||||
conf->withTbName = -1;
|
conf->withTbName = -1;
|
||||||
|
return TMQ_CONF_OK;
|
||||||
} else {
|
} else {
|
||||||
return TMQ_CONF_INVALID;
|
return TMQ_CONF_INVALID;
|
||||||
}
|
}
|
||||||
|
@ -395,6 +399,9 @@ int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
if (!pParam->async)
|
if (!pParam->async)
|
||||||
tsem_post(&pParam->rspSem);
|
tsem_post(&pParam->rspSem);
|
||||||
else {
|
else {
|
||||||
|
if (pParam->offsets) {
|
||||||
|
taosArrayDestroy(pParam->offsets);
|
||||||
|
}
|
||||||
tsem_destroy(&pParam->rspSem);
|
tsem_destroy(&pParam->rspSem);
|
||||||
/*if (pParam->pArray) {*/
|
/*if (pParam->pArray) {*/
|
||||||
/*taosArrayDestroy(pParam->pArray);*/
|
/*taosArrayDestroy(pParam->pArray);*/
|
||||||
|
@ -540,10 +547,10 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
// build msg
|
// build msg
|
||||||
// send to mnode
|
// send to mnode
|
||||||
SMqCMCommitOffsetReq req;
|
SMqCMCommitOffsetReq req;
|
||||||
SArray* pArray = NULL;
|
SArray* pOffsets = NULL;
|
||||||
|
|
||||||
if (offsets == NULL) {
|
if (offsets == NULL) {
|
||||||
pArray = taosArrayInit(0, sizeof(SMqOffset));
|
pOffsets = taosArrayInit(0, sizeof(SMqOffset));
|
||||||
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
||||||
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i);
|
||||||
for (int j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
for (int j = 0; j < taosArrayGetSize(pTopic->vgs); j++) {
|
||||||
|
@ -553,11 +560,11 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
strcpy(offset.cgroup, tmq->groupId);
|
strcpy(offset.cgroup, tmq->groupId);
|
||||||
offset.vgId = pVg->vgId;
|
offset.vgId = pVg->vgId;
|
||||||
offset.offset = pVg->currentOffset;
|
offset.offset = pVg->currentOffset;
|
||||||
taosArrayPush(pArray, &offset);
|
taosArrayPush(pOffsets, &offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
req.num = pArray->size;
|
req.num = pOffsets->size;
|
||||||
req.offsets = pArray->pData;
|
req.offsets = pOffsets->pData;
|
||||||
} else {
|
} else {
|
||||||
req.num = taosArrayGetSize(&offsets->container);
|
req.num = taosArrayGetSize(&offsets->container);
|
||||||
req.offsets = (SMqOffset*)offsets->container.pData;
|
req.offsets = (SMqOffset*)offsets->container.pData;
|
||||||
|
@ -591,6 +598,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
pParam->tmq = tmq;
|
pParam->tmq = tmq;
|
||||||
tsem_init(&pParam->rspSem, 0, 0);
|
tsem_init(&pParam->rspSem, 0, 0);
|
||||||
pParam->async = async;
|
pParam->async = async;
|
||||||
|
pParam->offsets = pOffsets;
|
||||||
|
|
||||||
pRequest->body.requestMsg = (SDataBuf){
|
pRequest->body.requestMsg = (SDataBuf){
|
||||||
.pData = buf,
|
.pData = buf,
|
||||||
|
@ -613,8 +621,8 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
tsem_destroy(&pParam->rspSem);
|
tsem_destroy(&pParam->rspSem);
|
||||||
taosMemoryFree(pParam);
|
taosMemoryFree(pParam);
|
||||||
|
|
||||||
if (pArray) {
|
if (pOffsets) {
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pOffsets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,7 +1023,7 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
|
||||||
atomic_store_32(&tmq->epSkipCnt, 0);
|
atomic_store_32(&tmq->epSkipCnt, 0);
|
||||||
#endif
|
#endif
|
||||||
int32_t tlen = sizeof(SMqAskEpReq);
|
int32_t tlen = sizeof(SMqAskEpReq);
|
||||||
SMqAskEpReq* req = taosMemoryMalloc(tlen);
|
SMqAskEpReq* req = taosMemoryCalloc(1, tlen);
|
||||||
if (req == NULL) {
|
if (req == NULL) {
|
||||||
tscError("failed to malloc get subscribe ep buf");
|
tscError("failed to malloc get subscribe ep buf");
|
||||||
/*atomic_store_8(&tmq->epStatus, 0);*/
|
/*atomic_store_8(&tmq->epStatus, 0);*/
|
||||||
|
@ -1025,7 +1033,7 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
|
||||||
req->epoch = htonl(tmq->epoch);
|
req->epoch = htonl(tmq->epoch);
|
||||||
strcpy(req->cgroup, tmq->groupId);
|
strcpy(req->cgroup, tmq->groupId);
|
||||||
|
|
||||||
SMqAskEpCbParam* pParam = taosMemoryMalloc(sizeof(SMqAskEpCbParam));
|
SMqAskEpCbParam* pParam = taosMemoryCalloc(1, sizeof(SMqAskEpCbParam));
|
||||||
if (pParam == NULL) {
|
if (pParam == NULL) {
|
||||||
tscError("failed to malloc subscribe param");
|
tscError("failed to malloc subscribe param");
|
||||||
taosMemoryFree(req);
|
taosMemoryFree(req);
|
||||||
|
@ -1107,7 +1115,7 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t waitTime, SMqClientTopic*
|
||||||
reqOffset = tmq->resetOffsetCfg;
|
reqOffset = tmq->resetOffsetCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqPollReq* pReq = taosMemoryMalloc(sizeof(SMqPollReq));
|
SMqPollReq* pReq = taosMemoryCalloc(1, sizeof(SMqPollReq));
|
||||||
if (pReq == NULL) {
|
if (pReq == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,7 +228,7 @@ TEST(testCase, smlParseCols_tag_Test) {
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cbin", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cbin", 4), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 4);
|
ASSERT_EQ(kv->keyLen, 4);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_NCHAR);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_NCHAR);
|
||||||
ASSERT_EQ(kv->valueLen, 17);
|
ASSERT_EQ(kv->length, 17);
|
||||||
ASSERT_EQ(strncasecmp(kv->value, "\"passit", 7), 0);
|
ASSERT_EQ(strncasecmp(kv->value, "\"passit", 7), 0);
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ TEST(testCase, smlParseCols_tag_Test) {
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cf64", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cf64", 4), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 4);
|
ASSERT_EQ(kv->keyLen, 4);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_NCHAR);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_NCHAR);
|
||||||
ASSERT_EQ(kv->valueLen, 7);
|
ASSERT_EQ(kv->length, 7);
|
||||||
ASSERT_EQ(strncasecmp(kv->value, "4.31f64", 7), 0);
|
ASSERT_EQ(strncasecmp(kv->value, "4.31f64", 7), 0);
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ TEST(testCase, smlParseCols_tag_Test) {
|
||||||
ASSERT_EQ(strncasecmp(kv->key, TAG, strlen(TAG)), 0);
|
ASSERT_EQ(strncasecmp(kv->key, TAG, strlen(TAG)), 0);
|
||||||
ASSERT_EQ(kv->keyLen, strlen(TAG));
|
ASSERT_EQ(kv->keyLen, strlen(TAG));
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_NCHAR);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_NCHAR);
|
||||||
ASSERT_EQ(kv->valueLen, strlen(TAG));
|
ASSERT_EQ(kv->length, strlen(TAG));
|
||||||
ASSERT_EQ(strncasecmp(kv->value, TAG, strlen(TAG)), 0);
|
ASSERT_EQ(strncasecmp(kv->value, TAG, strlen(TAG)), 0);
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
|
@ -499,12 +499,14 @@ TEST(testCase, smlProcess_influx_Test) {
|
||||||
TAOS_RES *res = taos_query(taos, "select * from t_6885c584b98481584ee13dac399e173d");
|
TAOS_RES *res = taos_query(taos, "select * from t_6885c584b98481584ee13dac399e173d");
|
||||||
ASSERT_NE(res, nullptr);
|
ASSERT_NE(res, nullptr);
|
||||||
int fieldNum = taos_field_count(res);
|
int fieldNum = taos_field_count(res);
|
||||||
ASSERT_EQ(fieldNum, 11);
|
ASSERT_EQ(fieldNum, 5);
|
||||||
int rowNum = taos_affected_rows(res);
|
int rowNum = taos_affected_rows(res);
|
||||||
ASSERT_EQ(rowNum, 2);
|
ASSERT_EQ(rowNum, 2);
|
||||||
for (int i = 0; i < rowNum; ++i) {
|
for (int i = 0; i < rowNum; ++i) {
|
||||||
TAOS_ROW rows = taos_fetch_row(res);
|
TAOS_ROW rows = taos_fetch_row(res);
|
||||||
}
|
}
|
||||||
|
taos_free_result(res);
|
||||||
|
smlDestroyInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
// different types
|
// different types
|
||||||
|
@ -530,6 +532,8 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
};
|
};
|
||||||
int ret = smlProcess(info, (char **)sql, sizeof(sql)/sizeof(sql[0]));
|
int ret = smlProcess(info, (char **)sql, sizeof(sql)/sizeof(sql[0]));
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
|
destroyRequest(request);
|
||||||
|
smlDestroyInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, smlGetTimestampLen_Test) {
|
TEST(testCase, smlGetTimestampLen_Test) {
|
||||||
|
@ -571,11 +575,12 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
ASSERT_NE(info, nullptr);
|
ASSERT_NE(info, nullptr);
|
||||||
|
|
||||||
const char *sql[4] = {
|
const char *sql[5] = {
|
||||||
"sys.if.bytes.out 1479496100 1.3E0 host=web01 interface=eth0",
|
"sys.if.bytes.out 1479496100 1.3E0 host=web01 interface=eth0",
|
||||||
"sys.if.bytes.out 1479496101 1.3E1 interface=eth0 host=web01",
|
"sys.if.bytes.out 1479496101 1.3E1 interface=eth0 host=web01",
|
||||||
"sys.if.bytes.out 1479496102 1.3E3 network=tcp",
|
"sys.if.bytes.out 1479496102 1.3E3 network=tcp",
|
||||||
"sys.procs.running 1479496100 42 host=web01"
|
"sys.procs.running 1479496100 42 host=web01 ",
|
||||||
|
" sys.procs.running 1479496200 42 host=web01=4"
|
||||||
};
|
};
|
||||||
int ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0]));
|
int ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0]));
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
|
@ -589,6 +594,7 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
for (int i = 0; i < rowNum; ++i) {
|
for (int i = 0; i < rowNum; ++i) {
|
||||||
TAOS_ROW rows = taos_fetch_row(res);
|
TAOS_ROW rows = taos_fetch_row(res);
|
||||||
}
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
res = taos_query(taos, "select * from t_6931529054e5637ca92c78a1ad441961");
|
res = taos_query(taos, "select * from t_6931529054e5637ca92c78a1ad441961");
|
||||||
ASSERT_NE(res, nullptr);
|
ASSERT_NE(res, nullptr);
|
||||||
|
@ -599,9 +605,11 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
for (int i = 0; i < rowNum; ++i) {
|
for (int i = 0; i < rowNum; ++i) {
|
||||||
TAOS_ROW rows = taos_fetch_row(res);
|
TAOS_ROW rows = taos_fetch_row(res);
|
||||||
}
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
smlDestroyInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, smlProcess_json_Test) {
|
TEST(testCase, smlProcess_json1_Test) {
|
||||||
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
ASSERT_NE(taos, nullptr);
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
|
@ -617,7 +625,8 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
ASSERT_NE(info, nullptr);
|
ASSERT_NE(info, nullptr);
|
||||||
|
|
||||||
const char *sql = "[\n"
|
const char *sql =
|
||||||
|
"[\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" \"metric\": \"sys.cpu.nice\",\n"
|
" \"metric\": \"sys.cpu.nice\",\n"
|
||||||
" \"timestamp\": 1346846400,\n"
|
" \"timestamp\": 1346846400,\n"
|
||||||
|
@ -649,9 +658,28 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
// for (int i = 0; i < rowNum; ++i) {
|
// for (int i = 0; i < rowNum; ++i) {
|
||||||
// TAOS_ROW rows = taos_fetch_row(res);
|
// TAOS_ROW rows = taos_fetch_row(res);
|
||||||
// }
|
// }
|
||||||
|
taos_free_result(pRes);
|
||||||
|
smlDestroyInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
sql = "{\n"
|
TEST(testCase, smlProcess_json2_Test) {
|
||||||
" \"metric\": \"meter_current\",\n"
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
|
TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(taos, "use sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
SRequestObj *request = (SRequestObj *)createRequest((STscObj *)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
|
ASSERT_NE(request, nullptr);
|
||||||
|
|
||||||
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
|
ASSERT_NE(info, nullptr);
|
||||||
|
const char *sql =
|
||||||
|
"{\n"
|
||||||
|
" \"metric\": \"meter_current0\",\n"
|
||||||
" \"timestamp\": {\n"
|
" \"timestamp\": {\n"
|
||||||
" \"value\" : 1346846400,\n"
|
" \"value\" : 1346846400,\n"
|
||||||
" \"type\" : \"s\"\n"
|
" \"type\" : \"s\"\n"
|
||||||
|
@ -672,11 +700,30 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
" \"id\": \"d1001\"\n"
|
" \"id\": \"d1001\"\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}";
|
"}";
|
||||||
ret = smlProcess(info, (char**)(&sql), -1);
|
int32_t ret = smlProcess(info, (char **)(&sql), -1);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
|
taos_free_result(pRes);
|
||||||
|
smlDestroyInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
sql = "{\n"
|
TEST(testCase, smlProcess_json3_Test) {
|
||||||
" \"metric\": \"meter_current\",\n"
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
|
TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(taos, "use sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
SRequestObj *request = (SRequestObj *)createRequest((STscObj *)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
|
ASSERT_NE(request, nullptr);
|
||||||
|
|
||||||
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
|
ASSERT_NE(info, nullptr);
|
||||||
|
const char *sql =
|
||||||
|
"{\n"
|
||||||
|
" \"metric\": \"meter_current1\",\n"
|
||||||
" \"timestamp\": {\n"
|
" \"timestamp\": {\n"
|
||||||
" \"value\" : 1346846400,\n"
|
" \"value\" : 1346846400,\n"
|
||||||
" \"type\" : \"s\"\n"
|
" \"type\" : \"s\"\n"
|
||||||
|
@ -716,7 +763,7 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
" },\n"
|
" },\n"
|
||||||
" \"t8\": { \n"
|
" \"t8\": { \n"
|
||||||
" \"value\" : \"北京\",\n"
|
" \"value\" : \"北京\",\n"
|
||||||
" \"type\" : \"binary\"\n"
|
" \"type\" : \"nchar\"\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
" \"t9\": { \n"
|
" \"t9\": { \n"
|
||||||
" \"value\" : true,\n"
|
" \"value\" : true,\n"
|
||||||
|
@ -725,13 +772,31 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
" \"id\": \"d1001\"\n"
|
" \"id\": \"d1001\"\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}";
|
"}";
|
||||||
ret = smlProcess(info, (char**)(&sql), -1);
|
int32_t ret = smlProcess(info, (char **)(&sql), -1);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
|
taos_free_result(pRes);
|
||||||
|
smlDestroyInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
sql = "{\n"
|
TEST(testCase, smlProcess_json4_Test) {
|
||||||
" \"metric\": \"meter_current\",\n"
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(taos, "use sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
|
ASSERT_NE(request, nullptr);
|
||||||
|
|
||||||
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
|
ASSERT_NE(info, nullptr);
|
||||||
|
const char *sql = "{\n"
|
||||||
|
" \"metric\": \"meter_current2\",\n"
|
||||||
" \"timestamp\": {\n"
|
" \"timestamp\": {\n"
|
||||||
" \"value\" : 1346846400000,\n"
|
" \"value\" : 1346846500000,\n"
|
||||||
" \"type\" : \"ms\"\n"
|
" \"type\" : \"ms\"\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
" \"value\": \"ni\",\n"
|
" \"value\": \"ni\",\n"
|
||||||
|
@ -763,12 +828,246 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
" \"t7\": \"nsj\",\n"
|
" \"t7\": \"nsj\",\n"
|
||||||
" \"t8\": { \n"
|
" \"t8\": { \n"
|
||||||
" \"value\" : \"北京\",\n"
|
" \"value\" : \"北京\",\n"
|
||||||
" \"type\" : \"binary\"\n"
|
" \"type\" : \"nchar\"\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
" \"t9\": false,\n"
|
" \"t9\": false,\n"
|
||||||
" \"id\": \"d1001\"\n"
|
" \"id\": \"d1001\"\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"}";
|
"}";
|
||||||
ret = smlProcess(info, (char**)(&sql), -1);
|
int32_t ret = smlProcess(info, (char**)(&sql), -1);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
|
taos_free_result(pRes);
|
||||||
|
smlDestroyInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, smlParseTelnetLine_error_Test) {
|
||||||
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(taos, "use sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
|
ASSERT_NE(request, nullptr);
|
||||||
|
|
||||||
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
|
ASSERT_NE(info, nullptr);
|
||||||
|
|
||||||
|
int32_t ret = 0;
|
||||||
|
const char *sql[19] = {
|
||||||
|
"sys.procs.running 14794961040 42 host=web01",
|
||||||
|
"sys.procs.running 14791040 42 host=web01",
|
||||||
|
"sys.procs.running erere 42 host=web01",
|
||||||
|
"sys.procs.running 1.6e10 42 host=web01",
|
||||||
|
"sys.procs.running 1.47949610 42 host=web01",
|
||||||
|
"sys.procs.running 147949610i 42 host=web01",
|
||||||
|
"sys.procs.running -147949610 42 host=web01",
|
||||||
|
"",
|
||||||
|
" ",
|
||||||
|
"sys ",
|
||||||
|
"sys.procs.running 1479496100 42 ",
|
||||||
|
"sys.procs.running 1479496100 42 host= ",
|
||||||
|
"sys.procs.running 1479496100 42or host=web01",
|
||||||
|
"sys.procs.running 1479496100 true host=web01",
|
||||||
|
"sys.procs.running 1479496100 \"binary\" host=web01",
|
||||||
|
"sys.procs.running 1479496100 L\"rfr\" host=web01",
|
||||||
|
"sys.procs.running 1479496100 42 host=web01 cpu= ",
|
||||||
|
"sys.procs.running 1479496100 42 host=web01 host=w2",
|
||||||
|
"sys.procs.running 1479496100 42 host=web01 host",
|
||||||
|
};
|
||||||
|
for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){
|
||||||
|
ret = smlParseTelnetLine(info, (void*)sql[i]);
|
||||||
|
ASSERT_NE(ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyRequest(request);
|
||||||
|
smlDestroyInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, smlParseTelnetLine_diff_type_Test) {
|
||||||
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(taos, "use sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
|
ASSERT_NE(request, nullptr);
|
||||||
|
|
||||||
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
|
ASSERT_NE(info, nullptr);
|
||||||
|
|
||||||
|
const char *sql[2] = {
|
||||||
|
"sys.procs.running 1479496104000 42 host=web01",
|
||||||
|
"sys.procs.running 1479496104000 42u8 host=web01"
|
||||||
|
};
|
||||||
|
int32_t ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0]));
|
||||||
|
ASSERT_NE(ret, 0);
|
||||||
|
|
||||||
|
destroyRequest(request);
|
||||||
|
smlDestroyInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, smlParseTelnetLine_json_error_Test) {
|
||||||
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(taos, "use sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
|
ASSERT_NE(request, nullptr);
|
||||||
|
|
||||||
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
|
ASSERT_NE(info, nullptr);
|
||||||
|
|
||||||
|
int32_t ret = 0;
|
||||||
|
const char *sql[] = {
|
||||||
|
"[\n"
|
||||||
|
" {\n"
|
||||||
|
" \"metric\": \"sys.cpu.nice\",\n"
|
||||||
|
" \"timestamp\": 13468464009999333322222223,\n"
|
||||||
|
" \"value\": 18,\n"
|
||||||
|
" \"tags\": {\n"
|
||||||
|
" \"host\": \"web01\",\n"
|
||||||
|
" \"dc\": \"lga\"\n"
|
||||||
|
" }\n"
|
||||||
|
" },\n"
|
||||||
|
"]",
|
||||||
|
"[\n"
|
||||||
|
" {\n"
|
||||||
|
" \"metric\": \"sys.cpu.nice\",\n"
|
||||||
|
" \"timestamp\": 1346846400i,\n"
|
||||||
|
" \"value\": 18,\n"
|
||||||
|
" \"tags\": {\n"
|
||||||
|
" \"host\": \"web01\",\n"
|
||||||
|
" \"dc\": \"lga\"\n"
|
||||||
|
" }\n"
|
||||||
|
" },\n"
|
||||||
|
"]",
|
||||||
|
"[\n"
|
||||||
|
" {\n"
|
||||||
|
" \"metric\": \"sys.cpu.nice\",\n"
|
||||||
|
" \"timestamp\": 1346846400,\n"
|
||||||
|
" \"value\": 18,\n"
|
||||||
|
" \"tags\": {\n"
|
||||||
|
" \"groupid\": { \n"
|
||||||
|
" \"value\" : 2,\n"
|
||||||
|
" \"type\" : \"nchar\"\n"
|
||||||
|
" },\n"
|
||||||
|
" \"location\": { \n"
|
||||||
|
" \"value\" : \"北京\",\n"
|
||||||
|
" \"type\" : \"binary\"\n"
|
||||||
|
" },\n"
|
||||||
|
" \"id\": \"d1001\"\n"
|
||||||
|
" }\n"
|
||||||
|
" },\n"
|
||||||
|
"]",
|
||||||
|
};
|
||||||
|
for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){
|
||||||
|
ret = smlParseTelnetLine(info, (void*)sql[i]);
|
||||||
|
ASSERT_NE(ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyRequest(request);
|
||||||
|
smlDestroyInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) {
|
||||||
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(taos, "use sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
|
ASSERT_NE(request, nullptr);
|
||||||
|
|
||||||
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
|
ASSERT_NE(info, nullptr);
|
||||||
|
|
||||||
|
const char *sql[2] = {
|
||||||
|
"[\n"
|
||||||
|
" {\n"
|
||||||
|
" \"metric\": \"sys.cpu.nice\",\n"
|
||||||
|
" \"timestamp\": 1346846400,\n"
|
||||||
|
" \"value\": 18,\n"
|
||||||
|
" \"tags\": {\n"
|
||||||
|
" \"host\": \"lga\"\n"
|
||||||
|
" }\n"
|
||||||
|
" },\n"
|
||||||
|
"]",
|
||||||
|
"[\n"
|
||||||
|
" {\n"
|
||||||
|
" \"metric\": \"sys.cpu.nice\",\n"
|
||||||
|
" \"timestamp\": 1346846400,\n"
|
||||||
|
" \"value\": 18,\n"
|
||||||
|
" \"tags\": {\n"
|
||||||
|
" \"host\": 8\n"
|
||||||
|
" }\n"
|
||||||
|
" },\n"
|
||||||
|
"]",
|
||||||
|
};
|
||||||
|
int32_t ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0]));
|
||||||
|
ASSERT_NE(ret, 0);
|
||||||
|
|
||||||
|
destroyRequest(request);
|
||||||
|
smlDestroyInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) {
|
||||||
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(taos, "use sml_db");
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
|
ASSERT_NE(request, nullptr);
|
||||||
|
|
||||||
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
|
ASSERT_NE(info, nullptr);
|
||||||
|
|
||||||
|
const char *sql[2] = {
|
||||||
|
"[\n"
|
||||||
|
" {\n"
|
||||||
|
" \"metric\": \"sys.cpu.nice\",\n"
|
||||||
|
" \"timestamp\": 1346846400,\n"
|
||||||
|
" \"value\": 18,\n"
|
||||||
|
" \"tags\": {\n"
|
||||||
|
" \"host\": \"lga\"\n"
|
||||||
|
" }\n"
|
||||||
|
" },\n"
|
||||||
|
"]",
|
||||||
|
"[\n"
|
||||||
|
" {\n"
|
||||||
|
" \"metric\": \"sys.cpu.nice\",\n"
|
||||||
|
" \"timestamp\": 1346846400,\n"
|
||||||
|
" \"value\": \"18\",\n"
|
||||||
|
" \"tags\": {\n"
|
||||||
|
" \"host\": \"fff\"\n"
|
||||||
|
" }\n"
|
||||||
|
" },\n"
|
||||||
|
"]",
|
||||||
|
};
|
||||||
|
int32_t ret = smlProcess(info, (char**)sql, sizeof(sql)/sizeof(sql[0]));
|
||||||
|
ASSERT_NE(ret, 0);
|
||||||
|
|
||||||
|
destroyRequest(request);
|
||||||
|
smlDestroyInfo(info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,6 +282,7 @@ int32_t taosAddClientLogCfg(SConfig *pCfg) {
|
||||||
if (cfgAddInt32(pCfg, "cDebugFlag", cDebugFlag, 0, 255, 1) != 0) return -1;
|
if (cfgAddInt32(pCfg, "cDebugFlag", cDebugFlag, 0, 255, 1) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "uDebugFlag", uDebugFlag, 0, 255, 1) != 0) return -1;
|
if (cfgAddInt32(pCfg, "uDebugFlag", uDebugFlag, 0, 255, 1) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "rpcDebugFlag", rpcDebugFlag, 0, 255, 1) != 0) return -1;
|
if (cfgAddInt32(pCfg, "rpcDebugFlag", rpcDebugFlag, 0, 255, 1) != 0) return -1;
|
||||||
|
if (cfgAddInt32(pCfg, "qDebugFlag", qDebugFlag, 0, 255, 1) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "tmrDebugFlag", tmrDebugFlag, 0, 255, 1) != 0) return -1;
|
if (cfgAddInt32(pCfg, "tmrDebugFlag", tmrDebugFlag, 0, 255, 1) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "jniDebugFlag", jniDebugFlag, 0, 255, 1) != 0) return -1;
|
if (cfgAddInt32(pCfg, "jniDebugFlag", jniDebugFlag, 0, 255, 1) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "simDebugFlag", 143, 0, 255, 1) != 0) return -1;
|
if (cfgAddInt32(pCfg, "simDebugFlag", 143, 0, 255, 1) != 0) return -1;
|
||||||
|
@ -464,6 +465,7 @@ static void taosSetClientLogCfg(SConfig *pCfg) {
|
||||||
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
|
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
|
||||||
cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32;
|
cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32;
|
||||||
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
|
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
|
||||||
|
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
|
||||||
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
|
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
|
||||||
tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32;
|
tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32;
|
||||||
jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32;
|
jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32;
|
||||||
|
|
|
@ -317,7 +317,11 @@ void buildChildTableName(RandTableName* rName) {
|
||||||
for (int j = 0; j < size; ++j) {
|
for (int j = 0; j < size; ++j) {
|
||||||
SSmlKv* tagKv = taosArrayGetP(rName->tags, j);
|
SSmlKv* tagKv = taosArrayGetP(rName->tags, j);
|
||||||
taosStringBuilderAppendStringLen(&sb, tagKv->key, tagKv->keyLen);
|
taosStringBuilderAppendStringLen(&sb, tagKv->key, tagKv->keyLen);
|
||||||
taosStringBuilderAppendStringLen(&sb, tagKv->value, tagKv->valueLen);
|
if(IS_VAR_DATA_TYPE(tagKv->type)){
|
||||||
|
taosStringBuilderAppendStringLen(&sb, tagKv->value, tagKv->length);
|
||||||
|
}else{
|
||||||
|
taosStringBuilderAppendStringLen(&sb, (char*)(&(tagKv->value)), tagKv->length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
char* keyJoined = taosStringBuilderGetResult(&sb, &len);
|
char* keyJoined = taosStringBuilderGetResult(&sb, &len);
|
||||||
|
|
|
@ -47,6 +47,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt);
|
||||||
int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
|
int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SNodeMsg *pMsg);
|
||||||
|
|
||||||
// dmMonitor.c
|
// dmMonitor.c
|
||||||
void dmGetVnodeLoads(SDnodeMgmt *pMgmt, SMonVloadInfo *pInfo);
|
void dmGetVnodeLoads(SDnodeMgmt *pMgmt, SMonVloadInfo *pInfo);
|
||||||
|
|
|
@ -120,6 +120,59 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dmGetServerRunStatus(SDnodeMgmt *pMgmt, SServerStatusRsp *pStatus) {
|
||||||
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_OK;
|
||||||
|
pStatus->details[0] = 0;
|
||||||
|
|
||||||
|
SServerStatusRsp statusRsp = {0};
|
||||||
|
SMonMloadInfo minfo = {0};
|
||||||
|
dmGetMnodeLoads(pMgmt, &minfo);
|
||||||
|
if (minfo.isMnode && minfo.load.syncState != TAOS_SYNC_STATE_LEADER &&
|
||||||
|
minfo.load.syncState != TAOS_SYNC_STATE_CANDIDATE) {
|
||||||
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||||
|
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SMonVloadInfo vinfo = {0};
|
||||||
|
dmGetVnodeLoads(pMgmt, &vinfo);
|
||||||
|
for (int32_t i = 0; i < taosArrayGetSize(vinfo.pVloads); ++i) {
|
||||||
|
SVnodeLoad *pLoad = taosArrayGet(vinfo.pVloads, i);
|
||||||
|
if (pLoad->syncState != TAOS_SYNC_STATE_LEADER && pLoad->syncState != TAOS_SYNC_STATE_FOLLOWER) {
|
||||||
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
||||||
|
snprintf(pStatus->details, sizeof(pStatus->details), "vnode:%d sync state is %s", pLoad->vgId,
|
||||||
|
syncStr(pLoad->syncState));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(vinfo.pVloads);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t dmProcessServerRunStatus(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
|
dDebug("server run status req is received");
|
||||||
|
SServerStatusRsp statusRsp = {0};
|
||||||
|
dmGetServerRunStatus(pMgmt, &statusRsp);
|
||||||
|
|
||||||
|
SRpcMsg rspMsg = {.handle = pMsg->rpcMsg.handle, .ahandle = pMsg->rpcMsg.ahandle, .refId = pMsg->rpcMsg.refId};
|
||||||
|
int32_t rspLen = tSerializeSServerStatusRsp(NULL, 0, &statusRsp);
|
||||||
|
if (rspLen < 0) {
|
||||||
|
rspMsg.code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pRsp = rpcMallocCont(rspLen);
|
||||||
|
if (pRsp == NULL) {
|
||||||
|
rspMsg.code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tSerializeSServerStatusRsp(pRsp, rspLen, &statusRsp);
|
||||||
|
pMsg->pRsp = pRsp;
|
||||||
|
pMsg->rspLen = rspLen;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
SArray *dmGetMsgHandles() {
|
SArray *dmGetMsgHandles() {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SArray *pArray = taosArrayInit(16, sizeof(SMgmtHandle));
|
SArray *pArray = taosArrayInit(16, sizeof(SMgmtHandle));
|
||||||
|
@ -135,6 +188,7 @@ SArray *dmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_BNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_BNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_BNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_BNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CONFIG_DNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CONFIG_DNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_DND_SERVER_STATUS, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
// Requests handled by MNODE
|
// Requests handled by MNODE
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT_RSP, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT_RSP, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -100,10 +100,10 @@ void dmStopMonitorThread(SDnodeMgmt *pMgmt) {
|
||||||
|
|
||||||
static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
SDnodeMgmt *pMgmt = pInfo->ahandle;
|
SDnodeMgmt *pMgmt = pInfo->ahandle;
|
||||||
|
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
tmsg_t msgType = pMsg->rpcMsg.msgType;
|
tmsg_t msgType = pMsg->rpcMsg.msgType;
|
||||||
dTrace("msg:%p, will be processed in dnode-mgmt queue", pMsg);
|
bool isRequest = msgType & 1u;
|
||||||
|
dTrace("msg:%p, will be processed in dnode-mgmt queue, type:%s", pMsg, TMSG_INFO(msgType));
|
||||||
|
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case TDMT_DND_CONFIG_DNODE:
|
case TDMT_DND_CONFIG_DNODE:
|
||||||
|
@ -139,17 +139,23 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
case TDMT_DND_DROP_BNODE:
|
case TDMT_DND_DROP_BNODE:
|
||||||
code = (*pMgmt->processDropNodeFp)(pMgmt->pDnode, BNODE, pMsg);
|
code = (*pMgmt->processDropNodeFp)(pMgmt->pDnode, BNODE, pMsg);
|
||||||
break;
|
break;
|
||||||
|
case TDMT_DND_SERVER_STATUS:
|
||||||
|
code = dmProcessServerRunStatus(pMgmt, pMsg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgType & 1u) {
|
if (isRequest) {
|
||||||
if (code != 0 && terrno != 0) code = terrno;
|
if (code != 0 && terrno != 0) code = terrno;
|
||||||
SRpcMsg rsp = {
|
SRpcMsg rsp = {
|
||||||
.handle = pMsg->rpcMsg.handle,
|
.handle = pMsg->rpcMsg.handle,
|
||||||
.ahandle = pMsg->rpcMsg.ahandle,
|
.ahandle = pMsg->rpcMsg.ahandle,
|
||||||
.code = code,
|
.code = code,
|
||||||
.refId = pMsg->rpcMsg.refId,
|
.refId = pMsg->rpcMsg.refId,
|
||||||
|
.pCont = pMsg->pRsp,
|
||||||
|
.contLen = pMsg->rspLen,
|
||||||
};
|
};
|
||||||
rpcSendResponse(&rsp);
|
rpcSendResponse(&rsp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,6 @@ typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int32_t vgVersion;
|
int32_t vgVersion;
|
||||||
int8_t dropped;
|
int8_t dropped;
|
||||||
uint64_t dbUid;
|
|
||||||
char db[TSDB_DB_FNAME_LEN];
|
|
||||||
char path[PATH_MAX + 20];
|
char path[PATH_MAX + 20];
|
||||||
} SWrapperCfg;
|
} SWrapperCfg;
|
||||||
|
|
||||||
|
@ -58,8 +56,6 @@ typedef struct {
|
||||||
int32_t vgVersion;
|
int32_t vgVersion;
|
||||||
int8_t dropped;
|
int8_t dropped;
|
||||||
int8_t accessState;
|
int8_t accessState;
|
||||||
uint64_t dbUid;
|
|
||||||
char *db;
|
|
||||||
char *path;
|
char *path;
|
||||||
SVnode *pImpl;
|
SVnode *pImpl;
|
||||||
STaosQueue *pWriteQ;
|
STaosQueue *pWriteQ;
|
||||||
|
|
|
@ -47,7 +47,7 @@ SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
|
||||||
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes) {
|
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes) {
|
||||||
int32_t code = TSDB_CODE_INVALID_JSON_FORMAT;
|
int32_t code = TSDB_CODE_INVALID_JSON_FORMAT;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 30000;
|
int32_t maxLen = 1024 * 1024;
|
||||||
char *content = taosMemoryCalloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
cJSON *root = NULL;
|
cJSON *root = NULL;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
@ -64,6 +64,11 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (content == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
len = (int32_t)taosReadFile(pFile, content, maxLen);
|
len = (int32_t)taosReadFile(pFile, content, maxLen);
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
dError("failed to read %s since content is null", file);
|
dError("failed to read %s since content is null", file);
|
||||||
|
@ -116,20 +121,6 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
pCfg->vgVersion = vgVersion->valueint;
|
pCfg->vgVersion = vgVersion->valueint;
|
||||||
|
|
||||||
cJSON *dbUid = cJSON_GetObjectItem(vnode, "dbUid");
|
|
||||||
if (!dbUid || dbUid->type != cJSON_String) {
|
|
||||||
dError("failed to read %s since dbUid not found", file);
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
pCfg->dbUid = atoll(dbUid->valuestring);
|
|
||||||
|
|
||||||
cJSON *db = cJSON_GetObjectItem(vnode, "db");
|
|
||||||
if (!db || db->type != cJSON_String) {
|
|
||||||
dError("failed to read %s since db not found", file);
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
tstrncpy(pCfg->db, db->valuestring, TSDB_DB_FNAME_LEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppCfgs = pCfgs;
|
*ppCfgs = pCfgs;
|
||||||
|
@ -165,8 +156,12 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
SVnodeObj **pVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
|
SVnodeObj **pVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 65536;
|
int32_t maxLen = 1024 * 1024;
|
||||||
char *content = taosMemoryCalloc(1, maxLen + 1);
|
char *content = taosMemoryCalloc(1, maxLen + 1);
|
||||||
|
if (content == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
len += snprintf(content + len, maxLen - len, "{\n");
|
len += snprintf(content + len, maxLen - len, "{\n");
|
||||||
len += snprintf(content + len, maxLen - len, " \"vnodes\": [\n");
|
len += snprintf(content + len, maxLen - len, " \"vnodes\": [\n");
|
||||||
|
@ -175,9 +170,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
|
||||||
len += snprintf(content + len, maxLen - len, " {\n");
|
len += snprintf(content + len, maxLen - len, " {\n");
|
||||||
len += snprintf(content + len, maxLen - len, " \"vgId\": %d,\n", pVnode->vgId);
|
len += snprintf(content + len, maxLen - len, " \"vgId\": %d,\n", pVnode->vgId);
|
||||||
len += snprintf(content + len, maxLen - len, " \"dropped\": %d,\n", pVnode->dropped);
|
len += snprintf(content + len, maxLen - len, " \"dropped\": %d,\n", pVnode->dropped);
|
||||||
len += snprintf(content + len, maxLen - len, " \"vgVersion\": %d,\n", pVnode->vgVersion);
|
len += snprintf(content + len, maxLen - len, " \"vgVersion\": %d\n", pVnode->vgVersion);
|
||||||
len += snprintf(content + len, maxLen - len, " \"dbUid\": \"%" PRIu64 "\",\n", pVnode->dbUid);
|
|
||||||
len += snprintf(content + len, maxLen - len, " \"db\": \"%s\"\n", pVnode->db);
|
|
||||||
if (i < numOfVnodes - 1) {
|
if (i < numOfVnodes - 1) {
|
||||||
len += snprintf(content + len, maxLen - len, " },\n");
|
len += snprintf(content + len, maxLen - len, " },\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -170,8 +170,6 @@ static void vmGenerateWrapperCfg(SVnodeMgmt *pMgmt, SCreateVnodeReq *pCreate, SW
|
||||||
pCfg->vgId = pCreate->vgId;
|
pCfg->vgId = pCreate->vgId;
|
||||||
pCfg->vgVersion = pCreate->vgVersion;
|
pCfg->vgVersion = pCreate->vgVersion;
|
||||||
pCfg->dropped = 0;
|
pCfg->dropped = 0;
|
||||||
pCfg->dbUid = pCreate->dbUid;
|
|
||||||
tstrncpy(pCfg->db, pCreate->db, TSDB_DB_FNAME_LEN);
|
|
||||||
snprintf(pCfg->path, sizeof(pCfg->path), "%s%svnode%d", pMgmt->path, TD_DIRSEP, pCreate->vgId);
|
snprintf(pCfg->path, sizeof(pCfg->path), "%s%svnode%d", pMgmt->path, TD_DIRSEP, pCreate->vgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +211,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
SVnode *pImpl = vnodeOpen(path, pMgmt->pTfs, pMgmt->msgCb);
|
SVnode *pImpl = vnodeOpen(path, pMgmt->pTfs, pMgmt->msgCb);
|
||||||
if (pImpl == NULL) {
|
if (pImpl == NULL) {
|
||||||
dError("vgId:%d, failed to create vnode since %s", createReq.vgId, terrstr());
|
dError("vgId:%d, failed to create vnode since %s", createReq.vgId, terrstr());
|
||||||
|
code = terrno;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,12 +57,10 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
||||||
pVnode->vgVersion = pCfg->vgVersion;
|
pVnode->vgVersion = pCfg->vgVersion;
|
||||||
pVnode->dropped = 0;
|
pVnode->dropped = 0;
|
||||||
pVnode->accessState = TSDB_VN_ALL_ACCCESS;
|
pVnode->accessState = TSDB_VN_ALL_ACCCESS;
|
||||||
pVnode->dbUid = pCfg->dbUid;
|
|
||||||
pVnode->db = tstrdup(pCfg->db);
|
|
||||||
pVnode->path = tstrdup(pCfg->path);
|
pVnode->path = tstrdup(pCfg->path);
|
||||||
pVnode->pImpl = pImpl;
|
pVnode->pImpl = pImpl;
|
||||||
|
|
||||||
if (pVnode->path == NULL || pVnode->db == NULL) {
|
if (pVnode->path == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +106,6 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pVnode->path);
|
taosMemoryFree(pVnode->path);
|
||||||
taosMemoryFree(pVnode->db);
|
|
||||||
taosMemoryFree(pVnode);
|
taosMemoryFree(pVnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ void dmSetEvent(SDnode *pDnode, EDndEvent event);
|
||||||
void dmReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
|
void dmReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
|
||||||
void dmReportStartupByWrapper(SMgmtWrapper *pWrapper, const char *pName, const char *pDesc);
|
void dmReportStartupByWrapper(SMgmtWrapper *pWrapper, const char *pName, const char *pDesc);
|
||||||
|
|
||||||
void dmProcessServerStatusReq(SDnode *pDnode, SRpcMsg *pMsg);
|
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg);
|
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg);
|
||||||
int32_t dmProcessCreateNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg);
|
int32_t dmProcessCreateNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg);
|
||||||
int32_t dmProcessDropNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg);
|
int32_t dmProcessDropNodeReq(SDnode *pDnode, EDndNodeType ntype, SNodeMsg *pMsg);
|
||||||
|
|
|
@ -235,44 +235,18 @@ void dmReportStartupByWrapper(SMgmtWrapper *pWrapper, const char *pName, const c
|
||||||
dmReportStartup(pWrapper->pDnode, pName, pDesc);
|
dmReportStartup(pWrapper->pDnode, pName, pDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmGetServerStatus(SDnode *pDnode, SServerStatusRsp *pStatus) {
|
static void dmGetServerStartupStatus(SDnode *pDnode, SServerStatusRsp *pStatus) {
|
||||||
SDnodeMgmt *pMgmt = pDnode->wrappers[DNODE].pMgmt;
|
SDnodeMgmt *pMgmt = pDnode->wrappers[DNODE].pMgmt;
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_OK;
|
|
||||||
pStatus->details[0] = 0;
|
pStatus->details[0] = 0;
|
||||||
|
|
||||||
if (pDnode->status == DND_STAT_INIT) {
|
if (pDnode->status == DND_STAT_INIT) {
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_NETWORK_OK;
|
pStatus->statusCode = TSDB_SRV_STATUS_NETWORK_OK;
|
||||||
snprintf(pStatus->details, sizeof(pStatus->details), "%s: %s", pDnode->startup.name, pDnode->startup.desc);
|
snprintf(pStatus->details, sizeof(pStatus->details), "%s: %s", pDnode->startup.name, pDnode->startup.desc);
|
||||||
return;
|
} else if (pDnode->status == DND_STAT_STOPPED) {
|
||||||
}
|
|
||||||
|
|
||||||
if (pDnode->status == DND_STAT_STOPPED) {
|
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_EXTING;
|
pStatus->statusCode = TSDB_SRV_STATUS_EXTING;
|
||||||
return;
|
} else {
|
||||||
|
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMonMloadInfo minfo = {0};
|
|
||||||
dmGetMnodeLoads(pMgmt, &minfo);
|
|
||||||
if (minfo.isMnode && minfo.load.syncState != TAOS_SYNC_STATE_LEADER &&
|
|
||||||
minfo.load.syncState != TAOS_SYNC_STATE_CANDIDATE) {
|
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
|
||||||
snprintf(pStatus->details, sizeof(pStatus->details), "mnode sync state is %s", syncStr(minfo.load.syncState));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SMonVloadInfo vinfo = {0};
|
|
||||||
dmGetVnodeLoads(pMgmt, &vinfo);
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(vinfo.pVloads); ++i) {
|
|
||||||
SVnodeLoad *pLoad = taosArrayGet(vinfo.pVloads, i);
|
|
||||||
if (pLoad->syncState != TAOS_SYNC_STATE_LEADER && pLoad->syncState != TAOS_SYNC_STATE_FOLLOWER) {
|
|
||||||
pStatus->statusCode = TSDB_SRV_STATUS_SERVICE_DEGRADED;
|
|
||||||
snprintf(pStatus->details, sizeof(pStatus->details), "vnode:%d sync state is %s", pLoad->vgId,
|
|
||||||
syncStr(pLoad->syncState));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayDestroy(vinfo.pVloads);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pReq) {
|
void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
|
@ -288,11 +262,11 @@ void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
rpcFreeCont(pReq->pCont);
|
rpcFreeCont(pReq->pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmProcessServerStatusReq(SDnode *pDnode, SRpcMsg *pReq) {
|
void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pReq) {
|
||||||
dDebug("server status req is received");
|
dDebug("server startup status req is received");
|
||||||
|
|
||||||
SServerStatusRsp statusRsp = {0};
|
SServerStatusRsp statusRsp = {0};
|
||||||
dmGetServerStatus(pDnode, &statusRsp);
|
dmGetServerStartupStatus(pDnode, &statusRsp);
|
||||||
|
|
||||||
SRpcMsg rspMsg = {.handle = pReq->handle, .ahandle = pReq->ahandle, .refId = pReq->refId};
|
SRpcMsg rspMsg = {.handle = pReq->handle, .ahandle = pReq->ahandle, .refId = pReq->refId};
|
||||||
int32_t rspLen = tSerializeSServerStatusRsp(NULL, 0, &statusRsp);
|
int32_t rspLen = tSerializeSServerStatusRsp(NULL, 0, &statusRsp);
|
||||||
|
|
|
@ -132,9 +132,13 @@ static void dmProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
|
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case TDMT_DND_SERVER_STATUS:
|
case TDMT_DND_SERVER_STATUS:
|
||||||
|
if (pDnode->status != DND_STAT_RUNNING) {
|
||||||
dTrace("server status req will be processed, handle:%p, app:%p", pMsg->handle, pMsg->ahandle);
|
dTrace("server status req will be processed, handle:%p, app:%p", pMsg->handle, pMsg->ahandle);
|
||||||
dmProcessServerStatusReq(pDnode, pMsg);
|
dmProcessServerStartupStatus(pDnode, pMsg);
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TDMT_DND_NET_TEST:
|
case TDMT_DND_NET_TEST:
|
||||||
dTrace("net test req will be processed, handle:%p, app:%p", pMsg->handle, pMsg->ahandle);
|
dTrace("net test req will be processed, handle:%p, app:%p", pMsg->handle, pMsg->ahandle);
|
||||||
dmProcessNetTestReq(pDnode, pMsg);
|
dmProcessNetTestReq(pDnode, pMsg);
|
||||||
|
|
|
@ -3,7 +3,7 @@ if(${BUILD_TEST})
|
||||||
add_subdirectory(qnode)
|
add_subdirectory(qnode)
|
||||||
add_subdirectory(bnode)
|
add_subdirectory(bnode)
|
||||||
add_subdirectory(snode)
|
add_subdirectory(snode)
|
||||||
add_subdirectory(mnode)
|
#add_subdirectory(mnode)
|
||||||
add_subdirectory(vnode)
|
add_subdirectory(vnode)
|
||||||
add_subdirectory(sut)
|
add_subdirectory(sut)
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
|
|
|
@ -1051,7 +1051,7 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
|
||||||
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans) {
|
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans) {
|
||||||
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->redoActions);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->redoActions);
|
||||||
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mError("failed to execute redoActions since %s", terrstr());
|
mError("failed to execute redoActions since:%s, code:0x%x", terrstr(), terrno);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ struct STqReadHandle {
|
||||||
SMeta* pVnodeMeta;
|
SMeta* pVnodeMeta;
|
||||||
SArray* pColIdList; // SArray<int16_t>
|
SArray* pColIdList; // SArray<int16_t>
|
||||||
int32_t sver;
|
int32_t sver;
|
||||||
|
int64_t cachedSchemaUid;
|
||||||
SSchemaWrapper* pSchemaWrapper;
|
SSchemaWrapper* pSchemaWrapper;
|
||||||
STSchema* pSchema;
|
STSchema* pSchema;
|
||||||
};
|
};
|
||||||
|
|
|
@ -559,6 +559,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
}
|
}
|
||||||
// db subscribe
|
// db subscribe
|
||||||
} else if (pExec->subType == TOPIC_SUB_TYPE__DB) {
|
} else if (pExec->subType == TOPIC_SUB_TYPE__DB) {
|
||||||
|
rsp.withSchema = 1;
|
||||||
STqReadHandle* pReader = pExec->pExecReader[workerId];
|
STqReadHandle* pReader = pExec->pExecReader[workerId];
|
||||||
tqReadHandleSetMsg(pReader, pCont, 0);
|
tqReadHandleSetMsg(pReader, pCont, 0);
|
||||||
while (tqNextDataBlock(pReader)) {
|
while (tqNextDataBlock(pReader)) {
|
||||||
|
|
|
@ -25,6 +25,7 @@ STqReadHandle* tqInitSubmitMsgScanner(SMeta* pMeta) {
|
||||||
pReadHandle->ver = -1;
|
pReadHandle->ver = -1;
|
||||||
pReadHandle->pColIdList = NULL;
|
pReadHandle->pColIdList = NULL;
|
||||||
pReadHandle->sver = -1;
|
pReadHandle->sver = -1;
|
||||||
|
pReadHandle->cachedSchemaUid = -1;
|
||||||
pReadHandle->pSchema = NULL;
|
pReadHandle->pSchema = NULL;
|
||||||
pReadHandle->pSchemaWrapper = NULL;
|
pReadHandle->pSchemaWrapper = NULL;
|
||||||
pReadHandle->tbIdHash = NULL;
|
pReadHandle->tbIdHash = NULL;
|
||||||
|
@ -84,19 +85,20 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* pGroupId, uint64_t* pUid, int32_t* pNumOfRows,
|
int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* pGroupId, uint64_t* pUid,
|
||||||
int16_t* pNumOfCols) {
|
int32_t* pNumOfRows, int16_t* pNumOfCols) {
|
||||||
/*int32_t sversion = pHandle->pBlock->sversion;*/
|
/*int32_t sversion = pHandle->pBlock->sversion;*/
|
||||||
// TODO set to real sversion
|
// TODO set to real sversion
|
||||||
*pUid = 0;
|
*pUid = 0;
|
||||||
|
|
||||||
int32_t sversion = 0;
|
int32_t sversion = 0;
|
||||||
if (pHandle->sver != sversion) {
|
if (pHandle->sver != sversion || pHandle->cachedSchemaUid != pHandle->msgIter.suid) {
|
||||||
pHandle->pSchema = metaGetTbTSchema(pHandle->pVnodeMeta, pHandle->msgIter.uid, sversion);
|
pHandle->pSchema = metaGetTbTSchema(pHandle->pVnodeMeta, pHandle->msgIter.uid, sversion);
|
||||||
|
|
||||||
// this interface use suid instead of uid
|
// this interface use suid instead of uid
|
||||||
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, pHandle->msgIter.suid, sversion, true);
|
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, pHandle->msgIter.suid, sversion, true);
|
||||||
pHandle->sver = sversion;
|
pHandle->sver = sversion;
|
||||||
|
pHandle->cachedSchemaUid = pHandle->msgIter.suid;
|
||||||
}
|
}
|
||||||
|
|
||||||
STSchema* pTschema = pHandle->pSchema;
|
STSchema* pTschema = pHandle->pSchema;
|
||||||
|
|
|
@ -114,24 +114,42 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
||||||
int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
SVnodeCfg *pCfg = (SVnodeCfg *)pObj;
|
SVnodeCfg *pCfg = (SVnodeCfg *)pObj;
|
||||||
|
|
||||||
if (tjsonGetNumberValue(pJson, "vgId", pCfg->vgId) < 0) return -1;
|
int32_t code;
|
||||||
|
tjsonGetNumberValue(pJson, "vgId", pCfg->vgId, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
if (tjsonGetStringValue(pJson, "dbname", pCfg->dbname) < 0) return -1;
|
if (tjsonGetStringValue(pJson, "dbname", pCfg->dbname) < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "dbId", pCfg->dbId) < 0) return -1;
|
tjsonGetNumberValue(pJson, "dbId", pCfg->dbId, code);
|
||||||
if (tjsonGetNumberValue(pJson, "szPage", pCfg->szPage) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "szCache", pCfg->szCache) < 0) return -1;
|
tjsonGetNumberValue(pJson, "szPage", pCfg->szPage, code);
|
||||||
if (tjsonGetNumberValue(pJson, "szBuf", pCfg->szBuf) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "isHeap", pCfg->isHeap) < 0) return -1;
|
tjsonGetNumberValue(pJson, "szCache", pCfg->szCache, code);
|
||||||
if (tjsonGetNumberValue(pJson, "isWeak", pCfg->isWeak) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1;
|
tjsonGetNumberValue(pJson, "szBuf", pCfg->szBuf, code);
|
||||||
if (tjsonGetNumberValue(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "compression", pCfg->tsdbCfg.compression) < 0) return -1;
|
tjsonGetNumberValue(pJson, "isHeap", pCfg->isHeap, code);
|
||||||
if (tjsonGetNumberValue(pJson, "slLevel", pCfg->tsdbCfg.slLevel) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1;
|
tjsonGetNumberValue(pJson, "isWeak", pCfg->isWeak, code);
|
||||||
if (tjsonGetNumberValue(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1;
|
tjsonGetNumberValue(pJson, "precision", pCfg->tsdbCfg.precision, code);
|
||||||
if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
tjsonGetNumberValue(pJson, "update", pCfg->tsdbCfg.update, code);
|
||||||
if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "compression", pCfg->tsdbCfg.compression, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "slLevel", pCfg->tsdbCfg.slLevel, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "daysPerFile", pCfg->tsdbCfg.days, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "minRows", pCfg->tsdbCfg.minRows, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "maxRows", pCfg->tsdbCfg.maxRows, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep0, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
SJson *pNodeRetentions = tjsonGetObjectItem(pJson, "retentions");
|
SJson *pNodeRetentions = tjsonGetObjectItem(pJson, "retentions");
|
||||||
int32_t nRetention = tjsonGetArraySize(pNodeRetentions);
|
int32_t nRetention = tjsonGetArraySize(pNodeRetentions);
|
||||||
if (nRetention > TSDB_RETENTION_MAX) {
|
if (nRetention > TSDB_RETENTION_MAX) {
|
||||||
|
@ -140,24 +158,36 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
for (int32_t i = 0; i < nRetention; ++i) {
|
for (int32_t i = 0; i < nRetention; ++i) {
|
||||||
SJson *pNodeRetention = tjsonGetArrayItem(pNodeRetentions, i);
|
SJson *pNodeRetention = tjsonGetArrayItem(pNodeRetentions, i);
|
||||||
ASSERT(pNodeRetention != NULL);
|
ASSERT(pNodeRetention != NULL);
|
||||||
tjsonGetNumberValue(pNodeRetention, "freq", (pCfg->tsdbCfg.retentions)[i].freq);
|
tjsonGetNumberValue(pNodeRetention, "freq", (pCfg->tsdbCfg.retentions)[i].freq, code);
|
||||||
tjsonGetNumberValue(pNodeRetention, "freqUnit", (pCfg->tsdbCfg.retentions)[i].freqUnit);
|
tjsonGetNumberValue(pNodeRetention, "freqUnit", (pCfg->tsdbCfg.retentions)[i].freqUnit, code);
|
||||||
tjsonGetNumberValue(pNodeRetention, "keep", (pCfg->tsdbCfg.retentions)[i].keep);
|
tjsonGetNumberValue(pNodeRetention, "keep", (pCfg->tsdbCfg.retentions)[i].keep, code);
|
||||||
tjsonGetNumberValue(pNodeRetention, "keepUnit", (pCfg->tsdbCfg.retentions)[i].keepUnit);
|
tjsonGetNumberValue(pNodeRetention, "keepUnit", (pCfg->tsdbCfg.retentions)[i].keepUnit, code);
|
||||||
}
|
}
|
||||||
if (tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1;
|
tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId, code);
|
||||||
if (tjsonGetNumberValue(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1;
|
tjsonGetNumberValue(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod, code);
|
||||||
if (tjsonGetNumberValue(pJson, "wal.rollPeriod", pCfg->walCfg.rollPeriod) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "wal.retentionSize", pCfg->walCfg.retentionSize) < 0) return -1;
|
tjsonGetNumberValue(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod, code);
|
||||||
if (tjsonGetNumberValue(pJson, "wal.segSize", pCfg->walCfg.segSize) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "wal.level", pCfg->walCfg.level) < 0) return -1;
|
tjsonGetNumberValue(pJson, "wal.rollPeriod", pCfg->walCfg.rollPeriod, code);
|
||||||
if (tjsonGetNumberValue(pJson, "hashBegin", pCfg->hashBegin) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "hashEnd", pCfg->hashEnd) < 0) return -1;
|
tjsonGetNumberValue(pJson, "wal.retentionSize", pCfg->walCfg.retentionSize, code);
|
||||||
if (tjsonGetNumberValue(pJson, "hashMethod", pCfg->hashMethod) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "wal.segSize", pCfg->walCfg.segSize, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "wal.level", pCfg->walCfg.level, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "hashBegin", pCfg->hashBegin, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "hashEnd", pCfg->hashEnd, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "hashMethod", pCfg->hashMethod, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
|
||||||
if (tjsonGetNumberValue(pJson, "syncCfg.replicaNum", pCfg->syncCfg.replicaNum) < 0) return -1;
|
tjsonGetNumberValue(pJson, "syncCfg.replicaNum", pCfg->syncCfg.replicaNum, code);
|
||||||
if (tjsonGetNumberValue(pJson, "syncCfg.myIndex", pCfg->syncCfg.myIndex) < 0) return -1;
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "syncCfg.myIndex", pCfg->syncCfg.myIndex, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
|
||||||
SJson *pNodeInfoArr = tjsonGetObjectItem(pJson, "syncCfg.nodeInfo");
|
SJson *pNodeInfoArr = tjsonGetObjectItem(pJson, "syncCfg.nodeInfo");
|
||||||
int arraySize = tjsonGetArraySize(pNodeInfoArr);
|
int arraySize = tjsonGetArraySize(pNodeInfoArr);
|
||||||
|
@ -166,7 +196,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
for (int i = 0; i < arraySize; ++i) {
|
for (int i = 0; i < arraySize; ++i) {
|
||||||
SJson *pNodeInfo = tjsonGetArrayItem(pNodeInfoArr, i);
|
SJson *pNodeInfo = tjsonGetArrayItem(pNodeInfoArr, i);
|
||||||
assert(pNodeInfo != NULL);
|
assert(pNodeInfo != NULL);
|
||||||
tjsonGetNumberValue(pNodeInfo, "nodePort", (pCfg->syncCfg.nodeInfo)[i].nodePort);
|
tjsonGetNumberValue(pNodeInfo, "nodePort", (pCfg->syncCfg.nodeInfo)[i].nodePort, code);
|
||||||
tjsonGetStringValue(pNodeInfo, "nodeFqdn", (pCfg->syncCfg.nodeInfo)[i].nodeFqdn);
|
tjsonGetStringValue(pNodeInfo, "nodeFqdn", (pCfg->syncCfg.nodeInfo)[i].nodeFqdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,8 +310,11 @@ static int vnodeEncodeState(const void *pObj, SJson *pJson) {
|
||||||
static int vnodeDecodeState(const SJson *pJson, void *pObj) {
|
static int vnodeDecodeState(const SJson *pJson, void *pObj) {
|
||||||
SVState *pState = (SVState *)pObj;
|
SVState *pState = (SVState *)pObj;
|
||||||
|
|
||||||
if (tjsonGetNumberValue(pJson, "commit version", pState->committed) < 0) return -1;
|
int32_t code;
|
||||||
if (tjsonGetNumberValue(pJson, "applied version", pState->applied) < 0) return -1;
|
tjsonGetNumberValue(pJson, "commit version", pState->committed, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
tjsonGetNumberValue(pJson, "applied version", pState->applied, code);
|
||||||
|
if(code < 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,18 +137,21 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
// open query
|
// open query
|
||||||
if (vnodeQueryOpen(pVnode)) {
|
if (vnodeQueryOpen(pVnode)) {
|
||||||
vError("vgId:%d failed to open vnode query since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode query since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vnode begin
|
// vnode begin
|
||||||
if (vnodeBegin(pVnode) < 0) {
|
if (vnodeBegin(pVnode) < 0) {
|
||||||
vError("vgId:%d failed to begin since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to begin since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open sync
|
// open sync
|
||||||
if (vnodeSyncOpen(pVnode, dir)) {
|
if (vnodeSyncOpen(pVnode, dir)) {
|
||||||
vError("vgId:%d failed to open sync since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open sync since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -842,6 +842,8 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctgDebug("Got subtable meta from cache, type:%d, dbFName:%s, tbName:%s, suid:%" PRIx64, tbMeta->tableType, dbFName, pTableName->tname, tbMeta->suid);
|
||||||
|
|
||||||
CTG_LOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
CTG_LOCK(CTG_READ, &dbCache->tbCache.stbLock);
|
||||||
|
|
||||||
STableMeta **stbMeta = taosHashGet(dbCache->tbCache.stbCache, &tbMeta->suid, sizeof(tbMeta->suid));
|
STableMeta **stbMeta = taosHashGet(dbCache->tbCache.stbCache, &tbMeta->suid, sizeof(tbMeta->suid));
|
||||||
|
@ -1656,6 +1658,11 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
|
||||||
if (orig) {
|
if (orig) {
|
||||||
origType = orig->tableType;
|
origType = orig->tableType;
|
||||||
|
|
||||||
|
if (origType == meta->tableType && orig->uid == meta->uid && orig->sversion >= meta->sversion && orig->tversion >= meta->tversion) {
|
||||||
|
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (origType == TSDB_SUPER_TABLE) {
|
if (origType == TSDB_SUPER_TABLE) {
|
||||||
if ((!isStb) || orig->suid != meta->suid) {
|
if ((!isStb) || orig->suid != meta->suid) {
|
||||||
CTG_LOCK(CTG_WRITE, &tbCache->stbLock);
|
CTG_LOCK(CTG_WRITE, &tbCache->stbLock);
|
||||||
|
@ -1693,7 +1700,7 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
|
||||||
CTG_CACHE_STAT_ADD(tblNum, 1);
|
CTG_CACHE_STAT_ADD(tblNum, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctgDebug("tbmeta updated to cache, dbFName:%s, tbName:%s, tbType:%d", dbFName, tbName, meta->tableType);
|
ctgDebug("tbmeta updated to cache, dbFName:%s, tbName:%s, tbType:%d, suid:%" PRIx64, dbFName, tbName, meta->tableType, meta->suid);
|
||||||
ctgdShowTableMeta(pCtg, tbName, meta);
|
ctgdShowTableMeta(pCtg, tbName, meta);
|
||||||
|
|
||||||
if (!isStb) {
|
if (!isStb) {
|
||||||
|
@ -1701,12 +1708,6 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (origType == TSDB_SUPER_TABLE && origSuid == meta->suid) {
|
|
||||||
CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock);
|
|
||||||
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
STableMeta *tbMeta = taosHashGet(tbCache->metaCache, tbName, strlen(tbName));
|
STableMeta *tbMeta = taosHashGet(tbCache->metaCache, tbName, strlen(tbName));
|
||||||
if (taosHashPut(tbCache->stbCache, &meta->suid, sizeof(meta->suid), &tbMeta, POINTER_BYTES) != 0) {
|
if (taosHashPut(tbCache->stbCache, &meta->suid, sizeof(meta->suid), &tbMeta, POINTER_BYTES) != 0) {
|
||||||
CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock);
|
CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock);
|
||||||
|
@ -1721,7 +1722,7 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
|
||||||
|
|
||||||
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
||||||
|
|
||||||
ctgDebug("stb updated to stbCache, dbFName:%s, tbName:%s, tbType:%d", dbFName, tbName, meta->tableType);
|
ctgDebug("stb updated to stbCache, dbFName:%s, tbName:%s, tbType:%d, suid:%" PRIx64 ",ma:%p", dbFName, tbName, meta->tableType, meta->suid, tbMeta);
|
||||||
|
|
||||||
SSTableMetaVersion metaRent = {.dbId = dbId, .suid = meta->suid, .sversion = meta->sversion, .tversion = meta->tversion};
|
SSTableMetaVersion metaRent = {.dbId = dbId, .suid = meta->suid, .sversion = meta->sversion, .tversion = meta->tversion};
|
||||||
strcpy(metaRent.dbFName, dbFName);
|
strcpy(metaRent.dbFName, dbFName);
|
||||||
|
|
|
@ -564,7 +564,7 @@ typedef struct SStateWindowOperatorInfo {
|
||||||
SAggSupporter aggSup;
|
SAggSupporter aggSup;
|
||||||
SGroupResInfo groupResInfo;
|
SGroupResInfo groupResInfo;
|
||||||
SWindowRowsSup winSup;
|
SWindowRowsSup winSup;
|
||||||
int32_t colIndex; // start row index
|
SColumn stateCol; // start row index
|
||||||
bool hasKey;
|
bool hasKey;
|
||||||
SStateKeys stateKey;
|
SStateKeys stateKey;
|
||||||
int32_t tsSlotId; // primary timestamp column slot id
|
int32_t tsSlotId; // primary timestamp column slot id
|
||||||
|
@ -636,7 +636,7 @@ int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t
|
||||||
int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols,
|
int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey);
|
SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey);
|
||||||
void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows);
|
void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows);
|
||||||
void doBuildResultDatablock(SExecTaskInfo *taskInfo, SOptrBasicInfo *pbInfo, SGroupResInfo* pGroupResInfo, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf);
|
void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf);
|
||||||
|
|
||||||
void finalizeMultiTupleQueryResult(int32_t numOfOutput, SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset);
|
void finalizeMultiTupleQueryResult(int32_t numOfOutput, SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset);
|
||||||
void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset,
|
void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset,
|
||||||
|
@ -659,6 +659,7 @@ void cleanupAggSup(SAggSupporter* pAggSup);
|
||||||
void destroyBasicOperatorInfo(void* param, int32_t numOfOutput);
|
void destroyBasicOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
|
void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
|
||||||
SInterval extractIntervalInfo(const STableScanPhysiNode* pTableScanNode);
|
SInterval extractIntervalInfo(const STableScanPhysiNode* pTableScanNode);
|
||||||
|
SColumn extractColumnFromColumnNode(SColumnNode* pColNode);
|
||||||
|
|
||||||
SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t capacity, SArray* pColMatchInfo);
|
SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t capacity, SArray* pColMatchInfo);
|
||||||
SSDataBlock* loadNextDataBlock(void* param);
|
SSDataBlock* loadNextDataBlock(void* param);
|
||||||
|
@ -706,13 +707,13 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
|
||||||
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, void* pDataReader, SSDataBlock* pResBlock,
|
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, void* pDataReader, SSDataBlock* pResBlock,
|
||||||
SArray* pColList, SArray* pTableIdList, SExecTaskInfo* pTaskInfo,
|
SArray* pColList, SArray* pTableIdList, SExecTaskInfo* pTaskInfo,
|
||||||
SNode* pConditions, SOperatorInfo* pOperatorDumy, SInterval* pInterval);
|
SNode* pConditions, SOperatorInfo* pOperatorDumy);
|
||||||
|
|
||||||
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
||||||
SInterval* pInterval, STimeWindow* pWindow, SSDataBlock* pResBlock, int32_t fillType, SNodeListNode* fillVal,
|
SInterval* pInterval, STimeWindow* pWindow, SSDataBlock* pResBlock, int32_t fillType, SNodeListNode* fillVal,
|
||||||
bool multigroupResult, SExecTaskInfo* pTaskInfo);
|
bool multigroupResult, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
||||||
SSDataBlock* pResBlock, STimeWindowAggSupp *pTwAggSupp, int32_t tsSlotId, SExecTaskInfo* pTaskInfo);
|
SSDataBlock* pResBlock, STimeWindowAggSupp *pTwAggSupp, int32_t tsSlotId, SColumn* pStateKeyCol, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResultBlock, SArray* pGroupColList, SExecTaskInfo* pTaskInfo,
|
SSDataBlock* pResultBlock, SArray* pGroupColList, SExecTaskInfo* pTaskInfo,
|
||||||
|
|
|
@ -155,9 +155,8 @@ SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn,
|
||||||
|
|
||||||
void operatorDummyCloseFn(void* param, int32_t numOfCols) {}
|
void operatorDummyCloseFn(void* param, int32_t numOfCols) {}
|
||||||
|
|
||||||
static int32_t doCopyToSDataBlock(SExecTaskInfo *taskInfo, SSDataBlock* pBlock, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf,
|
static int32_t doCopyToSDataBlock(SExecTaskInfo* taskInfo, SSDataBlock* pBlock, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo,
|
||||||
SGroupResInfo* pGroupResInfo, int32_t orderType, int32_t* rowCellOffset,
|
int32_t orderType, int32_t* rowCellOffset, SqlFunctionCtx* pCtx, int32_t numOfExprs);
|
||||||
SqlFunctionCtx* pCtx);
|
|
||||||
|
|
||||||
static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
|
static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
|
||||||
static void setResultBufSize(STaskAttr* pQueryAttr, SResultInfo* pResultInfo);
|
static void setResultBufSize(STaskAttr* pQueryAttr, SResultInfo* pResultInfo);
|
||||||
|
@ -746,7 +745,7 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
|
||||||
pCtx[i].order = order;
|
pCtx[i].order = order;
|
||||||
pCtx[i].size = pBlock->info.rows;
|
pCtx[i].size = pBlock->info.rows;
|
||||||
pCtx[i].pSrcBlock = pBlock;
|
pCtx[i].pSrcBlock = pBlock;
|
||||||
pCtx[i].currentStage = scanFlag;
|
pCtx[i].scanFlag = scanFlag;
|
||||||
|
|
||||||
SInputColumnInfoData* pInput = &pCtx[i].input;
|
SInputColumnInfoData* pInput = &pCtx[i].input;
|
||||||
pInput->uid = pBlock->info.uid;
|
pInput->uid = pBlock->info.uid;
|
||||||
|
@ -826,23 +825,22 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SqlFunctionCtx* pCtx) {
|
static int32_t doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SqlFunctionCtx* pCtx) {
|
||||||
for (int32_t k = 0; k < pOperator->numOfExprs; ++k) {
|
for (int32_t k = 0; k < pOperator->numOfExprs; ++k) {
|
||||||
if (functionNeedToExecute(&pCtx[k])) {
|
if (functionNeedToExecute(&pCtx[k])) {
|
||||||
pCtx[k].startTs = startTs;
|
pCtx[k].startTs = startTs;
|
||||||
// this can be set during create the struct
|
|
||||||
// todo add a dummy funtion to avoid process check
|
// todo add a dummy funtion to avoid process check
|
||||||
if (pCtx[k].fpSet.process != NULL) {
|
if (pCtx[k].fpSet.process != NULL) {
|
||||||
int32_t code = pCtx[k].fpSet.process(&pCtx[k]);
|
int32_t code = pCtx[k].fpSet.process(&pCtx[k]);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s call aggregate function error happens, code : %s",
|
qError("%s aggregate function error happens, code: %s", GET_TASKID(pOperator->pTaskInfo), tstrerror(code));
|
||||||
GET_TASKID(pOperator->pTaskInfo), tstrerror(code));
|
return code;
|
||||||
pOperator->pTaskInfo->code = code;
|
|
||||||
longjmp(pOperator->pTaskInfo->env, code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setPseudoOutputColInfo(SSDataBlock* pResult, SqlFunctionCtx* pCtx, SArray* pPseudoList) {
|
static void setPseudoOutputColInfo(SSDataBlock* pResult, SqlFunctionCtx* pCtx, SArray* pPseudoList) {
|
||||||
|
@ -899,6 +897,7 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
||||||
scalarCalculate(pExpr[k].pExpr->_optrRoot.pRootNode, pBlockList, &dest);
|
scalarCalculate(pExpr[k].pExpr->_optrRoot.pRootNode, pBlockList, &dest);
|
||||||
|
|
||||||
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
||||||
|
colInfoDataEnsureCapacity(pResColData, startOffset, pResult->info.capacity);
|
||||||
colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows);
|
colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows);
|
||||||
|
|
||||||
numOfRows = dest.numOfRows;
|
numOfRows = dest.numOfRows;
|
||||||
|
@ -938,6 +937,7 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
||||||
|
colInfoDataEnsureCapacity(pResColData, startOffset, pResult->info.capacity);
|
||||||
colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows);
|
colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows);
|
||||||
|
|
||||||
numOfRows = dest.numOfRows;
|
numOfRows = dest.numOfRows;
|
||||||
|
@ -998,18 +998,22 @@ static bool functionNeedToExecute(SqlFunctionCtx* pCtx) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pCtx->scanFlag == REPEAT_SCAN) {
|
||||||
|
return fmIsRepeatScanFunc(pCtx->functionId);
|
||||||
|
}
|
||||||
|
|
||||||
if (isRowEntryCompleted(pResInfo)) {
|
if (isRowEntryCompleted(pResInfo)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (functionId == FUNCTION_FIRST_DST || functionId == FUNCTION_FIRST) {
|
// if (functionId == FUNCTION_FIRST_DST || functionId == FUNCTION_FIRST) {
|
||||||
// return QUERY_IS_ASC_QUERY(pQueryAttr);
|
// // return QUERY_IS_ASC_QUERY(pQueryAttr);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// denote the order type
|
// // denote the order type
|
||||||
if ((functionId == FUNCTION_LAST_DST || functionId == FUNCTION_LAST)) {
|
// if ((functionId == FUNCTION_LAST_DST || functionId == FUNCTION_LAST)) {
|
||||||
// return pCtx->param[0].i == pQueryAttr->order.order;
|
// // return pCtx->param[0].i == pQueryAttr->order.order;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// in the reverse table scan, only the following functions need to be executed
|
// in the reverse table scan, only the following functions need to be executed
|
||||||
// if (IS_REVERSE_SCAN(pRuntimeEnv) ||
|
// if (IS_REVERSE_SCAN(pRuntimeEnv) ||
|
||||||
|
@ -1944,7 +1948,7 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t
|
||||||
cleanupResultRowEntry(pEntry);
|
cleanupResultRowEntry(pEntry);
|
||||||
|
|
||||||
pCtx[i].resultInfo = pEntry;
|
pCtx[i].resultInfo = pEntry;
|
||||||
pCtx[i].currentStage = stage;
|
pCtx[i].scanFlag = stage;
|
||||||
|
|
||||||
// set the timestamp output buffer for top/bottom/diff query
|
// set the timestamp output buffer for top/bottom/diff query
|
||||||
// int32_t fid = pCtx[i].functionId;
|
// int32_t fid = pCtx[i].functionId;
|
||||||
|
@ -2211,7 +2215,7 @@ void setExecutionContext(int32_t numOfOutput, uint64_t groupId, SExecTaskInfo* p
|
||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
int32_t doCopyToSDataBlock(SExecTaskInfo* taskInfo, SSDataBlock* pBlock, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo,
|
int32_t doCopyToSDataBlock(SExecTaskInfo* taskInfo, SSDataBlock* pBlock, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo,
|
||||||
int32_t orderType, int32_t* rowCellOffset, SqlFunctionCtx* pCtx) {
|
int32_t orderType, int32_t* rowCellOffset, SqlFunctionCtx* pCtx, int32_t numOfExprs) {
|
||||||
int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
|
int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
|
||||||
int32_t numOfResult = pBlock->info.rows; // there are already exists result rows
|
int32_t numOfResult = pBlock->info.rows; // there are already exists result rows
|
||||||
|
|
||||||
|
@ -2245,13 +2249,12 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* taskInfo, SSDataBlock* pBlock, SExprIn
|
||||||
|
|
||||||
pGroupResInfo->index += 1;
|
pGroupResInfo->index += 1;
|
||||||
|
|
||||||
for (int32_t j = 0; j < pBlock->info.numOfCols; ++j) {
|
for (int32_t j = 0; j < numOfExprs; ++j) {
|
||||||
int32_t slotId = pExprInfo[j].base.resSchema.slotId;
|
int32_t slotId = pExprInfo[j].base.resSchema.slotId;
|
||||||
|
|
||||||
pCtx[j].resultInfo = getResultCell(pRow, j, rowCellOffset);
|
pCtx[j].resultInfo = getResultCell(pRow, j, rowCellOffset);
|
||||||
if (pCtx[j].fpSet.finalize) {
|
if (pCtx[j].fpSet.finalize) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = pCtx[j].fpSet.finalize(&pCtx[j], pBlock);
|
||||||
code = pCtx[j].fpSet.finalize(&pCtx[j], pBlock);
|
|
||||||
if (TAOS_FAILED(code)) {
|
if (TAOS_FAILED(code)) {
|
||||||
qError("%s build result data block error, code %s", GET_TASKID(taskInfo), tstrerror(code));
|
qError("%s build result data block error, code %s", GET_TASKID(taskInfo), tstrerror(code));
|
||||||
taskInfo->code = code;
|
taskInfo->code = code;
|
||||||
|
@ -2283,10 +2286,13 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* taskInfo, SSDataBlock* pBlock, SExprIn
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doBuildResultDatablock(SExecTaskInfo *taskInfo, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo, SExprInfo* pExprInfo,
|
void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf) {
|
||||||
SDiskbasedBuf* pBuf) {
|
|
||||||
assert(pGroupResInfo->currentGroup <= pGroupResInfo->totalGroup);
|
assert(pGroupResInfo->currentGroup <= pGroupResInfo->totalGroup);
|
||||||
|
|
||||||
|
SExprInfo* pExprInfo = pOperator->pExpr;
|
||||||
|
int32_t numOfExprs = pOperator->numOfExprs;
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
int32_t* rowCellOffset = pbInfo->rowCellInfoOffset;
|
int32_t* rowCellOffset = pbInfo->rowCellInfoOffset;
|
||||||
SSDataBlock* pBlock = pbInfo->pRes;
|
SSDataBlock* pBlock = pbInfo->pRes;
|
||||||
SqlFunctionCtx* pCtx = pbInfo->pCtx;
|
SqlFunctionCtx* pCtx = pbInfo->pCtx;
|
||||||
|
@ -2297,7 +2303,7 @@ void doBuildResultDatablock(SExecTaskInfo *taskInfo, SOptrBasicInfo* pbInfo, SGr
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t orderType = TSDB_ORDER_ASC;
|
int32_t orderType = TSDB_ORDER_ASC;
|
||||||
doCopyToSDataBlock(taskInfo, pBlock, pExprInfo, pBuf, pGroupResInfo, orderType, rowCellOffset, pCtx);
|
doCopyToSDataBlock(pTaskInfo, pBlock, pExprInfo, pBuf, pGroupResInfo, orderType, rowCellOffset, pCtx, numOfExprs);
|
||||||
|
|
||||||
// add condition (pBlock->info.rows >= 1) just to runtime happy
|
// add condition (pBlock->info.rows >= 1) just to runtime happy
|
||||||
blockDataUpdateTsWindow(pBlock);
|
blockDataUpdateTsWindow(pBlock);
|
||||||
|
@ -3724,7 +3730,6 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
||||||
SAggOperatorInfo* pAggInfo = pOperator->info;
|
SAggOperatorInfo* pAggInfo = pOperator->info;
|
||||||
|
|
||||||
SOptrBasicInfo* pInfo = &pAggInfo->binfo;
|
SOptrBasicInfo* pInfo = &pAggInfo->binfo;
|
||||||
|
|
||||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||||
|
|
||||||
int32_t order = TSDB_ORDER_ASC;
|
int32_t order = TSDB_ORDER_ASC;
|
||||||
|
@ -3738,9 +3743,6 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if (pAggInfo->current != NULL) {
|
|
||||||
// setTagValue(pOperator, pAggInfo->current->pTable, pInfo->pCtx, pOperator->numOfExprs);
|
|
||||||
// }
|
|
||||||
|
|
||||||
int32_t code = getTableScanInfo(pOperator, &order, &scanFlag);
|
int32_t code = getTableScanInfo(pOperator, &order, &scanFlag);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -3752,15 +3754,17 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
||||||
code = projectApplyFunctions(pAggInfo->pScalarExprInfo, pBlock, pBlock, pAggInfo->pScalarCtx,
|
code = projectApplyFunctions(pAggInfo->pScalarExprInfo, pBlock, pBlock, pAggInfo->pScalarCtx,
|
||||||
pAggInfo->numOfScalarExpr, NULL);
|
pAggInfo->numOfScalarExpr, NULL);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pTaskInfo->code = code;
|
longjmp(pTaskInfo->env, code);
|
||||||
longjmp(pTaskInfo->env, pTaskInfo->code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setExecutionContext(pOperator->numOfExprs, pBlock->info.groupId, pTaskInfo, pAggInfo);
|
setExecutionContext(pOperator->numOfExprs, pBlock->info.groupId, pTaskInfo, pAggInfo);
|
||||||
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order, scanFlag, true);
|
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order, scanFlag, true);
|
||||||
doAggregateImpl(pOperator, 0, pInfo->pCtx);
|
code = doAggregateImpl(pOperator, 0, pInfo->pCtx);
|
||||||
|
if (code != 0) {
|
||||||
|
longjmp(pTaskInfo->env, code);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0 // test for encode/decode result info
|
#if 0 // test for encode/decode result info
|
||||||
if(pOperator->encodeResultRow){
|
if(pOperator->encodeResultRow){
|
||||||
|
@ -3802,7 +3806,7 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
doBuildResultDatablock(pTaskInfo, pInfo, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, pInfo, &pAggInfo->groupResInfo, pAggInfo->aggSup.pResultBuf);
|
||||||
if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) {
|
if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
|
@ -4807,17 +4811,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
|
|
||||||
SSDataBlock* pResBlockDumy = createResDataBlock(pDescNode);
|
|
||||||
|
|
||||||
SQueryTableDataCond cond = {0};
|
|
||||||
int32_t code = initQueryTableDataCond(&cond, pTableScanNode);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SInterval interval = extractIntervalInfo(pTableScanNode);
|
|
||||||
SOperatorInfo* pOperatorDumy = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
SOperatorInfo* pOperatorDumy = createTableScanOperatorInfo(pTableScanNode, pDataReader, pHandle, pTaskInfo);
|
||||||
|
|
||||||
SArray* tableIdList = extractTableIdList(pTableGroupInfo);
|
SArray* tableIdList = extractTableIdList(pTableGroupInfo);
|
||||||
|
@ -4825,7 +4818,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
|
|
||||||
SArray* pCols = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
|
SArray* pCols = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID);
|
||||||
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pDataReader, pResBlock, pCols, tableIdList, pTaskInfo,
|
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pDataReader, pResBlock, pCols, tableIdList, pTaskInfo,
|
||||||
pScanPhyNode->node.pConditions, pOperatorDumy, &interval);
|
pScanPhyNode->node.pConditions, pOperatorDumy);
|
||||||
taosArrayDestroy(tableIdList);
|
taosArrayDestroy(tableIdList);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
||||||
|
@ -4973,7 +4966,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||||
int32_t tsSlotId = ((SColumnNode*)pStateNode->window.pTspk)->slotId;
|
int32_t tsSlotId = ((SColumnNode*)pStateNode->window.pTspk)->slotId;
|
||||||
|
|
||||||
pOptr = createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, &as, tsSlotId, pTaskInfo);
|
SColumnNode* pColNode = (SColumnNode*)((STargetNode*)pStateNode->pStateKey)->pExpr;
|
||||||
|
SColumn col = extractColumnFromColumnNode(pColNode);
|
||||||
|
pOptr = createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, &as, tsSlotId, &col, pTaskInfo);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_JOIN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_JOIN == type) {
|
||||||
SJoinPhysiNode* pJoinNode = (SJoinPhysiNode*)pPhyNode;
|
SJoinPhysiNode* pJoinNode = (SJoinPhysiNode*)pPhyNode;
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||||
|
@ -5038,6 +5033,17 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SColumn extractColumnFromColumnNode(SColumnNode* pColNode) {
|
||||||
|
SColumn c = {0};
|
||||||
|
c.slotId = pColNode->slotId;
|
||||||
|
c.colId = pColNode->colId;
|
||||||
|
c.type = pColNode->node.resType.type;
|
||||||
|
c.bytes = pColNode->node.resType.bytes;
|
||||||
|
c.scale = pColNode->node.resType.scale;
|
||||||
|
c.precision = pColNode->node.resType.precision;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
SArray* extractColumnInfo(SNodeList* pNodeList) {
|
SArray* extractColumnInfo(SNodeList* pNodeList) {
|
||||||
size_t numOfCols = LIST_LENGTH(pNodeList);
|
size_t numOfCols = LIST_LENGTH(pNodeList);
|
||||||
SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn));
|
SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn));
|
||||||
|
@ -5052,15 +5058,7 @@ SArray* extractColumnInfo(SNodeList* pNodeList) {
|
||||||
if (nodeType(pNode->pExpr) == QUERY_NODE_COLUMN) {
|
if (nodeType(pNode->pExpr) == QUERY_NODE_COLUMN) {
|
||||||
SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
|
SColumnNode* pColNode = (SColumnNode*)pNode->pExpr;
|
||||||
|
|
||||||
// todo extract method
|
SColumn c = extractColumnFromColumnNode(pColNode);
|
||||||
SColumn c = {0};
|
|
||||||
c.slotId = pColNode->slotId;
|
|
||||||
c.colId = pColNode->colId;
|
|
||||||
c.type = pColNode->node.resType.type;
|
|
||||||
c.bytes = pColNode->node.resType.bytes;
|
|
||||||
c.scale = pColNode->node.resType.scale;
|
|
||||||
c.precision = pColNode->node.resType.precision;
|
|
||||||
|
|
||||||
taosArrayPush(pList, &c);
|
taosArrayPush(pList, &c);
|
||||||
} else if (nodeType(pNode->pExpr) == QUERY_NODE_VALUE) {
|
} else if (nodeType(pNode->pExpr) == QUERY_NODE_VALUE) {
|
||||||
SValueNode* pValNode = (SValueNode*)pNode->pExpr;
|
SValueNode* pValNode = (SValueNode*)pNode->pExpr;
|
||||||
|
|
|
@ -268,7 +268,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
||||||
SSDataBlock* pRes = pInfo->binfo.pRes;
|
SSDataBlock* pRes = pInfo->binfo.pRes;
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
doBuildResultDatablock(pTaskInfo, &pInfo->binfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
if (pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
||||||
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, false);
|
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, false);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
doBuildResultDatablock(pTaskInfo, &pInfo->binfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
doFilter(pInfo->pCondition, pRes);
|
doFilter(pInfo->pCondition, pRes);
|
||||||
|
|
||||||
bool hasRemain = hasRemainDataInCurrentGroup(&pInfo->groupResInfo);
|
bool hasRemain = hasRemainDataInCurrentGroup(&pInfo->groupResInfo);
|
||||||
|
|
|
@ -260,6 +260,53 @@ static void prepareForDescendingScan(STableScanInfo* pTableScanInfo, SqlFunction
|
||||||
pTableScanInfo->cond.order = TSDB_ORDER_DESC;
|
pTableScanInfo->cond.order = TSDB_ORDER_DESC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void addTagPseudoColumnData(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock) {
|
||||||
|
// currently only the tbname pseudo column
|
||||||
|
if (pTableScanInfo->numOfPseudoExpr == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SMetaReader mr = {0};
|
||||||
|
metaReaderInit(&mr, pTableScanInfo->readHandle.meta, 0);
|
||||||
|
metaGetTableEntryByUid(&mr, pBlock->info.uid);
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < pTableScanInfo->numOfPseudoExpr; ++j) {
|
||||||
|
SExprInfo* pExpr = &pTableScanInfo->pPseudoExpr[j];
|
||||||
|
|
||||||
|
int32_t dstSlotId = pExpr->base.resSchema.slotId;
|
||||||
|
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
||||||
|
colInfoDataEnsureCapacity(pColInfoData, 0, pBlock->info.rows);
|
||||||
|
|
||||||
|
int32_t functionId = pExpr->pExpr->_function.functionId;
|
||||||
|
|
||||||
|
// this is to handle the tbname
|
||||||
|
if (fmIsScanPseudoColumnFunc(functionId)) {
|
||||||
|
struct SScalarFuncExecFuncs fpSet = {0};
|
||||||
|
fmGetScalarFuncExecFuncs(functionId, &fpSet);
|
||||||
|
|
||||||
|
SColumnInfoData infoData = {0};
|
||||||
|
infoData.info.type = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
infoData.info.bytes = sizeof(uint64_t);
|
||||||
|
colInfoDataEnsureCapacity(&infoData, 0, 1);
|
||||||
|
|
||||||
|
colDataAppendInt64(&infoData, 0, &pBlock->info.uid);
|
||||||
|
SScalarParam srcParam = {
|
||||||
|
.numOfRows = pBlock->info.rows, .param = pTableScanInfo->readHandle.meta, .columnData = &infoData};
|
||||||
|
|
||||||
|
SScalarParam param = {.columnData = pColInfoData};
|
||||||
|
fpSet.process(&srcParam, 1, ¶m);
|
||||||
|
} else { // these are tags
|
||||||
|
const char* p = metaGetTableTagVal(&mr.me, pExpr->base.pParam[0].pCol->colId);
|
||||||
|
for (int32_t i = 0; i < pBlock->info.rows; ++i) {
|
||||||
|
colDataAppend(pColInfoData, i, p, (p == NULL));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
||||||
STableScanInfo* pTableScanInfo = pOperator->info;
|
STableScanInfo* pTableScanInfo = pOperator->info;
|
||||||
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||||
|
@ -285,23 +332,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
// currently only the tbname pseudo column
|
// currently only the tbname pseudo column
|
||||||
if (pTableScanInfo->numOfPseudoExpr > 0) {
|
if (pTableScanInfo->numOfPseudoExpr > 0) {
|
||||||
int32_t dstSlotId = pTableScanInfo->pPseudoExpr->base.resSchema.slotId;
|
addTagPseudoColumnData(pTableScanInfo, pBlock);
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
|
||||||
colInfoDataEnsureCapacity(pColInfoData, 0, pBlock->info.rows);
|
|
||||||
|
|
||||||
struct SScalarFuncExecFuncs fpSet;
|
|
||||||
fmGetScalarFuncExecFuncs(pTableScanInfo->pPseudoExpr->pExpr->_function.functionId, &fpSet);
|
|
||||||
|
|
||||||
SColumnInfoData infoData = {0};
|
|
||||||
infoData.info.type = TSDB_DATA_TYPE_BIGINT;
|
|
||||||
infoData.info.bytes = sizeof(uint64_t);
|
|
||||||
colInfoDataEnsureCapacity(&infoData, 0, 1);
|
|
||||||
|
|
||||||
colDataAppendInt64(&infoData, 0, &pBlock->info.uid);
|
|
||||||
SScalarParam srcParam = {.numOfRows = pBlock->info.rows, .param = pTableScanInfo->readHandle.meta, .columnData = &infoData};
|
|
||||||
|
|
||||||
SScalarParam param = {.columnData = pColInfoData};
|
|
||||||
fpSet.process(&srcParam, 1, ¶m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pBlock;
|
return pBlock;
|
||||||
|
@ -751,8 +782,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, void* pDataReader,
|
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, void* pDataReader,
|
||||||
SSDataBlock* pResBlock, SArray* pColList, SArray* pTableIdList,
|
SSDataBlock* pResBlock, SArray* pColList, SArray* pTableIdList,
|
||||||
SExecTaskInfo* pTaskInfo, SNode* pCondition, SOperatorInfo* pOperatorDumy,
|
SExecTaskInfo* pTaskInfo, SNode* pCondition, SOperatorInfo* pOperatorDumy ) {
|
||||||
SInterval* pInterval) {
|
|
||||||
SStreamBlockScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamBlockScanInfo));
|
SStreamBlockScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamBlockScanInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
|
@ -760,6 +790,8 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, void* pDataR
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STableScanInfo* pSTInfo = (STableScanInfo*)pOperatorDumy->info;
|
||||||
|
|
||||||
int32_t numOfOutput = taosArrayGetSize(pColList);
|
int32_t numOfOutput = taosArrayGetSize(pColList);
|
||||||
|
|
||||||
SArray* pColIds = taosArrayInit(4, sizeof(int16_t));
|
SArray* pColIds = taosArrayInit(4, sizeof(int16_t));
|
||||||
|
@ -792,7 +824,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, void* pDataR
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->primaryTsIndex = 0; // TODO(liuyao) get it from physical plan
|
pInfo->primaryTsIndex = 0; // TODO(liuyao) get it from physical plan
|
||||||
pInfo->pUpdateInfo = updateInfoInitP(pInterval, 10000); // TODO(liuyao) get watermark from physical plan
|
pInfo->pUpdateInfo = updateInfoInitP(&pSTInfo->interval, 10000); // TODO(liuyao) get watermark from physical plan
|
||||||
if (pInfo->pUpdateInfo == NULL) {
|
if (pInfo->pUpdateInfo == NULL) {
|
||||||
taosMemoryFreeClear(pInfo);
|
taosMemoryFreeClear(pInfo);
|
||||||
taosMemoryFreeClear(pOperator);
|
taosMemoryFreeClear(pOperator);
|
||||||
|
@ -805,7 +837,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, void* pDataR
|
||||||
pInfo->pDataReader = pDataReader;
|
pInfo->pDataReader = pDataReader;
|
||||||
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
|
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
|
||||||
pInfo->pOperatorDumy = pOperatorDumy;
|
pInfo->pOperatorDumy = pOperatorDumy;
|
||||||
pInfo->interval = *pInterval;
|
pInfo->interval = pSTInfo->interval;
|
||||||
|
|
||||||
pOperator->name = "StreamBlockScanOperator";
|
pOperator->name = "StreamBlockScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
||||||
|
|
|
@ -806,10 +806,22 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool compareVal(const char* v, const SStateKeys* pKey) {
|
||||||
|
if (IS_VAR_DATA_TYPE(pKey->type)) {
|
||||||
|
if (varDataLen(v) != varDataLen(pKey->pData)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return strncmp(varDataVal(v), varDataVal(pKey->pData), varDataLen(v)) == 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return memcmp(pKey->pData, v, pKey->bytes) == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorInfo* pInfo, SSDataBlock* pBlock) {
|
static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorInfo* pInfo, SSDataBlock* pBlock) {
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
SColumnInfoData* pStateColInfoData = taosArrayGet(pBlock->pDataBlock, pInfo->colIndex);
|
SColumnInfoData* pStateColInfoData = taosArrayGet(pBlock->pDataBlock, pInfo->stateCol.slotId);
|
||||||
int64_t gid = pBlock->info.groupId;
|
int64_t gid = pBlock->info.groupId;
|
||||||
|
|
||||||
bool masterScan = true;
|
bool masterScan = true;
|
||||||
|
@ -822,20 +834,28 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
|
||||||
SWindowRowsSup* pRowSup = &pInfo->winSup;
|
SWindowRowsSup* pRowSup = &pInfo->winSup;
|
||||||
pRowSup->numOfRows = 0;
|
pRowSup->numOfRows = 0;
|
||||||
|
|
||||||
|
struct SColumnDataAgg* pAgg = NULL;
|
||||||
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
for (int32_t j = 0; j < pBlock->info.rows; ++j) {
|
||||||
if (colDataIsNull(pStateColInfoData, pBlock->info.rows, j, pBlock->pBlockAgg[pInfo->colIndex])) {
|
pAgg = (pBlock->pBlockAgg != NULL)? pBlock->pBlockAgg[pInfo->stateCol.slotId]: NULL;
|
||||||
|
if (colDataIsNull(pStateColInfoData, pBlock->info.rows, j, pAgg)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* val = colDataGetData(pStateColInfoData, j);
|
char* val = colDataGetData(pStateColInfoData, j);
|
||||||
|
|
||||||
if (!pInfo->hasKey) {
|
if (!pInfo->hasKey) {
|
||||||
|
// todo extract method
|
||||||
|
if (IS_VAR_DATA_TYPE(pInfo->stateKey.type)) {
|
||||||
|
varDataCopy(pInfo->stateKey.pData, val);
|
||||||
|
} else {
|
||||||
memcpy(pInfo->stateKey.pData, val, bytes);
|
memcpy(pInfo->stateKey.pData, val, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
pInfo->hasKey = true;
|
pInfo->hasKey = true;
|
||||||
|
|
||||||
doKeepNewWindowStartInfo(pRowSup, tsList, j);
|
doKeepNewWindowStartInfo(pRowSup, tsList, j);
|
||||||
doKeepTuple(pRowSup, tsList[j]);
|
doKeepTuple(pRowSup, tsList[j]);
|
||||||
} else if (memcmp(pInfo->stateKey.pData, val, bytes) == 0) {
|
} else if (compareVal(val, &pInfo->stateKey)) {
|
||||||
doKeepTuple(pRowSup, tsList[j]);
|
doKeepTuple(pRowSup, tsList[j]);
|
||||||
if (j == 0 && pRowSup->startRowIndex != 0) {
|
if (j == 0 && pRowSup->startRowIndex != 0) {
|
||||||
pRowSup->startRowIndex = 0;
|
pRowSup->startRowIndex = 0;
|
||||||
|
@ -861,6 +881,13 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
|
||||||
// here we start a new session window
|
// here we start a new session window
|
||||||
doKeepNewWindowStartInfo(pRowSup, tsList, j);
|
doKeepNewWindowStartInfo(pRowSup, tsList, j);
|
||||||
doKeepTuple(pRowSup, tsList[j]);
|
doKeepTuple(pRowSup, tsList[j]);
|
||||||
|
|
||||||
|
// todo extract method
|
||||||
|
if (IS_VAR_DATA_TYPE(pInfo->stateKey.type)) {
|
||||||
|
varDataCopy(pInfo->stateKey.pData, val);
|
||||||
|
} else {
|
||||||
|
memcpy(pInfo->stateKey.pData, val, bytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,7 +915,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
|
||||||
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
doBuildResultDatablock(pTaskInfo, pBInfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -921,7 +948,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, true);
|
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, true);
|
||||||
blockDataEnsureCapacity(pBInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pBInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
doBuildResultDatablock(pTaskInfo, pBInfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
|
@ -948,7 +975,7 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDataEnsureCapacity(pBlock, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pBlock, pOperator->resultInfo.capacity);
|
||||||
doBuildResultDatablock(pTaskInfo, &pInfo->binfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
|
|
||||||
if (pBlock->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pBlock->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
|
@ -1012,7 +1039,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
doBuildResultDatablock(pOperator->pTaskInfo, &pInfo->binfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
}
|
}
|
||||||
|
@ -1053,7 +1080,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
|
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||||
doBuildResultDatablock(pOperator->pTaskInfo, &pInfo->binfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
|
|
||||||
// TODO: remove for stream
|
// TODO: remove for stream
|
||||||
/*ASSERT(pInfo->binfo.pRes->info.rows > 0);*/
|
/*ASSERT(pInfo->binfo.pRes->info.rows > 0);*/
|
||||||
|
@ -1283,7 +1310,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
||||||
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
doBuildResultDatablock(pOperator->pTaskInfo, pBInfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1316,7 +1343,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, true);
|
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, true);
|
||||||
blockDataEnsureCapacity(pBInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pBInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
doBuildResultDatablock(pOperator->pTaskInfo, pBInfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||||
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
|
@ -1406,14 +1433,21 @@ _error:
|
||||||
|
|
||||||
SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
||||||
SSDataBlock* pResBlock, STimeWindowAggSupp* pTwAggSup, int32_t tsSlotId,
|
SSDataBlock* pResBlock, STimeWindowAggSupp* pTwAggSup, int32_t tsSlotId,
|
||||||
SExecTaskInfo* pTaskInfo) {
|
SColumn* pStateKeyCol, SExecTaskInfo* pTaskInfo) {
|
||||||
SStateWindowOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStateWindowOperatorInfo));
|
SStateWindowOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStateWindowOperatorInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->colIndex = -1;
|
pInfo->stateCol = *pStateKeyCol;
|
||||||
|
pInfo->stateKey.type = pInfo->stateCol.type;
|
||||||
|
pInfo->stateKey.bytes = pInfo->stateCol.bytes;
|
||||||
|
pInfo->stateKey.pData = taosMemoryCalloc(1, pInfo->stateCol.bytes);
|
||||||
|
if (pInfo->stateKey.pData == NULL) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||||
|
|
||||||
initResultSizeInfo(pOperator, 4096);
|
initResultSizeInfo(pOperator, 4096);
|
||||||
|
|
|
@ -102,6 +102,11 @@ bool getMavgFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
bool mavgFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
bool mavgFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
int32_t mavgFunction(SqlFunctionCtx* pCtx);
|
int32_t mavgFunction(SqlFunctionCtx* pCtx);
|
||||||
|
|
||||||
|
bool getSampleFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
|
bool sampleFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
|
int32_t sampleFunction(SqlFunctionCtx* pCtx);
|
||||||
|
int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
|
||||||
bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -360,6 +360,32 @@ static int32_t translateMavg(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateSample(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
if (2 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||||
|
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
|
if (QUERY_NODE_COLUMN != nodeType(pPara)) {
|
||||||
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
|
"The input parameter of SAMPLE function can only be column");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||||
|
if (!IS_INTEGER_TYPE(paraType)) {
|
||||||
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
SExprNode* pCol = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
|
uint8_t colType = pCol->resType.type;
|
||||||
|
if (IS_VAR_DATA_TYPE(colType)) {
|
||||||
|
pFunc->node.resType = (SDataType){.bytes = pCol->resType.bytes, .type = colType};
|
||||||
|
} else {
|
||||||
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[colType].bytes, .type = colType};
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateLastRow(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateLastRow(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
// todo
|
// todo
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -814,6 +840,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.processFunc = mavgFunction,
|
.processFunc = mavgFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "sample",
|
||||||
|
.type = FUNCTION_TYPE_SAMPLE,
|
||||||
|
.classification = FUNC_MGT_NONSTANDARD_SQL_FUNC | FUNC_MGT_TIMELINE_FUNC,
|
||||||
|
.translateFunc = translateSample,
|
||||||
|
.getEnvFunc = getSampleFuncEnv,
|
||||||
|
.initFunc = sampleFunctionSetup,
|
||||||
|
.processFunc = sampleFunction,
|
||||||
|
.finalizeFunc = NULL
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "abs",
|
.name = "abs",
|
||||||
.type = FUNCTION_TYPE_ABS,
|
.type = FUNCTION_TYPE_ABS,
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#define HISTOGRAM_MAX_BINS_NUM 1000
|
#define HISTOGRAM_MAX_BINS_NUM 1000
|
||||||
#define MAVG_MAX_POINTS_NUM 1000
|
#define MAVG_MAX_POINTS_NUM 1000
|
||||||
|
#define SAMPLE_MAX_POINTS_NUM 1000
|
||||||
|
|
||||||
typedef struct SSumRes {
|
typedef struct SSumRes {
|
||||||
union {
|
union {
|
||||||
|
@ -150,6 +151,16 @@ typedef struct SMavgInfo {
|
||||||
double points[];
|
double points[];
|
||||||
} SMavgInfo;
|
} SMavgInfo;
|
||||||
|
|
||||||
|
typedef struct SSampleInfo {
|
||||||
|
int32_t samples;
|
||||||
|
int32_t totalPoints;
|
||||||
|
int32_t numSampled;
|
||||||
|
uint8_t colType;
|
||||||
|
int16_t colBytes;
|
||||||
|
char *data;
|
||||||
|
int64_t *timestamp;
|
||||||
|
} SSampleInfo;
|
||||||
|
|
||||||
#define SET_VAL(_info, numOfElem, res) \
|
#define SET_VAL(_info, numOfElem, res) \
|
||||||
do { \
|
do { \
|
||||||
if ((numOfElem) <= 0) { \
|
if ((numOfElem) <= 0) { \
|
||||||
|
@ -1645,7 +1656,7 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) {
|
||||||
int32_t type = pCol->info.type;
|
int32_t type = pCol->info.type;
|
||||||
|
|
||||||
SPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
SPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
if (pCtx->currentStage == REPEAT_SCAN && pInfo->stage == 0) {
|
if (pCtx->scanFlag == REPEAT_SCAN && pInfo->stage == 0) {
|
||||||
pInfo->stage += 1;
|
pInfo->stage += 1;
|
||||||
|
|
||||||
// all data are null, set it completed
|
// all data are null, set it completed
|
||||||
|
@ -3034,3 +3045,99 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
return numOfElems;
|
return numOfElems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getSampleFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
|
||||||
|
SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
|
SValueNode* pVal = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1);
|
||||||
|
int32_t numOfSamples = pVal->datum.i;
|
||||||
|
pEnv->calcMemSize = sizeof(SSampleInfo) + numOfSamples * (pCol->node.resType.bytes + sizeof(int64_t));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sampleFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo *pResultInfo) {
|
||||||
|
if (!functionSetup(pCtx, pResultInfo)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosSeedRand(taosSafeRand());
|
||||||
|
|
||||||
|
SSampleInfo *pInfo = GET_ROWCELL_INTERBUF(pResultInfo);
|
||||||
|
pInfo->samples = pCtx->param[1].param.i;
|
||||||
|
pInfo->totalPoints = 0;
|
||||||
|
pInfo->numSampled = 0;
|
||||||
|
pInfo->colType = pCtx->resDataInfo.type;
|
||||||
|
pInfo->colBytes = pCtx->resDataInfo.bytes;
|
||||||
|
if (pInfo->samples < 1 || pInfo->samples > SAMPLE_MAX_POINTS_NUM) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pInfo->data = (char *)pInfo + sizeof(SSampleInfo);
|
||||||
|
pInfo->timestamp = (int64_t *)((char *)pInfo + sizeof(SSampleInfo) + pInfo->samples * pInfo->colBytes);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sampleAssignResult(SSampleInfo* pInfo, char *data, TSKEY ts, int32_t index) {
|
||||||
|
assignVal(pInfo->data + index * pInfo->colBytes, data, pInfo->colBytes, pInfo->colType);
|
||||||
|
*(pInfo->timestamp + index) = ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void doReservoirSample(SSampleInfo* pInfo, char *data, TSKEY ts, int32_t index) {
|
||||||
|
pInfo->totalPoints++;
|
||||||
|
if (pInfo->numSampled < pInfo->samples) {
|
||||||
|
sampleAssignResult(pInfo, data, ts, pInfo->numSampled);
|
||||||
|
pInfo->numSampled++;
|
||||||
|
} else {
|
||||||
|
int32_t j = taosRand() % (pInfo->totalPoints);
|
||||||
|
if (j < pInfo->samples) {
|
||||||
|
sampleAssignResult(pInfo, data, ts, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t sampleFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
SSampleInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
TSKEY* tsList = (int64_t*)pInput->pPTS->pData;
|
||||||
|
|
||||||
|
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||||
|
SColumnInfoData* pTsOutput = pCtx->pTsOutput;
|
||||||
|
SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput;
|
||||||
|
|
||||||
|
int32_t startOffset = pCtx->offset;
|
||||||
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; i += 1) {
|
||||||
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
|
//colDataAppendNULL(pOutput, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* data = colDataGetData(pInputCol, i);
|
||||||
|
doReservoirSample(pInfo, data, tsList[i], i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pInfo->numSampled; ++i) {
|
||||||
|
int32_t pos = startOffset + i;
|
||||||
|
colDataAppend(pOutput, pos, pInfo->data + i * pInfo->colBytes, false);
|
||||||
|
//TODO: handle ts output
|
||||||
|
}
|
||||||
|
|
||||||
|
return pInfo->numSampled;
|
||||||
|
}
|
||||||
|
|
||||||
|
//int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
|
// SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
// SSampleInfo* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
|
||||||
|
// int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
||||||
|
// SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
|
//
|
||||||
|
// //int32_t currentRow = pBlock->info.rows;
|
||||||
|
// pResInfo->numOfRes = pInfo->numSampled;
|
||||||
|
//
|
||||||
|
// for (int32_t i = 0; i < pInfo->numSampled; ++i) {
|
||||||
|
// colDataAppend(pCol, i, pInfo->data + i * pInfo->colBytes, false);
|
||||||
|
// //TODO: handle ts output
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return pResInfo->numOfRes;
|
||||||
|
//}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
#define GET_TRUE_DATA_TYPE() \
|
#define GET_TRUE_DATA_TYPE() \
|
||||||
int32_t type = 0; \
|
int32_t type = 0; \
|
||||||
if (pCtx->currentStage == MERGE_STAGE) { \
|
if (pCtx->scanFlag == MERGE_STAGE) { \
|
||||||
type = pCtx->resDataInfo.type; \
|
type = pCtx->resDataInfo.type; \
|
||||||
assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY); \
|
assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY); \
|
||||||
} else { \
|
} else { \
|
||||||
|
@ -908,7 +908,7 @@ static void avg_func_merge(SqlFunctionCtx *pCtx) {
|
||||||
static void avg_finalizer(SqlFunctionCtx *pCtx) {
|
static void avg_finalizer(SqlFunctionCtx *pCtx) {
|
||||||
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
|
||||||
if (pCtx->currentStage == MERGE_STAGE) {
|
if (pCtx->scanFlag == MERGE_STAGE) {
|
||||||
assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY);
|
assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY);
|
||||||
|
|
||||||
if (GET_INT64_VAL(GET_ROWCELL_INTERBUF(pResInfo)) <= 0) {
|
if (GET_INT64_VAL(GET_ROWCELL_INTERBUF(pResInfo)) <= 0) {
|
||||||
|
@ -1152,7 +1152,7 @@ static void stddev_function(SqlFunctionCtx *pCtx) {
|
||||||
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||||
SStddevInfo *pStd = GET_ROWCELL_INTERBUF(pResInfo);
|
SStddevInfo *pStd = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
if (pCtx->currentStage == REPEAT_SCAN && pStd->stage == 0) {
|
if (pCtx->scanFlag == REPEAT_SCAN && pStd->stage == 0) {
|
||||||
pStd->stage++;
|
pStd->stage++;
|
||||||
avg_finalizer(pCtx);
|
avg_finalizer(pCtx);
|
||||||
|
|
||||||
|
@ -1814,7 +1814,7 @@ static STopBotInfo *getTopBotOutputInfo(SqlFunctionCtx *pCtx) {
|
||||||
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
|
||||||
// only the first_stage_merge is directly written data into final output buffer
|
// only the first_stage_merge is directly written data into final output buffer
|
||||||
if (pCtx->stableQuery && pCtx->currentStage != MERGE_STAGE) {
|
if (pCtx->stableQuery && pCtx->scanFlag != MERGE_STAGE) {
|
||||||
return (STopBotInfo*) pCtx->pOutput;
|
return (STopBotInfo*) pCtx->pOutput;
|
||||||
} else { // during normal table query and super table at the secondary_stage, result is written to intermediate buffer
|
} else { // during normal table query and super table at the secondary_stage, result is written to intermediate buffer
|
||||||
return GET_ROWCELL_INTERBUF(pResInfo);
|
return GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
@ -1956,7 +1956,7 @@ static void top_func_merge(SqlFunctionCtx *pCtx) {
|
||||||
for (int32_t i = 0; i < pInput->num; ++i) {
|
for (int32_t i = 0; i < pInput->num; ++i) {
|
||||||
int16_t type = (pCtx->resDataInfo.type == TSDB_DATA_TYPE_FLOAT)? TSDB_DATA_TYPE_DOUBLE:pCtx->resDataInfo.type;
|
int16_t type = (pCtx->resDataInfo.type == TSDB_DATA_TYPE_FLOAT)? TSDB_DATA_TYPE_DOUBLE:pCtx->resDataInfo.type;
|
||||||
// do_top_function_add(pOutput, (int32_t)pCtx->param[0].param.i, &pInput->res[i]->v.i, pInput->res[i]->timestamp,
|
// do_top_function_add(pOutput, (int32_t)pCtx->param[0].param.i, &pInput->res[i]->v.i, pInput->res[i]->timestamp,
|
||||||
// type, &pCtx->tagInfo, pInput->res[i]->pTags, pCtx->currentStage);
|
// type, &pCtx->tagInfo, pInput->res[i]->pTags, pCtx->scanFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_VAL(pCtx, pInput->num, pOutput->num);
|
SET_VAL(pCtx, pInput->num, pOutput->num);
|
||||||
|
@ -2013,7 +2013,7 @@ static void bottom_func_merge(SqlFunctionCtx *pCtx) {
|
||||||
for (int32_t i = 0; i < pInput->num; ++i) {
|
for (int32_t i = 0; i < pInput->num; ++i) {
|
||||||
int16_t type = (pCtx->resDataInfo.type == TSDB_DATA_TYPE_FLOAT) ? TSDB_DATA_TYPE_DOUBLE : pCtx->resDataInfo.type;
|
int16_t type = (pCtx->resDataInfo.type == TSDB_DATA_TYPE_FLOAT) ? TSDB_DATA_TYPE_DOUBLE : pCtx->resDataInfo.type;
|
||||||
// do_bottom_function_add(pOutput, (int32_t)pCtx->param[0].param.i, &pInput->res[i]->v.i, pInput->res[i]->timestamp, type,
|
// do_bottom_function_add(pOutput, (int32_t)pCtx->param[0].param.i, &pInput->res[i]->v.i, pInput->res[i]->timestamp, type,
|
||||||
// &pCtx->tagInfo, pInput->res[i]->pTags, pCtx->currentStage);
|
// &pCtx->tagInfo, pInput->res[i]->pTags, pCtx->scanFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_VAL(pCtx, pInput->num, pOutput->num);
|
SET_VAL(pCtx, pInput->num, pOutput->num);
|
||||||
|
@ -2073,7 +2073,7 @@ static void percentile_function(SqlFunctionCtx *pCtx) {
|
||||||
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||||
SPercentileInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
SPercentileInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
if (pCtx->currentStage == REPEAT_SCAN && pInfo->stage == 0) {
|
if (pCtx->scanFlag == REPEAT_SCAN && pInfo->stage == 0) {
|
||||||
pInfo->stage += 1;
|
pInfo->stage += 1;
|
||||||
|
|
||||||
// all data are null, set it completed
|
// all data are null, set it completed
|
||||||
|
@ -2180,7 +2180,7 @@ static SAPercentileInfo *getAPerctInfo(SqlFunctionCtx *pCtx) {
|
||||||
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||||
SAPercentileInfo* pInfo = NULL;
|
SAPercentileInfo* pInfo = NULL;
|
||||||
|
|
||||||
if (pCtx->stableQuery && pCtx->currentStage != MERGE_STAGE) {
|
if (pCtx->stableQuery && pCtx->scanFlag != MERGE_STAGE) {
|
||||||
pInfo = (SAPercentileInfo*) pCtx->pOutput;
|
pInfo = (SAPercentileInfo*) pCtx->pOutput;
|
||||||
} else {
|
} else {
|
||||||
pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
@ -2270,7 +2270,7 @@ static void apercentile_finalizer(SqlFunctionCtx *pCtx) {
|
||||||
SResultRowEntryInfo * pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo * pResInfo = GET_RES_INFO(pCtx);
|
||||||
SAPercentileInfo *pOutput = GET_ROWCELL_INTERBUF(pResInfo);
|
SAPercentileInfo *pOutput = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
if (pCtx->currentStage == MERGE_STAGE) {
|
if (pCtx->scanFlag == MERGE_STAGE) {
|
||||||
// if (pResInfo->hasResult == DATA_SET_FLAG) { // check for null
|
// if (pResInfo->hasResult == DATA_SET_FLAG) { // check for null
|
||||||
// assert(pOutput->pHisto->numOfElems > 0);
|
// assert(pOutput->pHisto->numOfElems > 0);
|
||||||
//
|
//
|
||||||
|
@ -2510,7 +2510,7 @@ static void copy_function(SqlFunctionCtx *pCtx);
|
||||||
|
|
||||||
static void tag_function(SqlFunctionCtx *pCtx) {
|
static void tag_function(SqlFunctionCtx *pCtx) {
|
||||||
SET_VAL(pCtx, 1, 1);
|
SET_VAL(pCtx, 1, 1);
|
||||||
if (pCtx->currentStage == MERGE_STAGE) {
|
if (pCtx->scanFlag == MERGE_STAGE) {
|
||||||
copy_function(pCtx);
|
copy_function(pCtx);
|
||||||
} else {
|
} else {
|
||||||
taosVariantDump(&pCtx->tag, pCtx->pOutput, pCtx->resDataInfo.type, true);
|
taosVariantDump(&pCtx->tag, pCtx->pOutput, pCtx->resDataInfo.type, true);
|
||||||
|
@ -2966,7 +2966,7 @@ static bool spread_function_setup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pRe
|
||||||
SSpreadInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
SSpreadInfo *pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
// this is the server-side setup function in client-side, the secondary merge do not need this procedure
|
// this is the server-side setup function in client-side, the secondary merge do not need this procedure
|
||||||
if (pCtx->currentStage == MERGE_STAGE) {
|
if (pCtx->scanFlag == MERGE_STAGE) {
|
||||||
// pCtx->param[0].param.d = DBL_MAX;
|
// pCtx->param[0].param.d = DBL_MAX;
|
||||||
// pCtx->param[3].param.d = -DBL_MAX;
|
// pCtx->param[3].param.d = -DBL_MAX;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3086,7 +3086,7 @@ void spread_function_finalizer(SqlFunctionCtx *pCtx) {
|
||||||
*/
|
*/
|
||||||
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
|
||||||
if (pCtx->currentStage == MERGE_STAGE) {
|
if (pCtx->scanFlag == MERGE_STAGE) {
|
||||||
assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY);
|
assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY);
|
||||||
|
|
||||||
// if (pResInfo->hasResult != DATA_SET_FLAG) {
|
// if (pResInfo->hasResult != DATA_SET_FLAG) {
|
||||||
|
|
|
@ -34,6 +34,9 @@ typedef struct SUdfdData {
|
||||||
uv_thread_t thread;
|
uv_thread_t thread;
|
||||||
uv_barrier_t barrier;
|
uv_barrier_t barrier;
|
||||||
uv_process_t process;
|
uv_process_t process;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
HANDLE jobHandle;
|
||||||
|
#endif
|
||||||
int spawnErr;
|
int spawnErr;
|
||||||
uv_pipe_t ctrlPipe;
|
uv_pipe_t ctrlPipe;
|
||||||
uv_async_t stopAsync;
|
uv_async_t stopAsync;
|
||||||
|
@ -104,6 +107,24 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) {
|
||||||
int err = uv_spawn(&pData->loop, &pData->process, &options);
|
int err = uv_spawn(&pData->loop, &pData->process, &options);
|
||||||
pData->process.data = (void*)pData;
|
pData->process.data = (void*)pData;
|
||||||
|
|
||||||
|
#ifdef WINDOWS
|
||||||
|
// End udfd.exe by Job.
|
||||||
|
if (pData->jobHandle != NULL) CloseHandle(pData->jobHandle);
|
||||||
|
pData->jobHandle = CreateJobObject(NULL, NULL);
|
||||||
|
bool add_job_ok = AssignProcessToJobObject(pData->jobHandle, pData->process.process_handle);
|
||||||
|
if (!add_job_ok) {
|
||||||
|
fnError("Assign udfd to job failed.");
|
||||||
|
} else {
|
||||||
|
JOBOBJECT_EXTENDED_LIMIT_INFORMATION limit_info;
|
||||||
|
memset(&limit_info, 0x0, sizeof(limit_info));
|
||||||
|
limit_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
|
||||||
|
bool set_auto_kill_ok = SetInformationJobObject(pData->jobHandle, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info));
|
||||||
|
if (!set_auto_kill_ok) {
|
||||||
|
fnError("Set job auto kill udfd failed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
fnError("can not spawn udfd. path: %s, error: %s", path, uv_strerror(err));
|
fnError("can not spawn udfd. path: %s, error: %s", path, uv_strerror(err));
|
||||||
}
|
}
|
||||||
|
@ -182,6 +203,9 @@ int32_t udfStopUdfd() {
|
||||||
uv_barrier_destroy(&pData->barrier);
|
uv_barrier_destroy(&pData->barrier);
|
||||||
uv_async_send(&pData->stopAsync);
|
uv_async_send(&pData->stopAsync);
|
||||||
uv_thread_join(&pData->thread);
|
uv_thread_join(&pData->thread);
|
||||||
|
#ifdef WINDOWS
|
||||||
|
if (pData->jobHandle != NULL) CloseHandle(pData->jobHandle);
|
||||||
|
#endif
|
||||||
fnInfo("dnode udfd cleaned up");
|
fnInfo("dnode udfd cleaned up");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInte
|
||||||
case TSDB_DATA_TYPE_INT: {
|
case TSDB_DATA_TYPE_INT: {
|
||||||
char* cell = udfColDataGetData(col, j);
|
char* cell = udfColDataGetData(col, j);
|
||||||
int32_t num = *(int32_t*)cell;
|
int32_t num = *(int32_t*)cell;
|
||||||
sumSquares += num * num;
|
sumSquares += (double)num * num;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
|
|
|
@ -317,15 +317,16 @@ static int32_t tableComInfoToJson(const void* pObj, SJson* pJson) {
|
||||||
static int32_t jsonToTableComInfo(const SJson* pJson, void* pObj) {
|
static int32_t jsonToTableComInfo(const SJson* pJson, void* pObj) {
|
||||||
STableComInfo* pNode = (STableComInfo*)pObj;
|
STableComInfo* pNode = (STableComInfo*)pObj;
|
||||||
|
|
||||||
int32_t code = tjsonGetNumberValue(pJson, jkTableComInfoNumOfTags, pNode->numOfTags);
|
int32_t code;
|
||||||
|
tjsonGetNumberValue(pJson, jkTableComInfoNumOfTags, pNode->numOfTags, code);;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableComInfoPrecision, pNode->precision);
|
tjsonGetNumberValue(pJson, jkTableComInfoPrecision, pNode->precision, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableComInfoNumOfColumns, pNode->numOfColumns);
|
tjsonGetNumberValue(pJson, jkTableComInfoNumOfColumns, pNode->numOfColumns, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableComInfoRowSize, pNode->rowSize);
|
tjsonGetNumberValue(pJson, jkTableComInfoRowSize, pNode->rowSize, code);;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -356,12 +357,13 @@ static int32_t schemaToJson(const void* pObj, SJson* pJson) {
|
||||||
static int32_t jsonToSchema(const SJson* pJson, void* pObj) {
|
static int32_t jsonToSchema(const SJson* pJson, void* pObj) {
|
||||||
SSchema* pNode = (SSchema*)pObj;
|
SSchema* pNode = (SSchema*)pObj;
|
||||||
|
|
||||||
int32_t code = tjsonGetNumberValue(pJson, jkSchemaType, pNode->type);
|
int32_t code;
|
||||||
|
tjsonGetNumberValue(pJson, jkSchemaType, pNode->type, code);;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkSchemaColId, pNode->colId);
|
tjsonGetNumberValue(pJson, jkSchemaColId, pNode->colId, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkSchemaBytes, pNode->bytes);
|
tjsonGetNumberValue(pJson, jkSchemaBytes, pNode->bytes, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetStringValue(pJson, jkSchemaName, pNode->name);
|
code = tjsonGetStringValue(pJson, jkSchemaName, pNode->name);
|
||||||
|
@ -412,21 +414,22 @@ static int32_t tableMetaToJson(const void* pObj, SJson* pJson) {
|
||||||
static int32_t jsonToTableMeta(const SJson* pJson, void* pObj) {
|
static int32_t jsonToTableMeta(const SJson* pJson, void* pObj) {
|
||||||
STableMeta* pNode = (STableMeta*)pObj;
|
STableMeta* pNode = (STableMeta*)pObj;
|
||||||
|
|
||||||
int32_t code = tjsonGetNumberValue(pJson, jkTableMetaVgId, pNode->vgId);
|
int32_t code;
|
||||||
|
tjsonGetNumberValue(pJson, jkTableMetaVgId, pNode->vgId, code);;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableMetaTableType, pNode->tableType);
|
tjsonGetNumberValue(pJson, jkTableMetaTableType, pNode->tableType, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableMetaUid, pNode->uid);
|
tjsonGetNumberValue(pJson, jkTableMetaUid, pNode->uid, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableMetaSuid, pNode->suid);
|
tjsonGetNumberValue(pJson, jkTableMetaSuid, pNode->suid, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableMetaSversion, pNode->sversion);
|
tjsonGetNumberValue(pJson, jkTableMetaSversion, pNode->sversion, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableMetaTversion, pNode->tversion);
|
tjsonGetNumberValue(pJson, jkTableMetaTversion, pNode->tversion, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonToObject(pJson, jkTableMetaComInfo, jsonToTableComInfo, &pNode->tableInfo);
|
code = tjsonToObject(pJson, jkTableMetaComInfo, jsonToTableComInfo, &pNode->tableInfo);
|
||||||
|
@ -602,7 +605,7 @@ static int32_t jsonToLogicFillNode(const SJson* pJson, void* pObj) {
|
||||||
|
|
||||||
int32_t code = jsonToLogicPlanNode(pJson, pObj);
|
int32_t code = jsonToLogicPlanNode(pJson, pObj);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkFillLogicPlanMode, pNode->mode);
|
tjsonGetNumberValue(pJson, jkFillLogicPlanMode, pNode->mode, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkFillLogicPlanWStartTs, &pNode->pWStartTs);
|
code = jsonToNodeObject(pJson, jkFillLogicPlanWStartTs, &pNode->pWStartTs);
|
||||||
|
@ -878,7 +881,7 @@ static int32_t jsonToLogicSubplan(const SJson* pJson, void* pObj) {
|
||||||
code = jsonToNodeObject(pJson, jkLogicSubplanRootNode, (SNode**)&pNode->pNode);
|
code = jsonToNodeObject(pJson, jkLogicSubplanRootNode, (SNode**)&pNode->pNode);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkLogicSubplanType, pNode->subplanType);
|
tjsonGetNumberValue(pJson, jkLogicSubplanType, pNode->subplanType, code);;
|
||||||
}
|
}
|
||||||
int32_t objSize = 0;
|
int32_t objSize = 0;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -1118,25 +1121,25 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
|
||||||
code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanRatio, &pNode->ratio);
|
code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanRatio, &pNode->ratio);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanDataRequired, pNode->dataRequired);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanDataRequired, pNode->dataRequired, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs);
|
code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanInterval, pNode->interval);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanInterval, pNode->interval, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanOffset, pNode->offset);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanOffset, pNode->offset, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSliding, pNode->sliding);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSliding, pNode->sliding, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit);
|
tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit, code);;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1178,7 +1181,7 @@ static int32_t jsonToPhysiSysTableScanNode(const SJson* pJson, void* pObj) {
|
||||||
code = tjsonGetBoolValue(pJson, jkSysTableScanPhysiPlanShowRewrite, &pNode->showRewrite);
|
code = tjsonGetBoolValue(pJson, jkSysTableScanPhysiPlanShowRewrite, &pNode->showRewrite);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkSysTableScanPhysiPlanAccountId, pNode->accountId);
|
tjsonGetNumberValue(pJson, jkSysTableScanPhysiPlanAccountId, pNode->accountId, code);;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1262,7 +1265,7 @@ static int32_t jsonToPhysiJoinNode(const SJson* pJson, void* pObj) {
|
||||||
|
|
||||||
int32_t code = jsonToPhysicPlanNode(pJson, pObj);
|
int32_t code = jsonToPhysicPlanNode(pJson, pObj);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkJoinPhysiPlanJoinType, pNode->joinType);
|
tjsonGetNumberValue(pJson, jkJoinPhysiPlanJoinType, pNode->joinType, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkJoinPhysiPlanOnConditions, &pNode->pOnConditions);
|
code = jsonToNodeObject(pJson, jkJoinPhysiPlanOnConditions, &pNode->pOnConditions);
|
||||||
|
@ -1424,10 +1427,10 @@ static int32_t jsonToPhysiWindowNode(const SJson* pJson, void* pObj) {
|
||||||
code = jsonToNodeObject(pJson, jkWindowPhysiPlanTsPk, (SNode**)&pNode->pTspk);
|
code = jsonToNodeObject(pJson, jkWindowPhysiPlanTsPk, (SNode**)&pNode->pTspk);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkWindowPhysiPlanTriggerType, pNode->triggerType);
|
tjsonGetNumberValue(pJson, jkWindowPhysiPlanTriggerType, pNode->triggerType, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkWindowPhysiPlanWatermark, pNode->watermark);
|
tjsonGetNumberValue(pJson, jkWindowPhysiPlanWatermark, pNode->watermark, code);;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1523,7 +1526,7 @@ static int32_t jsonToPhysiFillNode(const SJson* pJson, void* pObj) {
|
||||||
|
|
||||||
int32_t code = jsonToPhysicPlanNode(pJson, pObj);
|
int32_t code = jsonToPhysicPlanNode(pJson, pObj);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkFillPhysiPlanMode, pNode->mode);
|
tjsonGetNumberValue(pJson, jkFillPhysiPlanMode, pNode->mode, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkFillPhysiPlanWStartTs, &pNode->pWStartTs);
|
code = jsonToNodeObject(pJson, jkFillPhysiPlanWStartTs, &pNode->pWStartTs);
|
||||||
|
@ -1562,7 +1565,7 @@ static int32_t jsonToPhysiSessionWindowNode(const SJson* pJson, void* pObj) {
|
||||||
|
|
||||||
int32_t code = jsonToPhysiWindowNode(pJson, pObj);
|
int32_t code = jsonToPhysiWindowNode(pJson, pObj);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkSessionWindowPhysiPlanGap, pNode->gap);
|
tjsonGetNumberValue(pJson, jkSessionWindowPhysiPlanGap, pNode->gap, code);;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1724,7 +1727,7 @@ static int32_t jsonToSubplan(const SJson* pJson, void* pObj) {
|
||||||
|
|
||||||
int32_t code = tjsonToObject(pJson, jkSubplanId, jsonToSubplanId, &pNode->id);
|
int32_t code = tjsonToObject(pJson, jkSubplanId, jsonToSubplanId, &pNode->id);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkSubplanType, pNode->subplanType);
|
tjsonGetNumberValue(pJson, jkSubplanType, pNode->subplanType, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetIntValue(pJson, jkSubplanMsgType, &pNode->msgType);
|
code = tjsonGetIntValue(pJson, jkSubplanMsgType, &pNode->msgType);
|
||||||
|
@ -1914,7 +1917,7 @@ static int32_t jsonToColumnNode(const SJson* pJson, void* pObj) {
|
||||||
code = tjsonGetSmallIntValue(pJson, jkColumnColId, &pNode->colId);
|
code = tjsonGetSmallIntValue(pJson, jkColumnColId, &pNode->colId);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkColumnColType, pNode->colType);
|
tjsonGetNumberValue(pJson, jkColumnColType, pNode->colType, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetStringValue(pJson, jkColumnDbName, pNode->dbName);
|
code = tjsonGetStringValue(pJson, jkColumnDbName, pNode->dbName);
|
||||||
|
@ -2168,7 +2171,7 @@ static int32_t jsonToOperatorNode(const SJson* pJson, void* pObj) {
|
||||||
|
|
||||||
int32_t code = jsonToExprNode(pJson, pObj);
|
int32_t code = jsonToExprNode(pJson, pObj);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkOperatorType, pNode->opType);
|
tjsonGetNumberValue(pJson, jkOperatorType, pNode->opType, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkOperatorLeft, &pNode->pLeft);
|
code = jsonToNodeObject(pJson, jkOperatorLeft, &pNode->pLeft);
|
||||||
|
@ -2202,7 +2205,7 @@ static int32_t jsonToLogicConditionNode(const SJson* pJson, void* pObj) {
|
||||||
|
|
||||||
int32_t code = jsonToExprNode(pJson, pObj);
|
int32_t code = jsonToExprNode(pJson, pObj);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkLogicCondType, pNode->condType);
|
tjsonGetNumberValue(pJson, jkLogicCondType, pNode->condType, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkLogicCondParameters, &pNode->pParameterList);
|
code = jsonToNodeList(pJson, jkLogicCondParameters, &pNode->pParameterList);
|
||||||
|
@ -2384,10 +2387,10 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) {
|
||||||
|
|
||||||
int32_t code = jsonToNodeObject(pJson, jkOrderByExprExpr, &pNode->pExpr);
|
int32_t code = jsonToNodeObject(pJson, jkOrderByExprExpr, &pNode->pExpr);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkOrderByExprOrder, pNode->order);
|
tjsonGetNumberValue(pJson, jkOrderByExprOrder, pNode->order, code);;
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetNumberValue(pJson, jkOrderByExprNullOrder, pNode->nullOrder);
|
tjsonGetNumberValue(pJson, jkOrderByExprNullOrder, pNode->nullOrder, code);;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -2493,7 +2496,8 @@ static int32_t fillNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
static int32_t jsonToFillNode(const SJson* pJson, void* pObj) {
|
static int32_t jsonToFillNode(const SJson* pJson, void* pObj) {
|
||||||
SFillNode* pNode = (SFillNode*)pObj;
|
SFillNode* pNode = (SFillNode*)pObj;
|
||||||
|
|
||||||
int32_t code = tjsonGetNumberValue(pJson, jkFillMode, pNode->mode);
|
int32_t code;
|
||||||
|
tjsonGetNumberValue(pJson, jkFillMode, pNode->mode, code);;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkFillValues, &pNode->pValues);
|
code = jsonToNodeObject(pJson, jkFillValues, &pNode->pValues);
|
||||||
}
|
}
|
||||||
|
@ -3033,7 +3037,8 @@ static int32_t nodeToJson(const void* pObj, SJson* pJson) {
|
||||||
static int32_t jsonToNode(const SJson* pJson, void* pObj) {
|
static int32_t jsonToNode(const SJson* pJson, void* pObj) {
|
||||||
SNode* pNode = (SNode*)pObj;
|
SNode* pNode = (SNode*)pObj;
|
||||||
|
|
||||||
int32_t code = tjsonGetNumberValue(pJson, jkNodeType, pNode->type);
|
int32_t code;
|
||||||
|
tjsonGetNumberValue(pJson, jkNodeType, pNode->type, code);;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonToObject(pJson, nodesNodeName(pNode->type), jsonToSpecificNode, pNode);
|
code = tjsonToObject(pJson, nodesNodeName(pNode->type), jsonToSpecificNode, pNode);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
|
|
@ -758,7 +758,7 @@ static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, voi
|
||||||
int32_t output = 0;
|
int32_t output = 0;
|
||||||
if (!taosMbsToUcs4(value, len, (TdUcs4*)varDataVal(pa->buf), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) {
|
if (!taosMbsToUcs4(value, len, (TdUcs4*)varDataVal(pa->buf), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) {
|
||||||
char buf[512] = {0};
|
char buf[512] = {0};
|
||||||
snprintf(buf, tListLen(buf), "%s", strerror(errno));
|
snprintf(buf, tListLen(buf), " taosMbsToUcs4 error:%s", strerror(errno));
|
||||||
return buildSyntaxErrMsg(pMsgBuf, buf, value);
|
return buildSyntaxErrMsg(pMsgBuf, buf, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1227,16 +1227,20 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
|
||||||
if (NULL == *pQuery) {
|
if (NULL == *pQuery) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
(*pQuery)->pTableList = taosArrayInit(taosHashGetSize(context.pTableNameHashObj), sizeof(SName));
|
|
||||||
if (NULL == (*pQuery)->pTableList) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
(*pQuery)->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
(*pQuery)->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||||
(*pQuery)->haveResultSet = false;
|
(*pQuery)->haveResultSet = false;
|
||||||
(*pQuery)->msgType = TDMT_VND_SUBMIT;
|
(*pQuery)->msgType = TDMT_VND_SUBMIT;
|
||||||
(*pQuery)->pRoot = (SNode*)context.pOutput;
|
(*pQuery)->pRoot = (SNode*)context.pOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NULL == (*pQuery)->pTableList) {
|
||||||
|
(*pQuery)->pTableList = taosArrayInit(taosHashGetSize(context.pTableNameHashObj), sizeof(SName));
|
||||||
|
if (NULL == (*pQuery)->pTableList) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
context.pOutput->payloadType = PAYLOAD_TYPE_KV;
|
context.pOutput->payloadType = PAYLOAD_TYPE_KV;
|
||||||
|
|
||||||
int32_t code = skipInsertInto(&context);
|
int32_t code = skipInsertInto(&context);
|
||||||
|
@ -1668,7 +1672,11 @@ static int32_t smlBuildTagRow(SArray* cols, SKVRowBuilder* tagsBuilder, SParsedD
|
||||||
SSchema* pTagSchema = &pSchema[tags->boundColumns[i] - 1]; // colId starts with 1
|
SSchema* pTagSchema = &pSchema[tags->boundColumns[i] - 1]; // colId starts with 1
|
||||||
param.schema = pTagSchema;
|
param.schema = pTagSchema;
|
||||||
SSmlKv* kv = taosArrayGetP(cols, i);
|
SSmlKv* kv = taosArrayGetP(cols, i);
|
||||||
KvRowAppend(msg, kv->value, kv->valueLen, ¶m);
|
if(IS_VAR_DATA_TYPE(kv->type)){
|
||||||
|
KvRowAppend(msg, kv->value, kv->length, ¶m);
|
||||||
|
}else{
|
||||||
|
KvRowAppend(msg, &(kv->value), kv->length, ¶m);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*row = tdGetKVRowFromBuilder(tagsBuilder);
|
*row = tdGetKVRowFromBuilder(tagsBuilder);
|
||||||
|
@ -1766,15 +1774,17 @@ int32_t smlBindData(void *handle, SArray *tags, SArray *colsSchema, SArray *cols
|
||||||
if (!kv || kv->length == 0) {
|
if (!kv || kv->length == 0) {
|
||||||
MemRowAppend(&pBuf, NULL, 0, ¶m);
|
MemRowAppend(&pBuf, NULL, 0, ¶m);
|
||||||
} else {
|
} else {
|
||||||
int32_t colLen = pColSchema->bytes;
|
int32_t colLen = kv->length;
|
||||||
if (IS_VAR_DATA_TYPE(pColSchema->type)) {
|
if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
colLen = kv->length;
|
|
||||||
} else if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) {
|
|
||||||
kv->i = convertTimePrecision(kv->i, TSDB_TIME_PRECISION_NANO, pTableMeta->tableInfo.precision);
|
kv->i = convertTimePrecision(kv->i, TSDB_TIME_PRECISION_NANO, pTableMeta->tableInfo.precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(IS_VAR_DATA_TYPE(kv->type)){
|
||||||
|
MemRowAppend(&pBuf, kv->value, colLen, ¶m);
|
||||||
|
}else{
|
||||||
MemRowAppend(&pBuf, &(kv->value), colLen, ¶m);
|
MemRowAppend(&pBuf, &(kv->value), colLen, ¶m);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) {
|
if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) {
|
||||||
TSKEY tsKey = TD_ROW_KEY(row);
|
TSKEY tsKey = TD_ROW_KEY(row);
|
||||||
|
|
|
@ -1538,7 +1538,9 @@ static EDealRes checkStateExpr(SNode* pNode, void* pContext) {
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
STranslateContext* pCxt = pContext;
|
STranslateContext* pCxt = pContext;
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
if (!IS_INTEGER_TYPE(pCol->node.resType.type)) {
|
|
||||||
|
int32_t type = pCol->node.resType.type;
|
||||||
|
if (!IS_INTEGER_TYPE(type) && type != TSDB_DATA_TYPE_BOOL && !IS_VAR_DATA_TYPE(type)) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE);
|
||||||
}
|
}
|
||||||
if (COLUMN_TYPE_TAG == pCol->colType) {
|
if (COLUMN_TYPE_TAG == pCol->colType) {
|
||||||
|
|
|
@ -91,7 +91,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
case TSDB_CODE_PAR_AGG_FUNC_NESTING:
|
case TSDB_CODE_PAR_AGG_FUNC_NESTING:
|
||||||
return "Aggregate functions do not support nesting";
|
return "Aggregate functions do not support nesting";
|
||||||
case TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE:
|
case TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE:
|
||||||
return "Only support STATE_WINDOW on integer column";
|
return "Only support STATE_WINDOW on integer/bool/varchar column";
|
||||||
case TSDB_CODE_PAR_INVALID_STATE_WIN_COL:
|
case TSDB_CODE_PAR_INVALID_STATE_WIN_COL:
|
||||||
return "Not support STATE_WINDOW on tag column";
|
return "Not support STATE_WINDOW on tag column";
|
||||||
case TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE:
|
case TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE:
|
||||||
|
|
|
@ -184,5 +184,6 @@ int32_t qStmtParseQuerySql(SParseContext* pCxt, SQuery* pQuery) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = calculateConstant(pCxt, pQuery);
|
code = calculateConstant(pCxt, pQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,10 +228,12 @@ static void setScanWindowInfo(SScanLogicNode* pScan) {
|
||||||
static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
SOsdInfo info = {0};
|
SOsdInfo info = {0};
|
||||||
int32_t code = osdMatch(pCxt, pLogicNode, &info);
|
int32_t code = osdMatch(pCxt, pLogicNode, &info);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && info.pScan) {
|
||||||
|
setScanWindowInfo((SScanLogicNode*)info.pScan);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && (NULL != info.pDsoFuncs || NULL != info.pSdrFuncs)) {
|
if (TSDB_CODE_SUCCESS == code && (NULL != info.pDsoFuncs || NULL != info.pSdrFuncs)) {
|
||||||
info.pScan->dataRequired = osdGetDataRequired(info.pSdrFuncs);
|
info.pScan->dataRequired = osdGetDataRequired(info.pSdrFuncs);
|
||||||
info.pScan->pDynamicScanFuncs = info.pDsoFuncs;
|
info.pScan->pDynamicScanFuncs = info.pDsoFuncs;
|
||||||
setScanWindowInfo((SScanLogicNode*)info.pScan);
|
|
||||||
OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_OSD);
|
OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_OSD);
|
||||||
pCxt->optimized = true;
|
pCxt->optimized = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,6 +290,10 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isSuperTable, STabl
|
||||||
pTableMeta->sversion = msg->sversion;
|
pTableMeta->sversion = msg->sversion;
|
||||||
pTableMeta->tversion = msg->tversion;
|
pTableMeta->tversion = msg->tversion;
|
||||||
|
|
||||||
|
if (isSuperTable) {
|
||||||
|
qDebug("stable %s meta returned, suid:%" PRIx64, msg->stbName, pTableMeta->suid);
|
||||||
|
}
|
||||||
|
|
||||||
pTableMeta->tableInfo.numOfTags = msg->numOfTags;
|
pTableMeta->tableInfo.numOfTags = msg->numOfTags;
|
||||||
pTableMeta->tableInfo.precision = msg->precision;
|
pTableMeta->tableInfo.precision = msg->precision;
|
||||||
pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
|
pTableMeta->tableInfo.numOfColumns = msg->numOfColumns;
|
||||||
|
|
|
@ -27,15 +27,18 @@ typedef struct SScalarCtx {
|
||||||
SArray *pBlockList; /* element is SSDataBlock* */
|
SArray *pBlockList; /* element is SSDataBlock* */
|
||||||
SHashObj *pRes; /* element is SScalarParam */
|
SHashObj *pRes; /* element is SScalarParam */
|
||||||
void *param; // additional parameter (meta actually) for acquire value such as tbname/tags values
|
void *param; // additional parameter (meta actually) for acquire value such as tbname/tags values
|
||||||
|
SHashObj *udf2Handle;
|
||||||
} SScalarCtx;
|
} SScalarCtx;
|
||||||
|
|
||||||
|
|
||||||
#define SCL_DATA_TYPE_DUMMY_HASH 9000
|
#define SCL_DATA_TYPE_DUMMY_HASH 9000
|
||||||
#define SCL_DEFAULT_OP_NUM 10
|
#define SCL_DEFAULT_OP_NUM 10
|
||||||
|
#define SCL_DEFAULT_UDF_NUM 8
|
||||||
|
|
||||||
#define SCL_IS_CONST_NODE(_node) ((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type))
|
#define SCL_IS_CONST_NODE(_node) ((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type))
|
||||||
#define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList)
|
#define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList)
|
||||||
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0))
|
//#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0))
|
||||||
|
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type))
|
||||||
|
|
||||||
#define sclFatal(...) qFatal(__VA_ARGS__)
|
#define sclFatal(...) qFatal(__VA_ARGS__)
|
||||||
#define sclError(...) qError(__VA_ARGS__)
|
#define sclError(...) qError(__VA_ARGS__)
|
||||||
|
|
|
@ -153,6 +153,18 @@ void sclFreeRes(SHashObj *res) {
|
||||||
taosHashCleanup(res);
|
taosHashCleanup(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sclFreeUdfHandles(SHashObj *udf2handle) {
|
||||||
|
void *pIter = taosHashIterate(udf2handle, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
UdfcFuncHandle *handle = (UdfcFuncHandle *)pIter;
|
||||||
|
if (handle) {
|
||||||
|
teardownUdf(*handle);
|
||||||
|
}
|
||||||
|
pIter = taosHashIterate(udf2handle, pIter);
|
||||||
|
}
|
||||||
|
taosHashCleanup(udf2handle);
|
||||||
|
}
|
||||||
|
|
||||||
void sclFreeParam(SScalarParam *param) {
|
void sclFreeParam(SScalarParam *param) {
|
||||||
if (param->columnData != NULL) {
|
if (param->columnData != NULL) {
|
||||||
colDataDestroy(param->columnData);
|
colDataDestroy(param->columnData);
|
||||||
|
@ -362,22 +374,28 @@ int32_t sclExecFunction(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *outp
|
||||||
|
|
||||||
if (fmIsUserDefinedFunc(node->funcId)) {
|
if (fmIsUserDefinedFunc(node->funcId)) {
|
||||||
UdfcFuncHandle udfHandle = NULL;
|
UdfcFuncHandle udfHandle = NULL;
|
||||||
|
char* udfName = node->functionName;
|
||||||
code = setupUdf(node->functionName, &udfHandle);
|
if (ctx->udf2Handle) {
|
||||||
|
UdfcFuncHandle *pHandle = taosHashGet(ctx->udf2Handle, udfName, strlen(udfName));
|
||||||
|
if (pHandle) {
|
||||||
|
udfHandle = *pHandle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (udfHandle == NULL) {
|
||||||
|
code = setupUdf(udfName, &udfHandle);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
sclError("fmExecFunction error. setupUdf. function name: %s, code:%d", node->functionName, code);
|
sclError("fmExecFunction error. setupUdf. function name: %s, code:%d", udfName, code);
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
if (ctx->udf2Handle) {
|
||||||
|
taosHashPut(ctx->udf2Handle, udfName, strlen(udfName), &udfHandle, sizeof(UdfcFuncHandle));
|
||||||
|
}
|
||||||
|
}
|
||||||
code = callUdfScalarFunc(udfHandle, params, paramNum, output);
|
code = callUdfScalarFunc(udfHandle, params, paramNum, output);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
sclError("fmExecFunction error. callUdfScalarFunc. function name: %s, udf code:%d", node->functionName, code);
|
sclError("fmExecFunction error. callUdfScalarFunc. function name: %s, udf code:%d", node->functionName, code);
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
code = teardownUdf(udfHandle);
|
|
||||||
if (code != 0) {
|
|
||||||
sclError("fmExecFunction error. callUdfScalarFunc. function name: %s, udf code:%d", node->functionName, code);
|
|
||||||
goto _return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
SScalarFuncExecFuncs ffpSet = {0};
|
SScalarFuncExecFuncs ffpSet = {0};
|
||||||
code = fmGetScalarFuncExecFuncs(node->funcId, &ffpSet);
|
code = fmGetScalarFuncExecFuncs(node->funcId, &ffpSet);
|
||||||
|
@ -891,15 +909,20 @@ int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
|
||||||
SScalarCtx ctx = {0};
|
SScalarCtx ctx = {0};
|
||||||
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
if (NULL == ctx.pRes) {
|
if (NULL == ctx.pRes) {
|
||||||
sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM);
|
sclError("taosHashInit result map failed, num:%d", SCL_DEFAULT_OP_NUM);
|
||||||
|
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
ctx.udf2Handle = taosHashInit(SCL_DEFAULT_UDF_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
|
if (NULL == ctx.udf2Handle) {
|
||||||
|
sclError("taosHashInit udf to handle map failed, num:%d", SCL_DEFAULT_OP_NUM);
|
||||||
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
nodesRewriteExprPostOrder(&pNode, sclConstantsRewriter, (void *)&ctx);
|
nodesRewriteExprPostOrder(&pNode, sclConstantsRewriter, (void *)&ctx);
|
||||||
SCL_ERR_JRET(ctx.code);
|
SCL_ERR_JRET(ctx.code);
|
||||||
*pRes = pNode;
|
*pRes = pNode;
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
sclFreeUdfHandles(ctx.udf2Handle);
|
||||||
sclFreeRes(ctx.pRes);
|
sclFreeRes(ctx.pRes);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -915,10 +938,14 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
||||||
// TODO: OPT performance
|
// TODO: OPT performance
|
||||||
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
if (NULL == ctx.pRes) {
|
if (NULL == ctx.pRes) {
|
||||||
sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM);
|
sclError("taosHashInit result map failed, num:%d", SCL_DEFAULT_OP_NUM);
|
||||||
|
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
ctx.udf2Handle = taosHashInit(SCL_DEFAULT_UDF_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
|
if (NULL == ctx.udf2Handle) {
|
||||||
|
sclError("taosHashInit udf to handle map failed, num:%d", SCL_DEFAULT_OP_NUM);
|
||||||
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
nodesWalkExprPostOrder(pNode, sclCalcWalker, (void *)&ctx);
|
nodesWalkExprPostOrder(pNode, sclCalcWalker, (void *)&ctx);
|
||||||
SCL_ERR_JRET(ctx.code);
|
SCL_ERR_JRET(ctx.code);
|
||||||
|
|
||||||
|
@ -936,6 +963,7 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
//nodesDestroyNode(pNode);
|
//nodesDestroyNode(pNode);
|
||||||
|
sclFreeUdfHandles(ctx.udf2Handle);
|
||||||
sclFreeRes(ctx.pRes);
|
sclFreeRes(ctx.pRes);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, in
|
||||||
|
|
||||||
// sink
|
// sink
|
||||||
if (pTask->sinkType == TASK_SINK__TABLE) {
|
if (pTask->sinkType == TASK_SINK__TABLE) {
|
||||||
blockDebugShowData(pRes);
|
// blockDebugShowData(pRes);
|
||||||
pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pRes);
|
pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pRes);
|
||||||
} else if (pTask->sinkType == TASK_SINK__SMA) {
|
} else if (pTask->sinkType == TASK_SINK__SMA) {
|
||||||
pTask->smaSink.smaSink(pTask->ahandle, pTask->smaSink.smaId, pRes);
|
pTask->smaSink.smaSink(pTask->ahandle, pTask->smaSink.smaId, pRes);
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_UV
|
#ifdef USE_UV
|
||||||
|
|
||||||
#include "transComm.h"
|
#include "transComm.h"
|
||||||
|
|
||||||
typedef struct SCliConn {
|
typedef struct SCliConn {
|
||||||
|
@ -21,15 +20,16 @@ typedef struct SCliConn {
|
||||||
uv_connect_t connReq;
|
uv_connect_t connReq;
|
||||||
uv_stream_t* stream;
|
uv_stream_t* stream;
|
||||||
uv_write_t writeReq;
|
uv_write_t writeReq;
|
||||||
|
|
||||||
void* hostThrd;
|
void* hostThrd;
|
||||||
|
int hThrdIdx;
|
||||||
|
|
||||||
SConnBuffer readBuf;
|
SConnBuffer readBuf;
|
||||||
void* data;
|
|
||||||
STransQueue cliMsgs;
|
STransQueue cliMsgs;
|
||||||
queue conn;
|
queue conn;
|
||||||
uint64_t expireTime;
|
uint64_t expireTime;
|
||||||
int hThrdIdx;
|
|
||||||
STransCtx ctx;
|
|
||||||
|
|
||||||
|
STransCtx ctx;
|
||||||
bool broken; // link broken or not
|
bool broken; // link broken or not
|
||||||
ConnStatus status; //
|
ConnStatus status; //
|
||||||
|
|
||||||
|
@ -157,13 +157,11 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
|
||||||
transClearBuffer(&conn->readBuf); \
|
transClearBuffer(&conn->readBuf); \
|
||||||
transFreeMsg(transContFromHead((char*)head)); \
|
transFreeMsg(transContFromHead((char*)head)); \
|
||||||
tDebug("cli conn %p receive release request, ref: %d", conn, T_REF_VAL_GET(conn)); \
|
tDebug("cli conn %p receive release request, ref: %d", conn, T_REF_VAL_GET(conn)); \
|
||||||
while (T_REF_VAL_GET(conn) > 1) { \
|
if (T_REF_VAL_GET(conn) > 1) { \
|
||||||
transUnrefCliHandle(conn); \
|
|
||||||
} \
|
|
||||||
if (T_REF_VAL_GET(conn) == 1) { \
|
|
||||||
transUnrefCliHandle(conn); \
|
transUnrefCliHandle(conn); \
|
||||||
} \
|
} \
|
||||||
destroyCmsg(pMsg); \
|
destroyCmsg(pMsg); \
|
||||||
|
addConnToPool(((SCliThrdObj*)conn->hostThrd)->pool, conn); \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -707,7 +705,8 @@ SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrdObj* pThrd) {
|
||||||
void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
|
void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
|
||||||
uint64_t et = taosGetTimestampUs();
|
uint64_t et = taosGetTimestampUs();
|
||||||
uint64_t el = et - pMsg->st;
|
uint64_t el = et - pMsg->st;
|
||||||
tTrace("%s cli msg tran time cost: %" PRIu64 "us", ((STrans*)pThrd->pTransInst)->label, el);
|
tTrace("%s cli msg tran time cost: %" PRIu64 "us, threadID: %" PRId64 "", ((STrans*)pThrd->pTransInst)->label, el,
|
||||||
|
pThrd->thread);
|
||||||
|
|
||||||
STransConnCtx* pCtx = pMsg->ctx;
|
STransConnCtx* pCtx = pMsg->ctx;
|
||||||
STrans* pTransInst = pThrd->pTransInst;
|
STrans* pTransInst = pThrd->pTransInst;
|
||||||
|
@ -1030,8 +1029,8 @@ void transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra
|
||||||
|
|
||||||
SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[index];
|
SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[index];
|
||||||
|
|
||||||
tDebug("send request at thread:%d %p, dst: %s:%d, app:%p", index, pReq, EPSET_GET_INUSE_IP(&pCtx->epSet),
|
tDebug("send request at thread:%d, threadID: %" PRId64 ", msg: %p, dst: %s:%d, app:%p", index, thrd->thread, pReq,
|
||||||
EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->ahandle);
|
EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->ahandle);
|
||||||
ASSERT(transSendAsync(thrd->asyncPool, &(cliMsg->q)) == 0);
|
ASSERT(transSendAsync(thrd->asyncPool, &(cliMsg->q)) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,8 +1057,8 @@ void transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransM
|
||||||
cliMsg->type = Normal;
|
cliMsg->type = Normal;
|
||||||
|
|
||||||
SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[index];
|
SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[index];
|
||||||
tDebug("send request at thread:%d %p, dst: %s:%d, app:%p", index, pReq, EPSET_GET_INUSE_IP(&pCtx->epSet),
|
tDebug("send request at thread:%d, threadID:%" PRId64 ", msg: %p, dst: %s:%d, app:%p", index, thrd->thread, pReq,
|
||||||
EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->ahandle);
|
EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->ahandle);
|
||||||
|
|
||||||
transSendAsync(thrd->asyncPool, &(cliMsg->q));
|
transSendAsync(thrd->asyncPool, &(cliMsg->q));
|
||||||
tsem_t* pSem = pCtx->pSem;
|
tsem_t* pSem = pCtx->pSem;
|
||||||
|
|
|
@ -35,7 +35,6 @@ typedef struct SSrvConn {
|
||||||
uv_timer_t pTimer;
|
uv_timer_t pTimer;
|
||||||
|
|
||||||
queue queue;
|
queue queue;
|
||||||
int persist; // persist connection or not
|
|
||||||
SConnBuffer readBuf; // read buf,
|
SConnBuffer readBuf; // read buf,
|
||||||
int inType;
|
int inType;
|
||||||
void* pTransInst; // rpc init
|
void* pTransInst; // rpc init
|
||||||
|
@ -138,6 +137,7 @@ static void destroySmsg(SSrvMsg* smsg);
|
||||||
// check whether already read complete packet
|
// check whether already read complete packet
|
||||||
static SSrvConn* createConn(void* hThrd);
|
static SSrvConn* createConn(void* hThrd);
|
||||||
static void destroyConn(SSrvConn* conn, bool clear /*clear handle or not*/);
|
static void destroyConn(SSrvConn* conn, bool clear /*clear handle or not*/);
|
||||||
|
static int reallocConnRefHandle(SSrvConn* conn);
|
||||||
|
|
||||||
static void uvHandleQuit(SSrvMsg* msg, SWorkThrdObj* thrd);
|
static void uvHandleQuit(SSrvMsg* msg, SWorkThrdObj* thrd);
|
||||||
static void uvHandleRelease(SSrvMsg* msg, SWorkThrdObj* thrd);
|
static void uvHandleRelease(SSrvMsg* msg, SWorkThrdObj* thrd);
|
||||||
|
@ -180,6 +180,7 @@ static bool addHandleToAcceptloop(void* arg);
|
||||||
srvMsg->msg = tmsg; \
|
srvMsg->msg = tmsg; \
|
||||||
srvMsg->type = Release; \
|
srvMsg->type = Release; \
|
||||||
srvMsg->pConn = conn; \
|
srvMsg->pConn = conn; \
|
||||||
|
reallocConnRefHandle(conn); \
|
||||||
if (!transQueuePush(&conn->srvMsgs, srvMsg)) { \
|
if (!transQueuePush(&conn->srvMsgs, srvMsg)) { \
|
||||||
return; \
|
return; \
|
||||||
} \
|
} \
|
||||||
|
@ -360,10 +361,14 @@ void uvOnSendCb(uv_write_t* req, int status) {
|
||||||
tTrace("server conn %p data already was written on stream", conn);
|
tTrace("server conn %p data already was written on stream", conn);
|
||||||
if (!transQueueEmpty(&conn->srvMsgs)) {
|
if (!transQueueEmpty(&conn->srvMsgs)) {
|
||||||
SSrvMsg* msg = transQueuePop(&conn->srvMsgs);
|
SSrvMsg* msg = transQueuePop(&conn->srvMsgs);
|
||||||
if (msg->type == Release && conn->status != ConnNormal) {
|
// if (msg->type == Release && conn->status != ConnNormal) {
|
||||||
conn->status = ConnNormal;
|
// conn->status = ConnNormal;
|
||||||
transUnrefSrvHandle(conn);
|
// transUnrefSrvHandle(conn);
|
||||||
}
|
// reallocConnRefHandle(conn);
|
||||||
|
// destroySmsg(msg);
|
||||||
|
// transQueueClear(&conn->srvMsgs);
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
destroySmsg(msg);
|
destroySmsg(msg);
|
||||||
// send second data, just use for push
|
// send second data, just use for push
|
||||||
if (!transQueueEmpty(&conn->srvMsgs)) {
|
if (!transQueueEmpty(&conn->srvMsgs)) {
|
||||||
|
@ -421,8 +426,15 @@ static void uvPrepareSendData(SSrvMsg* smsg, uv_buf_t* wb) {
|
||||||
if (pConn->status == ConnNormal) {
|
if (pConn->status == ConnNormal) {
|
||||||
pHead->msgType = pConn->inType + 1;
|
pHead->msgType = pConn->inType + 1;
|
||||||
} else {
|
} else {
|
||||||
pHead->msgType = smsg->type == Release ? 0 : pMsg->msgType;
|
if (smsg->type == Release) {
|
||||||
|
pHead->msgType = 0;
|
||||||
|
pConn->status = ConnNormal;
|
||||||
|
transUnrefSrvHandle(pConn);
|
||||||
|
} else {
|
||||||
|
pHead->msgType = pMsg->msgType;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pHead->release = smsg->type == Release ? 1 : 0;
|
pHead->release = smsg->type == Release ? 1 : 0;
|
||||||
pHead->code = htonl(pMsg->code);
|
pHead->code = htonl(pMsg->code);
|
||||||
|
|
||||||
|
@ -517,7 +529,7 @@ void uvWorkerAsyncCb(uv_async_t* handle) {
|
||||||
int64_t refId = transMsg.refId;
|
int64_t refId = transMsg.refId;
|
||||||
SExHandle* exh2 = uvAcquireExHandle(refId);
|
SExHandle* exh2 = uvAcquireExHandle(refId);
|
||||||
if (exh2 == NULL || exh1 != exh2) {
|
if (exh2 == NULL || exh1 != exh2) {
|
||||||
tTrace("server handle %p except msg, ignore it", exh1);
|
tTrace("server handle except msg %p, ignore it", exh1);
|
||||||
uvReleaseExHandle(refId);
|
uvReleaseExHandle(refId);
|
||||||
destroySmsg(msg);
|
destroySmsg(msg);
|
||||||
continue;
|
continue;
|
||||||
|
@ -581,7 +593,8 @@ void uvOnAcceptCb(uv_stream_t* stream, int status) {
|
||||||
|
|
||||||
if (uv_accept(stream, (uv_stream_t*)cli) == 0) {
|
if (uv_accept(stream, (uv_stream_t*)cli) == 0) {
|
||||||
if (pObj->numOfWorkerReady < pObj->numOfThreads) {
|
if (pObj->numOfWorkerReady < pObj->numOfThreads) {
|
||||||
tError("worker-threads are not ready for all, need %d instead of %d.", pObj->numOfThreads, pObj->numOfWorkerReady);
|
tError("worker-threads are not ready for all, need %d instead of %d.", pObj->numOfThreads,
|
||||||
|
pObj->numOfWorkerReady);
|
||||||
uv_close((uv_handle_t*)cli, NULL);
|
uv_close((uv_handle_t*)cli, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -787,6 +800,19 @@ static void destroyConn(SSrvConn* conn, bool clear) {
|
||||||
// uv_shutdown(req, (uv_stream_t*)conn->pTcp, uvShutDownCb);
|
// uv_shutdown(req, (uv_stream_t*)conn->pTcp, uvShutDownCb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static int reallocConnRefHandle(SSrvConn* conn) {
|
||||||
|
uvReleaseExHandle(conn->refId);
|
||||||
|
uvRemoveExHandle(conn->refId);
|
||||||
|
// avoid app continue to send msg on invalid handle
|
||||||
|
SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle));
|
||||||
|
exh->handle = conn;
|
||||||
|
exh->pThrd = conn->hostThrd;
|
||||||
|
exh->refId = uvAddExHandle(exh);
|
||||||
|
uvAcquireExHandle(exh->refId);
|
||||||
|
conn->refId = exh->refId;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
static void uvDestroyConn(uv_handle_t* handle) {
|
static void uvDestroyConn(uv_handle_t* handle) {
|
||||||
SSrvConn* conn = handle->data;
|
SSrvConn* conn = handle->data;
|
||||||
if (conn == NULL) {
|
if (conn == NULL) {
|
||||||
|
@ -859,7 +885,8 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
||||||
snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%p-%lu", taosSafeRand(), GetCurrentProcessId());
|
snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%p-%lu", taosSafeRand(), GetCurrentProcessId());
|
||||||
#else
|
#else
|
||||||
char pipeName[PATH_MAX] = {0};
|
char pipeName[PATH_MAX] = {0};
|
||||||
snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08X-%lu", tsTempDir, TD_DIRSEP, taosSafeRand(), taosGetSelfPthreadId());
|
snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08X-%lu", tsTempDir, TD_DIRSEP, taosSafeRand(),
|
||||||
|
taosGetSelfPthreadId());
|
||||||
#endif
|
#endif
|
||||||
assert(0 == uv_pipe_bind(&srv->pipeListen, pipeName));
|
assert(0 == uv_pipe_bind(&srv->pipeListen, pipeName));
|
||||||
assert(0 == uv_listen((uv_stream_t*)&srv->pipeListen, SOMAXCONN, uvPipeListenCb));
|
assert(0 == uv_listen((uv_stream_t*)&srv->pipeListen, SOMAXCONN, uvPipeListenCb));
|
||||||
|
@ -959,6 +986,7 @@ void uvHandleQuit(SSrvMsg* msg, SWorkThrdObj* thrd) {
|
||||||
void uvHandleRelease(SSrvMsg* msg, SWorkThrdObj* thrd) {
|
void uvHandleRelease(SSrvMsg* msg, SWorkThrdObj* thrd) {
|
||||||
SSrvConn* conn = msg->pConn;
|
SSrvConn* conn = msg->pConn;
|
||||||
if (conn->status == ConnAcquire) {
|
if (conn->status == ConnAcquire) {
|
||||||
|
reallocConnRefHandle(conn);
|
||||||
if (!transQueuePush(&conn->srvMsgs, msg)) {
|
if (!transQueuePush(&conn->srvMsgs, msg)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ int64_t interlocked_add_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* interlocked_add_fetch_ptr(void* volatile* ptr, void* val) {
|
void* interlocked_add_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
return (void*)(_InterlockedExchangeAdd((int32_t volatile*)(ptr), (int32_t)val) + (int32_t)val);
|
return (void*)(_InterlockedExchangeAdd((int32_t volatile*)(ptr), (int32_t)val) + (int32_t)val);
|
||||||
#else
|
#else
|
||||||
return (void*)(InterlockedExchangeAdd64((int64_t volatile*)(ptr), (int64_t)val) + (int64_t)val);
|
return (void*)(InterlockedExchangeAdd64((int64_t volatile*)(ptr), (int64_t)val) + (int64_t)val);
|
||||||
|
@ -56,7 +56,7 @@ int32_t interlocked_and_fetch_32(int32_t volatile* ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t interlocked_and_fetch_64(int64_t volatile* ptr, int64_t val) {
|
int64_t interlocked_and_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
int64_t old, res;
|
int64_t old, res;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
|
@ -69,7 +69,7 @@ int64_t interlocked_and_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* interlocked_and_fetch_ptr(void* volatile* ptr, void* val) {
|
void* interlocked_and_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
return (void*)interlocked_and_fetch_32((int32_t volatile*)ptr, (int32_t)val);
|
return (void*)interlocked_and_fetch_32((int32_t volatile*)ptr, (int32_t)val);
|
||||||
#else
|
#else
|
||||||
return (void*)interlocked_and_fetch_64((int64_t volatile*)ptr, (int64_t)val);
|
return (void*)interlocked_and_fetch_64((int64_t volatile*)ptr, (int64_t)val);
|
||||||
|
@ -77,7 +77,7 @@ void* interlocked_and_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t interlocked_fetch_and_64(int64_t volatile* ptr, int64_t val) {
|
int64_t interlocked_fetch_and_64(int64_t volatile* ptr, int64_t val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
int64_t old;
|
int64_t old;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
|
@ -89,7 +89,7 @@ int64_t interlocked_fetch_and_64(int64_t volatile* ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* interlocked_fetch_and_ptr(void* volatile* ptr, void* val) {
|
void* interlocked_fetch_and_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
return (void*)_InterlockedAnd((int32_t volatile*)(ptr), (int32_t)(val));
|
return (void*)_InterlockedAnd((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#else
|
#else
|
||||||
return (void*)_InterlockedAnd64((int64_t volatile*)(ptr), (int64_t)(val));
|
return (void*)_InterlockedAnd64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
|
@ -109,7 +109,7 @@ int32_t interlocked_or_fetch_32(int32_t volatile* ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t interlocked_or_fetch_64(int64_t volatile* ptr, int64_t val) {
|
int64_t interlocked_or_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
int64_t old, res;
|
int64_t old, res;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
|
@ -122,7 +122,7 @@ int64_t interlocked_or_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* interlocked_or_fetch_ptr(void* volatile* ptr, void* val) {
|
void* interlocked_or_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
return (void*)interlocked_or_fetch_32((int32_t volatile*)ptr, (int32_t)val);
|
return (void*)interlocked_or_fetch_32((int32_t volatile*)ptr, (int32_t)val);
|
||||||
#else
|
#else
|
||||||
return (void*)interlocked_or_fetch_64((int64_t volatile*)ptr, (int64_t)val);
|
return (void*)interlocked_or_fetch_64((int64_t volatile*)ptr, (int64_t)val);
|
||||||
|
@ -130,7 +130,7 @@ void* interlocked_or_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t interlocked_fetch_or_64(int64_t volatile* ptr, int64_t val) {
|
int64_t interlocked_fetch_or_64(int64_t volatile* ptr, int64_t val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
int64_t old;
|
int64_t old;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
|
@ -142,7 +142,7 @@ int64_t interlocked_fetch_or_64(int64_t volatile* ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* interlocked_fetch_or_ptr(void* volatile* ptr, void* val) {
|
void* interlocked_fetch_or_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
return (void*)_InterlockedOr((int32_t volatile*)(ptr), (int32_t)(val));
|
return (void*)_InterlockedOr((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#else
|
#else
|
||||||
return (void*)interlocked_fetch_or_64((int64_t volatile*)(ptr), (int64_t)(val));
|
return (void*)interlocked_fetch_or_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
|
@ -162,7 +162,7 @@ int32_t interlocked_xor_fetch_32(int32_t volatile* ptr, int32_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t interlocked_xor_fetch_64(int64_t volatile* ptr, int64_t val) {
|
int64_t interlocked_xor_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
int64_t old, res;
|
int64_t old, res;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
|
@ -175,7 +175,7 @@ int64_t interlocked_xor_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* interlocked_xor_fetch_ptr(void* volatile* ptr, void* val) {
|
void* interlocked_xor_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
return (void*)interlocked_xor_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
return (void*)interlocked_xor_fetch_32((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#else
|
#else
|
||||||
return (void*)interlocked_xor_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
return (void*)interlocked_xor_fetch_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
|
@ -183,7 +183,7 @@ void* interlocked_xor_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t interlocked_fetch_xor_64(int64_t volatile* ptr, int64_t val) {
|
int64_t interlocked_fetch_xor_64(int64_t volatile* ptr, int64_t val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
int64_t old;
|
int64_t old;
|
||||||
do {
|
do {
|
||||||
old = *ptr;
|
old = *ptr;
|
||||||
|
@ -195,7 +195,7 @@ int64_t interlocked_fetch_xor_64(int64_t volatile* ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* interlocked_fetch_xor_ptr(void* volatile* ptr, void* val) {
|
void* interlocked_fetch_xor_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
return (void*)_InterlockedXor((int32_t volatile*)(ptr), (int32_t)(val));
|
return (void*)_InterlockedXor((int32_t volatile*)(ptr), (int32_t)(val));
|
||||||
#else
|
#else
|
||||||
return (void*)interlocked_fetch_xor_64((int64_t volatile*)(ptr), (int64_t)(val));
|
return (void*)interlocked_fetch_xor_64((int64_t volatile*)(ptr), (int64_t)(val));
|
||||||
|
@ -211,7 +211,7 @@ int64_t interlocked_sub_fetch_64(int64_t volatile* ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* interlocked_sub_fetch_ptr(void* volatile* ptr, void* val) {
|
void* interlocked_sub_fetch_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
return (void*)interlocked_sub_fetch_32((int32_t volatile*)ptr, (int32_t)val);
|
return (void*)interlocked_sub_fetch_32((int32_t volatile*)ptr, (int32_t)val);
|
||||||
#else
|
#else
|
||||||
return (void*)interlocked_add_fetch_64((int64_t volatile*)ptr, (int64_t)val);
|
return (void*)interlocked_add_fetch_64((int64_t volatile*)ptr, (int64_t)val);
|
||||||
|
@ -226,7 +226,7 @@ int64_t interlocked_fetch_sub_64(int64_t volatile* ptr, int64_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* interlocked_fetch_sub_ptr(void* volatile* ptr, void* val) {
|
void* interlocked_fetch_sub_ptr(void* volatile* ptr, void* val) {
|
||||||
#ifdef _TD_WINDOWS_32
|
#ifdef WINDOWS
|
||||||
return (void*)interlocked_fetch_sub_32((int32_t volatile*)ptr, (int32_t)val);
|
return (void*)interlocked_fetch_sub_32((int32_t volatile*)ptr, (int32_t)val);
|
||||||
#else
|
#else
|
||||||
return (void*)interlocked_fetch_sub_64((int64_t volatile*)ptr, (int64_t)val);
|
return (void*)interlocked_fetch_sub_64((int64_t volatile*)ptr, (int64_t)val);
|
||||||
|
|
|
@ -109,6 +109,7 @@ void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, cha
|
||||||
|
|
||||||
int64_t taosCopyFile(const char *from, const char *to) {
|
int64_t taosCopyFile(const char *from, const char *to) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
|
@ -152,16 +153,16 @@ int32_t taosRemoveFile(const char *path) { return remove(path); }
|
||||||
|
|
||||||
int32_t taosRenameFile(const char *oldName, const char *newName) {
|
int32_t taosRenameFile(const char *oldName, const char *newName) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
int32_t code = MoveFileEx(oldName, newName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED);
|
bool code = MoveFileEx(oldName, newName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED);
|
||||||
if (code < 0) {
|
if (!code) {
|
||||||
// printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
|
printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return !code;
|
||||||
#else
|
#else
|
||||||
int32_t code = rename(oldName, newName);
|
int32_t code = rename(oldName, newName);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
// printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
|
printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -169,11 +170,12 @@ int32_t taosRenameFile(const char *oldName, const char *newName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
|
int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
|
||||||
#ifdef WINDOWS
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
int32_t code = _stat(path, &fileStat);
|
||||||
|
#else
|
||||||
int32_t code = stat(path, &fileStat);
|
int32_t code = stat(path, &fileStat);
|
||||||
|
#endif
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -187,14 +189,15 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno) {
|
int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno) {
|
||||||
#ifdef WINDOWS
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
int32_t code = _stat(path, &fileStat);
|
||||||
|
#else
|
||||||
int32_t code = stat(path, &fileStat);
|
int32_t code = stat(path, &fileStat);
|
||||||
|
#endif
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +211,6 @@ int32_t taosDevInoFile(const char *path, int64_t *stDev, int64_t *stIno) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void autoDelFileListAdd(const char *path) { return; }
|
void autoDelFileListAdd(const char *path) { return; }
|
||||||
|
@ -276,9 +278,6 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosCloseFile(TdFilePtr *ppFile) {
|
int64_t taosCloseFile(TdFilePtr *ppFile) {
|
||||||
#ifdef WINDOWS
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
if (ppFile == NULL || *ppFile == NULL) {
|
if (ppFile == NULL || *ppFile == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +293,12 @@ int64_t taosCloseFile(TdFilePtr *ppFile) {
|
||||||
(*ppFile)->fp = NULL;
|
(*ppFile)->fp = NULL;
|
||||||
}
|
}
|
||||||
if ((*ppFile)->fd >= 0) {
|
if ((*ppFile)->fd >= 0) {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
HANDLE h = (HANDLE)_get_osfhandle((*ppFile)->fd);
|
||||||
|
!FlushFileBuffers(h);
|
||||||
|
#else
|
||||||
fsync((*ppFile)->fd);
|
fsync((*ppFile)->fd);
|
||||||
|
#endif
|
||||||
close((*ppFile)->fd);
|
close((*ppFile)->fd);
|
||||||
(*ppFile)->fd = -1;
|
(*ppFile)->fd = -1;
|
||||||
}
|
}
|
||||||
|
@ -306,7 +310,6 @@ int64_t taosCloseFile(TdFilePtr *ppFile) {
|
||||||
taosMemoryFree(*ppFile);
|
taosMemoryFree(*ppFile);
|
||||||
*ppFile = NULL;
|
*ppFile = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) {
|
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) {
|
||||||
|
@ -412,13 +415,17 @@ int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
||||||
#ifdef WINDOWS
|
if (pFile == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
}
|
||||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||||
|
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
int32_t code = _fstat(pFile->fd, &fileStat);
|
||||||
|
#else
|
||||||
int32_t code = fstat(pFile->fd, &fileStat);
|
int32_t code = fstat(pFile->fd, &fileStat);
|
||||||
|
#endif
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -432,7 +439,6 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosLockFile(TdFilePtr pFile) {
|
int32_t taosLockFile(TdFilePtr pFile) {
|
||||||
|
@ -459,7 +465,7 @@ int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
if (pFile->fd < 0) {
|
if (pFile->fd < 0) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
printf("%s\n", "fd arg was negative");
|
printf("Ftruncate file error, fd arg was negative\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,27 +522,21 @@ int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosFsyncFile(TdFilePtr pFile) {
|
int32_t taosFsyncFile(TdFilePtr pFile) {
|
||||||
#ifdef WINDOWS
|
|
||||||
if (pFile->fd < 0) {
|
|
||||||
errno = EBADF;
|
|
||||||
printf("%s\n", "fd arg was negative");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
HANDLE h = (HANDLE)_get_osfhandle(pFile->fd);
|
|
||||||
|
|
||||||
return !FlushFileBuffers(h);
|
|
||||||
#else
|
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFile->fp != NULL) return fflush(pFile->fp);
|
if (pFile->fp != NULL) return fflush(pFile->fp);
|
||||||
if (pFile->fd >= 0) return fsync(pFile->fd);
|
if (pFile->fd >= 0) {
|
||||||
|
#ifdef WINDOWS
|
||||||
return 0;
|
HANDLE h = (HANDLE)_get_osfhandle(pFile->fd);
|
||||||
|
return !FlushFileBuffers(h);
|
||||||
|
#else
|
||||||
|
return fsync(pFile->fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size) {
|
int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size) {
|
||||||
if (pFileOut == NULL || pFileIn == NULL) {
|
if (pFileOut == NULL || pFileIn == NULL) {
|
||||||
|
|
|
@ -138,7 +138,7 @@ static void print_line(Dwarf_Debug dbg, Dwarf_Line line, Dwarf_Addr pc) {
|
||||||
dwarf_linesrc(line, &linesrc, NULL);
|
dwarf_linesrc(line, &linesrc, NULL);
|
||||||
dwarf_lineno(line, &lineno, NULL);
|
dwarf_lineno(line, &lineno, NULL);
|
||||||
}
|
}
|
||||||
printf("%s:%" DW_PR_DUu "\n", linesrc, lineno);
|
printf("BackTrace %08" PRId64 " %s:%" DW_PR_DUu "\n", taosGetSelfPthreadId(), linesrc, lineno);
|
||||||
if (line) dwarf_dealloc(dbg, linesrc, DW_DLA_STRING);
|
if (line) dwarf_dealloc(dbg, linesrc, DW_DLA_STRING);
|
||||||
}
|
}
|
||||||
void taosPrintBackTrace() {
|
void taosPrintBackTrace() {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
int32_t taosNewProc(char **args) {
|
int32_t taosNewProc(char **args) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
int32_t pid = fork();
|
int32_t pid = fork();
|
||||||
|
@ -36,6 +37,7 @@ int32_t taosNewProc(char **args) {
|
||||||
|
|
||||||
void taosWaitProc(int32_t pid) {
|
void taosWaitProc(int32_t pid) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
int32_t status = -1;
|
int32_t status = -1;
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
|
@ -44,6 +46,7 @@ void taosWaitProc(int32_t pid) {
|
||||||
|
|
||||||
void taosKillProc(int32_t pid) {
|
void taosKillProc(int32_t pid) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
kill(pid, SIGINT);
|
kill(pid, SIGINT);
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,6 +54,7 @@ void taosKillProc(int32_t pid) {
|
||||||
|
|
||||||
bool taosProcExist(int32_t pid) {
|
bool taosProcExist(int32_t pid) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
int32_t p = getpgid(pid);
|
int32_t p = getpgid(pid);
|
||||||
|
|
|
@ -23,6 +23,7 @@ static int32_t shmids[MAX_SHMIDS] = {0};
|
||||||
|
|
||||||
static void taosDeleteCreatedShms() {
|
static void taosDeleteCreatedShms() {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
for (int32_t i = 0; i < MAX_SHMIDS; ++i) {
|
for (int32_t i = 0; i < MAX_SHMIDS; ++i) {
|
||||||
int32_t shmid = shmids[i] - 1;
|
int32_t shmid = shmids[i] - 1;
|
||||||
|
@ -35,6 +36,7 @@ static void taosDeleteCreatedShms() {
|
||||||
|
|
||||||
int32_t taosCreateShm(SShm* pShm, int32_t key, int32_t shmsize) {
|
int32_t taosCreateShm(SShm* pShm, int32_t key, int32_t shmsize) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
pShm->id = -1;
|
pShm->id = -1;
|
||||||
|
|
||||||
|
@ -75,6 +77,7 @@ int32_t taosCreateShm(SShm* pShm, int32_t key, int32_t shmsize) {
|
||||||
|
|
||||||
void taosDropShm(SShm* pShm) {
|
void taosDropShm(SShm* pShm) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
if (pShm->id >= 0) {
|
if (pShm->id >= 0) {
|
||||||
if (pShm->ptr != NULL) {
|
if (pShm->ptr != NULL) {
|
||||||
|
@ -90,6 +93,7 @@ void taosDropShm(SShm* pShm) {
|
||||||
|
|
||||||
int32_t taosAttachShm(SShm* pShm) {
|
int32_t taosAttachShm(SShm* pShm) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,7 @@ int32_t taosGetSockOpt(TdSocketPtr pSocket, int32_t level, int32_t optname, void
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
return getsockopt(pSocket->fd, level, optname, optval, (int *)optlen);
|
return getsockopt(pSocket->fd, level, optname, optval, (int *)optlen);
|
||||||
|
@ -642,6 +643,7 @@ int32_t taosKeepTcpAlive(TdSocketPtr pSocket) {
|
||||||
int taosGetLocalIp(const char *eth, char *ip) {
|
int taosGetLocalIp(const char *eth, char *ip) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
// DO NOTHAING
|
// DO NOTHAING
|
||||||
|
assert(0);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -668,6 +670,7 @@ int taosGetLocalIp(const char *eth, char *ip) {
|
||||||
int taosValidIp(uint32_t ip) {
|
int taosValidIp(uint32_t ip) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
// DO NOTHAING
|
// DO NOTHAING
|
||||||
|
assert(0);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
@ -866,6 +869,7 @@ int64_t taosCopyFds(TdSocketPtr pSrcSocket, TdSocketPtr pDestSocket, int64_t len
|
||||||
|
|
||||||
void taosBlockSIGPIPE() {
|
void taosBlockSIGPIPE() {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
// assert(0);
|
||||||
#else
|
#else
|
||||||
sigset_t signal_mask;
|
sigset_t signal_mask;
|
||||||
sigemptyset(&signal_mask);
|
sigemptyset(&signal_mask);
|
||||||
|
@ -976,14 +980,12 @@ void tinet_ntoa(char *ipstr, uint32_t ip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosIgnSIGPIPE() {
|
void taosIgnSIGPIPE() {
|
||||||
#ifdef WINDOWS
|
|
||||||
#else
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosSetMaskSIGPIPE() {
|
void taosSetMaskSIGPIPE() {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
// assert(0);
|
||||||
#else
|
#else
|
||||||
sigset_t signal_mask;
|
sigset_t signal_mask;
|
||||||
sigemptyset(&signal_mask);
|
sigemptyset(&signal_mask);
|
||||||
|
@ -1005,6 +1007,7 @@ int32_t taosGetSocketName(TdSocketPtr pSocket, struct sockaddr *destAddr, int *a
|
||||||
TdEpollPtr taosCreateEpoll(int32_t size) {
|
TdEpollPtr taosCreateEpoll(int32_t size) {
|
||||||
EpollFd fd = -1;
|
EpollFd fd = -1;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
fd = epoll_create(size);
|
fd = epoll_create(size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1027,6 +1030,7 @@ int32_t taosCtlEpoll(TdEpollPtr pEpoll, int32_t epollOperate, TdSocketPtr pSocke
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
code = epoll_ctl(pEpoll->fd, epollOperate, pSocket->fd, event);
|
code = epoll_ctl(pEpoll->fd, epollOperate, pSocket->fd, event);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1038,6 +1042,7 @@ int32_t taosWaitEpoll(TdEpollPtr pEpoll, struct epoll_event *event, int32_t maxE
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
code = epoll_wait(pEpoll->fd, event, maxEvents, timeout);
|
code = epoll_wait(pEpoll->fd, event, maxEvents, timeout);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -129,7 +129,21 @@ static void taosGetProcIOnfos() {
|
||||||
|
|
||||||
static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
|
static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
FILETIME pre_idleTime = {0};
|
||||||
|
FILETIME pre_kernelTime = {0};
|
||||||
|
FILETIME pre_userTime = {0};
|
||||||
|
FILETIME idleTime;
|
||||||
|
FILETIME kernelTime;
|
||||||
|
FILETIME userTime;
|
||||||
|
bool res = GetSystemTimes(&idleTime, &kernelTime, &userTime);
|
||||||
|
if (res) {
|
||||||
|
cpuInfo->idle = CompareFileTime(&pre_idleTime, &idleTime);
|
||||||
|
cpuInfo->system = CompareFileTime(&pre_kernelTime, &kernelTime);
|
||||||
|
cpuInfo->user = CompareFileTime(&pre_userTime, &userTime);
|
||||||
|
cpuInfo->nice = 0;
|
||||||
|
}
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
TdFilePtr pFile = taosOpenFile(tsSysCpuFile, TD_FILE_READ | TD_FILE_STREAM);
|
TdFilePtr pFile = taosOpenFile(tsSysCpuFile, TD_FILE_READ | TD_FILE_STREAM);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
|
@ -155,7 +169,18 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
|
||||||
|
|
||||||
static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
|
static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
FILETIME pre_krnlTm = {0};
|
||||||
|
FILETIME pre_usrTm = {0};
|
||||||
|
FILETIME creatTm, exitTm, krnlTm, usrTm;
|
||||||
|
|
||||||
|
if (GetThreadTimes(GetCurrentThread(), &creatTm, &exitTm, &krnlTm, &usrTm)) {
|
||||||
|
cpuInfo->stime = CompareFileTime(&pre_krnlTm, &krnlTm);
|
||||||
|
cpuInfo->utime = CompareFileTime(&pre_usrTm, &usrTm);
|
||||||
|
cpuInfo->cutime = 0;
|
||||||
|
cpuInfo->cstime = 0;
|
||||||
|
}
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
|
assert(0);
|
||||||
#else
|
#else
|
||||||
TdFilePtr pFile = taosOpenFile(tsProcCpuFile, TD_FILE_READ | TD_FILE_STREAM);
|
TdFilePtr pFile = taosOpenFile(tsProcCpuFile, TD_FILE_READ | TD_FILE_STREAM);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
|
@ -219,6 +244,7 @@ void taosGetSystemInfo() {
|
||||||
|
|
||||||
int32_t taosGetEmail(char *email, int32_t maxLen) {
|
int32_t taosGetEmail(char *email, int32_t maxLen) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
// assert(0);
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
const char *filepath = "/usr/local/taos/email";
|
const char *filepath = "/usr/local/taos/email";
|
||||||
|
|
||||||
|
@ -250,6 +276,7 @@ int32_t taosGetEmail(char *email, int32_t maxLen) {
|
||||||
|
|
||||||
int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
|
int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
@ -305,6 +332,7 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) {
|
||||||
|
|
||||||
int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
|
int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
@ -716,9 +744,7 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
GUID guid;
|
GUID guid;
|
||||||
CoCreateGuid(&guid);
|
CoCreateGuid(&guid);
|
||||||
|
memcpy(uid, &guid, uidlen);
|
||||||
sprintf(uid, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0],
|
|
||||||
guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
|
@ -750,6 +776,7 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
|
||||||
|
|
||||||
char *taosGetCmdlineByPID(int pid) {
|
char *taosGetCmdlineByPID(int pid) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
assert(0);
|
||||||
return "";
|
return "";
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
static char cmdline[1024];
|
static char cmdline[1024];
|
||||||
|
|
|
@ -33,6 +33,7 @@ typedef struct FILE TdCmd;
|
||||||
|
|
||||||
void* taosLoadDll(const char* filename) {
|
void* taosLoadDll(const char* filename) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
assert(0);
|
||||||
return NULL;
|
return NULL;
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -51,6 +52,7 @@ void* taosLoadDll(const char* filename) {
|
||||||
|
|
||||||
void* taosLoadSym(void* handle, char* name) {
|
void* taosLoadSym(void* handle, char* name) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
assert(0);
|
||||||
return NULL;
|
return NULL;
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -71,6 +73,7 @@ void* taosLoadSym(void* handle, char* name) {
|
||||||
|
|
||||||
void taosCloseDll(void* handle) {
|
void taosCloseDll(void* handle) {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
assert(0);
|
||||||
return;
|
return;
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
return;
|
return;
|
||||||
|
@ -121,6 +124,7 @@ int taosSetConsoleEcho(bool on) {
|
||||||
|
|
||||||
void taosSetTerminalMode() {
|
void taosSetTerminalMode() {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
// assert(0);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
struct termios newtio;
|
struct termios newtio;
|
||||||
|
@ -154,7 +158,7 @@ void taosSetTerminalMode() {
|
||||||
|
|
||||||
int32_t taosGetOldTerminalMode() {
|
int32_t taosGetOldTerminalMode() {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
// assert(0);
|
||||||
#else
|
#else
|
||||||
/* Make sure stdin is a terminal. */
|
/* Make sure stdin is a terminal. */
|
||||||
if (!isatty(STDIN_FILENO)) {
|
if (!isatty(STDIN_FILENO)) {
|
||||||
|
@ -172,7 +176,7 @@ int32_t taosGetOldTerminalMode() {
|
||||||
|
|
||||||
void taosResetTerminalMode() {
|
void taosResetTerminalMode() {
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
// assert(0);
|
||||||
#else
|
#else
|
||||||
if (tcsetattr(0, TCSANOW, &oldtio) != 0) {
|
if (tcsetattr(0, TCSANOW, &oldtio) != 0) {
|
||||||
fprintf(stderr, "Fail to reset the terminal properties!\n");
|
fprintf(stderr, "Fail to reset the terminal properties!\n");
|
||||||
|
|
|
@ -640,13 +640,14 @@ int32_t cfgLoadFromEnvVar(SConfig *pConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) {
|
int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) {
|
||||||
char *buf, *name, *value, *value2, *value3;
|
char buf[1024], *name, *value, *value2, *value3;
|
||||||
int32_t olen, vlen, vlen2, vlen3;
|
int32_t olen, vlen, vlen2, vlen3;
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
if (envCmd == NULL) return 0;
|
if (envCmd == NULL) return 0;
|
||||||
while (envCmd[index]!=NULL) {
|
while (envCmd[index]!=NULL) {
|
||||||
buf = taosMemoryMalloc(strlen(envCmd[index]));
|
strncpy(buf, envCmd[index], sizeof(buf)-1);
|
||||||
taosEnvToCfg(envCmd[index], buf);
|
buf[sizeof(buf)-1] = 0;
|
||||||
|
taosEnvToCfg(buf, buf);
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
name = value = value2 = value3 = NULL;
|
name = value = value2 = value3 = NULL;
|
||||||
|
@ -671,8 +672,6 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) {
|
||||||
if (value2 != NULL && value3 != NULL && value2[0] != 0 && value3[0] != 0 && strcasecmp(name, "dataDir") == 0) {
|
if (value2 != NULL && value3 != NULL && value2[0] != 0 && value3[0] != 0 && strcasecmp(name, "dataDir") == 0) {
|
||||||
cfgSetTfsItem(pConfig, name, value, value2, value3, CFG_STYPE_ENV_CMD);
|
cfgSetTfsItem(pConfig, name, value, value2, value3, CFG_STYPE_ENV_CMD);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uInfo("load from env cmd cfg success");
|
uInfo("load from env cmd cfg success");
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
case_file=/tmp/cases.task
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo "$0"
|
||||||
|
echo -e "\t -o output case file"
|
||||||
|
echo -e "\t -e enterprise edition"
|
||||||
|
echo -e "\t -h help"
|
||||||
|
}
|
||||||
|
|
||||||
|
ent=0
|
||||||
|
while getopts "o:eh" opt; do
|
||||||
|
case $opt in
|
||||||
|
o)
|
||||||
|
case_file=$OPTARG
|
||||||
|
;;
|
||||||
|
e)
|
||||||
|
ent=1
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG"
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
script_dir=`dirname $0`
|
||||||
|
cd $script_dir
|
||||||
|
|
||||||
|
if [ $ent -eq 0 ]; then
|
||||||
|
echo ",,unit-test,bash test.sh" >$case_file
|
||||||
|
else
|
||||||
|
echo ",,unit-test,bash test.sh -e" >$case_file
|
||||||
|
fi
|
||||||
|
cat ../script/jenkins/basic.txt |grep -v "^#"|grep -v "^$"|sed "s/^/,,script,/" >>$case_file
|
||||||
|
grep "^python" ../system-test/fulltest.sh |sed "s/^/,,system-test,/" >>$case_file
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo "$0"
|
||||||
|
echo -e "\t -w work dir"
|
||||||
|
echo -e "\t -e enterprise edition"
|
||||||
|
echo -e "\t -t make thread count"
|
||||||
|
echo -e "\t -h help"
|
||||||
|
}
|
||||||
|
|
||||||
|
ent=0
|
||||||
|
while getopts "w:t:eh" opt; do
|
||||||
|
case $opt in
|
||||||
|
w)
|
||||||
|
WORKDIR=$OPTARG
|
||||||
|
;;
|
||||||
|
e)
|
||||||
|
ent=1
|
||||||
|
;;
|
||||||
|
t)
|
||||||
|
THREAD_COUNT=$OPTARG
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG"
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$WORKDIR" ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "$THREAD_COUNT" ]; then
|
||||||
|
THREAD_COUNT=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ulimit -c unlimited
|
||||||
|
|
||||||
|
if [ $ent -eq 0 ]; then
|
||||||
|
REP_DIR=/home/TDengine
|
||||||
|
REP_MOUNT_PARAM=$WORKDIR/TDengine:/home/TDengine
|
||||||
|
else
|
||||||
|
REP_DIR=/home/TDinternal
|
||||||
|
REP_MOUNT_PARAM=$WORKDIR/TDinternal:/home/TDinternal
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run \
|
||||||
|
-v $REP_MOUNT_PARAM \
|
||||||
|
--rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_TOOLS=true;make -j $THREAD_COUNT"
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
exit $ret
|
||||||
|
|
|
@ -0,0 +1,357 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo "$0"
|
||||||
|
echo -e "\t -m vm config file"
|
||||||
|
echo -e "\t -t task file"
|
||||||
|
echo -e "\t -b branch"
|
||||||
|
echo -e "\t -l log dir"
|
||||||
|
echo -e "\t -e enterprise edition"
|
||||||
|
echo -e "\t -o default timeout value"
|
||||||
|
echo -e "\t -h help"
|
||||||
|
}
|
||||||
|
|
||||||
|
ent=0
|
||||||
|
while getopts "m:t:b:l:o:eh" opt; do
|
||||||
|
case $opt in
|
||||||
|
m)
|
||||||
|
config_file=$OPTARG
|
||||||
|
;;
|
||||||
|
t)
|
||||||
|
t_file=$OPTARG
|
||||||
|
;;
|
||||||
|
b)
|
||||||
|
branch=$OPTARG
|
||||||
|
;;
|
||||||
|
l)
|
||||||
|
log_dir=$OPTARG
|
||||||
|
;;
|
||||||
|
e)
|
||||||
|
ent=1
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
timeout_param="-o $OPTARG"
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG"
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
#config_file=$1
|
||||||
|
if [ -z $config_file ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! -f $config_file ]; then
|
||||||
|
echo "$config_file not found"
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
#t_file=$2
|
||||||
|
if [ -z $t_file ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! -f $t_file ]; then
|
||||||
|
echo "$t_file not found"
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
date_tag=`date +%Y%m%d-%H%M%S`
|
||||||
|
if [ -z $log_dir ]; then
|
||||||
|
log_dir="log/${branch}_${date_tag}"
|
||||||
|
else
|
||||||
|
log_dir="$log_dir/${branch}_${date_tag}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
hosts=()
|
||||||
|
usernames=()
|
||||||
|
passwords=()
|
||||||
|
workdirs=()
|
||||||
|
threads=()
|
||||||
|
|
||||||
|
i=0
|
||||||
|
while [ 1 ]; do
|
||||||
|
host=`jq .[$i].host $config_file`
|
||||||
|
if [ "$host" = "null" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
username=`jq .[$i].username $config_file`
|
||||||
|
if [ "$username" = "null" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
password=`jq .[$i].password $config_file`
|
||||||
|
if [ "$password" = "null" ]; then
|
||||||
|
password=""
|
||||||
|
fi
|
||||||
|
workdir=`jq .[$i].workdir $config_file`
|
||||||
|
if [ "$workdir" = "null" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
thread=`jq .[$i].thread $config_file`
|
||||||
|
if [ "$thread" = "null" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
hosts[i]=`echo $host|sed 's/\"$//'|sed 's/^\"//'`
|
||||||
|
usernames[i]=`echo $username|sed 's/\"$//'|sed 's/^\"//'`
|
||||||
|
passwords[i]=`echo $password|sed 's/\"$//'|sed 's/^\"//'`
|
||||||
|
workdirs[i]=`echo $workdir|sed 's/\"$//'|sed 's/^\"//'`
|
||||||
|
threads[i]=$thread
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
function prepare_cases() {
|
||||||
|
cat $t_file >>$task_file
|
||||||
|
local i=0
|
||||||
|
while [ $i -lt $1 ]; do
|
||||||
|
echo "%%FINISHED%%" >>$task_file
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean_tmp() {
|
||||||
|
# clean tmp dir
|
||||||
|
local index=$1
|
||||||
|
local ssh_script="sshpass -p ${passwords[index]} ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}"
|
||||||
|
if [ -z ${passwords[index]} ]; then
|
||||||
|
ssh_script="ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}"
|
||||||
|
fi
|
||||||
|
local cmd="${ssh_script} rm -rf ${workdirs[index]}/tmp"
|
||||||
|
${cmd}
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_thread() {
|
||||||
|
local index=$1
|
||||||
|
local thread_no=$2
|
||||||
|
local runcase_script="sshpass -p ${passwords[index]} ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}"
|
||||||
|
if [ -z ${passwords[index]} ]; then
|
||||||
|
runcase_script="ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}"
|
||||||
|
fi
|
||||||
|
local count=0
|
||||||
|
local script="${workdirs[index]}/TDengine/tests/parallel_test/run_container.sh"
|
||||||
|
if [ $ent -ne 0 ]; then
|
||||||
|
local script="${workdirs[index]}/TDinternal/community/tests/parallel_test/run_container.sh -e"
|
||||||
|
fi
|
||||||
|
local cmd="${runcase_script} ${script}"
|
||||||
|
|
||||||
|
# script="echo"
|
||||||
|
while [ 1 ]; do
|
||||||
|
local line=`flock -x $lock_file -c "head -n1 $task_file;sed -i \"1d\" $task_file"`
|
||||||
|
if [ "x$line" = "x%%FINISHED%%" ]; then
|
||||||
|
# echo "$index . $thread_no EXIT"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ -z "$line" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "$line"|grep -q "^#"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
local case_redo_time=`echo "$line"|cut -d, -f2`
|
||||||
|
if [ -z "$case_redo_time" ]; then
|
||||||
|
case_redo_time=${DEFAULT_RETRY_TIME:-2}
|
||||||
|
fi
|
||||||
|
local exec_dir=`echo "$line"|cut -d, -f3`
|
||||||
|
local case_cmd=`echo "$line"|cut -d, -f4`
|
||||||
|
local case_file=""
|
||||||
|
echo "$case_cmd"|grep -q "\.sh"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
case_file=`echo "$case_cmd"|grep -o ".*\.sh"|awk '{print $NF}'`
|
||||||
|
fi
|
||||||
|
echo "$case_cmd"|grep -q "^python3"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
case_file=`echo "$case_cmd"|grep -o ".*\.py"|awk '{print $NF}'`
|
||||||
|
fi
|
||||||
|
echo "$case_cmd"|grep -q "\.sim"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
case_file=`echo "$case_cmd"|grep -o ".*\.sim"|awk '{print $NF}'`
|
||||||
|
fi
|
||||||
|
if [ -z "$case_file" ]; then
|
||||||
|
case_file=`echo "$case_cmd"|awk '{print $NF}'`
|
||||||
|
fi
|
||||||
|
if [ -z "$case_file" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
case_file="$exec_dir/${case_file}.${index}.${thread_no}.${count}"
|
||||||
|
count=$(( count + 1 ))
|
||||||
|
local case_path=`dirname "$case_file"`
|
||||||
|
if [ ! -z "$case_path" ]; then
|
||||||
|
mkdir -p $log_dir/$case_path
|
||||||
|
fi
|
||||||
|
cmd="${runcase_script} ${script} -w ${workdirs[index]} -c \"${case_cmd}\" -t ${thread_no} -d ${exec_dir} ${timeout_param}"
|
||||||
|
# echo "$thread_no $count $cmd"
|
||||||
|
local ret=0
|
||||||
|
local redo_count=1
|
||||||
|
start_time=`date +%s`
|
||||||
|
while [ ${redo_count} -lt 6 ]; do
|
||||||
|
if [ -f $log_dir/$case_file.log ]; then
|
||||||
|
cp $log_dir/$case_file.log $log_dir/$case_file.${redo_count}.redolog
|
||||||
|
fi
|
||||||
|
echo "${hosts[index]}-${thread_no} order:${count}, redo:${redo_count} task:${line}" >$log_dir/$case_file.log
|
||||||
|
echo -e "\e[33m >>>>> \e[0m ${case_cmd}"
|
||||||
|
date >>$log_dir/$case_file.log
|
||||||
|
# $cmd 2>&1 | tee -a $log_dir/$case_file.log
|
||||||
|
# ret=${PIPESTATUS[0]}
|
||||||
|
$cmd >>$log_dir/$case_file.log 2>&1
|
||||||
|
ret=$?
|
||||||
|
echo "${hosts[index]} `date` ret:${ret}" >>$log_dir/$case_file.log
|
||||||
|
if [ $ret -eq 0 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
redo=0
|
||||||
|
grep -q "wait too long for taosd start" $log_dir/$case_file.log
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
redo=1
|
||||||
|
fi
|
||||||
|
grep -q "kex_exchange_identification: Connection closed by remote host" $log_dir/$case_file.log
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
redo=1
|
||||||
|
fi
|
||||||
|
grep -q "ssh_exchange_identification: Connection closed by remote host" $log_dir/$case_file.log
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
redo=1
|
||||||
|
fi
|
||||||
|
grep -q "kex_exchange_identification: read: Connection reset by peer" $log_dir/$case_file.log
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
redo=1
|
||||||
|
fi
|
||||||
|
grep -q "Database not ready" $log_dir/$case_file.log
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
redo=1
|
||||||
|
fi
|
||||||
|
grep -q "Unable to establish connection" $log_dir/$case_file.log
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
redo=1
|
||||||
|
fi
|
||||||
|
if [ $redo_count -lt $case_redo_time ]; then
|
||||||
|
redo=1
|
||||||
|
fi
|
||||||
|
if [ $redo -eq 0 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
redo_count=$(( redo_count + 1 ))
|
||||||
|
done
|
||||||
|
end_time=`date +%s`
|
||||||
|
echo >>$log_dir/$case_file.log
|
||||||
|
echo "${hosts[index]} execute time: $(( end_time - start_time ))s" >>$log_dir/$case_file.log
|
||||||
|
# echo "$thread_no ${line} DONE"
|
||||||
|
if [ $ret -ne 0 ]; then
|
||||||
|
flock -x $lock_file -c "echo \"${hosts[index]} ret:${ret} ${line}\" >>$log_dir/failed.log"
|
||||||
|
mkdir -p $log_dir/${case_file}.coredump
|
||||||
|
local remote_coredump_dir="${workdirs[index]}/tmp/thread_volume/$thread_no/coredump"
|
||||||
|
local scpcmd="sshpass -p ${passwords[index]} scp -o StrictHostKeyChecking=no -r ${usernames[index]}@${hosts[index]}"
|
||||||
|
if [ -z ${passwords[index]} ]; then
|
||||||
|
scpcmd="scp -o StrictHostKeyChecking=no -r ${usernames[index]}@${hosts[index]}"
|
||||||
|
fi
|
||||||
|
cmd="$scpcmd:${remote_coredump_dir}/* $log_dir/${case_file}.coredump/"
|
||||||
|
$cmd # 2>/dev/null
|
||||||
|
local case_info=`echo "$line"|cut -d, -f 3,4`
|
||||||
|
local corefile=`ls $log_dir/${case_file}.coredump/`
|
||||||
|
corefile=`find $log_dir/${case_file}.coredump/ -name "core.*"`
|
||||||
|
echo -e "$case_info \e[31m failed\e[0m"
|
||||||
|
echo "=========================log============================"
|
||||||
|
cat $log_dir/$case_file.log
|
||||||
|
echo "====================================================="
|
||||||
|
echo -e "\e[34m log file: $log_dir/$case_file.log \e[0m"
|
||||||
|
if [ ! -z "$corefile" ]; then
|
||||||
|
echo -e "\e[34m corefiles: $corefile \e[0m"
|
||||||
|
local build_dir=$log_dir/build_${hosts[index]}
|
||||||
|
local remote_build_dir="${workdirs[index]}/TDengine/debug/build"
|
||||||
|
if [ $ent -ne 0 ]; then
|
||||||
|
remote_build_dir="${workdirs[index]}/TDinternal/debug/build"
|
||||||
|
fi
|
||||||
|
mkdir $build_dir 2>/dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
# scp build binary
|
||||||
|
cmd="$scpcmd:${remote_build_dir}/* ${build_dir}/"
|
||||||
|
echo "$cmd"
|
||||||
|
$cmd >/dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# get remote sim dir
|
||||||
|
local remote_sim_dir="${workdirs[index]}/tmp/thread_volume/$thread_no"
|
||||||
|
local tarcmd="sshpass -p ${passwords[index]} ssh -o StrictHostKeyChecking=no -r ${usernames[index]}@${hosts[index]}"
|
||||||
|
if [ -z ${passwords[index]} ]; then
|
||||||
|
tarcmd="ssh -o StrictHostKeyChecking=no ${usernames[index]}@${hosts[index]}"
|
||||||
|
fi
|
||||||
|
cmd="$tarcmd sh -c \"cd $remote_sim_dir; tar -czf sim.tar.gz sim\""
|
||||||
|
$cmd
|
||||||
|
local remote_sim_tar="${workdirs[index]}/tmp/thread_volume/$thread_no/sim.tar.gz"
|
||||||
|
scpcmd="sshpass -p ${passwords[index]} scp -o StrictHostKeyChecking=no -r ${usernames[index]}@${hosts[index]}"
|
||||||
|
if [ -z ${passwords[index]} ]; then
|
||||||
|
scpcmd="scp -o StrictHostKeyChecking=no -r ${usernames[index]}@${hosts[index]}"
|
||||||
|
fi
|
||||||
|
cmd="$scpcmd:${remote_sim_tar} $log_dir/${case_file}.sim.tar.gz"
|
||||||
|
$cmd
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# echo "hosts: ${hosts[@]}"
|
||||||
|
# echo "usernames: ${usernames[@]}"
|
||||||
|
# echo "passwords: ${passwords[@]}"
|
||||||
|
# echo "workdirs: ${workdirs[@]}"
|
||||||
|
# echo "threads: ${threads[@]}"
|
||||||
|
# TODO: check host accessibility
|
||||||
|
|
||||||
|
i=0
|
||||||
|
while [ $i -lt ${#hosts[*]} ]; do
|
||||||
|
clean_tmp $i &
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done
|
||||||
|
wait
|
||||||
|
|
||||||
|
mkdir -p $log_dir
|
||||||
|
rm -rf $log_dir/*
|
||||||
|
task_file=$log_dir/$$.task
|
||||||
|
lock_file=$log_dir/$$.lock
|
||||||
|
|
||||||
|
i=0
|
||||||
|
j=0
|
||||||
|
while [ $i -lt ${#hosts[*]} ]; do
|
||||||
|
j=$(( j + threads[i] ))
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done
|
||||||
|
prepare_cases $j
|
||||||
|
|
||||||
|
i=0
|
||||||
|
while [ $i -lt ${#hosts[*]} ]; do
|
||||||
|
j=0
|
||||||
|
while [ $j -lt ${threads[i]} ]; do
|
||||||
|
run_thread $i $j &
|
||||||
|
j=$(( j + 1 ))
|
||||||
|
done
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
rm -f $lock_file
|
||||||
|
rm -f $task_file
|
||||||
|
|
||||||
|
# docker ps -a|grep -v CONTAINER|awk '{print $1}'|xargs docker rm -f
|
||||||
|
RET=0
|
||||||
|
i=1
|
||||||
|
if [ -f "$log_dir/failed.log" ]; then
|
||||||
|
echo "====================================================="
|
||||||
|
while read line; do
|
||||||
|
line=`echo "$line"|cut -d, -f 3,4`
|
||||||
|
echo -e "$i. $line \e[31m failed\e[0m" >&2
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done <$log_dir/failed.log
|
||||||
|
RET=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${log_dir}" >&2
|
||||||
|
|
||||||
|
date
|
||||||
|
|
||||||
|
exit $RET
|
|
@ -0,0 +1,74 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo "$0"
|
||||||
|
echo -e "\t -d execution dir"
|
||||||
|
echo -e "\t -c command"
|
||||||
|
echo -e "\t -e enterprise edition"
|
||||||
|
echo -e "\t -o default timeout value"
|
||||||
|
echo -e "\t -h help"
|
||||||
|
}
|
||||||
|
|
||||||
|
ent=0
|
||||||
|
while getopts "d:c:o:eh" opt; do
|
||||||
|
case $opt in
|
||||||
|
d)
|
||||||
|
exec_dir=$OPTARG
|
||||||
|
;;
|
||||||
|
c)
|
||||||
|
cmd=$OPTARG
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
TIMEOUT_CMD="timeout $OPTARG"
|
||||||
|
;;
|
||||||
|
e)
|
||||||
|
ent=1
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG"
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$exec_dir" ]; then
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [ -z "$cmd" ]; then
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $ent -eq 0 ]; then
|
||||||
|
export PATH=$PATH:/home/TDengine/debug/build/bin
|
||||||
|
export LD_LIBRARY_PATH=/home/TDengine/debug/build/lib
|
||||||
|
ln -s /home/TDengine/debug/build/lib/libtaos.so /usr/lib/libtaos.so 2>/dev/null
|
||||||
|
CONTAINER_TESTDIR=/home/TDengine
|
||||||
|
else
|
||||||
|
export PATH=$PATH:/home/TDinternal/debug/build/bin
|
||||||
|
export LD_LIBRARY_PATH=/home/TDinternal/debug/build/lib
|
||||||
|
ln -s /home/TDinternal/debug/build/lib/libtaos.so /usr/lib/libtaos.so 2>/dev/null
|
||||||
|
CONTAINER_TESTDIR=/home/TDinternal/community
|
||||||
|
fi
|
||||||
|
mkdir -p /var/lib/taos/subscribe
|
||||||
|
mkdir -p /var/log/taos
|
||||||
|
mkdir -p /var/lib/taos
|
||||||
|
|
||||||
|
cd $CONTAINER_TESTDIR/tests/$exec_dir
|
||||||
|
ulimit -c unlimited
|
||||||
|
|
||||||
|
$TIMEOUT_CMD $cmd
|
||||||
|
RET=$?
|
||||||
|
|
||||||
|
if [ $RET -ne 0 ]; then
|
||||||
|
pwd
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit $RET
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo "$0"
|
||||||
|
echo -e "\t -w work dir"
|
||||||
|
echo -e "\t -d execution dir"
|
||||||
|
echo -e "\t -c command"
|
||||||
|
echo -e "\t -t thread number"
|
||||||
|
echo -e "\t -e enterprise edition"
|
||||||
|
echo -e "\t -o default timeout value"
|
||||||
|
echo -e "\t -h help"
|
||||||
|
}
|
||||||
|
|
||||||
|
ent=0
|
||||||
|
while getopts "w:d:c:t:o:eh" opt; do
|
||||||
|
case $opt in
|
||||||
|
w)
|
||||||
|
WORKDIR=$OPTARG
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
exec_dir=$OPTARG
|
||||||
|
;;
|
||||||
|
c)
|
||||||
|
cmd=$OPTARG
|
||||||
|
;;
|
||||||
|
t)
|
||||||
|
thread_no=$OPTARG
|
||||||
|
;;
|
||||||
|
e)
|
||||||
|
ent=1
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
extra_param="-o $OPTARG"
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG"
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$WORKDIR" ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "$exec_dir" ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "$cmd" ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "$thread_no" ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ $ent -ne 0 ]; then
|
||||||
|
# enterprise edition
|
||||||
|
extra_param="$extra_param -e"
|
||||||
|
INTERNAL_REPDIR=$WORKDIR/TDinternal
|
||||||
|
REPDIR=$INTERNAL_REPDIR/community
|
||||||
|
CONTAINER_TESTDIR=/home/TDinternal/community
|
||||||
|
SIM_DIR=/home/TDinternal/sim
|
||||||
|
REP_MOUNT_PARAM="$INTERNAL_REPDIR:/home/TDinternal"
|
||||||
|
else
|
||||||
|
# community edition
|
||||||
|
REPDIR=$WORKDIR/TDengine
|
||||||
|
CONTAINER_TESTDIR=/home/TDengine
|
||||||
|
SIM_DIR=/home/TDengine/sim
|
||||||
|
REP_MOUNT_PARAM="$REPDIR:/home/TDengine"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ulimit -c unlimited
|
||||||
|
|
||||||
|
TMP_DIR=$WORKDIR/tmp
|
||||||
|
|
||||||
|
MOUNT_DIR=""
|
||||||
|
rm -rf ${TMP_DIR}/thread_volume/$thread_no/sim
|
||||||
|
mkdir -p ${TMP_DIR}/thread_volume/$thread_no/sim/tsim
|
||||||
|
mkdir -p ${TMP_DIR}/thread_volume/$thread_no/coredump
|
||||||
|
rm -rf ${TMP_DIR}/thread_volume/$thread_no/coredump/*
|
||||||
|
if [ ! -d "${TMP_DIR}/thread_volume/$thread_no/$exec_dir" ]; then
|
||||||
|
subdir=`echo "$exec_dir"|cut -d/ -f1`
|
||||||
|
echo "cp -rf ${REPDIR}/tests/$subdir ${TMP_DIR}/thread_volume/$thread_no/"
|
||||||
|
cp -rf ${REPDIR}/tests/$subdir ${TMP_DIR}/thread_volume/$thread_no/
|
||||||
|
fi
|
||||||
|
MOUNT_DIR="$TMP_DIR/thread_volume/$thread_no/$exec_dir:$CONTAINER_TESTDIR/tests/$exec_dir"
|
||||||
|
echo "$thread_no -> ${exec_dir}:$cmd"
|
||||||
|
coredump_dir=`cat /proc/sys/kernel/core_pattern | xargs dirname`
|
||||||
|
|
||||||
|
docker run \
|
||||||
|
-v $REP_MOUNT_PARAM \
|
||||||
|
-v $MOUNT_DIR \
|
||||||
|
-v "$TMP_DIR/thread_volume/$thread_no/sim:${SIM_DIR}" \
|
||||||
|
-v ${TMP_DIR}/thread_volume/$thread_no/coredump:$coredump_dir \
|
||||||
|
-v $WORKDIR/taos-connector-python/taos:/usr/local/lib/python3.8/site-packages/taos:ro \
|
||||||
|
--rm --ulimit core=-1 taos_test:v1.0 $CONTAINER_TESTDIR/tests/parallel_test/run_case.sh -d "$exec_dir" -c "$cmd" $extra_param
|
||||||
|
ret=$?
|
||||||
|
exit $ret
|
||||||
|
|
|
@ -30,17 +30,12 @@ class TDSimClient:
|
||||||
"locale": "en_US.UTF-8",
|
"locale": "en_US.UTF-8",
|
||||||
"charset": "UTF-8",
|
"charset": "UTF-8",
|
||||||
"asyncLog": "0",
|
"asyncLog": "0",
|
||||||
"minTablesPerVnode": "4",
|
"rpcDebugFlag": "143",
|
||||||
"maxTablesPerVnode": "1000",
|
|
||||||
"tableIncStepPerVnode": "10000",
|
|
||||||
"maxVgroupsPerDb": "1000",
|
|
||||||
"sdbDebugFlag": "143",
|
|
||||||
"rpcDebugFlag": "135",
|
|
||||||
"tmrDebugFlag": "131",
|
"tmrDebugFlag": "131",
|
||||||
"cDebugFlag": "135",
|
"cDebugFlag": "143",
|
||||||
"udebugFlag": "135",
|
"udebugFlag": "143",
|
||||||
"jnidebugFlag": "135",
|
"jnidebugFlag": "143",
|
||||||
"qdebugFlag": "135",
|
"qdebugFlag": "143",
|
||||||
"telemetryReporting": "0",
|
"telemetryReporting": "0",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,36 +110,29 @@ class TDDnode:
|
||||||
self.testCluster = False
|
self.testCluster = False
|
||||||
self.valgrind = 0
|
self.valgrind = 0
|
||||||
self.cfgDict = {
|
self.cfgDict = {
|
||||||
"numOfLogLines": "100000000",
|
|
||||||
"mnodeEqualVnodeNum": "0",
|
|
||||||
"walLevel": "2",
|
"walLevel": "2",
|
||||||
"fsync": "1000",
|
"fsync": "1000",
|
||||||
"statusInterval": "1",
|
|
||||||
"numOfMnodes": "3",
|
|
||||||
"numOfThreadsPerCore": "2.0",
|
|
||||||
"monitor": "0",
|
"monitor": "0",
|
||||||
"maxVnodeConnections": "30000",
|
|
||||||
"maxMgmtConnections": "30000",
|
|
||||||
"maxMeterConnections": "30000",
|
|
||||||
"maxShellConns": "30000",
|
"maxShellConns": "30000",
|
||||||
"locale": "en_US.UTF-8",
|
"locale": "en_US.UTF-8",
|
||||||
"charset": "UTF-8",
|
"charset": "UTF-8",
|
||||||
"asyncLog": "0",
|
"asyncLog": "0",
|
||||||
"anyIp": "0",
|
"mDebugFlag": "143",
|
||||||
"telemetryReporting": "0",
|
"dDebugFlag": "143",
|
||||||
"dDebugFlag": "135",
|
"vDebugFlag": "143",
|
||||||
"tsdbDebugFlag": "135",
|
"tqDebugFlag": "143",
|
||||||
"mDebugFlag": "135",
|
"cDebugFlag": "143",
|
||||||
"sdbDebugFlag": "135",
|
"jniDebugFlag": "143",
|
||||||
"rpcDebugFlag": "135",
|
"qDebugFlag": "143",
|
||||||
|
"rpcDebugFlag": "143",
|
||||||
"tmrDebugFlag": "131",
|
"tmrDebugFlag": "131",
|
||||||
"cDebugFlag": "135",
|
"uDebugFlag": "143",
|
||||||
"httpDebugFlag": "135",
|
"sDebugFlag": "135",
|
||||||
"monitorDebugFlag": "135",
|
"wDebugFlag": "143",
|
||||||
"udebugFlag": "135",
|
"qdebugFlag": "143",
|
||||||
"jnidebugFlag": "135",
|
"numOfLogLines": "100000000",
|
||||||
"qdebugFlag": "135",
|
"statusInterval": "1",
|
||||||
"maxSQLLength": "1048576"
|
"telemetryReporting": "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
def init(self, path):
|
def init(self, path):
|
||||||
|
|
|
@ -9,10 +9,12 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "../../../include/client/taos.h"
|
#include "../../../include/client/taos.h"
|
||||||
|
|
||||||
|
#define FUNCTION_TEST_IDX 1
|
||||||
|
|
||||||
int32_t shortColList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_INT};
|
int32_t shortColList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_INT};
|
||||||
int32_t fullColList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_BOOL, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_UTINYINT, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_USMALLINT, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_UINT, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_UBIGINT, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_BINARY, TSDB_DATA_TYPE_NCHAR};
|
int32_t fullColList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_BOOL, TSDB_DATA_TYPE_TINYINT, TSDB_DATA_TYPE_UTINYINT, TSDB_DATA_TYPE_SMALLINT, TSDB_DATA_TYPE_USMALLINT, TSDB_DATA_TYPE_INT, TSDB_DATA_TYPE_UINT, TSDB_DATA_TYPE_BIGINT, TSDB_DATA_TYPE_UBIGINT, TSDB_DATA_TYPE_FLOAT, TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_BINARY, TSDB_DATA_TYPE_NCHAR};
|
||||||
int32_t bindColTypeList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_NCHAR};
|
int32_t bindColTypeList[] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_INT};
|
||||||
int32_t optrIdxList[] = {0, 9};
|
int32_t optrIdxList[] = {0, 7};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* oper;
|
char* oper;
|
||||||
|
@ -53,7 +55,6 @@ FuncInfo funcInfo[] = {
|
||||||
{"count", 1},
|
{"count", 1},
|
||||||
{"sum", 1},
|
{"sum", 1},
|
||||||
{"min", 1},
|
{"min", 1},
|
||||||
{"sin", 1},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
char *bpStbPrefix = "st";
|
char *bpStbPrefix = "st";
|
||||||
|
@ -66,6 +67,10 @@ int32_t bpDefaultStbId = 1;
|
||||||
//char *varoperatorList[] = {">", ">=", "<", "<=", "=", "<>", "in", "not in", "like", "not like", "match", "nmatch"};
|
//char *varoperatorList[] = {">", ">=", "<", "<=", "=", "<>", "in", "not in", "like", "not like", "match", "nmatch"};
|
||||||
|
|
||||||
#define tListLen(x) (sizeof(x) / sizeof((x)[0]))
|
#define tListLen(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
|
||||||
|
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
|
||||||
|
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
|
||||||
|
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t* tsData;
|
int64_t* tsData;
|
||||||
|
@ -165,8 +170,11 @@ CaseCfg gCase[] = {
|
||||||
// 22
|
// 22
|
||||||
{"insert:AUTO1-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, true, true, insertAUTOTest1, 10, 10, 2, 0, 0, 0, 1, -1},
|
{"insert:AUTO1-FULL", tListLen(fullColList), fullColList, TTYPE_INSERT, true, true, insertAUTOTest1, 10, 10, 2, 0, 0, 0, 1, -1},
|
||||||
|
|
||||||
{"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryColumnTest, 10, 10, 1, 3, 0, 0, 1, 2},
|
// {"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryColumnTest, 10, 10, 1, 3, 0, 0, 1, 2},
|
||||||
{"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryMiscTest, 2, 10, 1, 3, 0, 0, 1, 2},
|
// {"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryMiscTest, 10, 10, 1, 3, 0, 0, 1, 2},
|
||||||
|
|
||||||
|
{"query:SUBT-COLUMN", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryColumnTest, 1, 10, 1, 1, 0, 0, 1, 2},
|
||||||
|
{"query:SUBT-MISC", tListLen(fullColList), fullColList, TTYPE_QUERY, false, false, queryMiscTest, 2, 10, 1, 1, 0, 0, 1, 2},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -181,6 +189,7 @@ typedef struct {
|
||||||
bool printQuerySql;
|
bool printQuerySql;
|
||||||
bool printStmtSql;
|
bool printStmtSql;
|
||||||
bool autoCreateTbl;
|
bool autoCreateTbl;
|
||||||
|
bool numericParam;
|
||||||
int32_t rowNum; //row num for one table
|
int32_t rowNum; //row num for one table
|
||||||
int32_t bindColNum;
|
int32_t bindColNum;
|
||||||
int32_t bindTagNum;
|
int32_t bindTagNum;
|
||||||
|
@ -207,6 +216,7 @@ CaseCtrl gCaseCtrl = { // default
|
||||||
.printQuerySql = true,
|
.printQuerySql = true,
|
||||||
.printStmtSql = true,
|
.printStmtSql = true,
|
||||||
.autoCreateTbl = false,
|
.autoCreateTbl = false,
|
||||||
|
.numericParam = false,
|
||||||
.rowNum = 0,
|
.rowNum = 0,
|
||||||
.bindColNum = 0,
|
.bindColNum = 0,
|
||||||
.bindTagNum = 0,
|
.bindTagNum = 0,
|
||||||
|
@ -259,26 +269,22 @@ CaseCtrl gCaseCtrl = {
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
CaseCtrl gCaseCtrl = { // query case with specified col&oper
|
CaseCtrl gCaseCtrl = { // query case with specified col&oper
|
||||||
.bindNullNum = 0,
|
.bindNullNum = 1,
|
||||||
.printCreateTblSql = false,
|
.printCreateTblSql = false,
|
||||||
.printQuerySql = true,
|
.printQuerySql = true,
|
||||||
.printStmtSql = true,
|
.printStmtSql = true,
|
||||||
.rowNum = 0,
|
.rowNum = 0,
|
||||||
.bindColNum = 0,
|
.bindColNum = 0,
|
||||||
.bindRowNum = 0,
|
.bindRowNum = 0,
|
||||||
.bindColTypeNum = 0,
|
.optrIdxListNum = tListLen(optrIdxList),
|
||||||
.bindColTypeList = NULL,
|
.optrIdxList = optrIdxList,
|
||||||
.optrIdxListNum = 0,
|
.bindColTypeNum = tListLen(bindColTypeList),
|
||||||
.optrIdxList = NULL,
|
.bindColTypeList = bindColTypeList,
|
||||||
.checkParamNum = false,
|
.checkParamNum = false,
|
||||||
.printRes = true,
|
.printRes = true,
|
||||||
.runTimes = 0,
|
.runTimes = 0,
|
||||||
.caseRunIdx = -1,
|
.caseRunIdx = -1,
|
||||||
.optrIdxListNum = 0,
|
.caseIdx = 23,
|
||||||
.optrIdxList = NULL,
|
|
||||||
.bindColTypeNum = 0,
|
|
||||||
.bindColTypeList = NULL,
|
|
||||||
.caseIdx = 24,
|
|
||||||
.caseNum = 1,
|
.caseNum = 1,
|
||||||
.caseRunNum = 1,
|
.caseRunNum = 1,
|
||||||
};
|
};
|
||||||
|
@ -303,11 +309,11 @@ CaseCtrl gCaseCtrl = { // query case with specified col&oper
|
||||||
.printRes = true,
|
.printRes = true,
|
||||||
.runTimes = 0,
|
.runTimes = 0,
|
||||||
.caseRunIdx = -1,
|
.caseRunIdx = -1,
|
||||||
//.optrIdxListNum = tListLen(optrIdxList),
|
.optrIdxListNum = tListLen(optrIdxList),
|
||||||
//.optrIdxList = optrIdxList,
|
.optrIdxList = optrIdxList,
|
||||||
//.bindColTypeNum = tListLen(bindColTypeList),
|
.bindColTypeNum = tListLen(bindColTypeList),
|
||||||
//.bindColTypeList = bindColTypeList,
|
.bindColTypeList = bindColTypeList,
|
||||||
.caseIdx = 22,
|
.caseIdx = 24,
|
||||||
.caseNum = 1,
|
.caseNum = 1,
|
||||||
.caseRunNum = 1,
|
.caseRunNum = 1,
|
||||||
};
|
};
|
||||||
|
@ -661,11 +667,11 @@ void bpGenerateConstInFuncSQL(BindData *data, int32_t tblIdx) {
|
||||||
void generateQueryMiscSQL(BindData *data, int32_t tblIdx) {
|
void generateQueryMiscSQL(BindData *data, int32_t tblIdx) {
|
||||||
switch(tblIdx) {
|
switch(tblIdx) {
|
||||||
case 0:
|
case 0:
|
||||||
bpGenerateConstInOpSQL(data, tblIdx);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
//TODO FILL TEST
|
//TODO FILL TEST
|
||||||
default:
|
default:
|
||||||
|
bpGenerateConstInOpSQL(data, tblIdx);
|
||||||
|
break;
|
||||||
|
case FUNCTION_TEST_IDX:
|
||||||
bpGenerateConstInFuncSQL(data, tblIdx);
|
bpGenerateConstInFuncSQL(data, tblIdx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -709,6 +715,16 @@ void generateColDataType(BindData *data, int32_t bindIdx, int32_t colIdx, int32_
|
||||||
} else if (gCurCase->fullCol) {
|
} else if (gCurCase->fullCol) {
|
||||||
*dataType = gCurCase->colList[bindIdx];
|
*dataType = gCurCase->colList[bindIdx];
|
||||||
return;
|
return;
|
||||||
|
} else if (gCaseCtrl.numericParam) {
|
||||||
|
while (true) {
|
||||||
|
*dataType = rand() % (TSDB_DATA_TYPE_MAX - 1) + 1;
|
||||||
|
if (!IS_NUMERIC_TYPE(*dataType)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
} else if (0 == colIdx) {
|
} else if (0 == colIdx) {
|
||||||
*dataType = TSDB_DATA_TYPE_TIMESTAMP;
|
*dataType = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
return;
|
return;
|
||||||
|
@ -1046,6 +1062,10 @@ int32_t prepareQueryMiscData(BindData *data, int32_t tblIdx) {
|
||||||
data->binaryLen[i] = gVarCharLen;
|
data->binaryLen[i] = gVarCharLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tblIdx == FUNCTION_TEST_IDX) {
|
||||||
|
gCaseCtrl.numericParam = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (int b = 0; b < bindNum; b++) {
|
for (int b = 0; b < bindNum; b++) {
|
||||||
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
for (int c = 0; c < gCurCase->bindColNum; ++c) {
|
||||||
prepareColData(BP_BIND_COL, data, b*gCurCase->bindColNum+c, b*gCurCase->bindRowNum, c);
|
prepareColData(BP_BIND_COL, data, b*gCurCase->bindColNum+c, b*gCurCase->bindRowNum, c);
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
|
|
||||||
# ---- tstream
|
# ---- tstream
|
||||||
./test.sh -f tsim/tstream/basic0.sim
|
./test.sh -f tsim/tstream/basic0.sim
|
||||||
|
./test.sh -f tsim/tstream/basic1.sim
|
||||||
|
|
||||||
# ---- transaction
|
# ---- transaction
|
||||||
./test.sh -f tsim/trans/create_db.sim
|
./test.sh -f tsim/trans/create_db.sim
|
||||||
|
|
|
@ -94,6 +94,31 @@ endi
|
||||||
if $data00 != 2.645751311 then
|
if $data00 != 2.645751311 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql insert into t2 values(now+4s, 4, 8)(now+5s, 5, 9);
|
||||||
|
sql select udf2(f1-f2), udf2(f1+f2) from t2;
|
||||||
|
print $rows , $data00 , $data01
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1;
|
||||||
|
endi
|
||||||
|
if $data00 != 5.656854249 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data01 != 18.547236991 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select udf2(udf1(f2-f1)), udf2(udf1(f2/f1)) from t2;
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != 176.000000000 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data01 != 152.420471066 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
print $rows , $data00 , $data01
|
||||||
sql drop function udf1;
|
sql drop function udf1;
|
||||||
sql show functions;
|
sql show functions;
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
|
|
|
@ -0,0 +1,375 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sleep 50
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print =============== create database
|
||||||
|
sql create database test vgroups 1
|
||||||
|
sql show databases
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print $data00 $data01 $data02
|
||||||
|
|
||||||
|
sql use test
|
||||||
|
|
||||||
|
|
||||||
|
sql create table t1(ts timestamp, a int, b int , c int, d double);
|
||||||
|
sql create stream streams1 trigger at_once into streamt as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s);
|
||||||
|
sql insert into t1 values(1648791213000,1,2,3,1.0);
|
||||||
|
sql insert into t1 values(1648791223001,2,2,3,1.1);
|
||||||
|
sql insert into t1 values(1648791233002,3,2,3,2.1);
|
||||||
|
sql insert into t1 values(1648791243003,4,2,3,3.1);
|
||||||
|
sql insert into t1 values(1648791213004,4,2,3,4.1);
|
||||||
|
sleep 1000
|
||||||
|
sql select _wstartts, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||||
|
|
||||||
|
if $rows != 4 then
|
||||||
|
print ======$rows
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
# row 0
|
||||||
|
if $data01 != 2 then
|
||||||
|
print ======$data01
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 2 then
|
||||||
|
print ======$data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data03 != 5 then
|
||||||
|
print ======$data03
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data04 != 2 then
|
||||||
|
print ======$data04
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data05 != 3 then
|
||||||
|
print ======$data05
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
# row 1
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======$data11
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 1 then
|
||||||
|
print ======$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data13 != 2 then
|
||||||
|
print ======$data13
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data14 != 2 then
|
||||||
|
print ======$data14
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data15 != 3 then
|
||||||
|
print ======$data15
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
# row 2
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======$data21
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data22 != 1 then
|
||||||
|
print ======$data22
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data23 != 3 then
|
||||||
|
print ======$data23
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data24 != 2 then
|
||||||
|
print ======$data24
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data25 != 3 then
|
||||||
|
print ======$data25
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
# row 3
|
||||||
|
if $data31 != 1 then
|
||||||
|
print ======$data31
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data32 != 1 then
|
||||||
|
print ======$data32
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data33 != 4 then
|
||||||
|
print ======$data33
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data34 != 2 then
|
||||||
|
print ======$data34
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data35 != 3 then
|
||||||
|
print ======$data35
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791223001,12,14,13,11.1);
|
||||||
|
sleep 100
|
||||||
|
sql select _wstartts, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||||
|
|
||||||
|
if $rows != 4 then
|
||||||
|
print ======$rows
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
# row 0
|
||||||
|
if $data01 != 2 then
|
||||||
|
print ======$data01
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data02 != 2 then
|
||||||
|
print ======$data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data03 != 5 then
|
||||||
|
print ======$data03
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data04 != 2 then
|
||||||
|
print ======$data04
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data05 != 3 then
|
||||||
|
print ======$data05
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
# row 1
|
||||||
|
if $data11 != 1 then
|
||||||
|
print ======$data11
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 1 then
|
||||||
|
print ======$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data13 != 12 then
|
||||||
|
print ======$data13
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data14 != 14 then
|
||||||
|
print ======$data14
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data15 != 13 then
|
||||||
|
print ======$data15
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
# row 2
|
||||||
|
if $data21 != 1 then
|
||||||
|
print ======$data21
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data22 != 1 then
|
||||||
|
print ======$data22
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data23 != 3 then
|
||||||
|
print ======$data23
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data24 != 2 then
|
||||||
|
print ======$data24
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data25 != 3 then
|
||||||
|
print ======$data25
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
# row 3
|
||||||
|
if $data31 != 1 then
|
||||||
|
print ======$data31
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data32 != 1 then
|
||||||
|
print ======$data32
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data33 != 4 then
|
||||||
|
print ======$data33
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data34 != 2 then
|
||||||
|
print ======$data34
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data35 != 3 then
|
||||||
|
print ======$data35
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791223002,12,14,13,11.1);
|
||||||
|
sleep 100
|
||||||
|
sql select _wstartts, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||||
|
|
||||||
|
# row 1
|
||||||
|
if $data11 != 2 then
|
||||||
|
print ======$data11
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 2 then
|
||||||
|
print ======$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data13 != 24 then
|
||||||
|
print ======$data13
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data14 != 14 then
|
||||||
|
print ======$data14
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data15 != 13 then
|
||||||
|
print ======$data15
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791223003,12,14,13,11.1);
|
||||||
|
sleep 100
|
||||||
|
sql select _wstartts, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||||
|
|
||||||
|
# row 1
|
||||||
|
if $data11 != 3 then
|
||||||
|
print ======$data11
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 3 then
|
||||||
|
print ======$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data13 != 36 then
|
||||||
|
print ======$data13
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data14 != 14 then
|
||||||
|
print ======$data14
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data15 != 13 then
|
||||||
|
print ======$data15
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791223001,1,1,1,1.1);
|
||||||
|
sql insert into t1 values(1648791223002,2,2,2,2.1);
|
||||||
|
sql insert into t1 values(1648791223003,3,3,3,3.1);
|
||||||
|
sleep 100
|
||||||
|
sql select _wstartts, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||||
|
|
||||||
|
# row 1
|
||||||
|
if $data11 != 3 then
|
||||||
|
print ======$data11
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data12 != 3 then
|
||||||
|
print ======$data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data13 != 6 then
|
||||||
|
print ======$data13
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data14 != 3 then
|
||||||
|
print ======$data14
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data15 != 1 then
|
||||||
|
print ======$data15
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql insert into t1 values(1648791233003,3,2,3,2.1);
|
||||||
|
sql insert into t1 values(1648791233002,5,6,7,8.1);
|
||||||
|
sql insert into t1 values(1648791233002,3,2,3,2.1);
|
||||||
|
sleep 100
|
||||||
|
sql select _wstartts, c1, c2 ,c3 ,c4, c5 from streamt;
|
||||||
|
|
||||||
|
# row 2
|
||||||
|
if $data21 != 2 then
|
||||||
|
print ======$data21
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data22 != 2 then
|
||||||
|
print ======$data22
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data23 != 6 then
|
||||||
|
print ======$data23
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data24 != 2 then
|
||||||
|
print ======$data24
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data25 != 3 then
|
||||||
|
print ======$data25
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -138,7 +138,8 @@ class TDTestCase:
|
||||||
if "2: service ok" in retVal:
|
if "2: service ok" in retVal:
|
||||||
tdLog.info("taos -k success")
|
tdLog.info("taos -k success")
|
||||||
else:
|
else:
|
||||||
tdLog.exit("taos -k fail")
|
tdLog.info(retVal)
|
||||||
|
tdLog.exit("taos -k fail 1")
|
||||||
|
|
||||||
# stop taosd
|
# stop taosd
|
||||||
tdDnodes.stop(1)
|
tdDnodes.stop(1)
|
||||||
|
@ -149,7 +150,8 @@ class TDTestCase:
|
||||||
if "0: unavailable" in retVal:
|
if "0: unavailable" in retVal:
|
||||||
tdLog.info("taos -k success")
|
tdLog.info("taos -k success")
|
||||||
else:
|
else:
|
||||||
tdLog.exit("taos -k fail")
|
tdLog.info(retVal)
|
||||||
|
tdLog.exit("taos -k fail 2")
|
||||||
|
|
||||||
# restart taosd
|
# restart taosd
|
||||||
tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
|
@ -158,7 +160,8 @@ class TDTestCase:
|
||||||
if "2: service ok" in retVal:
|
if "2: service ok" in retVal:
|
||||||
tdLog.info("taos -k success")
|
tdLog.info("taos -k success")
|
||||||
else:
|
else:
|
||||||
tdLog.exit("taos -k fail")
|
tdLog.info(retVal)
|
||||||
|
tdLog.exit("taos -k fail 3")
|
||||||
|
|
||||||
tdLog.printNoPrefix("================================ parameter: -n")
|
tdLog.printNoPrefix("================================ parameter: -n")
|
||||||
# stop taosd
|
# stop taosd
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TDTestCase:
|
||||||
|
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor(), True)
|
||||||
|
|
||||||
def __query_condition(self,tbname):
|
def __query_condition(self,tbname):
|
||||||
query_condition = []
|
query_condition = []
|
||||||
|
|
|
@ -15,8 +15,16 @@ class TDTestCase:
|
||||||
def run(self): # sourcery skip: extract-duplicate-method
|
def run(self): # sourcery skip: extract-duplicate-method
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
# get system timezone
|
# get system timezone
|
||||||
time_zone = os.popen('timedatectl | grep zone').read(
|
time_zone_arr = os.popen('timedatectl | grep zone').read(
|
||||||
).strip().split(':')[1].lstrip()
|
).strip().split(':')
|
||||||
|
if len(time_zone_arr) > 1:
|
||||||
|
time_zone = time_zone_arr[1].lstrip()
|
||||||
|
else:
|
||||||
|
# possibly in a docker container
|
||||||
|
time_zone_1 = os.popen('ls -l /etc/localtime|awk -F/ \'{print $(NF-1) "/" $NF}\'').read().strip()
|
||||||
|
time_zone_2 = os.popen('date "+(%Z, %z)"').read().strip()
|
||||||
|
time_zone = time_zone_1 + " " + time_zone_2
|
||||||
|
print("expected time zone: " + time_zone)
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create tables==========")
|
tdLog.printNoPrefix("==========step1:create tables==========")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
|
|
|
@ -0,0 +1,400 @@
|
||||||
|
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import socket
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
#rpcDebugFlagVal = '143'
|
||||||
|
#clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
|
||||||
|
#clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal
|
||||||
|
#updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
|
||||||
|
#updatecfgDict["rpcDebugFlag"] = rpcDebugFlagVal
|
||||||
|
#print ("===================: ", updatecfgDict)
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
#tdSql.init(conn.cursor())
|
||||||
|
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||||
|
|
||||||
|
def getBuildPath(self):
|
||||||
|
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
if ("community" in selfPath):
|
||||||
|
projPath = selfPath[:selfPath.find("community")]
|
||||||
|
else:
|
||||||
|
projPath = selfPath[:selfPath.find("tests")]
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(projPath):
|
||||||
|
if ("taosd" in files):
|
||||||
|
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||||
|
if ("packaging" not in rootRealPath):
|
||||||
|
buildPath = root[:len(root) - len("/build/bin")]
|
||||||
|
break
|
||||||
|
return buildPath
|
||||||
|
|
||||||
|
def newcur(self,cfg,host,port):
|
||||||
|
user = "root"
|
||||||
|
password = "taosdata"
|
||||||
|
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
|
||||||
|
cur=con.cursor()
|
||||||
|
print(cur)
|
||||||
|
return cur
|
||||||
|
|
||||||
|
def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg,showRow,cdbName,valgrind=0):
|
||||||
|
shellCmd = 'nohup '
|
||||||
|
if valgrind == 1:
|
||||||
|
logFile = cfgPath + '/../log/valgrind-tmq.log'
|
||||||
|
shellCmd = 'nohup valgrind --log-file=' + logFile
|
||||||
|
shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes '
|
||||||
|
|
||||||
|
shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath
|
||||||
|
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName)
|
||||||
|
shellCmd += "> /dev/null 2>&1 &"
|
||||||
|
tdLog.info(shellCmd)
|
||||||
|
os.system(shellCmd)
|
||||||
|
|
||||||
|
def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl):
|
||||||
|
tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups))
|
||||||
|
tsql.execute("use %s" %dbName)
|
||||||
|
tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName)
|
||||||
|
pre_create = "create table"
|
||||||
|
sql = pre_create
|
||||||
|
#tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname))
|
||||||
|
for i in range(ctbNum):
|
||||||
|
sql += " %s_%d using %s tags(%d)"%(stbName,i,stbName,i+1)
|
||||||
|
if (i > 0) and (i%100 == 0):
|
||||||
|
tsql.execute(sql)
|
||||||
|
sql = pre_create
|
||||||
|
if sql != pre_create:
|
||||||
|
tsql.execute(sql)
|
||||||
|
|
||||||
|
event.set()
|
||||||
|
tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum))
|
||||||
|
return
|
||||||
|
|
||||||
|
def insert_data(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs):
|
||||||
|
tdLog.debug("start to insert data ............")
|
||||||
|
tsql.execute("use %s" %dbName)
|
||||||
|
pre_insert = "insert into "
|
||||||
|
sql = pre_insert
|
||||||
|
|
||||||
|
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
|
||||||
|
for i in range(ctbNum):
|
||||||
|
sql += " %s_%d values "%(stbName,i)
|
||||||
|
for j in range(rowsPerTbl):
|
||||||
|
sql += "(%d, %d, 'tmqrow_%d') "%(startTs + j, j, j)
|
||||||
|
if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)):
|
||||||
|
tsql.execute(sql)
|
||||||
|
if j < rowsPerTbl - 1:
|
||||||
|
sql = "insert into %s_%d values " %(stbName,i)
|
||||||
|
else:
|
||||||
|
sql = "insert into "
|
||||||
|
#end sql
|
||||||
|
if sql != pre_insert:
|
||||||
|
#print("insert sql:%s"%sql)
|
||||||
|
tsql.execute(sql)
|
||||||
|
tdLog.debug("insert data ............ [OK]")
|
||||||
|
return
|
||||||
|
|
||||||
|
def prepareEnv(self, **parameterDict):
|
||||||
|
print ("input parameters:")
|
||||||
|
print (parameterDict)
|
||||||
|
# create new connector for my thread
|
||||||
|
tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030)
|
||||||
|
self.create_tables(tsql,\
|
||||||
|
parameterDict["dbName"],\
|
||||||
|
parameterDict["vgroups"],\
|
||||||
|
parameterDict["stbName"],\
|
||||||
|
parameterDict["ctbNum"],\
|
||||||
|
parameterDict["rowsPerTbl"])
|
||||||
|
|
||||||
|
self.insert_data(tsql,\
|
||||||
|
parameterDict["dbName"],\
|
||||||
|
parameterDict["stbName"],\
|
||||||
|
parameterDict["ctbNum"],\
|
||||||
|
parameterDict["rowsPerTbl"],\
|
||||||
|
parameterDict["batchNum"],\
|
||||||
|
parameterDict["startTs"])
|
||||||
|
return
|
||||||
|
|
||||||
|
def tmqCase1(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 1: Produce while one consume to subscribe one db")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db1', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 200, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups']))
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
tdLog.info("create topics from db")
|
||||||
|
topicName1 = 'topic_db1'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as %s" %(topicName1, parameterDict['dbName']))
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"]
|
||||||
|
topicList = topicName1
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
event.wait()
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow, cdbName)
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from %s.consumeresult"%cdbName)
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
tdLog.info("consumer result: %d, %d"%(tdSql.getData(0 , 2), tdSql.getData(0 , 3)))
|
||||||
|
tdSql.checkData(0 , 1, consumerId)
|
||||||
|
# mulit rows and mulit tables in one sql, this num of msg is not sure
|
||||||
|
#tdSql.checkData(0 , 2, expectmsgcnt)
|
||||||
|
tdSql.checkData(0 , 3, expectrowcnt+1)
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicName1)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 1 end ...... ")
|
||||||
|
|
||||||
|
def tmqCase2(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 2: Produce while two consumers to subscribe one db")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db2', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups']))
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
tdLog.info("create topics from db")
|
||||||
|
topicName1 = 'topic_db1'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as %s" %(topicName1, parameterDict['dbName']))
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"]
|
||||||
|
topicList = topicName1
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
consumerId = 1
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
event.wait()
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow, cdbName)
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from %s.consumeresult"%cdbName)
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 2:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
consumerId0 = tdSql.getData(0 , 1)
|
||||||
|
consumerId1 = tdSql.getData(1 , 1)
|
||||||
|
actConsumeRows0 = tdSql.getData(0 , 3)
|
||||||
|
actConsumeRows1 = tdSql.getData(1 , 3)
|
||||||
|
|
||||||
|
tdLog.info("consumer %d rows: %d"%(consumerId0, actConsumeRows0))
|
||||||
|
tdLog.info("consumer %d rows: %d"%(consumerId1, actConsumeRows1))
|
||||||
|
|
||||||
|
totalConsumeRows = actConsumeRows0 + actConsumeRows1
|
||||||
|
if totalConsumeRows != expectrowcnt + 2:
|
||||||
|
tdLog.exit("tmq consume rows error!")
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicName1)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 2 end ...... ")
|
||||||
|
|
||||||
|
def tmqCase3(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 3: Produce while one consumers to subscribe one db, include 2 stb")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db3', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups']))
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
parameterDict2 = {'cfg': '', \
|
||||||
|
'dbName': 'db3', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb2', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2)
|
||||||
|
prepareEnvThread2.start()
|
||||||
|
|
||||||
|
tdLog.info("create topics from db")
|
||||||
|
topicName1 = 'topic_db1'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as %s" %(topicName1, parameterDict['dbName']))
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + parameterDict2["rowsPerTbl"] * parameterDict2["ctbNum"]
|
||||||
|
topicList = topicName1
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
# consumerId = 1
|
||||||
|
# sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
# sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
# tdSql.query(sql)
|
||||||
|
|
||||||
|
event.wait()
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow, cdbName)
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
prepareEnvThread2.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from %s.consumeresult"%cdbName)
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
consumerId0 = tdSql.getData(0 , 1)
|
||||||
|
#consumerId1 = tdSql.getData(1 , 1)
|
||||||
|
actConsumeRows0 = tdSql.getData(0 , 3)
|
||||||
|
#actConsumeRows1 = tdSql.getData(1 , 3)
|
||||||
|
|
||||||
|
tdLog.info("consumer %d rows: %d"%(consumerId0, actConsumeRows0))
|
||||||
|
#tdLog.info("consumer %d rows: %d"%(consumerId1, actConsumeRows1))
|
||||||
|
|
||||||
|
#totalConsumeRows = actConsumeRows0 + actConsumeRows1
|
||||||
|
if actConsumeRows0 != expectrowcnt + 1:
|
||||||
|
tdLog.exit("tmq consume rows error!")
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicName1)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 3 end ...... ")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
buildPath = self.getBuildPath()
|
||||||
|
if (buildPath == ""):
|
||||||
|
tdLog.exit("taosd not found!")
|
||||||
|
else:
|
||||||
|
tdLog.info("taosd found in %s" % buildPath)
|
||||||
|
cfgPath = buildPath + "/../sim/psim/cfg"
|
||||||
|
tdLog.info("cfgPath: %s" % cfgPath)
|
||||||
|
|
||||||
|
#self.tmqCase1(cfgPath, buildPath)
|
||||||
|
self.tmqCase2(cfgPath, buildPath)
|
||||||
|
#self.tmqCase3(cfgPath, buildPath)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
event = threading.Event()
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -0,0 +1,489 @@
|
||||||
|
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import socket
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
|
||||||
|
#clientCfgDict = {'qdebugflag':'143'}
|
||||||
|
#updatecfgDict = {'clientCfg': {}, 'qdebugflag':'143'}
|
||||||
|
#updatecfgDict["clientCfg"] = clientCfgDict
|
||||||
|
#print ("===================: ", updatecfgDict)
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
#tdSql.init(conn.cursor())
|
||||||
|
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||||
|
|
||||||
|
def getBuildPath(self):
|
||||||
|
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
if ("community" in selfPath):
|
||||||
|
projPath = selfPath[:selfPath.find("community")]
|
||||||
|
else:
|
||||||
|
projPath = selfPath[:selfPath.find("tests")]
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(projPath):
|
||||||
|
if ("taosd" in files):
|
||||||
|
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||||
|
if ("packaging" not in rootRealPath):
|
||||||
|
buildPath = root[:len(root) - len("/build/bin")]
|
||||||
|
break
|
||||||
|
return buildPath
|
||||||
|
|
||||||
|
def newcur(self,cfg,host,port):
|
||||||
|
user = "root"
|
||||||
|
password = "taosdata"
|
||||||
|
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
|
||||||
|
cur=con.cursor()
|
||||||
|
print(cur)
|
||||||
|
return cur
|
||||||
|
|
||||||
|
def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl):
|
||||||
|
tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups))
|
||||||
|
tsql.execute("use %s" %dbName)
|
||||||
|
tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName)
|
||||||
|
pre_create = "create table"
|
||||||
|
sql = pre_create
|
||||||
|
#tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname))
|
||||||
|
for i in range(ctbNum):
|
||||||
|
sql += " %s_%d using %s tags(%d)"%(stbName,i,stbName,i+1)
|
||||||
|
if (i > 0) and (i%100 == 0):
|
||||||
|
tsql.execute(sql)
|
||||||
|
sql = pre_create
|
||||||
|
if sql != pre_create:
|
||||||
|
tsql.execute(sql)
|
||||||
|
|
||||||
|
tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum))
|
||||||
|
return
|
||||||
|
|
||||||
|
def insert_data(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs):
|
||||||
|
tdLog.debug("start to insert data ............")
|
||||||
|
tsql.execute("use %s" %dbName)
|
||||||
|
pre_insert = "insert into "
|
||||||
|
sql = pre_insert
|
||||||
|
|
||||||
|
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
|
||||||
|
for i in range(ctbNum):
|
||||||
|
sql += " %s_%d values "%(stbName,i)
|
||||||
|
for j in range(rowsPerTbl):
|
||||||
|
sql += "(%d, %d, 'tmqrow_%d') "%(startTs + j, j, j)
|
||||||
|
if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)):
|
||||||
|
tsql.execute(sql)
|
||||||
|
if j < rowsPerTbl - 1:
|
||||||
|
sql = "insert into %s_%d values " %(stbName,i)
|
||||||
|
else:
|
||||||
|
sql = "insert into "
|
||||||
|
#end sql
|
||||||
|
if sql != pre_insert:
|
||||||
|
#print("insert sql:%s"%sql)
|
||||||
|
tsql.execute(sql)
|
||||||
|
tdLog.debug("insert data ............ [OK]")
|
||||||
|
return
|
||||||
|
|
||||||
|
def prepareEnv(self, **parameterDict):
|
||||||
|
print ("input parameters:")
|
||||||
|
print (parameterDict)
|
||||||
|
# create new connector for my thread
|
||||||
|
tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030)
|
||||||
|
self.create_tables(tsql,\
|
||||||
|
parameterDict["dbName"],\
|
||||||
|
parameterDict["vgroups"],\
|
||||||
|
parameterDict["stbName"],\
|
||||||
|
parameterDict["ctbNum"],\
|
||||||
|
parameterDict["rowsPerTbl"])
|
||||||
|
|
||||||
|
self.insert_data(tsql,\
|
||||||
|
parameterDict["dbName"],\
|
||||||
|
parameterDict["stbName"],\
|
||||||
|
parameterDict["ctbNum"],\
|
||||||
|
parameterDict["rowsPerTbl"],\
|
||||||
|
parameterDict["batchNum"],\
|
||||||
|
parameterDict["startTs"])
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def tmqCase1(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 1: Produce while consume")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db', \
|
||||||
|
'vgroups': 1, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 1000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
# wait stb ready
|
||||||
|
while 1:
|
||||||
|
tdSql.query("show %s.stables"%parameterDict['dbName'])
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
tdLog.info("create topics from super table")
|
||||||
|
topicFromStb = 'topic_stb_column'
|
||||||
|
topicFromCtb = 'topic_ctb_column'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb, parameterDict['dbName'], parameterDict['stbName']))
|
||||||
|
tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s_0" %(topicFromCtb, parameterDict['dbName'], parameterDict['stbName']))
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
tdSql.query("show topics")
|
||||||
|
#tdSql.checkRows(2)
|
||||||
|
topic1 = tdSql.getData(0 , 0)
|
||||||
|
topic2 = tdSql.getData(1 , 0)
|
||||||
|
|
||||||
|
tdLog.info("show topics: %s, %s"%(topic1, topic2))
|
||||||
|
if topic1 != topicFromStb and topic1 != topicFromCtb:
|
||||||
|
tdLog.exit("topic error1")
|
||||||
|
if topic2 != topicFromStb and topic2 != topicFromCtb:
|
||||||
|
tdLog.exit("topic error2")
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)")
|
||||||
|
tdSql.query("create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)")
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"]
|
||||||
|
topicList = topicFromStb
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into consumeinfo values "
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
tdLog.info("check stb if there are data")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select count(*) from %s"%parameterDict["stbName"])
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
countOfStb = tdSql.getData(0, 0)
|
||||||
|
if countOfStb != 0:
|
||||||
|
tdLog.info("count from stb: %d"%countOfStb)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
|
||||||
|
shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath
|
||||||
|
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName)
|
||||||
|
shellCmd += "> /dev/null 2>&1 &"
|
||||||
|
tdLog.info(shellCmd)
|
||||||
|
os.system(shellCmd)
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from consumeresult")
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
tdLog.info("consumer result: %d, %d"%(tdSql.getData(0 , 2), tdSql.getData(0 , 3)))
|
||||||
|
tdSql.checkData(0 , 1, consumerId)
|
||||||
|
# mulit rows and mulit tables in one sql, this num of msg is not sure
|
||||||
|
#tdSql.checkData(0 , 2, expectmsgcnt)
|
||||||
|
tdSql.checkData(0 , 3, expectrowcnt)
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicFromStb)
|
||||||
|
tdSql.query("drop topic %s"%topicFromCtb)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 1 end ...... ")
|
||||||
|
|
||||||
|
def tmqCase2(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 2: add child table with consuming ")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db2', \
|
||||||
|
'vgroups': 1, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 10000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
# wait db ready
|
||||||
|
while 1:
|
||||||
|
tdSql.query("show databases")
|
||||||
|
if tdSql.getRows() == 4:
|
||||||
|
print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0),)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
tdSql.query("use %s"%parameterDict['dbName'])
|
||||||
|
# wait stb ready
|
||||||
|
while 1:
|
||||||
|
tdSql.query("show %s.stables"%parameterDict['dbName'])
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
tdLog.info("create topics from super table")
|
||||||
|
topicFromStb = 'topic_stb_column2'
|
||||||
|
topicFromCtb = 'topic_ctb_column2'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb, parameterDict['dbName'], parameterDict['stbName']))
|
||||||
|
tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s_0" %(topicFromCtb, parameterDict['dbName'], parameterDict['stbName']))
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
tdSql.query("show topics")
|
||||||
|
topic1 = tdSql.getData(0 , 0)
|
||||||
|
topic2 = tdSql.getData(1 , 0)
|
||||||
|
tdLog.info("show topics: %s, %s"%(topic1, topic2))
|
||||||
|
if topic1 != topicFromStb and topic1 != topicFromCtb:
|
||||||
|
tdLog.exit("topic error1")
|
||||||
|
if topic2 != topicFromStb and topic2 != topicFromCtb:
|
||||||
|
tdLog.exit("topic error2")
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
rowsOfNewCtb = 1000
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + rowsOfNewCtb
|
||||||
|
topicList = topicFromStb
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into consumeinfo values "
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
tdLog.info("check stb if there are data")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select count(*) from %s"%parameterDict["stbName"])
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
countOfStb = tdSql.getData(0, 0)
|
||||||
|
if countOfStb != 0:
|
||||||
|
tdLog.info("count from stb: %d"%countOfStb)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
|
||||||
|
shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath
|
||||||
|
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName)
|
||||||
|
shellCmd += "> /dev/null 2>&1 &"
|
||||||
|
tdLog.info(shellCmd)
|
||||||
|
os.system(shellCmd)
|
||||||
|
|
||||||
|
# create new child table and insert data
|
||||||
|
newCtbName = 'newctb'
|
||||||
|
tdSql.query("create table %s.%s using %s.%s tags(9999)"%(parameterDict["dbName"], newCtbName, parameterDict["dbName"], parameterDict["stbName"]))
|
||||||
|
startTs = parameterDict["startTs"]
|
||||||
|
for j in range(rowsOfNewCtb):
|
||||||
|
sql = "insert into %s.%s values (%d, %d, 'tmqrow_%d') "%(parameterDict["dbName"], newCtbName, startTs + j, j, j)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
tdLog.debug("insert data into new child table ............ [OK]")
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from consumeresult")
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
tdSql.checkData(0 , 1, consumerId)
|
||||||
|
tdSql.checkData(0 , 3, expectrowcnt)
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicFromStb)
|
||||||
|
tdSql.query("drop topic %s"%topicFromCtb)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 2 end ...... ")
|
||||||
|
|
||||||
|
def tmqCase3(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 3: tow topics, each contains a stable, \
|
||||||
|
but at the beginning, no ctables in the stable of one topic,\
|
||||||
|
after starting consumer, create ctables ")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db3', \
|
||||||
|
'vgroups': 1, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 30000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
# wait db ready
|
||||||
|
while 1:
|
||||||
|
tdSql.query("show databases")
|
||||||
|
if tdSql.getRows() == 4:
|
||||||
|
print (tdSql.getData(0,0), tdSql.getData(1,0),tdSql.getData(2,0),)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
tdSql.query("use %s"%parameterDict['dbName'])
|
||||||
|
# wait stb ready
|
||||||
|
while 1:
|
||||||
|
tdSql.query("show %s.stables"%parameterDict['dbName'])
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
tdLog.info("create stable2 for the seconde topic")
|
||||||
|
parameterDict2 = {'cfg': '', \
|
||||||
|
'dbName': 'db3', \
|
||||||
|
'vgroups': 1, \
|
||||||
|
'stbName': 'stb2', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 30000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict2['cfg'] = cfgPath
|
||||||
|
tdSql.execute("create stable if not exists %s.%s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%(parameterDict2['dbName'], parameterDict2['stbName']))
|
||||||
|
|
||||||
|
tdLog.info("create topics from super table")
|
||||||
|
topicFromStb = 'topic_stb_column3'
|
||||||
|
topicFromStb2 = 'topic_stb_column32'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb, parameterDict['dbName'], parameterDict['stbName']))
|
||||||
|
tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb2, parameterDict2['dbName'], parameterDict2['stbName']))
|
||||||
|
|
||||||
|
tdSql.query("show topics")
|
||||||
|
topic1 = tdSql.getData(0 , 0)
|
||||||
|
topic2 = tdSql.getData(1 , 0)
|
||||||
|
tdLog.info("show topics: %s, %s"%(topic1, topic2))
|
||||||
|
if topic1 != topicFromStb and topic1 != topicFromStb2:
|
||||||
|
tdLog.exit("topic error1")
|
||||||
|
if topic2 != topicFromStb and topic2 != topicFromStb2:
|
||||||
|
tdLog.exit("topic error2")
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + parameterDict2["rowsPerTbl"] * parameterDict2["ctbNum"]
|
||||||
|
topicList = topicFromStb + ',' + topicFromStb2
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into consumeinfo values "
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
tdLog.info("check stb if there are data")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select count(*) from %s"%parameterDict["stbName"])
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
countOfStb = tdSql.getData(0, 0)
|
||||||
|
if countOfStb != 0:
|
||||||
|
tdLog.info("count from stb: %d"%countOfStb)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
|
||||||
|
shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath
|
||||||
|
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName)
|
||||||
|
shellCmd += "> /dev/null 2>&1 &"
|
||||||
|
tdLog.info(shellCmd)
|
||||||
|
os.system(shellCmd)
|
||||||
|
|
||||||
|
# start the second thread to create new child table and insert data
|
||||||
|
prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2)
|
||||||
|
prepareEnvThread2.start()
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
prepareEnvThread2.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from consumeresult")
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
tdSql.checkData(0 , 1, consumerId)
|
||||||
|
tdSql.checkData(0 , 3, expectrowcnt)
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicFromStb)
|
||||||
|
tdSql.query("drop topic %s"%topicFromStb2)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 3 end ...... ")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
buildPath = self.getBuildPath()
|
||||||
|
if (buildPath == ""):
|
||||||
|
tdLog.exit("taosd not found!")
|
||||||
|
else:
|
||||||
|
tdLog.info("taosd found in %s" % buildPath)
|
||||||
|
cfgPath = buildPath + "/../sim/psim/cfg"
|
||||||
|
tdLog.info("cfgPath: %s" % cfgPath)
|
||||||
|
|
||||||
|
#self.tmqCase1(cfgPath, buildPath)
|
||||||
|
#self.tmqCase2(cfgPath, buildPath)
|
||||||
|
self.tmqCase3(cfgPath, buildPath)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -0,0 +1,405 @@
|
||||||
|
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import socket
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
#rpcDebugFlagVal = '143'
|
||||||
|
#clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
|
||||||
|
#clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal
|
||||||
|
#updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
|
||||||
|
#updatecfgDict["rpcDebugFlag"] = rpcDebugFlagVal
|
||||||
|
#print ("===================: ", updatecfgDict)
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
#tdSql.init(conn.cursor())
|
||||||
|
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||||
|
|
||||||
|
def getBuildPath(self):
|
||||||
|
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
if ("community" in selfPath):
|
||||||
|
projPath = selfPath[:selfPath.find("community")]
|
||||||
|
else:
|
||||||
|
projPath = selfPath[:selfPath.find("tests")]
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(projPath):
|
||||||
|
if ("taosd" in files):
|
||||||
|
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||||
|
if ("packaging" not in rootRealPath):
|
||||||
|
buildPath = root[:len(root) - len("/build/bin")]
|
||||||
|
break
|
||||||
|
return buildPath
|
||||||
|
|
||||||
|
def newcur(self,cfg,host,port):
|
||||||
|
user = "root"
|
||||||
|
password = "taosdata"
|
||||||
|
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
|
||||||
|
cur=con.cursor()
|
||||||
|
print(cur)
|
||||||
|
return cur
|
||||||
|
|
||||||
|
def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg,showRow,cdbName,valgrind):
|
||||||
|
shellCmd = 'nohup '
|
||||||
|
if valgrind == 1:
|
||||||
|
logFile = cfgPath + '/../log/valgrind-tmq.log'
|
||||||
|
shellCmd = 'nohup valgrind --log-file=' + logFile
|
||||||
|
shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes '
|
||||||
|
|
||||||
|
shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath
|
||||||
|
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName)
|
||||||
|
shellCmd += "> /dev/null 2>&1 &"
|
||||||
|
tdLog.info(shellCmd)
|
||||||
|
os.system(shellCmd)
|
||||||
|
|
||||||
|
def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl):
|
||||||
|
tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups))
|
||||||
|
tsql.execute("use %s" %dbName)
|
||||||
|
tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName)
|
||||||
|
pre_create = "create table"
|
||||||
|
sql = pre_create
|
||||||
|
#tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname))
|
||||||
|
for i in range(ctbNum):
|
||||||
|
sql += " %s_%d using %s tags(%d)"%(stbName,i,stbName,i+1)
|
||||||
|
if (i > 0) and (i%100 == 0):
|
||||||
|
tsql.execute(sql)
|
||||||
|
sql = pre_create
|
||||||
|
if sql != pre_create:
|
||||||
|
tsql.execute(sql)
|
||||||
|
|
||||||
|
event.set()
|
||||||
|
tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum))
|
||||||
|
return
|
||||||
|
|
||||||
|
def insert_data(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs):
|
||||||
|
tdLog.debug("start to insert data ............")
|
||||||
|
tsql.execute("use %s" %dbName)
|
||||||
|
pre_insert = "insert into "
|
||||||
|
sql = pre_insert
|
||||||
|
|
||||||
|
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
|
||||||
|
for i in range(ctbNum):
|
||||||
|
sql += " %s_%d values "%(stbName,i)
|
||||||
|
for j in range(rowsPerTbl):
|
||||||
|
sql += "(%d, %d, 'tmqrow_%d') "%(startTs + j, j, j)
|
||||||
|
if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)):
|
||||||
|
tsql.execute(sql)
|
||||||
|
if j < rowsPerTbl - 1:
|
||||||
|
sql = "insert into %s_%d values " %(stbName,i)
|
||||||
|
else:
|
||||||
|
sql = "insert into "
|
||||||
|
#end sql
|
||||||
|
if sql != pre_insert:
|
||||||
|
#print("insert sql:%s"%sql)
|
||||||
|
tsql.execute(sql)
|
||||||
|
tdLog.debug("insert data ............ [OK]")
|
||||||
|
return
|
||||||
|
|
||||||
|
def prepareEnv(self, **parameterDict):
|
||||||
|
print ("input parameters:")
|
||||||
|
print (parameterDict)
|
||||||
|
# create new connector for my thread
|
||||||
|
tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030)
|
||||||
|
self.create_tables(tsql,\
|
||||||
|
parameterDict["dbName"],\
|
||||||
|
parameterDict["vgroups"],\
|
||||||
|
parameterDict["stbName"],\
|
||||||
|
parameterDict["ctbNum"],\
|
||||||
|
parameterDict["rowsPerTbl"])
|
||||||
|
|
||||||
|
self.insert_data(tsql,\
|
||||||
|
parameterDict["dbName"],\
|
||||||
|
parameterDict["stbName"],\
|
||||||
|
parameterDict["ctbNum"],\
|
||||||
|
parameterDict["rowsPerTbl"],\
|
||||||
|
parameterDict["batchNum"],\
|
||||||
|
parameterDict["startTs"])
|
||||||
|
return
|
||||||
|
|
||||||
|
def tmqCase1(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 1: Produce while one consume to subscribe one db")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db1', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 10000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups']))
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
tdLog.info("create topics from db")
|
||||||
|
topicName1 = 'topic_db1'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as %s" %(topicName1, parameterDict['dbName']))
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"]
|
||||||
|
topicList = topicName1
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
event.wait()
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
|
||||||
|
valgrind = 1
|
||||||
|
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow, cdbName,valgrind)
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from %s.consumeresult"%cdbName)
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
tdLog.info("consumer result: %d, %d"%(tdSql.getData(0 , 2), tdSql.getData(0 , 3)))
|
||||||
|
tdSql.checkData(0 , 1, consumerId)
|
||||||
|
# mulit rows and mulit tables in one sql, this num of msg is not sure
|
||||||
|
#tdSql.checkData(0 , 2, expectmsgcnt)
|
||||||
|
tdSql.checkData(0 , 3, expectrowcnt)
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicName1)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 1 end ...... ")
|
||||||
|
|
||||||
|
def tmqCase2(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 2: Produce while two consumers to subscribe one db")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db2', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups']))
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
tdLog.info("create topics from db")
|
||||||
|
topicName1 = 'topic_db1'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as %s" %(topicName1, parameterDict['dbName']))
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"]
|
||||||
|
topicList = topicName1
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
consumerId = 1
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
event.wait()
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
|
||||||
|
valgrind = 1
|
||||||
|
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow, cdbName,valgrind)
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from %s.consumeresult"%cdbName)
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 2:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
consumerId0 = tdSql.getData(0 , 1)
|
||||||
|
consumerId1 = tdSql.getData(1 , 1)
|
||||||
|
actConsumeRows0 = tdSql.getData(0 , 3)
|
||||||
|
actConsumeRows1 = tdSql.getData(1 , 3)
|
||||||
|
|
||||||
|
tdLog.info("consumer %d rows: %d"%(consumerId0, actConsumeRows0))
|
||||||
|
tdLog.info("consumer %d rows: %d"%(consumerId1, actConsumeRows1))
|
||||||
|
|
||||||
|
totalConsumeRows = actConsumeRows0 + actConsumeRows1
|
||||||
|
if totalConsumeRows != expectrowcnt:
|
||||||
|
tdLog.exit("tmq consume rows error!")
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicName1)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 2 end ...... ")
|
||||||
|
|
||||||
|
def tmqCase3(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 3: Produce while one consumers to subscribe one db, include 2 stb")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db3', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups']))
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
parameterDict2 = {'cfg': '', \
|
||||||
|
'dbName': 'db3', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb2', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2)
|
||||||
|
prepareEnvThread2.start()
|
||||||
|
|
||||||
|
tdLog.info("create topics from db")
|
||||||
|
topicName1 = 'topic_db1'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as %s" %(topicName1, parameterDict['dbName']))
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + parameterDict2["rowsPerTbl"] * parameterDict2["ctbNum"]
|
||||||
|
topicList = topicName1
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
# consumerId = 1
|
||||||
|
# sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
# sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
# tdSql.query(sql)
|
||||||
|
|
||||||
|
event.wait()
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
valgrind = 1
|
||||||
|
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow, cdbName,valgrind)
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
prepareEnvThread2.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from %s.consumeresult"%cdbName)
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
consumerId0 = tdSql.getData(0 , 1)
|
||||||
|
#consumerId1 = tdSql.getData(1 , 1)
|
||||||
|
actConsumeRows0 = tdSql.getData(0 , 3)
|
||||||
|
#actConsumeRows1 = tdSql.getData(1 , 3)
|
||||||
|
|
||||||
|
tdLog.info("consumer %d rows: %d"%(consumerId0, actConsumeRows0))
|
||||||
|
#tdLog.info("consumer %d rows: %d"%(consumerId1, actConsumeRows1))
|
||||||
|
|
||||||
|
#totalConsumeRows = actConsumeRows0 + actConsumeRows1
|
||||||
|
if actConsumeRows0 != expectrowcnt:
|
||||||
|
tdLog.exit("tmq consume rows error!")
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicName1)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 3 end ...... ")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
buildPath = self.getBuildPath()
|
||||||
|
if (buildPath == ""):
|
||||||
|
tdLog.exit("taosd not found!")
|
||||||
|
else:
|
||||||
|
tdLog.info("taosd found in %s" % buildPath)
|
||||||
|
cfgPath = buildPath + "/../sim/psim/cfg"
|
||||||
|
tdLog.info("cfgPath: %s" % cfgPath)
|
||||||
|
|
||||||
|
self.tmqCase1(cfgPath, buildPath)
|
||||||
|
#self.tmqCase2(cfgPath, buildPath)
|
||||||
|
#self.tmqCase3(cfgPath, buildPath)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
event = threading.Event()
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -0,0 +1,400 @@
|
||||||
|
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import socket
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
#rpcDebugFlagVal = '143'
|
||||||
|
#clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
|
||||||
|
#clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal
|
||||||
|
#updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''}
|
||||||
|
#updatecfgDict["rpcDebugFlag"] = rpcDebugFlagVal
|
||||||
|
#print ("===================: ", updatecfgDict)
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
#tdSql.init(conn.cursor())
|
||||||
|
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||||
|
|
||||||
|
def getBuildPath(self):
|
||||||
|
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
if ("community" in selfPath):
|
||||||
|
projPath = selfPath[:selfPath.find("community")]
|
||||||
|
else:
|
||||||
|
projPath = selfPath[:selfPath.find("tests")]
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(projPath):
|
||||||
|
if ("taosd" in files):
|
||||||
|
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||||
|
if ("packaging" not in rootRealPath):
|
||||||
|
buildPath = root[:len(root) - len("/build/bin")]
|
||||||
|
break
|
||||||
|
return buildPath
|
||||||
|
|
||||||
|
def newcur(self,cfg,host,port):
|
||||||
|
user = "root"
|
||||||
|
password = "taosdata"
|
||||||
|
con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port)
|
||||||
|
cur=con.cursor()
|
||||||
|
print(cur)
|
||||||
|
return cur
|
||||||
|
|
||||||
|
def startTmqSimProcess(self,buildPath,cfgPath,pollDelay,dbName,showMsg,showRow,cdbName,valgrind=0):
|
||||||
|
shellCmd = 'nohup '
|
||||||
|
if valgrind == 1:
|
||||||
|
logFile = cfgPath + '/../log/valgrind-tmq.log'
|
||||||
|
shellCmd = 'nohup valgrind --log-file=' + logFile
|
||||||
|
shellCmd += '--tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all --num-callers=20 -v --workaround-gcc296-bugs=yes '
|
||||||
|
|
||||||
|
shellCmd += buildPath + '/build/bin/tmq_sim -c ' + cfgPath
|
||||||
|
shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, dbName, showMsg, showRow, cdbName)
|
||||||
|
shellCmd += "> /dev/null 2>&1 &"
|
||||||
|
tdLog.info(shellCmd)
|
||||||
|
os.system(shellCmd)
|
||||||
|
|
||||||
|
def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl):
|
||||||
|
tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups))
|
||||||
|
tsql.execute("use %s" %dbName)
|
||||||
|
tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName)
|
||||||
|
pre_create = "create table"
|
||||||
|
sql = pre_create
|
||||||
|
#tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname))
|
||||||
|
for i in range(ctbNum):
|
||||||
|
sql += " %s_%d using %s tags(%d)"%(stbName,i,stbName,i+1)
|
||||||
|
if (i > 0) and (i%100 == 0):
|
||||||
|
tsql.execute(sql)
|
||||||
|
sql = pre_create
|
||||||
|
if sql != pre_create:
|
||||||
|
tsql.execute(sql)
|
||||||
|
|
||||||
|
event.set()
|
||||||
|
tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum))
|
||||||
|
return
|
||||||
|
|
||||||
|
def insert_data(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs):
|
||||||
|
tdLog.debug("start to insert data ............")
|
||||||
|
tsql.execute("use %s" %dbName)
|
||||||
|
pre_insert = "insert into "
|
||||||
|
sql = pre_insert
|
||||||
|
|
||||||
|
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
|
||||||
|
for i in range(ctbNum):
|
||||||
|
sql += " %s_%d values "%(stbName,i)
|
||||||
|
for j in range(rowsPerTbl):
|
||||||
|
sql += "(%d, %d, 'tmqrow_%d') "%(startTs + j, j, j)
|
||||||
|
if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)):
|
||||||
|
tsql.execute(sql)
|
||||||
|
if j < rowsPerTbl - 1:
|
||||||
|
sql = "insert into %s_%d values " %(stbName,i)
|
||||||
|
else:
|
||||||
|
sql = "insert into "
|
||||||
|
#end sql
|
||||||
|
if sql != pre_insert:
|
||||||
|
#print("insert sql:%s"%sql)
|
||||||
|
tsql.execute(sql)
|
||||||
|
tdLog.debug("insert data ............ [OK]")
|
||||||
|
return
|
||||||
|
|
||||||
|
def prepareEnv(self, **parameterDict):
|
||||||
|
print ("input parameters:")
|
||||||
|
print (parameterDict)
|
||||||
|
# create new connector for my thread
|
||||||
|
tsql=self.newcur(parameterDict['cfg'], 'localhost', 6030)
|
||||||
|
self.create_tables(tsql,\
|
||||||
|
parameterDict["dbName"],\
|
||||||
|
parameterDict["vgroups"],\
|
||||||
|
parameterDict["stbName"],\
|
||||||
|
parameterDict["ctbNum"],\
|
||||||
|
parameterDict["rowsPerTbl"])
|
||||||
|
|
||||||
|
self.insert_data(tsql,\
|
||||||
|
parameterDict["dbName"],\
|
||||||
|
parameterDict["stbName"],\
|
||||||
|
parameterDict["ctbNum"],\
|
||||||
|
parameterDict["rowsPerTbl"],\
|
||||||
|
parameterDict["batchNum"],\
|
||||||
|
parameterDict["startTs"])
|
||||||
|
return
|
||||||
|
|
||||||
|
def tmqCase1(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 1: Produce while one consume to subscribe one db")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db1', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 200, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups']))
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
tdLog.info("create topics from db")
|
||||||
|
topicName1 = 'topic_db1'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as %s" %(topicName1, parameterDict['dbName']))
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"]
|
||||||
|
topicList = topicName1
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
event.wait()
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow, cdbName)
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from %s.consumeresult"%cdbName)
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
tdLog.info("consumer result: %d, %d"%(tdSql.getData(0 , 2), tdSql.getData(0 , 3)))
|
||||||
|
tdSql.checkData(0 , 1, consumerId)
|
||||||
|
# mulit rows and mulit tables in one sql, this num of msg is not sure
|
||||||
|
#tdSql.checkData(0 , 2, expectmsgcnt)
|
||||||
|
tdSql.checkData(0 , 3, expectrowcnt+1)
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicName1)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 1 end ...... ")
|
||||||
|
|
||||||
|
def tmqCase2(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 2: Produce while two consumers to subscribe one db")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db2', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups']))
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
tdLog.info("create topics from db")
|
||||||
|
topicName1 = 'topic_db1'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as %s" %(topicName1, parameterDict['dbName']))
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"]
|
||||||
|
topicList = topicName1
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
consumerId = 1
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
event.wait()
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow, cdbName)
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from %s.consumeresult"%cdbName)
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 2:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
consumerId0 = tdSql.getData(0 , 1)
|
||||||
|
consumerId1 = tdSql.getData(1 , 1)
|
||||||
|
actConsumeRows0 = tdSql.getData(0 , 3)
|
||||||
|
actConsumeRows1 = tdSql.getData(1 , 3)
|
||||||
|
|
||||||
|
tdLog.info("consumer %d rows: %d"%(consumerId0, actConsumeRows0))
|
||||||
|
tdLog.info("consumer %d rows: %d"%(consumerId1, actConsumeRows1))
|
||||||
|
|
||||||
|
totalConsumeRows = actConsumeRows0 + actConsumeRows1
|
||||||
|
if totalConsumeRows != expectrowcnt + 2:
|
||||||
|
tdLog.exit("tmq consume rows error!")
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicName1)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 2 end ...... ")
|
||||||
|
|
||||||
|
def tmqCase3(self, cfgPath, buildPath):
|
||||||
|
tdLog.printNoPrefix("======== test case 3: Produce while one consumers to subscribe one db, include 2 stb")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'cfg': '', \
|
||||||
|
'dbName': 'db3', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups']))
|
||||||
|
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
parameterDict2 = {'cfg': '', \
|
||||||
|
'dbName': 'db3', \
|
||||||
|
'vgroups': 4, \
|
||||||
|
'stbName': 'stb2', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 100000, \
|
||||||
|
'batchNum': 100, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
parameterDict['cfg'] = cfgPath
|
||||||
|
|
||||||
|
prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2)
|
||||||
|
prepareEnvThread2.start()
|
||||||
|
|
||||||
|
tdLog.info("create topics from db")
|
||||||
|
topicName1 = 'topic_db1'
|
||||||
|
|
||||||
|
tdSql.execute("create topic %s as %s" %(topicName1, parameterDict['dbName']))
|
||||||
|
|
||||||
|
tdLog.info("create consume info table and consume result table")
|
||||||
|
cdbName = parameterDict["dbName"]
|
||||||
|
tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)"%cdbName)
|
||||||
|
tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName)
|
||||||
|
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = parameterDict["rowsPerTbl"] * parameterDict["ctbNum"] + parameterDict2["rowsPerTbl"] * parameterDict2["ctbNum"]
|
||||||
|
topicList = topicName1
|
||||||
|
ifcheckdata = 0
|
||||||
|
keyList = 'group.id:cgrp1,\
|
||||||
|
enable.auto.commit:false,\
|
||||||
|
auto.commit.interval.ms:6000,\
|
||||||
|
auto.offset.reset:earliest'
|
||||||
|
sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
tdSql.query(sql)
|
||||||
|
|
||||||
|
# consumerId = 1
|
||||||
|
# sql = "insert into %s.consumeinfo values "%cdbName
|
||||||
|
# sql += "(now, %d, '%s', '%s', %d, %d)"%(consumerId, topicList, keyList, expectrowcnt, ifcheckdata)
|
||||||
|
# tdSql.query(sql)
|
||||||
|
|
||||||
|
event.wait()
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
pollDelay = 5
|
||||||
|
showMsg = 1
|
||||||
|
showRow = 1
|
||||||
|
self.startTmqSimProcess(buildPath,cfgPath,pollDelay,parameterDict["dbName"],showMsg, showRow, cdbName)
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
prepareEnvThread2.join()
|
||||||
|
|
||||||
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
|
while 1:
|
||||||
|
tdSql.query("select * from %s.consumeresult"%cdbName)
|
||||||
|
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
|
||||||
|
if tdSql.getRows() == 1:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
consumerId0 = tdSql.getData(0 , 1)
|
||||||
|
#consumerId1 = tdSql.getData(1 , 1)
|
||||||
|
actConsumeRows0 = tdSql.getData(0 , 3)
|
||||||
|
#actConsumeRows1 = tdSql.getData(1 , 3)
|
||||||
|
|
||||||
|
tdLog.info("consumer %d rows: %d"%(consumerId0, actConsumeRows0))
|
||||||
|
#tdLog.info("consumer %d rows: %d"%(consumerId1, actConsumeRows1))
|
||||||
|
|
||||||
|
#totalConsumeRows = actConsumeRows0 + actConsumeRows1
|
||||||
|
if actConsumeRows0 != expectrowcnt + 1:
|
||||||
|
tdLog.exit("tmq consume rows error!")
|
||||||
|
|
||||||
|
tdSql.query("drop topic %s"%topicName1)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 3 end ...... ")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
buildPath = self.getBuildPath()
|
||||||
|
if (buildPath == ""):
|
||||||
|
tdLog.exit("taosd not found!")
|
||||||
|
else:
|
||||||
|
tdLog.info("taosd found in %s" % buildPath)
|
||||||
|
cfgPath = buildPath + "/../sim/psim/cfg"
|
||||||
|
tdLog.info("cfgPath: %s" % cfgPath)
|
||||||
|
|
||||||
|
#self.tmqCase1(cfgPath, buildPath)
|
||||||
|
self.tmqCase2(cfgPath, buildPath)
|
||||||
|
#self.tmqCase3(cfgPath, buildPath)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
event = threading.Event()
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -179,7 +179,7 @@ void parseArgument(int32_t argc, char* argv[]) {
|
||||||
} else if (strcmp(argv[i], "-y") == 0) {
|
} else if (strcmp(argv[i], "-y") == 0) {
|
||||||
g_stConfInfo.consumeDelay = atol(argv[++i]);
|
g_stConfInfo.consumeDelay = atol(argv[++i]);
|
||||||
} else {
|
} else {
|
||||||
printf("%s unknow para: %s %s", GREEN, argv[++i], NC);
|
pError("%s unknow para: %s %s", GREEN, argv[++i], NC);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ int queryDB(TAOS* taos, char* command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tmq_commit_cb_print(tmq_t* tmq, tmq_resp_err_t resp, tmq_topic_vgroup_list_t* offsets, void* param) {
|
static void tmq_commit_cb_print(tmq_t* tmq, tmq_resp_err_t resp, tmq_topic_vgroup_list_t* offsets, void* param) {
|
||||||
printf("tmq_commit_cb_print() commit %d\n", resp);
|
pError("tmq_commit_cb_print() commit %d\n", resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void build_consumer(SThreadInfo* pInfo) {
|
void build_consumer(SThreadInfo* pInfo) {
|
||||||
|
@ -318,7 +318,7 @@ int32_t saveConsumeResult(SThreadInfo* pInfo) {
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, sqlStr);
|
TAOS_RES* pRes = taos_query(pConn, sqlStr);
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("error in save consumeinfo, reason:%s\n", taos_errstr(pRes));
|
pError("error in save consumeinfo, reason:%s\n", taos_errstr(pRes));
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ void* consumeThreadFunc(void* param) {
|
||||||
|
|
||||||
tmq_resp_err_t err = tmq_subscribe(pInfo->tmq, pInfo->topicList);
|
tmq_resp_err_t err = tmq_subscribe(pInfo->tmq, pInfo->topicList);
|
||||||
if (err) {
|
if (err) {
|
||||||
printf("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err));
|
pError("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,14 +388,14 @@ void* consumeThreadFunc(void* param) {
|
||||||
|
|
||||||
err = tmq_unsubscribe(pInfo->tmq);
|
err = tmq_unsubscribe(pInfo->tmq);
|
||||||
if (err) {
|
if (err) {
|
||||||
printf("tmq_unsubscribe() fail, reason: %s\n", tmq_err2str(err));
|
pError("tmq_unsubscribe() fail, reason: %s\n", tmq_err2str(err));
|
||||||
pInfo->consumeMsgCnt = -1;
|
pInfo->consumeMsgCnt = -1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = tmq_consumer_close(pInfo->tmq);
|
err = tmq_consumer_close(pInfo->tmq);
|
||||||
if (err) {
|
if (err) {
|
||||||
printf("tmq_consumer_close() fail, reason: %s\n", tmq_err2str(err));
|
pError("tmq_consumer_close() fail, reason: %s\n", tmq_err2str(err));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
pInfo->tmq = NULL;
|
pInfo->tmq = NULL;
|
||||||
|
@ -451,7 +451,7 @@ int32_t getConsumeInfo() {
|
||||||
sprintf(sqlStr, "select * from %s.consumeinfo", g_stConfInfo.cdbName);
|
sprintf(sqlStr, "select * from %s.consumeinfo", g_stConfInfo.cdbName);
|
||||||
TAOS_RES* pRes = taos_query(pConn, sqlStr);
|
TAOS_RES* pRes = taos_query(pConn, sqlStr);
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("error in get consumeinfo, reason:%s\n", taos_errstr(pRes));
|
pError("error in get consumeinfo, reason:%s\n", taos_errstr(pRes));
|
||||||
taosFprintfFile(g_fp, "error in get consumeinfo, reason:%s\n", taos_errstr(pRes));
|
taosFprintfFile(g_fp, "error in get consumeinfo, reason:%s\n", taos_errstr(pRes));
|
||||||
taosCloseFile(&g_fp);
|
taosCloseFile(&g_fp);
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
echo "$0"
|
||||||
|
echo -e "\t -e enterprise edition"
|
||||||
|
echo -e "\t -h help"
|
||||||
|
}
|
||||||
|
|
||||||
|
ent=0
|
||||||
|
while getopts "eh" opt; do
|
||||||
|
case $opt in
|
||||||
|
e)
|
||||||
|
ent=1
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG"
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
script_dir=`dirname $0`
|
||||||
|
cd ${script_dir}
|
||||||
|
PWD=`pwd`
|
||||||
|
|
||||||
|
if [ $ent -eq 0 ]; then
|
||||||
|
cd ../../debug
|
||||||
|
else
|
||||||
|
cd ../../../debug
|
||||||
|
fi
|
||||||
|
|
||||||
|
ctest -j8
|
||||||
|
ret=$?
|
||||||
|
exit $ret
|
||||||
|
|
|
@ -332,7 +332,7 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) {
|
||||||
shellInitArgs(argc, argv);
|
shellInitArgs(argc, argv);
|
||||||
shell.info.clientVersion =
|
shell.info.clientVersion =
|
||||||
"Welcome to the TDengine shell from %s, Client Version:%s\n"
|
"Welcome to the TDengine shell from %s, Client Version:%s\n"
|
||||||
"Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.\n\n";
|
"Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.\n\n";
|
||||||
shell.info.promptHeader = "taos> ";
|
shell.info.promptHeader = "taos> ";
|
||||||
shell.info.promptContinue = " -> ";
|
shell.info.promptContinue = " -> ";
|
||||||
shell.info.promptSize = 6;
|
shell.info.promptSize = 6;
|
||||||
|
|
|
@ -53,79 +53,6 @@ static void shellResetCommand(SShellCmd *cmd, const char s[]);
|
||||||
static void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos);
|
static void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos);
|
||||||
static void shellShowOnScreen(SShellCmd *cmd);
|
static void shellShowOnScreen(SShellCmd *cmd);
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
|
||||||
// static void shellPrintContinuePrompt() { printf("%s", shell.args.promptContinue); }
|
|
||||||
// static void shellPrintPrompt() { printf("%s", shell.args.promptHeader); }
|
|
||||||
|
|
||||||
void shellUpdateBuffer(SShellCmd *cmd) {
|
|
||||||
if (shellRegexMatch(cmd->buffer, "(\\s+$)|(^$)", REG_EXTENDED)) strcat(cmd->command, " ");
|
|
||||||
strcat(cmd->buffer, cmd->command);
|
|
||||||
|
|
||||||
memset(cmd->command, 0, SHELL_MAX_COMMAND_SIZE);
|
|
||||||
cmd->cursorOffset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int shellIsReadyGo(SShellCmd *cmd) {
|
|
||||||
char *total = taosMemoryMalloc(SHELL_MAX_COMMAND_SIZE);
|
|
||||||
memset(total, 0, SHELL_MAX_COMMAND_SIZE);
|
|
||||||
sprintf(total, "%s%s", cmd->buffer, cmd->command);
|
|
||||||
|
|
||||||
char *reg_str =
|
|
||||||
"(^.*;\\s*$)|(^\\s*$)|(^\\s*exit\\s*$)|(^\\s*q\\s*$)|(^\\s*quit\\s*$)|(^"
|
|
||||||
"\\s*clear\\s*$)";
|
|
||||||
if (shellRegexMatch(total, reg_str, REG_EXTENDED | REG_ICASE)) {
|
|
||||||
taosMemoryFree(total);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFree(total);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void shellInsertChar(SShellCmd *cmd, char c) {
|
|
||||||
if (cmd->cursorOffset >= SHELL_MAX_COMMAND_SIZE) {
|
|
||||||
fprintf(stdout, "sql is larger than %d bytes", SHELL_MAX_COMMAND_SIZE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cmd->command[cmd->cursorOffset++] = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t shellReadCommand(char command[]) {
|
|
||||||
SShellCmd cmd;
|
|
||||||
memset(&cmd, 0, sizeof(cmd));
|
|
||||||
cmd.buffer = (char *)taosMemoryCalloc(1, SHELL_MAX_COMMAND_SIZE);
|
|
||||||
cmd.command = (char *)taosMemoryCalloc(1, SHELL_MAX_COMMAND_SIZE);
|
|
||||||
|
|
||||||
// Read input.
|
|
||||||
char c;
|
|
||||||
while (1) {
|
|
||||||
c = getchar();
|
|
||||||
|
|
||||||
switch (c) {
|
|
||||||
case '\n':
|
|
||||||
case '\r':
|
|
||||||
if (shellIsReadyGo(&cmd)) {
|
|
||||||
sprintf(command, "%s%s", cmd.buffer, cmd.command);
|
|
||||||
taosMemoryFree(cmd.buffer);
|
|
||||||
cmd.buffer = NULL;
|
|
||||||
taosMemoryFree(cmd.command);
|
|
||||||
cmd.command = NULL;
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
// shellPrintContinuePrompt();
|
|
||||||
shellUpdateBuffer(&cmd);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
shellInsertChar(&cmd, c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int32_t shellCountPrefixOnes(uint8_t c) {
|
int32_t shellCountPrefixOnes(uint8_t c) {
|
||||||
uint8_t mask = 127;
|
uint8_t mask = 127;
|
||||||
mask = ~mask;
|
mask = ~mask;
|
||||||
|
@ -181,7 +108,10 @@ void shellInsertChar(SShellCmd *cmd, char *c, int32_t size) {
|
||||||
cmd->cursorOffset += size;
|
cmd->cursorOffset += size;
|
||||||
cmd->screenOffset += taosWcharWidth(wc);
|
cmd->screenOffset += taosWcharWidth(wc);
|
||||||
cmd->endOffset += taosWcharWidth(wc);
|
cmd->endOffset += taosWcharWidth(wc);
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#else
|
||||||
shellShowOnScreen(cmd);
|
shellShowOnScreen(cmd);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void shellBackspaceChar(SShellCmd *cmd) {
|
void shellBackspaceChar(SShellCmd *cmd) {
|
||||||
|
@ -371,17 +301,33 @@ void shellResetCommand(SShellCmd *cmd, const char s[]) {
|
||||||
shellShowOnScreen(cmd);
|
shellShowOnScreen(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos) {
|
|
||||||
|
void shellGetScreenSize(int32_t *ws_col, int32_t *ws_row) {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
|
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
|
||||||
|
if (ws_col != NULL) *ws_col = csbi.srWindow.Right - csbi.srWindow.Left + 1;
|
||||||
|
if (ws_row != NULL) *ws_row = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
|
||||||
|
#else
|
||||||
struct winsize w;
|
struct winsize w;
|
||||||
if (ioctl(0, TIOCGWINSZ, &w) < 0 || w.ws_col == 0 || w.ws_row == 0) {
|
if (ioctl(0, TIOCGWINSZ, &w) < 0 || w.ws_col == 0 || w.ws_row == 0) {
|
||||||
// fprintf(stderr, "No stream device, and use default value(col 120, row 30)\n");
|
// fprintf(stderr, "No stream device, and use default value(col 120, row 30)\n");
|
||||||
w.ws_col = 120;
|
if (ws_col != NULL) *ws_col = 120;
|
||||||
w.ws_row = 30;
|
if (ws_row != NULL) *ws_row = 30;
|
||||||
|
} else {
|
||||||
|
if (ws_col != NULL) *ws_col = w.ws_col;
|
||||||
|
if (ws_row != NULL) *ws_row = w.ws_row;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t cursor_x = cursor_pos / w.ws_col;
|
void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos) {
|
||||||
int32_t cursor_y = cursor_pos % w.ws_col;
|
int32_t ws_col;
|
||||||
int32_t command_x = ecmd_pos / w.ws_col;
|
shellGetScreenSize(&ws_col, NULL);
|
||||||
|
|
||||||
|
int32_t cursor_x = cursor_pos / ws_col;
|
||||||
|
int32_t cursor_y = cursor_pos % ws_col;
|
||||||
|
int32_t command_x = ecmd_pos / ws_col;
|
||||||
shellPositionCursor(cursor_y, LEFT);
|
shellPositionCursor(cursor_y, LEFT);
|
||||||
shellPositionCursor(command_x - cursor_x, DOWN);
|
shellPositionCursor(command_x - cursor_x, DOWN);
|
||||||
fprintf(stdout, "\033[2K");
|
fprintf(stdout, "\033[2K");
|
||||||
|
@ -393,12 +339,8 @@ void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void shellShowOnScreen(SShellCmd *cmd) {
|
void shellShowOnScreen(SShellCmd *cmd) {
|
||||||
struct winsize w;
|
int32_t ws_col;
|
||||||
if (ioctl(0, TIOCGWINSZ, &w) < 0 || w.ws_col == 0 || w.ws_row == 0) {
|
shellGetScreenSize(&ws_col, NULL);
|
||||||
// fprintf(stderr, "No stream device\n");
|
|
||||||
w.ws_col = 120;
|
|
||||||
w.ws_row = 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
TdWchar wc;
|
TdWchar wc;
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
|
@ -411,8 +353,7 @@ void shellShowOnScreen(SShellCmd *cmd) {
|
||||||
} else {
|
} else {
|
||||||
sprintf(total_string, "%s%s", shell.info.promptContinue, cmd->command);
|
sprintf(total_string, "%s%s", shell.info.promptContinue, cmd->command);
|
||||||
}
|
}
|
||||||
|
int32_t remain_column = ws_col;
|
||||||
int32_t remain_column = w.ws_col;
|
|
||||||
for (char *str = total_string; size < cmd->commandSize + PSIZE;) {
|
for (char *str = total_string; size < cmd->commandSize + PSIZE;) {
|
||||||
int32_t ret = taosMbToWchar(&wc, str, MB_CUR_MAX);
|
int32_t ret = taosMbToWchar(&wc, str, MB_CUR_MAX);
|
||||||
if (ret < 0) break;
|
if (ret < 0) break;
|
||||||
|
@ -425,10 +366,10 @@ void shellShowOnScreen(SShellCmd *cmd) {
|
||||||
} else {
|
} else {
|
||||||
if (remain_column == width) {
|
if (remain_column == width) {
|
||||||
printf("%lc\n\r", wc);
|
printf("%lc\n\r", wc);
|
||||||
remain_column = w.ws_col;
|
remain_column = ws_col;
|
||||||
} else {
|
} else {
|
||||||
printf("\n\r%lc", wc);
|
printf("\n\r%lc", wc);
|
||||||
remain_column = w.ws_col - width;
|
remain_column = ws_col - width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,17 +377,16 @@ void shellShowOnScreen(SShellCmd *cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(total_string);
|
taosMemoryFree(total_string);
|
||||||
|
|
||||||
// Position the cursor
|
// Position the cursor
|
||||||
int32_t cursor_pos = cmd->screenOffset + PSIZE;
|
int32_t cursor_pos = cmd->screenOffset + PSIZE;
|
||||||
int32_t ecmd_pos = cmd->endOffset + PSIZE;
|
int32_t ecmd_pos = cmd->endOffset + PSIZE;
|
||||||
|
|
||||||
int32_t cursor_x = cursor_pos / w.ws_col;
|
int32_t cursor_x = cursor_pos / ws_col;
|
||||||
int32_t cursor_y = cursor_pos % w.ws_col;
|
int32_t cursor_y = cursor_pos % ws_col;
|
||||||
// int32_t cursor_y = cursor % w.ws_col;
|
// int32_t cursor_y = cursor % ws_col;
|
||||||
int32_t command_x = ecmd_pos / w.ws_col;
|
int32_t command_x = ecmd_pos / ws_col;
|
||||||
int32_t command_y = ecmd_pos % w.ws_col;
|
int32_t command_y = ecmd_pos % ws_col;
|
||||||
// int32_t command_y = (command.size() + PSIZE) % w.ws_col;
|
// int32_t command_y = (command.size() + PSIZE) % ws_col;
|
||||||
shellPositionCursor(command_y, LEFT);
|
shellPositionCursor(command_y, LEFT);
|
||||||
shellPositionCursor(command_x, UP);
|
shellPositionCursor(command_x, UP);
|
||||||
shellPositionCursor(cursor_x, DOWN);
|
shellPositionCursor(cursor_x, DOWN);
|
||||||
|
@ -490,7 +430,11 @@ int32_t shellReadCommand(char *command) {
|
||||||
case 3:
|
case 3:
|
||||||
printf("\n");
|
printf("\n");
|
||||||
shellResetCommand(&cmd, "");
|
shellResetCommand(&cmd, "");
|
||||||
|
#ifdef WINDOWS
|
||||||
|
raise(SIGINT);
|
||||||
|
#else
|
||||||
kill(0, SIGINT);
|
kill(0, SIGINT);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case 4: // EOF or Ctrl+D
|
case 4: // EOF or Ctrl+D
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -503,7 +447,10 @@ int32_t shellReadCommand(char *command) {
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#else
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
#endif
|
||||||
if (shellIsReadyGo(&cmd)) {
|
if (shellIsReadyGo(&cmd)) {
|
||||||
sprintf(command, "%s%s", cmd.buffer, cmd.command);
|
sprintf(command, "%s%s", cmd.buffer, cmd.command);
|
||||||
taosMemoryFreeClear(cmd.buffer);
|
taosMemoryFreeClear(cmd.buffer);
|
||||||
|
@ -608,5 +555,3 @@ int32_t shellReadCommand(char *command) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -29,11 +29,11 @@ static void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD
|
||||||
static int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres);
|
static int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres);
|
||||||
static void shellPrintNChar(const char *str, int32_t length, int32_t width);
|
static void shellPrintNChar(const char *str, int32_t length, int32_t width);
|
||||||
static void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t length, int32_t precision);
|
static void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t length, int32_t precision);
|
||||||
static int32_t shellVerticalPrintResult(TAOS_RES *tres);
|
static int32_t shellVerticalPrintResult(TAOS_RES *tres, const char *sql);
|
||||||
static int32_t shellCalcColWidth(TAOS_FIELD *field, int32_t precision);
|
static int32_t shellCalcColWidth(TAOS_FIELD *field, int32_t precision);
|
||||||
static void shellPrintHeader(TAOS_FIELD *fields, int32_t *width, int32_t num_fields);
|
static void shellPrintHeader(TAOS_FIELD *fields, int32_t *width, int32_t num_fields);
|
||||||
static int32_t shellHorizontalPrintResult(TAOS_RES *tres);
|
static int32_t shellHorizontalPrintResult(TAOS_RES *tres, const char *sql);
|
||||||
static int32_t shellDumpResult(TAOS_RES *tres, char *fname, int32_t *error_no, bool vertical);
|
static int32_t shellDumpResult(TAOS_RES *tres, char *fname, int32_t *error_no, bool vertical, const char *sql);
|
||||||
static void shellReadHistory();
|
static void shellReadHistory();
|
||||||
static void shellWriteHistory();
|
static void shellWriteHistory();
|
||||||
static void shellPrintError(TAOS_RES *tres, int64_t st);
|
static void shellPrintError(TAOS_RES *tres, int64_t st);
|
||||||
|
@ -190,7 +190,7 @@ void shellRunSingleCommandImp(char *command) {
|
||||||
if (pFields != NULL) { // select and show kinds of commands
|
if (pFields != NULL) { // select and show kinds of commands
|
||||||
int32_t error_no = 0;
|
int32_t error_no = 0;
|
||||||
|
|
||||||
int32_t numOfRows = shellDumpResult(pSql, fname, &error_no, printMode);
|
int32_t numOfRows = shellDumpResult(pSql, fname, &error_no, printMode, command);
|
||||||
if (numOfRows < 0) return;
|
if (numOfRows < 0) return;
|
||||||
|
|
||||||
et = taosGetTimestampUs();
|
et = taosGetTimestampUs();
|
||||||
|
@ -272,6 +272,7 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int n;
|
||||||
char buf[TSDB_MAX_BYTES_PER_ROW];
|
char buf[TSDB_MAX_BYTES_PER_ROW];
|
||||||
switch (field->type) {
|
switch (field->type) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
|
@ -280,20 +281,37 @@ void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, i
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
taosFprintfFile(pFile, "%d", *((int8_t *)val));
|
taosFprintfFile(pFile, "%d", *((int8_t *)val));
|
||||||
break;
|
break;
|
||||||
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
|
taosFprintfFile(pFile, "%u", *((uint8_t *)val));
|
||||||
|
break;
|
||||||
case TSDB_DATA_TYPE_SMALLINT:
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
taosFprintfFile(pFile, "%d", *((int16_t *)val));
|
taosFprintfFile(pFile, "%d", *((int16_t *)val));
|
||||||
break;
|
break;
|
||||||
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
|
taosFprintfFile(pFile, "%u", *((uint16_t *)val));
|
||||||
|
break;
|
||||||
case TSDB_DATA_TYPE_INT:
|
case TSDB_DATA_TYPE_INT:
|
||||||
taosFprintfFile(pFile, "%d", *((int32_t *)val));
|
taosFprintfFile(pFile, "%d", *((int32_t *)val));
|
||||||
break;
|
break;
|
||||||
|
case TSDB_DATA_TYPE_UINT:
|
||||||
|
taosFprintfFile(pFile, "%u", *((uint32_t *)val));
|
||||||
|
break;
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
taosFprintfFile(pFile, "%" PRId64, *((int64_t *)val));
|
taosFprintfFile(pFile, "%" PRId64, *((int64_t *)val));
|
||||||
break;
|
break;
|
||||||
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
|
taosFprintfFile(pFile, "%" PRIu64, *((uint64_t *)val));
|
||||||
|
break;
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
taosFprintfFile(pFile, "%.5f", GET_FLOAT_VAL(val));
|
taosFprintfFile(pFile, "%.5f", GET_FLOAT_VAL(val));
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
taosFprintfFile(pFile, "%.9f", GET_DOUBLE_VAL(val));
|
n = snprintf(buf, TSDB_MAX_BYTES_PER_ROW, "%*.9f", length, GET_DOUBLE_VAL(val));
|
||||||
|
if (n > TMAX(25, length)) {
|
||||||
|
taosFprintfFile(pFile, "%*.15e", length, GET_DOUBLE_VAL(val));
|
||||||
|
} else {
|
||||||
|
taosFprintfFile(pFile, "%s", buf);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
|
@ -435,6 +453,7 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int n;
|
||||||
char buf[TSDB_MAX_BYTES_PER_ROW];
|
char buf[TSDB_MAX_BYTES_PER_ROW];
|
||||||
switch (field->type) {
|
switch (field->type) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
|
@ -468,7 +487,12 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t
|
||||||
printf("%*.5f", width, GET_FLOAT_VAL(val));
|
printf("%*.5f", width, GET_FLOAT_VAL(val));
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
printf("%*.9f", width, GET_DOUBLE_VAL(val));
|
n = snprintf(buf, TSDB_MAX_BYTES_PER_ROW, "%*.9f", width, GET_DOUBLE_VAL(val));
|
||||||
|
if (n > TMAX(25, width)) {
|
||||||
|
printf("%*.15e", width, GET_DOUBLE_VAL(val));
|
||||||
|
} else {
|
||||||
|
printf("%s", buf);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
|
@ -483,7 +507,16 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t shellVerticalPrintResult(TAOS_RES *tres) {
|
bool shellIsLimitQuery(const char *sql) {
|
||||||
|
//todo refactor
|
||||||
|
if (strcasestr(sql, " limit ") != NULL) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t shellVerticalPrintResult(TAOS_RES *tres, const char *sql) {
|
||||||
TAOS_ROW row = taos_fetch_row(tres);
|
TAOS_ROW row = taos_fetch_row(tres);
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -503,7 +536,7 @@ int32_t shellVerticalPrintResult(TAOS_RES *tres) {
|
||||||
|
|
||||||
uint64_t resShowMaxNum = UINT64_MAX;
|
uint64_t resShowMaxNum = UINT64_MAX;
|
||||||
|
|
||||||
if (shell.args.commands == NULL && shell.args.file[0] == 0) {
|
if (shell.args.commands == NULL && shell.args.file[0] == 0 && !shellIsLimitQuery(sql)) {
|
||||||
resShowMaxNum = SHELL_DEFAULT_RES_SHOW_NUM;
|
resShowMaxNum = SHELL_DEFAULT_RES_SHOW_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,8 +558,13 @@ int32_t shellVerticalPrintResult(TAOS_RES *tres) {
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
} else if (showMore) {
|
} else if (showMore) {
|
||||||
printf("[100 Rows showed, and more rows are fetching but will not be showed. You can ctrl+c to stop or wait.]\n");
|
printf("\n");
|
||||||
printf("[You can add limit statement to get more or redirect results to specific file to get all.]\n");
|
printf(" Notice: The result shows only the first %d rows.\n", SHELL_DEFAULT_RES_SHOW_NUM);
|
||||||
|
printf(" You can use the `LIMIT` clause to get fewer result to show.\n");
|
||||||
|
printf(" Or use '>>' to redirect the whole set of the result to a specified file.\n");
|
||||||
|
printf("\n");
|
||||||
|
printf(" You can use Ctrl+C to stop the underway fetching.\n");
|
||||||
|
printf("\n");
|
||||||
showMore = 0;
|
showMore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,7 +656,7 @@ void shellPrintHeader(TAOS_FIELD *fields, int32_t *width, int32_t num_fields) {
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t shellHorizontalPrintResult(TAOS_RES *tres) {
|
int32_t shellHorizontalPrintResult(TAOS_RES *tres, const char *sql) {
|
||||||
TAOS_ROW row = taos_fetch_row(tres);
|
TAOS_ROW row = taos_fetch_row(tres);
|
||||||
if (row == NULL) {
|
if (row == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -637,7 +675,7 @@ int32_t shellHorizontalPrintResult(TAOS_RES *tres) {
|
||||||
|
|
||||||
uint64_t resShowMaxNum = UINT64_MAX;
|
uint64_t resShowMaxNum = UINT64_MAX;
|
||||||
|
|
||||||
if (shell.args.commands == NULL && shell.args.file[0] == 0) {
|
if (shell.args.commands == NULL && shell.args.file[0] == 0 && !shellIsLimitQuery(sql)) {
|
||||||
resShowMaxNum = SHELL_DEFAULT_RES_SHOW_NUM;
|
resShowMaxNum = SHELL_DEFAULT_RES_SHOW_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,8 +693,13 @@ int32_t shellHorizontalPrintResult(TAOS_RES *tres) {
|
||||||
}
|
}
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
} else if (showMore) {
|
} else if (showMore) {
|
||||||
printf("[100 Rows showed, and more rows are fetching but will not be showed. You can ctrl+c to stop or wait.]\n");
|
printf("\n");
|
||||||
printf("[You can add limit statement to show more or redirect results to specific file to get all.]\n");
|
printf(" Notice: The result shows only the first %d rows.\n", SHELL_DEFAULT_RES_SHOW_NUM);
|
||||||
|
printf(" You can use the `LIMIT` clause to get fewer result to show.\n");
|
||||||
|
printf(" Or use '>>' to redirect the whole set of the result to a specified file.\n");
|
||||||
|
printf("\n");
|
||||||
|
printf(" You can use Ctrl+C to stop the underway fetching.\n");
|
||||||
|
printf("\n");
|
||||||
showMore = 0;
|
showMore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,14 +710,14 @@ int32_t shellHorizontalPrintResult(TAOS_RES *tres) {
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t shellDumpResult(TAOS_RES *tres, char *fname, int32_t *error_no, bool vertical) {
|
int32_t shellDumpResult(TAOS_RES *tres, char *fname, int32_t *error_no, bool vertical, const char *sql) {
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
if (fname != NULL) {
|
if (fname != NULL) {
|
||||||
numOfRows = shellDumpResultToFile(fname, tres);
|
numOfRows = shellDumpResultToFile(fname, tres);
|
||||||
} else if (vertical) {
|
} else if (vertical) {
|
||||||
numOfRows = shellVerticalPrintResult(tres);
|
numOfRows = shellVerticalPrintResult(tres, sql);
|
||||||
} else {
|
} else {
|
||||||
numOfRows = shellHorizontalPrintResult(tres);
|
numOfRows = shellHorizontalPrintResult(tres, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
*error_no = taos_errno(tres);
|
*error_no = taos_errno(tres);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0ae9f872c26d5da8cb61aa9eb00b5c7aeba10ec4
|
Subproject commit 0aad27d725f4ee6b18daf1db0c07d933aed16eea
|
Loading…
Reference in New Issue