Merge branch 'feature/qnode' of https://github.com/taosdata/TDengine into feature/qnode
This commit is contained in:
commit
314c15d366
81
Jenkinsfile2
81
Jenkinsfile2
|
@ -47,36 +47,67 @@ def pre_test(){
|
||||||
script {
|
script {
|
||||||
if (env.CHANGE_TARGET == 'master') {
|
if (env.CHANGE_TARGET == 'master') {
|
||||||
sh '''
|
sh '''
|
||||||
|
cd ${WK}
|
||||||
|
git checkout master
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
git checkout master
|
git checkout master
|
||||||
'''
|
'''
|
||||||
} else if(env.CHANGE_TARGET == '2.0') {
|
} else if(env.CHANGE_TARGET == '2.0') {
|
||||||
sh '''
|
sh '''
|
||||||
|
cd ${WK}
|
||||||
|
git checkout 2.0
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
git checkout 2.0
|
git checkout 2.0
|
||||||
'''
|
'''
|
||||||
} else if(env.CHANGE_TARGET == '3.0') {
|
} else if(env.CHANGE_TARGET == '3.0') {
|
||||||
sh '''
|
sh '''
|
||||||
|
cd ${WK}
|
||||||
|
git checkout 3.0
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
git checkout 3.0
|
git checkout 3.0
|
||||||
[ -d contrib/bdb ] && cd contrib/bdb && git clean -fxd && cd ../..
|
|
||||||
'''
|
'''
|
||||||
} else {
|
} else {
|
||||||
sh '''
|
sh '''
|
||||||
|
cd ${WK}
|
||||||
|
git checkout develop
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
git checkout develop
|
git checkout develop
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (env.CHANGE_URL =~ /\/TDengine\//) {
|
||||||
|
sh '''
|
||||||
|
cd ${WKC}
|
||||||
|
git pull >/dev/null
|
||||||
|
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||||
|
git checkout -qf FETCH_HEAD
|
||||||
|
git log|head -n20
|
||||||
|
cd ${WK}
|
||||||
|
git pull >/dev/null
|
||||||
|
git log|head -n20
|
||||||
|
'''
|
||||||
|
} else if (env.CHANGE_URL =~ /\/TDinternal\//) {
|
||||||
|
sh '''
|
||||||
|
cd ${WK}
|
||||||
|
git pull >/dev/null
|
||||||
|
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
||||||
|
git checkout -qf FETCH_HEAD
|
||||||
|
git log|head -n20
|
||||||
|
cd ${WKC}
|
||||||
|
git pull >/dev/null
|
||||||
|
git log|head -n20
|
||||||
|
'''
|
||||||
|
} else {
|
||||||
|
sh '''
|
||||||
|
echo "unmatched reposiotry ${CHANGE_URL}"
|
||||||
|
'''
|
||||||
|
}
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
git pull >/dev/null
|
|
||||||
git fetch origin +refs/pull/${CHANGE_ID}/merge
|
|
||||||
git checkout -qf FETCH_HEAD
|
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
'''
|
'''
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WKC}
|
cd ${WK}
|
||||||
export TZ=Asia/Harbin
|
export TZ=Asia/Harbin
|
||||||
date
|
date
|
||||||
rm -rf debug
|
rm -rf debug
|
||||||
|
@ -162,8 +193,8 @@ pipeline {
|
||||||
options { skipDefaultCheckout() }
|
options { skipDefaultCheckout() }
|
||||||
environment{
|
environment{
|
||||||
WK = '/var/lib/jenkins/workspace/TDinternal'
|
WK = '/var/lib/jenkins/workspace/TDinternal'
|
||||||
WKC= '/var/lib/jenkins/workspace/TDengine'
|
WKC = '/var/lib/jenkins/workspace/TDinternal/community'
|
||||||
WKPY= '/var/lib/jenkins/workspace/taos-connector-python'
|
WKPY = '/var/lib/jenkins/workspace/taos-connector-python'
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('run test') {
|
stage('run test') {
|
||||||
|
@ -177,15 +208,33 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
timeout(time: 45, unit: 'MINUTES'){
|
timeout(time: 45, unit: 'MINUTES'){
|
||||||
pre_test()
|
pre_test()
|
||||||
sh '''
|
script {
|
||||||
cd ${WKC}/debug
|
if (env.CHANGE_URL =~ /\/TDengine\//) {
|
||||||
ctest -VV
|
sh '''
|
||||||
'''
|
cd ${WK}/debug
|
||||||
sh '''
|
ctest -VV
|
||||||
export LD_LIBRARY_PATH=${WKC}/debug/build/lib
|
'''
|
||||||
cd ${WKC}/tests/system-test
|
sh '''
|
||||||
./fulltest.sh
|
export LD_LIBRARY_PATH=${WK}/debug/build/lib
|
||||||
'''
|
cd ${WKC}/tests/system-test
|
||||||
|
./fulltest.sh
|
||||||
|
'''
|
||||||
|
} 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 '''
|
sh '''
|
||||||
cd ${WKC}/tests
|
cd ${WKC}/tests
|
||||||
./test-all.sh b1fq
|
./test-all.sh b1fq
|
||||||
|
|
|
@ -85,11 +85,11 @@ ELSE ()
|
||||||
|
|
||||||
IF (${SANITIZER} MATCHES "true")
|
IF (${SANITIZER} MATCHES "true")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
|
||||||
MESSAGE(STATUS "Will compile with Address Sanitizer!")
|
MESSAGE(STATUS "Will compile with Address Sanitizer!")
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-literal-suffix -Werror=return-type -fpermissive -fPIC -gdwarf-2 -g3")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
|
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
|
|
@ -89,7 +89,7 @@ extern char *qtypeStr[];
|
||||||
|
|
||||||
#define TSDB_PORT_HTTP 11
|
#define TSDB_PORT_HTTP 11
|
||||||
|
|
||||||
#define TD_DEBUG_PRINT_ROW
|
#undef TD_DEBUG_PRINT_ROW
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "talgo.h"
|
#include "talgo.h"
|
||||||
|
#include "tencode.h"
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
|
@ -25,6 +26,73 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct SSchema SSchema;
|
||||||
|
typedef struct STColumn STColumn;
|
||||||
|
typedef struct STSchema STSchema;
|
||||||
|
typedef struct STSRow2 STSRow2;
|
||||||
|
typedef struct STSRowBuilder STSRowBuilder;
|
||||||
|
typedef struct SKVIdx SKVIdx;
|
||||||
|
|
||||||
|
// STSchema
|
||||||
|
|
||||||
|
// STSRow2
|
||||||
|
int32_t tEncodeTSRow(SEncoder *pEncoder, const STSRow2 *pRow);
|
||||||
|
int32_t tDecodeTSRow(SDecoder *pDecoder, STSRow2 *pRow);
|
||||||
|
|
||||||
|
// STSchema
|
||||||
|
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema **ppTSchema);
|
||||||
|
void tTSchemaDestroy(STSchema *pTSchema);
|
||||||
|
|
||||||
|
// STSRowBuilder
|
||||||
|
int32_t tTSRowBuilderInit(STSRowBuilder *pBuilder, int32_t sver, SSchema *pSchema, int32_t nCols);
|
||||||
|
void tTSRowBuilderClear(STSRowBuilder *pBuilder);
|
||||||
|
void tTSRowBuilderReset(STSRowBuilder *pBuilder);
|
||||||
|
int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, const uint8_t *pData, uint32_t nData);
|
||||||
|
int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow);
|
||||||
|
|
||||||
|
// STRUCT =================
|
||||||
|
struct STColumn {
|
||||||
|
col_id_t colId;
|
||||||
|
int8_t type;
|
||||||
|
int8_t flags;
|
||||||
|
int32_t bytes;
|
||||||
|
int32_t offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct STSchema {
|
||||||
|
int32_t numOfCols;
|
||||||
|
int32_t version;
|
||||||
|
int32_t flen;
|
||||||
|
int32_t vlen;
|
||||||
|
int32_t tlen;
|
||||||
|
STColumn columns[];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct STSRow2 {
|
||||||
|
TSKEY ts;
|
||||||
|
uint32_t flags;
|
||||||
|
union {
|
||||||
|
int32_t sver;
|
||||||
|
int32_t ncols;
|
||||||
|
};
|
||||||
|
uint32_t nData;
|
||||||
|
const uint8_t *pData;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct STSRowBuilder {
|
||||||
|
STColumn *pTColumn;
|
||||||
|
STSchema *pTSchema;
|
||||||
|
int32_t szKVBuf;
|
||||||
|
uint8_t *pKVBuf;
|
||||||
|
int32_t szTPBuf;
|
||||||
|
uint8_t *pTPBuf;
|
||||||
|
int32_t nCols;
|
||||||
|
int32_t kvVLen;
|
||||||
|
int32_t tpVLen;
|
||||||
|
STSRow2 row;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 1 //====================================
|
||||||
// Imported since 3.0 and use bitmap to demonstrate None/Null/Norm, while use Null/Norm below 3.0 without of bitmap.
|
// Imported since 3.0 and use bitmap to demonstrate None/Null/Norm, while use Null/Norm below 3.0 without of bitmap.
|
||||||
#define TD_SUPPORT_BITMAP
|
#define TD_SUPPORT_BITMAP
|
||||||
#define TD_SUPPORT_READ2
|
#define TD_SUPPORT_READ2
|
||||||
|
@ -59,15 +127,6 @@ extern "C" {
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
// ----------------- TSDB COLUMN DEFINITION
|
// ----------------- TSDB COLUMN DEFINITION
|
||||||
#pragma pack(push, 1)
|
|
||||||
typedef struct {
|
|
||||||
col_id_t colId; // column ID(start from PRIMARYKEY_TIMESTAMP_COL_ID(1))
|
|
||||||
int8_t type; // column type
|
|
||||||
int8_t flags; // flags: 0 no index, 1 SCHEMA_SMA_ON, 2 SCHEMA_IDX_ON
|
|
||||||
int32_t bytes; // column bytes (0~16M)
|
|
||||||
int32_t offset; // point offset in STpRow after the header part.
|
|
||||||
} STColumn;
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
#define colType(col) ((col)->type)
|
#define colType(col) ((col)->type)
|
||||||
#define colFlags(col) ((col)->flags)
|
#define colFlags(col) ((col)->flags)
|
||||||
|
@ -82,15 +141,6 @@ typedef struct {
|
||||||
#define colSetOffset(col, o) (colOffset(col) = (o))
|
#define colSetOffset(col, o) (colOffset(col) = (o))
|
||||||
|
|
||||||
// ----------------- TSDB SCHEMA DEFINITION
|
// ----------------- TSDB SCHEMA DEFINITION
|
||||||
typedef struct {
|
|
||||||
int32_t numOfCols; // Number of columns appended
|
|
||||||
schema_ver_t version; // schema version
|
|
||||||
uint16_t flen; // First part length in a STpRow after the header part
|
|
||||||
int32_t vlen; // pure value part length, excluded the overhead (bytes only)
|
|
||||||
int32_t tlen; // maximum length of a STpRow without the header part
|
|
||||||
// (sizeof(VarDataOffsetT) + sizeof(VarDataLenT) + (bytes))
|
|
||||||
STColumn columns[];
|
|
||||||
} STSchema;
|
|
||||||
|
|
||||||
#define schemaNCols(s) ((s)->numOfCols)
|
#define schemaNCols(s) ((s)->numOfCols)
|
||||||
#define schemaVersion(s) ((s)->version)
|
#define schemaVersion(s) ((s)->version)
|
||||||
|
@ -386,6 +436,7 @@ static FORCE_INLINE int32_t tdAddColToKVRow(SKVRowBuilder *pBuilder, col_id_t co
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,8 +273,10 @@ int32_t tEncodeSSubmitRsp(SEncoder* pEncoder, const SSubmitRsp* pRsp);
|
||||||
int32_t tDecodeSSubmitRsp(SDecoder* pDecoder, SSubmitRsp* pRsp);
|
int32_t tDecodeSSubmitRsp(SDecoder* pDecoder, SSubmitRsp* pRsp);
|
||||||
void tFreeSSubmitRsp(SSubmitRsp *pRsp);
|
void tFreeSSubmitRsp(SSubmitRsp *pRsp);
|
||||||
|
|
||||||
#define SCHEMA_SMA_ON 0x1
|
#define COL_SMA_ON ((int8_t)0x1)
|
||||||
#define SCHEMA_IDX_ON 0x2
|
#define COL_IDX_ON ((int8_t)0x2)
|
||||||
|
#define COL_VAL_SET ((int8_t)0x4)
|
||||||
|
|
||||||
typedef struct SSchema {
|
typedef struct SSchema {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
int8_t flags;
|
int8_t flags;
|
||||||
|
@ -283,7 +285,7 @@ typedef struct SSchema {
|
||||||
char name[TSDB_COL_NAME_LEN];
|
char name[TSDB_COL_NAME_LEN];
|
||||||
} SSchema;
|
} SSchema;
|
||||||
|
|
||||||
#define IS_BSMA_ON(s) (((s)->flags & 0x01) == SCHEMA_SMA_ON)
|
#define IS_BSMA_ON(s) (((s)->flags & 0x01) == COL_SMA_ON)
|
||||||
|
|
||||||
#define SSCHMEA_TYPE(s) ((s)->type)
|
#define SSCHMEA_TYPE(s) ((s)->type)
|
||||||
#define SSCHMEA_FLAGS(s) ((s)->flags)
|
#define SSCHMEA_FLAGS(s) ((s)->flags)
|
||||||
|
@ -297,6 +299,109 @@ typedef struct {
|
||||||
SSchema* pSchema;
|
SSchema* pSchema;
|
||||||
} SSchemaWrapper;
|
} SSchemaWrapper;
|
||||||
|
|
||||||
|
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
|
||||||
|
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
|
||||||
|
if (pSW == NULL) return pSW;
|
||||||
|
pSW->nCols = pSchemaWrapper->nCols;
|
||||||
|
pSW->sver = pSchemaWrapper->sver;
|
||||||
|
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||||
|
if (pSW->pSchema == NULL) {
|
||||||
|
taosMemoryFree(pSW);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
|
||||||
|
return pSW;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void tDeleteSSchemaWrapper(SSchemaWrapper* pSchemaWrapper) {
|
||||||
|
taosMemoryFree(pSchemaWrapper->pSchema);
|
||||||
|
taosMemoryFree(pSchemaWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) {
|
||||||
|
int32_t tlen = 0;
|
||||||
|
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
||||||
|
tlen += taosEncodeFixedI8(buf, pSchema->flags);
|
||||||
|
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
|
||||||
|
tlen += taosEncodeFixedI16(buf, pSchema->colId);
|
||||||
|
tlen += taosEncodeString(buf, pSchema->name);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void* taosDecodeSSchema(const void* buf, SSchema* pSchema) {
|
||||||
|
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
||||||
|
buf = taosDecodeFixedI8(buf, &pSchema->flags);
|
||||||
|
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
||||||
|
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
||||||
|
buf = taosDecodeStringTo(buf, pSchema->name);
|
||||||
|
return (void*)buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tEncodeSSchema(SEncoder* pEncoder, const SSchema* pSchema) {
|
||||||
|
if (tEncodeI8(pEncoder, pSchema->type) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pSchema->flags) < 0) return -1;
|
||||||
|
if (tEncodeI32v(pEncoder, pSchema->bytes) < 0) return -1;
|
||||||
|
if (tEncodeI16v(pEncoder, pSchema->colId) < 0) return -1;
|
||||||
|
if (tEncodeCStr(pEncoder, pSchema->name) < 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tDecodeSSchema(SDecoder* pDecoder, SSchema* pSchema) {
|
||||||
|
if (tDecodeI8(pDecoder, &pSchema->type) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pSchema->flags) < 0) return -1;
|
||||||
|
if (tDecodeI32v(pDecoder, &pSchema->bytes) < 0) return -1;
|
||||||
|
if (tDecodeI16v(pDecoder, &pSchema->colId) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(pDecoder, pSchema->name) < 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWrapper* pSW) {
|
||||||
|
int32_t tlen = 0;
|
||||||
|
tlen += taosEncodeVariantI32(buf, pSW->nCols);
|
||||||
|
tlen += taosEncodeVariantI32(buf, pSW->sver);
|
||||||
|
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||||
|
tlen += taosEncodeSSchema(buf, &pSW->pSchema[i]);
|
||||||
|
}
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapper* pSW) {
|
||||||
|
buf = taosDecodeVariantI32(buf, &pSW->nCols);
|
||||||
|
buf = taosDecodeVariantI32(buf, &pSW->sver);
|
||||||
|
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||||
|
if (pSW->pSchema == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||||
|
buf = taosDecodeSSchema(buf, &pSW->pSchema[i]);
|
||||||
|
}
|
||||||
|
return (void*)buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSchemaWrapper* pSW) {
|
||||||
|
if (tEncodeI32v(pEncoder, pSW->nCols) < 0) return -1;
|
||||||
|
if (tEncodeI32v(pEncoder, pSW->sver) < 0) return -1;
|
||||||
|
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||||
|
if (tEncodeSSchema(pEncoder, &pSW->pSchema[i]) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
||||||
|
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
||||||
|
if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1;
|
||||||
|
|
||||||
|
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||||
|
if (pSW->pSchema == NULL) return -1;
|
||||||
|
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||||
|
if (tDecodeSSchema(pDecoder, &pSW->pSchema[i]) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
STSchema* tdGetSTSChemaFromSSChema(SSchema** pSchema, int32_t nCols);
|
STSchema* tdGetSTSChemaFromSSChema(SSchema** pSchema, int32_t nCols);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1880,7 +1985,7 @@ typedef struct SMqHbTopicInfo {
|
||||||
int32_t epoch;
|
int32_t epoch;
|
||||||
int64_t topicUid;
|
int64_t topicUid;
|
||||||
char name[TSDB_TOPIC_FNAME_LEN];
|
char name[TSDB_TOPIC_FNAME_LEN];
|
||||||
SArray* pVgInfo;
|
SArray* pVgInfo; // SArray<SMqHbVgInfo>
|
||||||
} SMqHbTopicInfo;
|
} SMqHbTopicInfo;
|
||||||
|
|
||||||
static FORCE_INLINE int32_t taosEncodeSMqHbTopicInfoMsg(void** buf, const SMqHbTopicInfo* pTopicInfo) {
|
static FORCE_INLINE int32_t taosEncodeSMqHbTopicInfoMsg(void** buf, const SMqHbTopicInfo* pTopicInfo) {
|
||||||
|
@ -1999,49 +2104,6 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
|
||||||
return (void*)buf;
|
return (void*)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int8_t reserved;
|
|
||||||
} SMqRebVgRsp;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int64_t leftForVer;
|
|
||||||
int32_t vgId;
|
|
||||||
int32_t epoch;
|
|
||||||
int64_t consumerId;
|
|
||||||
char topicName[TSDB_TOPIC_FNAME_LEN];
|
|
||||||
char cgroup[TSDB_CGROUP_LEN];
|
|
||||||
char* sql;
|
|
||||||
char* physicalPlan;
|
|
||||||
char* qmsg;
|
|
||||||
} SMqSetCVgReq;
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSMqSetCVgReq(void** buf, const SMqSetCVgReq* pReq) {
|
|
||||||
int32_t tlen = 0;
|
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->leftForVer);
|
|
||||||
tlen += taosEncodeFixedI32(buf, pReq->vgId);
|
|
||||||
tlen += taosEncodeFixedI32(buf, pReq->epoch);
|
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->consumerId);
|
|
||||||
tlen += taosEncodeString(buf, pReq->topicName);
|
|
||||||
tlen += taosEncodeString(buf, pReq->cgroup);
|
|
||||||
tlen += taosEncodeString(buf, pReq->sql);
|
|
||||||
tlen += taosEncodeString(buf, pReq->physicalPlan);
|
|
||||||
tlen += taosEncodeString(buf, pReq->qmsg);
|
|
||||||
return tlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void* tDecodeSMqSetCVgReq(void* buf, SMqSetCVgReq* pReq) {
|
|
||||||
buf = taosDecodeFixedI64(buf, &pReq->leftForVer);
|
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->vgId);
|
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->epoch);
|
|
||||||
buf = taosDecodeFixedI64(buf, &pReq->consumerId);
|
|
||||||
buf = taosDecodeStringTo(buf, pReq->topicName);
|
|
||||||
buf = taosDecodeStringTo(buf, pReq->cgroup);
|
|
||||||
buf = taosDecodeString(buf, &pReq->sql);
|
|
||||||
buf = taosDecodeString(buf, &pReq->physicalPlan);
|
|
||||||
buf = taosDecodeString(buf, &pReq->qmsg);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
|
@ -2063,109 +2125,6 @@ int32_t tDecodeSMqOffset(SDecoder* decoder, SMqOffset* pOffset);
|
||||||
int32_t tEncodeSMqCMCommitOffsetReq(SEncoder* encoder, const SMqCMCommitOffsetReq* pReq);
|
int32_t tEncodeSMqCMCommitOffsetReq(SEncoder* encoder, const SMqCMCommitOffsetReq* pReq);
|
||||||
int32_t tDecodeSMqCMCommitOffsetReq(SDecoder* decoder, SMqCMCommitOffsetReq* pReq);
|
int32_t tDecodeSMqCMCommitOffsetReq(SDecoder* decoder, SMqCMCommitOffsetReq* pReq);
|
||||||
|
|
||||||
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
|
|
||||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
|
|
||||||
if (pSW == NULL) return pSW;
|
|
||||||
pSW->nCols = pSchemaWrapper->nCols;
|
|
||||||
pSW->sver = pSchemaWrapper->sver;
|
|
||||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
|
||||||
if (pSW->pSchema == NULL) {
|
|
||||||
taosMemoryFree(pSW);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
|
|
||||||
return pSW;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void tDeleteSSchemaWrapper(SSchemaWrapper* pSchemaWrapper) {
|
|
||||||
taosMemoryFree(pSchemaWrapper->pSchema);
|
|
||||||
taosMemoryFree(pSchemaWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) {
|
|
||||||
int32_t tlen = 0;
|
|
||||||
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
|
||||||
tlen += taosEncodeFixedI8(buf, pSchema->flags);
|
|
||||||
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
|
|
||||||
tlen += taosEncodeFixedI16(buf, pSchema->colId);
|
|
||||||
tlen += taosEncodeString(buf, pSchema->name);
|
|
||||||
return tlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void* taosDecodeSSchema(const void* buf, SSchema* pSchema) {
|
|
||||||
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
|
||||||
buf = taosDecodeFixedI8(buf, &pSchema->flags);
|
|
||||||
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
|
||||||
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
|
||||||
buf = taosDecodeStringTo(buf, pSchema->name);
|
|
||||||
return (void*)buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSSchema(SEncoder* pEncoder, const SSchema* pSchema) {
|
|
||||||
if (tEncodeI8(pEncoder, pSchema->type) < 0) return -1;
|
|
||||||
if (tEncodeI8(pEncoder, pSchema->flags) < 0) return -1;
|
|
||||||
if (tEncodeI32v(pEncoder, pSchema->bytes) < 0) return -1;
|
|
||||||
if (tEncodeI16v(pEncoder, pSchema->colId) < 0) return -1;
|
|
||||||
if (tEncodeCStr(pEncoder, pSchema->name) < 0) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeSSchema(SDecoder* pDecoder, SSchema* pSchema) {
|
|
||||||
if (tDecodeI8(pDecoder, &pSchema->type) < 0) return -1;
|
|
||||||
if (tDecodeI8(pDecoder, &pSchema->flags) < 0) return -1;
|
|
||||||
if (tDecodeI32v(pDecoder, &pSchema->bytes) < 0) return -1;
|
|
||||||
if (tDecodeI16v(pDecoder, &pSchema->colId) < 0) return -1;
|
|
||||||
if (tDecodeCStrTo(pDecoder, pSchema->name) < 0) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWrapper* pSW) {
|
|
||||||
int32_t tlen = 0;
|
|
||||||
tlen += taosEncodeVariantI32(buf, pSW->nCols);
|
|
||||||
tlen += taosEncodeVariantI32(buf, pSW->sver);
|
|
||||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
|
||||||
tlen += taosEncodeSSchema(buf, &pSW->pSchema[i]);
|
|
||||||
}
|
|
||||||
return tlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void* taosDecodeSSchemaWrapper(const void* buf, SSchemaWrapper* pSW) {
|
|
||||||
buf = taosDecodeVariantI32(buf, &pSW->nCols);
|
|
||||||
buf = taosDecodeVariantI32(buf, &pSW->sver);
|
|
||||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
|
||||||
if (pSW->pSchema == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
|
||||||
buf = taosDecodeSSchema(buf, &pSW->pSchema[i]);
|
|
||||||
}
|
|
||||||
return (void*)buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SEncoder* pEncoder, const SSchemaWrapper* pSW) {
|
|
||||||
if (tEncodeI32v(pEncoder, pSW->nCols) < 0) return -1;
|
|
||||||
if (tEncodeI32v(pEncoder, pSW->sver) < 0) return -1;
|
|
||||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
|
||||||
if (tEncodeSSchema(pEncoder, &pSW->pSchema[i]) < 0) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SDecoder* pDecoder, SSchemaWrapper* pSW) {
|
|
||||||
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
|
||||||
if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1;
|
|
||||||
|
|
||||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
|
||||||
if (pSW->pSchema == NULL) return -1;
|
|
||||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
|
||||||
if (tDecodeSSchema(pDecoder, &pSW->pSchema[i]) < 0) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
char stb[TSDB_TABLE_FNAME_LEN];
|
char stb[TSDB_TABLE_FNAME_LEN];
|
||||||
|
@ -2434,6 +2393,21 @@ typedef struct {
|
||||||
SEpSet epSet;
|
SEpSet epSet;
|
||||||
} SMqSubVgEp;
|
} SMqSubVgEp;
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tEncodeSMqSubVgEp(void** buf, const SMqSubVgEp* pVgEp) {
|
||||||
|
int32_t tlen = 0;
|
||||||
|
tlen += taosEncodeFixedI32(buf, pVgEp->vgId);
|
||||||
|
tlen += taosEncodeFixedI64(buf, pVgEp->offset);
|
||||||
|
tlen += taosEncodeSEpSet(buf, &pVgEp->epSet);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void* tDecodeSMqSubVgEp(void* buf, SMqSubVgEp* pVgEp) {
|
||||||
|
buf = taosDecodeFixedI32(buf, &pVgEp->vgId);
|
||||||
|
buf = taosDecodeFixedI64(buf, &pVgEp->offset);
|
||||||
|
buf = taosDecodeSEpSet(buf, &pVgEp->epSet);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char topic[TSDB_TOPIC_FNAME_LEN];
|
char topic[TSDB_TOPIC_FNAME_LEN];
|
||||||
int8_t isSchemaAdaptive;
|
int8_t isSchemaAdaptive;
|
||||||
|
@ -2441,6 +2415,43 @@ typedef struct {
|
||||||
SSchemaWrapper schema;
|
SSchemaWrapper schema;
|
||||||
} SMqSubTopicEp;
|
} SMqSubTopicEp;
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tEncodeSMqSubTopicEp(void** buf, const SMqSubTopicEp* pTopicEp) {
|
||||||
|
int32_t tlen = 0;
|
||||||
|
tlen += taosEncodeString(buf, pTopicEp->topic);
|
||||||
|
tlen += taosEncodeFixedI8(buf, pTopicEp->isSchemaAdaptive);
|
||||||
|
int32_t sz = taosArrayGetSize(pTopicEp->vgs);
|
||||||
|
tlen += taosEncodeFixedI32(buf, sz);
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
SMqSubVgEp* pVgEp = (SMqSubVgEp*)taosArrayGet(pTopicEp->vgs, i);
|
||||||
|
tlen += tEncodeSMqSubVgEp(buf, pVgEp);
|
||||||
|
}
|
||||||
|
tlen += taosEncodeSSchemaWrapper(buf, &pTopicEp->schema);
|
||||||
|
return tlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void* tDecodeSMqSubTopicEp(void* buf, SMqSubTopicEp* pTopicEp) {
|
||||||
|
buf = taosDecodeStringTo(buf, pTopicEp->topic);
|
||||||
|
buf = taosDecodeFixedI8(buf, &pTopicEp->isSchemaAdaptive);
|
||||||
|
int32_t sz;
|
||||||
|
buf = taosDecodeFixedI32(buf, &sz);
|
||||||
|
pTopicEp->vgs = taosArrayInit(sz, sizeof(SMqSubVgEp));
|
||||||
|
if (pTopicEp->vgs == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
SMqSubVgEp vgEp;
|
||||||
|
buf = tDecodeSMqSubVgEp(buf, &vgEp);
|
||||||
|
taosArrayPush(pTopicEp->vgs, &vgEp);
|
||||||
|
}
|
||||||
|
buf = taosDecodeSSchemaWrapper(buf, &pTopicEp->schema);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) {
|
||||||
|
// taosMemoryFree(pSubTopicEp->schema.pSchema);
|
||||||
|
taosArrayDestroy(pSubTopicEp->vgs);
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMqRspHead head;
|
SMqRspHead head;
|
||||||
int64_t reqOffset;
|
int64_t reqOffset;
|
||||||
|
@ -2519,58 +2530,6 @@ typedef struct {
|
||||||
SArray* topics; // SArray<SMqSubTopicEp>
|
SArray* topics; // SArray<SMqSubTopicEp>
|
||||||
} SMqAskEpRsp;
|
} SMqAskEpRsp;
|
||||||
|
|
||||||
static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) {
|
|
||||||
// taosMemoryFree(pSubTopicEp->schema.pSchema);
|
|
||||||
taosArrayDestroy(pSubTopicEp->vgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSMqSubVgEp(void** buf, const SMqSubVgEp* pVgEp) {
|
|
||||||
int32_t tlen = 0;
|
|
||||||
tlen += taosEncodeFixedI32(buf, pVgEp->vgId);
|
|
||||||
tlen += taosEncodeFixedI64(buf, pVgEp->offset);
|
|
||||||
tlen += taosEncodeSEpSet(buf, &pVgEp->epSet);
|
|
||||||
return tlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void* tDecodeSMqSubVgEp(void* buf, SMqSubVgEp* pVgEp) {
|
|
||||||
buf = taosDecodeFixedI32(buf, &pVgEp->vgId);
|
|
||||||
buf = taosDecodeFixedI64(buf, &pVgEp->offset);
|
|
||||||
buf = taosDecodeSEpSet(buf, &pVgEp->epSet);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSMqSubTopicEp(void** buf, const SMqSubTopicEp* pTopicEp) {
|
|
||||||
int32_t tlen = 0;
|
|
||||||
tlen += taosEncodeString(buf, pTopicEp->topic);
|
|
||||||
tlen += taosEncodeFixedI8(buf, pTopicEp->isSchemaAdaptive);
|
|
||||||
int32_t sz = taosArrayGetSize(pTopicEp->vgs);
|
|
||||||
tlen += taosEncodeFixedI32(buf, sz);
|
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
|
||||||
SMqSubVgEp* pVgEp = (SMqSubVgEp*)taosArrayGet(pTopicEp->vgs, i);
|
|
||||||
tlen += tEncodeSMqSubVgEp(buf, pVgEp);
|
|
||||||
}
|
|
||||||
tlen += taosEncodeSSchemaWrapper(buf, &pTopicEp->schema);
|
|
||||||
return tlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void* tDecodeSMqSubTopicEp(void* buf, SMqSubTopicEp* pTopicEp) {
|
|
||||||
buf = taosDecodeStringTo(buf, pTopicEp->topic);
|
|
||||||
buf = taosDecodeFixedI8(buf, &pTopicEp->isSchemaAdaptive);
|
|
||||||
int32_t sz;
|
|
||||||
buf = taosDecodeFixedI32(buf, &sz);
|
|
||||||
pTopicEp->vgs = taosArrayInit(sz, sizeof(SMqSubVgEp));
|
|
||||||
if (pTopicEp->vgs == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
|
||||||
SMqSubVgEp vgEp;
|
|
||||||
buf = tDecodeSMqSubVgEp(buf, &vgEp);
|
|
||||||
taosArrayPush(pTopicEp->vgs, &vgEp);
|
|
||||||
}
|
|
||||||
buf = taosDecodeSSchemaWrapper(buf, &pTopicEp->schema);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSMqAskEpRsp(void** buf, const SMqAskEpRsp* pRsp) {
|
static FORCE_INLINE int32_t tEncodeSMqAskEpRsp(void** buf, const SMqAskEpRsp* pRsp) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
// tlen += taosEncodeString(buf, pRsp->cgroup);
|
// tlen += taosEncodeString(buf, pRsp->cgroup);
|
||||||
|
|
|
@ -36,12 +36,11 @@ typedef struct SVariant {
|
||||||
};
|
};
|
||||||
} SVariant;
|
} SVariant;
|
||||||
|
|
||||||
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value, bool *issigned);
|
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value);
|
||||||
|
int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value);
|
||||||
|
|
||||||
bool taosVariantIsValid(SVariant *pVar);
|
bool taosVariantIsValid(SVariant *pVar);
|
||||||
|
|
||||||
void taosVariantCreate(SVariant *pVar, const char *z, int32_t n, int32_t type);
|
|
||||||
|
|
||||||
void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type);
|
void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type);
|
||||||
|
|
||||||
void taosVariantDestroy(SVariant *pV);
|
void taosVariantDestroy(SVariant *pV);
|
||||||
|
@ -59,10 +58,10 @@ int32_t taosVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t taosVariantTypeSetType(SVariant *pVariant, char type);
|
int32_t taosVariantTypeSetType(SVariant *pVariant, char type);
|
||||||
char * taosVariantGet(SVariant *pVar, int32_t type);
|
char *taosVariantGet(SVariant *pVar, int32_t type);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_COMMON_VARIANT_H_*/
|
#endif /*_TD_COMMON_VARIANT_H_*/
|
||||||
|
|
|
@ -48,7 +48,8 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
|
||||||
// @pSource one execution location of this group of datasource subplans
|
// @pSource one execution location of this group of datasource subplans
|
||||||
int32_t qSetSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId, SDownstreamSourceNode* pSource);
|
int32_t qSetSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId, SDownstreamSourceNode* pSource);
|
||||||
|
|
||||||
int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_MULTI_BIND* pParams, int32_t colIdx, uint64_t queryId);
|
int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_MULTI_BIND* pParams, int32_t colIdx, uint64_t queryId,
|
||||||
|
bool* pEmptyResult);
|
||||||
|
|
||||||
// Convert to subplan to string for the scheduler to send to the executor
|
// Convert to subplan to string for the scheduler to send to the executor
|
||||||
int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen);
|
int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen);
|
||||||
|
|
|
@ -208,6 +208,7 @@ int32_t walReadWithFp(SWal *, FWalWrite writeFp, int64_t verStart, int32_t readN
|
||||||
int64_t walGetFirstVer(SWal *);
|
int64_t walGetFirstVer(SWal *);
|
||||||
int64_t walGetSnapshotVer(SWal *);
|
int64_t walGetSnapshotVer(SWal *);
|
||||||
int64_t walGetLastVer(SWal *);
|
int64_t walGetLastVer(SWal *);
|
||||||
|
int64_t walGetCommittedVer(SWal *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,6 +457,55 @@ static FORCE_INLINE void* tDecoderMalloc(SDecoder* pCoder, int32_t size) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tPutBinary(uint8_t* p, const uint8_t* pData, uint32_t nData) {
|
||||||
|
int n = 0;
|
||||||
|
uint32_t v = nData;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if (v <= 0x7f) {
|
||||||
|
if (p) p[n] = v;
|
||||||
|
n++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p) p[n] = (v & 0x7f) | 0x80;
|
||||||
|
n++;
|
||||||
|
v >>= 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p) {
|
||||||
|
memcpy(p + n, pData, nData);
|
||||||
|
}
|
||||||
|
n += nData;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tGetBinary(const uint8_t* p, const uint8_t** ppData, uint32_t* nData) {
|
||||||
|
int32_t n = 0;
|
||||||
|
uint32_t tv = 0;
|
||||||
|
uint32_t t;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if (p[n] <= 0x7f) {
|
||||||
|
t = p[n];
|
||||||
|
tv |= (t << (7 * n));
|
||||||
|
n++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
t = p[n] & 0x7f;
|
||||||
|
tv |= (t << (7 * n));
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nData) *nData = n;
|
||||||
|
if (ppData) *ppData = p + n;
|
||||||
|
|
||||||
|
n += tv;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -71,6 +71,7 @@ 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;
|
||||||
|
|
|
@ -138,14 +138,14 @@ typedef struct {
|
||||||
} SSmlHandle;
|
} SSmlHandle;
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
static uint64_t linesSmlHandleId = 0;
|
static volatile int64_t linesSmlHandleId = 0;
|
||||||
static const char* TS = "_ts";
|
static const char* TS = "_ts";
|
||||||
static const char* TAG = "_tagNone";
|
static const char* TAG = "_tagNone";
|
||||||
|
|
||||||
//=================================================================================================
|
//=================================================================================================
|
||||||
|
|
||||||
static uint64_t smlGenId() {
|
static int64_t smlGenId() {
|
||||||
uint64_t id;
|
int64_t id;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
id = atomic_add_fetch_64(&linesSmlHandleId, 1);
|
id = atomic_add_fetch_64(&linesSmlHandleId, 1);
|
||||||
|
@ -239,15 +239,13 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
|
||||||
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);
|
||||||
const char* errStr = taos_errstr(res);
|
const char* errStr = taos_errstr(res);
|
||||||
char* begin = strstr(errStr, "duplicated column names");
|
|
||||||
bool tscDupColNames = (begin != NULL);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%"PRIx64" apply schema action. error: %s", info->id, errStr);
|
uError("SML:0x%"PRIx64" apply schema action. error: %s", info->id, errStr);
|
||||||
}
|
}
|
||||||
taos_free_result(res);
|
taos_free_result(res);
|
||||||
|
|
||||||
// if (code == TSDB_CODE_MND_FIELD_ALREADY_EXIST || code == TSDB_CODE_MND_TAG_ALREADY_EXIST || tscDupColNames) {
|
// if (code == TSDB_CODE_MND_FIELD_ALREADY_EXIST || code == TSDB_CODE_MND_TAG_ALREADY_EXIST || tscDupColNames) {
|
||||||
if (code == TSDB_CODE_MND_TAG_ALREADY_EXIST || tscDupColNames) {
|
if (code == TSDB_CODE_MND_TAG_ALREADY_EXIST) {
|
||||||
TAOS_RES* res2 = taos_query(info->taos, "RESET QUERY CACHE");
|
TAOS_RES* res2 = taos_query(info->taos, "RESET QUERY CACHE");
|
||||||
code = taos_errno(res2);
|
code = taos_errno(res2);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -265,15 +263,13 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
|
||||||
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);
|
||||||
const char* errStr = taos_errstr(res);
|
const char* errStr = taos_errstr(res);
|
||||||
char* begin = strstr(errStr, "duplicated column names");
|
|
||||||
bool tscDupColNames = (begin != NULL);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
uError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res));
|
uError("SML:0x%"PRIx64" apply schema action. error : %s", info->id, taos_errstr(res));
|
||||||
}
|
}
|
||||||
taos_free_result(res);
|
taos_free_result(res);
|
||||||
|
|
||||||
// if (code ==TSDB_CODE_MND_TAG_ALREADY_EXIST || code == TSDB_CODE_MND_FIELD_ALREAY_EXIST || tscDupColNames) {
|
// if (code ==TSDB_CODE_MND_TAG_ALREADY_EXIST || code == TSDB_CODE_MND_FIELD_ALREAY_EXIST || tscDupColNames) {
|
||||||
if (code ==TSDB_CODE_MND_TAG_ALREADY_EXIST || tscDupColNames) {
|
if (code ==TSDB_CODE_MND_TAG_ALREADY_EXIST) {
|
||||||
TAOS_RES* res2 = taos_query(info->taos, "RESET QUERY CACHE");
|
TAOS_RES* res2 = taos_query(info->taos, "RESET QUERY CACHE");
|
||||||
code = taos_errno(res2);
|
code = taos_errno(res2);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -337,7 +333,7 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
|
||||||
SArray *cols = action->createSTable.fields;
|
SArray *cols = action->createSTable.fields;
|
||||||
|
|
||||||
for(int i = 0; i < taosArrayGetSize(cols); i++){
|
for(int i = 0; i < taosArrayGetSize(cols); i++){
|
||||||
SSmlKv *kv = taosArrayGetP(cols, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
||||||
smlBuildColumnDescription(kv, pos, freeBytes, &outBytes);
|
smlBuildColumnDescription(kv, pos, freeBytes, &outBytes);
|
||||||
pos += outBytes; freeBytes -= outBytes;
|
pos += outBytes; freeBytes -= outBytes;
|
||||||
*pos = ','; ++pos; --freeBytes;
|
*pos = ','; ++pos; --freeBytes;
|
||||||
|
@ -350,7 +346,7 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
|
||||||
|
|
||||||
cols = action->createSTable.tags;
|
cols = action->createSTable.tags;
|
||||||
for(int i = 0; i < taosArrayGetSize(cols); i++){
|
for(int i = 0; i < taosArrayGetSize(cols); i++){
|
||||||
SSmlKv *kv = taosArrayGetP(cols, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
||||||
smlBuildColumnDescription(kv, pos, freeBytes, &outBytes);
|
smlBuildColumnDescription(kv, pos, freeBytes, &outBytes);
|
||||||
pos += outBytes; freeBytes -= outBytes;
|
pos += outBytes; freeBytes -= outBytes;
|
||||||
*pos = ','; ++pos; --freeBytes;
|
*pos = ','; ++pos; --freeBytes;
|
||||||
|
@ -390,7 +386,7 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
|
||||||
static int32_t smlModifyDBSchemas(SSmlHandle* info) {
|
static int32_t smlModifyDBSchemas(SSmlHandle* info) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
SSmlSTableMeta** tableMetaSml = taosHashIterate(info->superTables, NULL);
|
SSmlSTableMeta** tableMetaSml = (SSmlSTableMeta**)taosHashIterate(info->superTables, NULL);
|
||||||
while (tableMetaSml) {
|
while (tableMetaSml) {
|
||||||
SSmlSTableMeta* sTableData = *tableMetaSml;
|
SSmlSTableMeta* sTableData = *tableMetaSml;
|
||||||
|
|
||||||
|
@ -406,8 +402,7 @@ 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 = {0};
|
SSchemaAction schemaAction = { SCHEMA_ACTION_CREATE_STABLE, 0};
|
||||||
schemaAction.action = SCHEMA_ACTION_CREATE_STABLE;
|
|
||||||
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;
|
||||||
|
@ -430,7 +425,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) {
|
||||||
}
|
}
|
||||||
sTableData->tableMeta = pTableMeta;
|
sTableData->tableMeta = pTableMeta;
|
||||||
|
|
||||||
tableMetaSml = taosHashIterate(info->superTables, tableMetaSml);
|
tableMetaSml = (SSmlSTableMeta**)taosHashIterate(info->superTables, tableMetaSml);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -996,7 +991,7 @@ static int32_t smlParseString(const char* sql, SSmlLineInfo *elements, SSmlMsgBu
|
||||||
|
|
||||||
static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, bool isTag, SHashObj *dumplicateKey, SSmlMsgBuf *msg){
|
static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, bool isTag, SHashObj *dumplicateKey, SSmlMsgBuf *msg){
|
||||||
if(isTag && len == 0){
|
if(isTag && len == 0){
|
||||||
SSmlKv *kv = taosMemoryCalloc(sizeof(SSmlKv), 1);
|
SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1);
|
||||||
kv->key = TAG;
|
kv->key = TAG;
|
||||||
kv->keyLen = strlen(TAG);
|
kv->keyLen = strlen(TAG);
|
||||||
kv->value = TAG;
|
kv->value = TAG;
|
||||||
|
@ -1053,7 +1048,7 @@ static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, bool is
|
||||||
}
|
}
|
||||||
|
|
||||||
// add kv to SSmlKv
|
// add kv to SSmlKv
|
||||||
SSmlKv *kv = taosMemoryCalloc(sizeof(SSmlKv), 1);
|
SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1);
|
||||||
kv->key = key;
|
kv->key = key;
|
||||||
kv->keyLen = keyLen;
|
kv->keyLen = keyLen;
|
||||||
kv->value = value;
|
kv->value = value;
|
||||||
|
@ -1199,7 +1194,7 @@ static int32_t smlParseTS(SSmlHandle* info, const char* data, int32_t len, SArra
|
||||||
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
|
||||||
SSmlKv *kv = taosMemoryCalloc(sizeof(SSmlKv), 1);
|
SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1);
|
||||||
if(!kv){
|
if(!kv){
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1259,12 +1254,12 @@ static int32_t smlParseTS(SSmlHandle* info, const char* data, int32_t len, SArra
|
||||||
static bool smlUpdateMeta(SSmlSTableMeta* tableMeta, SArray *tags, SArray *cols, SSmlMsgBuf *msg){
|
static bool smlUpdateMeta(SSmlSTableMeta* tableMeta, SArray *tags, SArray *cols, SSmlMsgBuf *msg){
|
||||||
if(tags){
|
if(tags){
|
||||||
for (int i = 0; i < taosArrayGetSize(tags); ++i) {
|
for (int i = 0; i < taosArrayGetSize(tags); ++i) {
|
||||||
SSmlKv *kv = taosArrayGetP(tags, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(tags, i);
|
||||||
ASSERT(kv->type == TSDB_DATA_TYPE_NCHAR);
|
ASSERT(kv->type == TSDB_DATA_TYPE_NCHAR);
|
||||||
|
|
||||||
uint8_t *index = taosHashGet(tableMeta->tagHash, kv->key, kv->keyLen);
|
uint8_t *index = (uint8_t *)taosHashGet(tableMeta->tagHash, kv->key, kv->keyLen);
|
||||||
if(index){
|
if(index){
|
||||||
SSmlKv **value = taosArrayGet(tableMeta->tags, *index);
|
SSmlKv **value = (SSmlKv **)taosArrayGet(tableMeta->tags, *index);
|
||||||
ASSERT((*value)->type == TSDB_DATA_TYPE_NCHAR);
|
ASSERT((*value)->type == TSDB_DATA_TYPE_NCHAR);
|
||||||
if(kv->valueLen > (*value)->valueLen){ // tags type is nchar
|
if(kv->valueLen > (*value)->valueLen){ // tags type is nchar
|
||||||
*value = kv;
|
*value = kv;
|
||||||
|
@ -1281,11 +1276,11 @@ static bool smlUpdateMeta(SSmlSTableMeta* tableMeta, SArray *tags, SArray *cols,
|
||||||
|
|
||||||
if(cols){
|
if(cols){
|
||||||
for (int i = 1; i < taosArrayGetSize(cols); ++i) { //jump timestamp
|
for (int i = 1; i < taosArrayGetSize(cols); ++i) { //jump timestamp
|
||||||
SSmlKv *kv = taosArrayGetP(cols, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
||||||
|
|
||||||
int16_t *index = taosHashGet(tableMeta->fieldHash, kv->key, kv->keyLen);
|
int16_t *index = (int16_t *)taosHashGet(tableMeta->fieldHash, kv->key, kv->keyLen);
|
||||||
if(index){
|
if(index){
|
||||||
SSmlKv **value = taosArrayGet(tableMeta->cols, *index);
|
SSmlKv **value = (SSmlKv **)taosArrayGet(tableMeta->cols, *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;
|
||||||
|
@ -1311,7 +1306,7 @@ static bool smlUpdateMeta(SSmlSTableMeta* tableMeta, SArray *tags, SArray *cols,
|
||||||
static void smlInsertMeta(SSmlSTableMeta* tableMeta, SArray *tags, SArray *cols){
|
static void smlInsertMeta(SSmlSTableMeta* tableMeta, SArray *tags, SArray *cols){
|
||||||
if(tags){
|
if(tags){
|
||||||
for (uint8_t i = 0; i < taosArrayGetSize(tags); ++i) {
|
for (uint8_t i = 0; i < taosArrayGetSize(tags); ++i) {
|
||||||
SSmlKv *kv = taosArrayGetP(tags, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(tags, i);
|
||||||
taosArrayPush(tableMeta->tags, &kv);
|
taosArrayPush(tableMeta->tags, &kv);
|
||||||
taosHashPut(tableMeta->tagHash, kv->key, kv->keyLen, &i, CHAR_BYTES);
|
taosHashPut(tableMeta->tagHash, kv->key, kv->keyLen, &i, CHAR_BYTES);
|
||||||
}
|
}
|
||||||
|
@ -1319,7 +1314,7 @@ static void smlInsertMeta(SSmlSTableMeta* tableMeta, SArray *tags, SArray *cols)
|
||||||
|
|
||||||
if(cols){
|
if(cols){
|
||||||
for (int16_t i = 0; i < taosArrayGetSize(cols); ++i) {
|
for (int16_t i = 0; i < taosArrayGetSize(cols); ++i) {
|
||||||
SSmlKv *kv = taosArrayGetP(cols, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
||||||
taosArrayPush(tableMeta->cols, &kv);
|
taosArrayPush(tableMeta->cols, &kv);
|
||||||
taosHashPut(tableMeta->fieldHash, kv->key, kv->keyLen, &i, SHORT_BYTES);
|
taosHashPut(tableMeta->fieldHash, kv->key, kv->keyLen, &i, SHORT_BYTES);
|
||||||
}
|
}
|
||||||
|
@ -1327,7 +1322,7 @@ static void smlInsertMeta(SSmlSTableMeta* tableMeta, SArray *tags, SArray *cols)
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSmlTableInfo* smlBuildTableInfo(bool format){
|
static SSmlTableInfo* smlBuildTableInfo(bool format){
|
||||||
SSmlTableInfo *tag = taosMemoryCalloc(sizeof(SSmlTableInfo), 1);
|
SSmlTableInfo *tag = (SSmlTableInfo *)taosMemoryCalloc(sizeof(SSmlTableInfo), 1);
|
||||||
if(!tag){
|
if(!tag){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1354,7 +1349,7 @@ static SSmlTableInfo* smlBuildTableInfo(bool format){
|
||||||
return tag;
|
return tag;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
taosMemoryFreeClear(tag);
|
taosMemoryFree(tag);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1364,18 +1359,17 @@ static void smlDestroyBuildTableInfo(SSmlTableInfo *tag, bool format){
|
||||||
}else{
|
}else{
|
||||||
tag->cols = taosArrayInit(16, POINTER_BYTES);
|
tag->cols = taosArrayInit(16, POINTER_BYTES);
|
||||||
for(size_t i = 0; i < taosArrayGetSize(tag->cols); i++){
|
for(size_t i = 0; i < taosArrayGetSize(tag->cols); i++){
|
||||||
SHashObj *kvHash = taosArrayGetP(tag->cols, i);
|
SHashObj *kvHash = (SHashObj *)taosArrayGetP(tag->cols, i);
|
||||||
void** p1 = taosHashIterate(kvHash, NULL);
|
void** p1 = (void**)taosHashIterate(kvHash, NULL);
|
||||||
while (p1) {
|
while (p1) {
|
||||||
SSmlKv* kv = *p1;
|
taosMemoryFree(*p1);
|
||||||
taosMemoryFreeClear(kv);
|
p1 = (void**)taosHashIterate(kvHash, p1);
|
||||||
p1 = taosHashIterate(kvHash, p1);
|
|
||||||
}
|
}
|
||||||
taosHashCleanup(kvHash);
|
taosHashCleanup(kvHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosArrayDestroy(tag->tags);
|
taosArrayDestroy(tag->tags);
|
||||||
taosMemoryFreeClear(tag);
|
taosMemoryFree(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlDealCols(SSmlTableInfo* oneTable, bool dataFormat, SArray *cols){
|
static int32_t smlDealCols(SSmlTableInfo* oneTable, bool dataFormat, SArray *cols){
|
||||||
|
@ -1390,7 +1384,7 @@ static int32_t smlDealCols(SSmlTableInfo* oneTable, bool dataFormat, SArray *col
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
for(size_t i = 0; i < taosArrayGetSize(cols); i++){
|
for(size_t i = 0; i < taosArrayGetSize(cols); i++){
|
||||||
SSmlKv *kv = taosArrayGetP(cols, i);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
||||||
taosHashPut(kvHash, kv->key, kv->keyLen, &kv, POINTER_BYTES); // todo key need escape, like \=, because find by schema name later
|
taosHashPut(kvHash, kv->key, kv->keyLen, &kv, POINTER_BYTES); // todo key need escape, like \=, because find by schema name later
|
||||||
}
|
}
|
||||||
taosArrayPush(oneTable->cols, &kvHash);
|
taosArrayPush(oneTable->cols, &kvHash);
|
||||||
|
@ -1399,7 +1393,7 @@ static int32_t smlDealCols(SSmlTableInfo* oneTable, bool dataFormat, SArray *col
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSmlSTableMeta* smlBuildSTableMeta(){
|
static SSmlSTableMeta* smlBuildSTableMeta(){
|
||||||
SSmlSTableMeta* meta = taosMemoryCalloc(sizeof(SSmlSTableMeta), 1);
|
SSmlSTableMeta* meta = (SSmlSTableMeta*)taosMemoryCalloc(sizeof(SSmlSTableMeta), 1);
|
||||||
if(!meta){
|
if(!meta){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1429,7 +1423,7 @@ static SSmlSTableMeta* smlBuildSTableMeta(){
|
||||||
return meta;
|
return meta;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
taosMemoryFreeClear(meta);
|
taosMemoryFree(meta);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1475,9 +1469,9 @@ static int32_t smlParseLine(SSmlHandle* info, const char* sql) {
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSmlTableInfo **oneTable = taosHashGet(info->childTables, elements.measure, elements.measureTagsLen);
|
SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashGet(info->childTables, elements.measure, elements.measureTagsLen);
|
||||||
if(oneTable){
|
if(oneTable){
|
||||||
SSmlSTableMeta** tableMeta = taosHashGet(info->superTables, elements.measure, elements.measureLen);
|
SSmlSTableMeta** tableMeta = (SSmlSTableMeta**)taosHashGet(info->superTables, elements.measure, elements.measureLen);
|
||||||
ASSERT(tableMeta);
|
ASSERT(tableMeta);
|
||||||
ret = smlUpdateMeta(*tableMeta, NULL, cols, &info->msgBuf); // update meta cols
|
ret = smlUpdateMeta(*tableMeta, NULL, cols, &info->msgBuf); // update meta cols
|
||||||
if(!ret){
|
if(!ret){
|
||||||
|
@ -1511,12 +1505,12 @@ static int32_t smlParseLine(SSmlHandle* info, const char* sql) {
|
||||||
|
|
||||||
tinfo->sTableName = elements.measure;
|
tinfo->sTableName = elements.measure;
|
||||||
tinfo->sTableNameLen = elements.measureLen;
|
tinfo->sTableNameLen = elements.measureLen;
|
||||||
RandTableName rName = {.tags=tinfo->tags, .sTableName=tinfo->sTableName, .sTableNameLen=tinfo->sTableNameLen,
|
RandTableName rName = { tinfo->tags, tinfo->sTableName, tinfo->sTableNameLen,
|
||||||
.childTableName=tinfo->childTableName};
|
tinfo->childTableName, 0 };
|
||||||
buildChildTableName(&rName);
|
buildChildTableName(&rName);
|
||||||
tinfo->uid = rName.uid;
|
tinfo->uid = rName.uid;
|
||||||
|
|
||||||
SSmlSTableMeta** tableMeta = 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, tinfo->tags, cols, &info->msgBuf);
|
ret = smlUpdateMeta(*tableMeta, tinfo->tags, cols, &info->msgBuf);
|
||||||
if(!ret){
|
if(!ret){
|
||||||
|
@ -1545,20 +1539,18 @@ static void smlDestroyInfo(SSmlHandle* info){
|
||||||
smlDestroyHandle(info->exec);
|
smlDestroyHandle(info->exec);
|
||||||
|
|
||||||
// destroy info->childTables
|
// destroy info->childTables
|
||||||
void** p1 = taosHashIterate(info->childTables, NULL);
|
void** p1 = (void**)taosHashIterate(info->childTables, NULL);
|
||||||
while (p1) {
|
while (p1) {
|
||||||
SSmlTableInfo* oneTable = *p1;
|
smlDestroyBuildTableInfo((SSmlTableInfo*)(*p1), info->dataFormat);
|
||||||
smlDestroyBuildTableInfo(oneTable, info->dataFormat);
|
p1 = (void**)taosHashIterate(info->childTables, p1);
|
||||||
p1 = taosHashIterate(info->childTables, p1);
|
|
||||||
}
|
}
|
||||||
taosHashCleanup(info->childTables);
|
taosHashCleanup(info->childTables);
|
||||||
|
|
||||||
// destroy info->superTables
|
// destroy info->superTables
|
||||||
p1 = taosHashIterate(info->superTables, NULL);
|
p1 = (void**)taosHashIterate(info->superTables, NULL);
|
||||||
while (p1) {
|
while (p1) {
|
||||||
SSmlSTableMeta* oneTable = *p1;
|
smlDestroySTableMeta((SSmlSTableMeta*)(*p1));
|
||||||
smlDestroySTableMeta(oneTable);
|
p1 = (void**)taosHashIterate(info->superTables, p1);
|
||||||
p1 = taosHashIterate(info->superTables, p1);
|
|
||||||
}
|
}
|
||||||
taosHashCleanup(info->superTables);
|
taosHashCleanup(info->superTables);
|
||||||
|
|
||||||
|
@ -1571,13 +1563,13 @@ static void smlDestroyInfo(SSmlHandle* info){
|
||||||
|
|
||||||
static SSmlHandle* smlBuildSmlInfo(TAOS* taos, SRequestObj* request, SMLProtocolType protocol, int8_t precision, bool dataFormat){
|
static SSmlHandle* smlBuildSmlInfo(TAOS* taos, SRequestObj* request, SMLProtocolType protocol, int8_t precision, bool dataFormat){
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SSmlHandle* info = taosMemoryCalloc(1, sizeof(SSmlHandle));
|
SSmlHandle* info = (SSmlHandle*)taosMemoryCalloc(1, sizeof(SSmlHandle));
|
||||||
if (NULL == info) {
|
if (NULL == info) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
info->id = smlGenId();
|
info->id = smlGenId();
|
||||||
|
|
||||||
info->pQuery = taosMemoryCalloc(1, sizeof(SQuery));
|
info->pQuery = (SQuery *)taosMemoryCalloc(1, sizeof(SQuery));
|
||||||
if (NULL == info->pQuery) {
|
if (NULL == info->pQuery) {
|
||||||
uError("SML:0x%"PRIx64" create info->pQuery error", info->id);
|
uError("SML:0x%"PRIx64" create info->pQuery error", info->id);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -1592,7 +1584,7 @@ static SSmlHandle* smlBuildSmlInfo(TAOS* taos, SRequestObj* request, SMLProtocol
|
||||||
}
|
}
|
||||||
((SVnodeModifOpStmt*)(info->pQuery->pRoot))->payloadType = PAYLOAD_TYPE_KV;
|
((SVnodeModifOpStmt*)(info->pQuery->pRoot))->payloadType = PAYLOAD_TYPE_KV;
|
||||||
|
|
||||||
info->taos = taos;
|
info->taos = (STscObj *)taos;
|
||||||
code = catalogGetHandle(info->taos->pAppInfo->clusterId, &info->pCatalog);
|
code = catalogGetHandle(info->taos->pAppInfo->clusterId, &info->pCatalog);
|
||||||
if(code != TSDB_CODE_SUCCESS){
|
if(code != TSDB_CODE_SUCCESS){
|
||||||
uError("SML:0x%"PRIx64" get catalog error %d", info->id, code);
|
uError("SML:0x%"PRIx64" get catalog error %d", info->id, code);
|
||||||
|
@ -1634,7 +1626,7 @@ cleanup:
|
||||||
static int32_t smlInsertData(SSmlHandle* info) {
|
static int32_t smlInsertData(SSmlHandle* info) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SSmlTableInfo** oneTable = taosHashIterate(info->childTables, NULL);
|
SSmlTableInfo** oneTable = (SSmlTableInfo**)taosHashIterate(info->childTables, NULL);
|
||||||
while (oneTable) {
|
while (oneTable) {
|
||||||
SSmlTableInfo* tableData = *oneTable;
|
SSmlTableInfo* tableData = *oneTable;
|
||||||
|
|
||||||
|
@ -1650,7 +1642,7 @@ static int32_t smlInsertData(SSmlHandle* info) {
|
||||||
}
|
}
|
||||||
taosHashPut(info->pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg));
|
taosHashPut(info->pVgHash, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg));
|
||||||
|
|
||||||
SSmlSTableMeta** pMeta = taosHashGet(info->superTables, tableData->sTableName, tableData->sTableNameLen);
|
SSmlSTableMeta** pMeta = (SSmlSTableMeta** )taosHashGet(info->superTables, tableData->sTableName, tableData->sTableNameLen);
|
||||||
ASSERT (NULL != pMeta && NULL != *pMeta);
|
ASSERT (NULL != pMeta && NULL != *pMeta);
|
||||||
|
|
||||||
// use tablemeta of stable to save vgid and uid of child table
|
// use tablemeta of stable to save vgid and uid of child table
|
||||||
|
@ -1662,7 +1654,7 @@ static int32_t smlInsertData(SSmlHandle* info) {
|
||||||
if(code != TSDB_CODE_SUCCESS){
|
if(code != TSDB_CODE_SUCCESS){
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
oneTable = taosHashIterate(info->childTables, oneTable);
|
oneTable = (SSmlTableInfo**)taosHashIterate(info->childTables, oneTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
smlBuildOutput(info->exec, info->pVgHash);
|
smlBuildOutput(info->exec, info->pVgHash);
|
||||||
|
@ -1748,12 +1740,12 @@ cleanup:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision) {
|
TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision) {
|
||||||
SRequestObj* request = createRequest(taos, NULL, NULL, TSDB_SQL_INSERT);
|
SRequestObj* request = (SRequestObj*)createRequest((STscObj *)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
if(!request){
|
if(!request){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSmlHandle* info = smlBuildSmlInfo(taos, request, protocol, precision, true);
|
SSmlHandle* info = smlBuildSmlInfo(taos, request, (SMLProtocolType)protocol, precision, true);
|
||||||
if(!info){
|
if(!info){
|
||||||
return (TAOS_RES*)request;
|
return (TAOS_RES*)request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
|
|
||||||
#include "clientInt.h"
|
#include "clientInt.h"
|
||||||
#include "clientLog.h"
|
#include "clientLog.h"
|
||||||
#include "clientStmt.h"
|
|
||||||
#include "tdef.h"
|
#include "tdef.h"
|
||||||
|
|
||||||
|
#include "clientStmt.h"
|
||||||
|
|
||||||
int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
switch (newStatus) {
|
switch (newStatus) {
|
||||||
case STMT_PREPARE:
|
case STMT_PREPARE:
|
||||||
break;
|
break;
|
||||||
|
@ -29,11 +30,11 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
||||||
if (STMT_STATUS_EQ(INIT) || STMT_STATUS_EQ(BIND_COL)) {
|
if (STMT_STATUS_EQ(INIT) || STMT_STATUS_EQ(BIND_COL)) {
|
||||||
code = TSDB_CODE_TSC_STMT_API_ERROR;
|
code = TSDB_CODE_TSC_STMT_API_ERROR;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if ((pStmt->sql.type == STMT_TYPE_MULTI_INSERT) && ()) {
|
if ((pStmt->sql.type == STMT_TYPE_MULTI_INSERT) && ()) {
|
||||||
code = TSDB_CODE_TSC_STMT_API_ERROR;
|
code = TSDB_CODE_TSC_STMT_API_ERROR;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
case STMT_BIND_COL:
|
case STMT_BIND_COL:
|
||||||
if (STMT_STATUS_EQ(INIT) || STMT_STATUS_EQ(BIND)) {
|
if (STMT_STATUS_EQ(INIT) || STMT_STATUS_EQ(BIND)) {
|
||||||
|
@ -62,8 +63,7 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t stmtGetTbName(TAOS_STMT* stmt, char** tbName) {
|
||||||
int32_t stmtGetTbName(TAOS_STMT *stmt, char **tbName) {
|
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
pStmt->sql.type = STMT_TYPE_MULTI_INSERT;
|
pStmt->sql.type = STMT_TYPE_MULTI_INSERT;
|
||||||
|
@ -79,10 +79,10 @@ int32_t stmtGetTbName(TAOS_STMT *stmt, char **tbName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t stmtBackupQueryFields(STscStmt* pStmt) {
|
int32_t stmtBackupQueryFields(STscStmt* pStmt) {
|
||||||
SStmtQueryResInfo *pRes = &pStmt->sql.queryRes;
|
SStmtQueryResInfo* pRes = &pStmt->sql.queryRes;
|
||||||
pRes->numOfCols = pStmt->exec.pRequest->body.resInfo.numOfCols;
|
pRes->numOfCols = pStmt->exec.pRequest->body.resInfo.numOfCols;
|
||||||
pRes->precision = pStmt->exec.pRequest->body.resInfo.precision;
|
pRes->precision = pStmt->exec.pRequest->body.resInfo.precision;
|
||||||
|
|
||||||
int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
|
int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
|
||||||
pRes->fields = taosMemoryMalloc(size);
|
pRes->fields = taosMemoryMalloc(size);
|
||||||
pRes->userFields = taosMemoryMalloc(size);
|
pRes->userFields = taosMemoryMalloc(size);
|
||||||
|
@ -96,9 +96,9 @@ int32_t stmtBackupQueryFields(STscStmt* pStmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
||||||
SStmtQueryResInfo *pRes = &pStmt->sql.queryRes;
|
SStmtQueryResInfo* pRes = &pStmt->sql.queryRes;
|
||||||
int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
|
int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
|
||||||
|
|
||||||
pStmt->exec.pRequest->body.resInfo.numOfCols = pRes->numOfCols;
|
pStmt->exec.pRequest->body.resInfo.numOfCols = pRes->numOfCols;
|
||||||
pStmt->exec.pRequest->body.resInfo.precision = pRes->precision;
|
pStmt->exec.pRequest->body.resInfo.precision = pRes->precision;
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ int32_t stmtGetExecInfo(TAOS_STMT* stmt, SHashObj** pVgHash, SHashObj** pBlockHa
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t stmtCacheBlock(STscStmt *pStmt) {
|
int32_t stmtCacheBlock(STscStmt* pStmt) {
|
||||||
if (pStmt->sql.type != STMT_TYPE_MULTI_INSERT) {
|
if (pStmt->sql.type != STMT_TYPE_MULTI_INSERT) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -185,8 +185,8 @@ int32_t stmtCacheBlock(STscStmt *pStmt) {
|
||||||
STMT_ERR_RET(qCloneStmtDataBlock(&pDst, *pSrc));
|
STMT_ERR_RET(qCloneStmtDataBlock(&pDst, *pSrc));
|
||||||
|
|
||||||
SStmtTableCache cache = {
|
SStmtTableCache cache = {
|
||||||
.pDataBlock = pDst,
|
.pDataBlock = pDst,
|
||||||
.boundTags = pStmt->bInfo.boundTags,
|
.boundTags = pStmt->bInfo.boundTags,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (taosHashPut(pStmt->sql.pTableCache, &cacheUid, sizeof(cacheUid), &cache, sizeof(cache))) {
|
if (taosHashPut(pStmt->sql.pTableCache, &cacheUid, sizeof(cacheUid), &cache, sizeof(cache))) {
|
||||||
|
@ -213,11 +213,11 @@ int32_t stmtParseSql(STscStmt* pStmt) {
|
||||||
if (NULL == pStmt->exec.pRequest) {
|
if (NULL == pStmt->exec.pRequest) {
|
||||||
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
|
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
STMT_ERR_RET(parseSql(pStmt->exec.pRequest, false, &pStmt->sql.pQuery, &stmtCb));
|
STMT_ERR_RET(parseSql(pStmt->exec.pRequest, false, &pStmt->sql.pQuery, &stmtCb));
|
||||||
|
|
||||||
pStmt->bInfo.needParse = false;
|
pStmt->bInfo.needParse = false;
|
||||||
|
|
||||||
switch (nodeType(pStmt->sql.pQuery->pRoot)) {
|
switch (nodeType(pStmt->sql.pQuery->pRoot)) {
|
||||||
case QUERY_NODE_VNODE_MODIF_STMT:
|
case QUERY_NODE_VNODE_MODIF_STMT:
|
||||||
if (0 == pStmt->sql.type) {
|
if (0 == pStmt->sql.type) {
|
||||||
|
@ -267,7 +267,7 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) {
|
||||||
|
|
||||||
if (keepTable && (strlen(pStmt->bInfo.tbFName) == keyLen) && strncmp(pStmt->bInfo.tbFName, key, keyLen) == 0) {
|
if (keepTable && (strlen(pStmt->bInfo.tbFName) == keyLen) && strncmp(pStmt->bInfo.tbFName, key, keyLen) == 0) {
|
||||||
STMT_ERR_RET(qResetStmtDataBlock(pBlocks, true));
|
STMT_ERR_RET(qResetStmtDataBlock(pBlocks, true));
|
||||||
|
|
||||||
pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
|
pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -279,6 +279,7 @@ 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;
|
||||||
|
@ -299,15 +300,15 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
|
||||||
qDestroyQuery(pStmt->sql.pQuery);
|
qDestroyQuery(pStmt->sql.pQuery);
|
||||||
qDestroyQueryPlan(pStmt->sql.pQueryPlan);
|
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);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SStmtTableCache* pCache = (SStmtTableCache*)pIter;
|
SStmtTableCache* pCache = (SStmtTableCache*)pIter;
|
||||||
|
|
||||||
qDestroyStmtDataBlock(pCache->pDataBlock);
|
qDestroyStmtDataBlock(pCache->pDataBlock);
|
||||||
destroyBoundColumnInfo(pCache->boundTags);
|
destroyBoundColumnInfo(pCache->boundTags);
|
||||||
taosMemoryFreeClear(pCache->boundTags);
|
taosMemoryFreeClear(pCache->boundTags);
|
||||||
|
|
||||||
pIter = taosHashIterate(pStmt->sql.pTableCache, pIter);
|
pIter = taosHashIterate(pStmt->sql.pTableCache, pIter);
|
||||||
}
|
}
|
||||||
taosHashCleanup(pStmt->sql.pTableCache);
|
taosHashCleanup(pStmt->sql.pTableCache);
|
||||||
|
@ -339,6 +340,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
|
||||||
|
|
||||||
STableDataBlocks *pBlockInExec = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
STableDataBlocks *pBlockInExec = taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||||
if (pBlockInExec) {
|
if (pBlockInExec) {
|
||||||
|
pStmt->bInfo.needParse = false;
|
||||||
pStmt->bInfo.inExecCache = true;
|
pStmt->bInfo.inExecCache = true;
|
||||||
|
|
||||||
if (pStmt->sql.autoCreateTbl) {
|
if (pStmt->sql.autoCreateTbl) {
|
||||||
|
@ -364,7 +366,10 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
|
||||||
SStmtTableCache* pCache = taosHashGet(pStmt->sql.pTableCache, &pStmt->bInfo.tbSuid, sizeof(pStmt->bInfo.tbSuid));
|
SStmtTableCache* pCache = taosHashGet(pStmt->sql.pTableCache, &pStmt->bInfo.tbSuid, sizeof(pStmt->bInfo.tbSuid));
|
||||||
if (pCache) {
|
if (pCache) {
|
||||||
pStmt->bInfo.needParse = false;
|
pStmt->bInfo.needParse = false;
|
||||||
|
pStmt->exec.autoCreateTbl = true;
|
||||||
|
|
||||||
|
pStmt->bInfo.tbUid = 0;
|
||||||
|
|
||||||
STableDataBlocks* pNewBlock = NULL;
|
STableDataBlocks* pNewBlock = NULL;
|
||||||
STMT_ERR_RET(stmtRebuildDataBlock(pStmt, pCache->pDataBlock, &pNewBlock, 0));
|
STMT_ERR_RET(stmtRebuildDataBlock(pStmt, pCache->pDataBlock, &pNewBlock, 0));
|
||||||
|
|
||||||
|
@ -384,15 +389,15 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
|
||||||
int32_t code = catalogGetTableMeta(pStmt->pCatalog, pStmt->taos->pAppInfo->pTransporter, &ep, &pStmt->bInfo.sname, &pTableMeta);
|
int32_t code = catalogGetTableMeta(pStmt->pCatalog, pStmt->taos->pAppInfo->pTransporter, &ep, &pStmt->bInfo.sname, &pTableMeta);
|
||||||
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
|
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
|
||||||
STMT_ERR_RET(stmtCleanBindInfo(pStmt));
|
STMT_ERR_RET(stmtCleanBindInfo(pStmt));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STMT_ERR_RET(code);
|
STMT_ERR_RET(code);
|
||||||
|
|
||||||
uint64_t uid = pTableMeta->uid;
|
uint64_t uid = pTableMeta->uid;
|
||||||
uint64_t suid = pTableMeta->suid;
|
uint64_t suid = pTableMeta->suid;
|
||||||
int8_t tableType = pTableMeta->tableType;
|
int8_t tableType = pTableMeta->tableType;
|
||||||
taosMemoryFree(pTableMeta);
|
taosMemoryFree(pTableMeta);
|
||||||
uint64_t cacheUid = (TSDB_CHILD_TABLE == tableType) ? suid : uid;
|
uint64_t cacheUid = (TSDB_CHILD_TABLE == tableType) ? suid : uid;
|
||||||
|
|
||||||
|
@ -409,9 +414,9 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
|
||||||
|
|
||||||
STMT_ERR_RET(TSDB_CODE_TSC_APP_ERROR);
|
STMT_ERR_RET(TSDB_CODE_TSC_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
pStmt->bInfo.needParse = false;
|
pStmt->bInfo.needParse = false;
|
||||||
|
|
||||||
pStmt->bInfo.tbUid = uid;
|
pStmt->bInfo.tbUid = uid;
|
||||||
pStmt->bInfo.tbSuid = suid;
|
pStmt->bInfo.tbSuid = suid;
|
||||||
pStmt->bInfo.tbType = tableType;
|
pStmt->bInfo.tbType = tableType;
|
||||||
|
@ -437,7 +442,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
|
||||||
if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock, POINTER_BYTES)) {
|
if (taosHashPut(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName), &pNewBlock, POINTER_BYTES)) {
|
||||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,9 +465,8 @@ int32_t stmtResetStmt(STscStmt* pStmt) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAOS_STMT* stmtInit(TAOS* taos) {
|
||||||
TAOS_STMT *stmtInit(TAOS *taos) {
|
STscObj* pObj = (STscObj*)taos;
|
||||||
STscObj* pObj = (STscObj*)taos;
|
|
||||||
STscStmt* pStmt = NULL;
|
STscStmt* pStmt = NULL;
|
||||||
|
|
||||||
pStmt = taosMemoryCalloc(1, sizeof(STscStmt));
|
pStmt = taosMemoryCalloc(1, sizeof(STscStmt));
|
||||||
|
@ -481,11 +485,11 @@ TAOS_STMT *stmtInit(TAOS *taos) {
|
||||||
pStmt->taos = pObj;
|
pStmt->taos = pObj;
|
||||||
pStmt->bInfo.needParse = true;
|
pStmt->bInfo.needParse = true;
|
||||||
pStmt->sql.status = STMT_INIT;
|
pStmt->sql.status = STMT_INIT;
|
||||||
|
|
||||||
return pStmt;
|
return pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
|
int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
if (pStmt->sql.status >= STMT_PREPARE) {
|
if (pStmt->sql.status >= STMT_PREPARE) {
|
||||||
|
@ -497,15 +501,14 @@ int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length) {
|
||||||
if (length <= 0) {
|
if (length <= 0) {
|
||||||
length = strlen(sql);
|
length = strlen(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
pStmt->sql.sqlStr = strndup(sql, length);
|
pStmt->sql.sqlStr = strndup(sql, length);
|
||||||
pStmt->sql.sqlLen = length;
|
pStmt->sql.sqlLen = length;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) {
|
||||||
int stmtSetTbName(TAOS_STMT *stmt, const char *tbName) {
|
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTBNAME));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTBNAME));
|
||||||
|
@ -534,7 +537,7 @@ int stmtSetTbName(TAOS_STMT *stmt, const char *tbName) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stmtSetTbTags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags) {
|
int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTAGS));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTAGS));
|
||||||
|
@ -552,14 +555,14 @@ int stmtSetTbTags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags) {
|
||||||
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
||||||
STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
STMT_ERR_RET(qBindStmtTagsValue(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.sname.tname, tags, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen));
|
STMT_ERR_RET(qBindStmtTagsValue(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.sname.tname,
|
||||||
|
tags, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t stmtFetchTagFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD** fields) {
|
||||||
int32_t stmtFetchTagFields(STscStmt* pStmt, int32_t *fieldNum, TAOS_FIELD** fields) {
|
|
||||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||||
tscError("invalid operation to get query tag fileds");
|
tscError("invalid operation to get query tag fileds");
|
||||||
STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||||
|
@ -576,7 +579,7 @@ int32_t stmtFetchTagFields(STscStmt* pStmt, int32_t *fieldNum, TAOS_FIELD** fiel
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t stmtFetchColFields(STscStmt* pStmt, int32_t *fieldNum, TAOS_FIELD** fields) {
|
int32_t stmtFetchColFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD** fields) {
|
||||||
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
if (STMT_TYPE_QUERY == pStmt->sql.type) {
|
||||||
tscError("invalid operation to get query column fileds");
|
tscError("invalid operation to get query column fileds");
|
||||||
STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR);
|
||||||
|
@ -590,13 +593,14 @@ int32_t stmtFetchColFields(STscStmt* pStmt, int32_t *fieldNum, TAOS_FIELD** fiel
|
||||||
|
|
||||||
STMT_ERR_RET(qBuildStmtColFields(*pDataBlock, fieldNum, fields));
|
STMT_ERR_RET(qBuildStmtColFields(*pDataBlock, fieldNum, fields));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 && STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
|
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
|
||||||
|
STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
|
||||||
pStmt->bInfo.needParse = false;
|
pStmt->bInfo.needParse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,7 +608,7 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
|
||||||
taos_free_result(pStmt->exec.pRequest);
|
taos_free_result(pStmt->exec.pRequest);
|
||||||
pStmt->exec.pRequest = NULL;
|
pStmt->exec.pRequest = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == pStmt->exec.pRequest) {
|
if (NULL == pStmt->exec.pRequest) {
|
||||||
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
|
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
|
||||||
}
|
}
|
||||||
|
@ -624,8 +628,8 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
|
||||||
} else {
|
} else {
|
||||||
STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
|
STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
STMT_RET(qStmtBindParam(pStmt->sql.pQueryPlan, bind, colIdx, pStmt->exec.pRequest->requestId));
|
STMT_RET(qStmtBindParam(pStmt->sql.pQueryPlan, bind, colIdx, pStmt->exec.pRequest->requestId, &pStmt->exec.emptyRes));
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
||||||
|
@ -647,25 +651,25 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pStmt->bInfo.sBindLastIdx = colIdx;
|
pStmt->bInfo.sBindLastIdx = colIdx;
|
||||||
|
|
||||||
if (0 == colIdx) {
|
if (0 == colIdx) {
|
||||||
pStmt->bInfo.sBindRowNum = bind->num;
|
pStmt->bInfo.sBindRowNum = bind->num;
|
||||||
}
|
}
|
||||||
|
|
||||||
qBindStmtSingleColValue(*pDataBlock, bind, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen, colIdx, pStmt->bInfo.sBindRowNum);
|
qBindStmtSingleColValue(*pDataBlock, bind, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen, colIdx,
|
||||||
|
pStmt->bInfo.sBindRowNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int stmtAddBatch(TAOS_STMT* stmt) {
|
||||||
int stmtAddBatch(TAOS_STMT *stmt) {
|
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_ADD_BATCH));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_ADD_BATCH));
|
||||||
|
|
||||||
STMT_ERR_RET(stmtCacheBlock(pStmt));
|
STMT_ERR_RET(stmtCacheBlock(pStmt));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,7 +736,11 @@ 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) {
|
||||||
scheduleQuery(pStmt->exec.pRequest, pStmt->sql.pQueryPlan, pStmt->sql.nodeList, NULL);
|
if (pStmt->exec.emptyRes) {
|
||||||
|
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));
|
||||||
|
@ -747,7 +755,7 @@ int stmtExec(TAOS_STMT *stmt) {
|
||||||
STMT_ERR_RET(TSDB_CODE_NEED_RETRY);
|
STMT_ERR_RET(TSDB_CODE_NEED_RETRY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STMT_ERR_JRET(pStmt->exec.pRequest->code);
|
STMT_ERR_JRET(pStmt->exec.pRequest->code);
|
||||||
|
|
||||||
pStmt->exec.affectedRows = taos_affected_rows(pStmt->exec.pRequest);
|
pStmt->exec.affectedRows = taos_affected_rows(pStmt->exec.pRequest);
|
||||||
|
@ -767,12 +775,11 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
++pStmt->sql.runTimes;
|
++pStmt->sql.runTimes;
|
||||||
|
|
||||||
STMT_RET(code);
|
STMT_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int stmtClose(TAOS_STMT* stmt) {
|
||||||
int stmtClose(TAOS_STMT *stmt) {
|
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
STMT_RET(stmtCleanSQLInfo(pStmt));
|
STMT_RET(stmtCleanSQLInfo(pStmt));
|
||||||
|
@ -780,11 +787,11 @@ int stmtClose(TAOS_STMT *stmt) {
|
||||||
taosMemoryFree(stmt);
|
taosMemoryFree(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *stmtErrstr(TAOS_STMT *stmt) {
|
const char* stmtErrstr(TAOS_STMT* stmt) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
if (stmt == NULL || NULL == pStmt->exec.pRequest) {
|
if (stmt == NULL || NULL == pStmt->exec.pRequest) {
|
||||||
return (char*) tstrerror(terrno);
|
return (char*)tstrerror(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
pStmt->exec.pRequest->code = terrno;
|
pStmt->exec.pRequest->code = terrno;
|
||||||
|
@ -792,15 +799,11 @@ const char *stmtErrstr(TAOS_STMT *stmt) {
|
||||||
return taos_errstr(pStmt->exec.pRequest);
|
return taos_errstr(pStmt->exec.pRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
int stmtAffectedRows(TAOS_STMT *stmt) {
|
int stmtAffectedRows(TAOS_STMT* stmt) { return ((STscStmt*)stmt)->affectedRows; }
|
||||||
return ((STscStmt*)stmt)->affectedRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
int stmtAffectedRowsOnce(TAOS_STMT *stmt) {
|
int stmtAffectedRowsOnce(TAOS_STMT* stmt) { return ((STscStmt*)stmt)->exec.affectedRows; }
|
||||||
return ((STscStmt*)stmt)->exec.affectedRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
int stmtIsInsert(TAOS_STMT *stmt, int *insert) {
|
int stmtIsInsert(TAOS_STMT* stmt, int* insert) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
if (pStmt->sql.type) {
|
if (pStmt->sql.type) {
|
||||||
|
@ -808,16 +811,17 @@ int stmtIsInsert(TAOS_STMT *stmt, int *insert) {
|
||||||
} else {
|
} else {
|
||||||
*insert = isInsertSql(pStmt->sql.sqlStr, 0);
|
*insert = isInsertSql(pStmt->sql.sqlStr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stmtGetParamNum(TAOS_STMT *stmt, int *nums) {
|
int stmtGetParamNum(TAOS_STMT* stmt, int* nums) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_FETCH_FIELDS));
|
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_FETCH_FIELDS));
|
||||||
|
|
||||||
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 && STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
|
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
|
||||||
|
STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
|
||||||
pStmt->bInfo.needParse = false;
|
pStmt->bInfo.needParse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,7 +829,7 @@ int stmtGetParamNum(TAOS_STMT *stmt, int *nums) {
|
||||||
taos_free_result(pStmt->exec.pRequest);
|
taos_free_result(pStmt->exec.pRequest);
|
||||||
pStmt->exec.pRequest = NULL;
|
pStmt->exec.pRequest = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == pStmt->exec.pRequest) {
|
if (NULL == pStmt->exec.pRequest) {
|
||||||
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
|
STMT_ERR_RET(buildRequest(pStmt->taos, pStmt->sql.sqlStr, pStmt->sql.sqlLen, &pStmt->exec.pRequest));
|
||||||
}
|
}
|
||||||
|
@ -843,16 +847,16 @@ int stmtGetParamNum(TAOS_STMT *stmt, int *nums) {
|
||||||
} else {
|
} else {
|
||||||
STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
|
STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
*nums = taosArrayGetSize(pStmt->sql.pQueryPlan->pPlaceholderValues);
|
*nums = taosArrayGetSize(pStmt->sql.pQueryPlan->pPlaceholderValues);
|
||||||
} else {
|
} else {
|
||||||
STMT_ERR_RET(stmtFetchColFields(stmt, nums, NULL));
|
STMT_ERR_RET(stmtFetchColFields(stmt, nums, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAOS_RES *stmtUseResult(TAOS_STMT *stmt) {
|
TAOS_RES* stmtUseResult(TAOS_STMT* stmt) {
|
||||||
STscStmt* pStmt = (STscStmt*)stmt;
|
STscStmt* pStmt = (STscStmt*)stmt;
|
||||||
|
|
||||||
if (STMT_TYPE_QUERY != pStmt->sql.type) {
|
if (STMT_TYPE_QUERY != pStmt->sql.type) {
|
||||||
|
@ -862,6 +866,3 @@ TAOS_RES *stmtUseResult(TAOS_STMT *stmt) {
|
||||||
|
|
||||||
return pStmt->exec.pRequest;
|
return pStmt->exec.pRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ TEST(testCase, smlParseCols_tag_Test) {
|
||||||
msgBuf.len = 256;
|
msgBuf.len = 256;
|
||||||
|
|
||||||
SArray *cols = taosArrayInit(16, POINTER_BYTES);
|
SArray *cols = taosArrayInit(16, POINTER_BYTES);
|
||||||
ASSERT_NE(cols, NULL);
|
ASSERT_NE(cols, nullptr);
|
||||||
SHashObj *dumplicateKey = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
SHashObj *dumplicateKey = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
const char *data =
|
const char *data =
|
||||||
|
@ -226,7 +226,7 @@ TEST(testCase, smlParseCols_tag_Test) {
|
||||||
ASSERT_EQ(size, 19);
|
ASSERT_EQ(size, 19);
|
||||||
|
|
||||||
// nchar
|
// nchar
|
||||||
SSmlKv *kv = taosArrayGetP(cols, 0);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, 0);
|
||||||
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);
|
||||||
|
@ -235,7 +235,7 @@ TEST(testCase, smlParseCols_tag_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// nchar
|
// nchar
|
||||||
kv = taosArrayGetP(cols, 3);
|
kv = (SSmlKv *)taosArrayGetP(cols, 3);
|
||||||
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);
|
||||||
|
@ -257,7 +257,7 @@ TEST(testCase, smlParseCols_tag_Test) {
|
||||||
ASSERT_EQ(size, 1);
|
ASSERT_EQ(size, 1);
|
||||||
|
|
||||||
// nchar
|
// nchar
|
||||||
kv = taosArrayGetP(cols, 0);
|
kv = (SSmlKv *)taosArrayGetP(cols, 0);
|
||||||
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);
|
||||||
|
@ -276,7 +276,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
msgBuf.len = 256;
|
msgBuf.len = 256;
|
||||||
|
|
||||||
SArray *cols = taosArrayInit(16, POINTER_BYTES);
|
SArray *cols = taosArrayInit(16, POINTER_BYTES);
|
||||||
ASSERT_NE(cols, NULL);
|
ASSERT_NE(cols, nullptr);
|
||||||
|
|
||||||
SHashObj *dumplicateKey = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
SHashObj *dumplicateKey = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
ASSERT_EQ(size, 19);
|
ASSERT_EQ(size, 19);
|
||||||
|
|
||||||
// binary
|
// binary
|
||||||
SSmlKv *kv = taosArrayGetP(cols, 0);
|
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, 0);
|
||||||
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_BINARY);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BINARY);
|
||||||
|
@ -297,7 +297,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// nchar
|
// nchar
|
||||||
kv = taosArrayGetP(cols, 1);
|
kv = (SSmlKv *)taosArrayGetP(cols, 1);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cnch", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cnch", 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);
|
||||||
|
@ -306,7 +306,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// bool
|
// bool
|
||||||
kv = taosArrayGetP(cols, 2);
|
kv = (SSmlKv *)taosArrayGetP(cols, 2);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cbool", 5), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cbool", 5), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 5);
|
ASSERT_EQ(kv->keyLen, 5);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BOOL);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BOOL);
|
||||||
|
@ -315,7 +315,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// double
|
// double
|
||||||
kv = taosArrayGetP(cols, 3);
|
kv = (SSmlKv *)taosArrayGetP(cols, 3);
|
||||||
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_DOUBLE);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_DOUBLE);
|
||||||
|
@ -325,7 +325,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// float
|
// float
|
||||||
kv = taosArrayGetP(cols, 4);
|
kv = (SSmlKv *)taosArrayGetP(cols, 4);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cf32_", 5), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cf32_", 5), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 5);
|
ASSERT_EQ(kv->keyLen, 5);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_FLOAT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_FLOAT);
|
||||||
|
@ -335,7 +335,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// float
|
// float
|
||||||
kv = taosArrayGetP(cols, 5);
|
kv = (SSmlKv *)taosArrayGetP(cols, 5);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cf32", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cf32", 4), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 4);
|
ASSERT_EQ(kv->keyLen, 4);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_FLOAT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_FLOAT);
|
||||||
|
@ -345,7 +345,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// tiny int
|
// tiny int
|
||||||
kv = taosArrayGetP(cols, 6);
|
kv = (SSmlKv *)taosArrayGetP(cols, 6);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "ci8", 3), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "ci8", 3), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 3);
|
ASSERT_EQ(kv->keyLen, 3);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_TINYINT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_TINYINT);
|
||||||
|
@ -354,7 +354,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// unsigned tiny int
|
// unsigned tiny int
|
||||||
kv = taosArrayGetP(cols, 7);
|
kv = (SSmlKv *)taosArrayGetP(cols, 7);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cu8", 3), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cu8", 3), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 3);
|
ASSERT_EQ(kv->keyLen, 3);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_UTINYINT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_UTINYINT);
|
||||||
|
@ -363,7 +363,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// small int
|
// small int
|
||||||
kv = taosArrayGetP(cols, 8);
|
kv = (SSmlKv *)taosArrayGetP(cols, 8);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "ci16", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "ci16", 4), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 4);
|
ASSERT_EQ(kv->keyLen, 4);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_SMALLINT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_SMALLINT);
|
||||||
|
@ -372,7 +372,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// unsigned smallint
|
// unsigned smallint
|
||||||
kv = taosArrayGetP(cols, 9);
|
kv = (SSmlKv *)taosArrayGetP(cols, 9);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cu16", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cu16", 4), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 4);
|
ASSERT_EQ(kv->keyLen, 4);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_USMALLINT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_USMALLINT);
|
||||||
|
@ -381,7 +381,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// int
|
// int
|
||||||
kv = taosArrayGetP(cols, 10);
|
kv = (SSmlKv *)taosArrayGetP(cols, 10);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "ci32", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "ci32", 4), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 4);
|
ASSERT_EQ(kv->keyLen, 4);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_INT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_INT);
|
||||||
|
@ -390,7 +390,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// unsigned int
|
// unsigned int
|
||||||
kv = taosArrayGetP(cols, 11);
|
kv = (SSmlKv *)taosArrayGetP(cols, 11);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cu32", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cu32", 4), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 4);
|
ASSERT_EQ(kv->keyLen, 4);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_UINT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_UINT);
|
||||||
|
@ -400,7 +400,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
|
|
||||||
|
|
||||||
// bigint
|
// bigint
|
||||||
kv = taosArrayGetP(cols, 12);
|
kv = (SSmlKv *)taosArrayGetP(cols, 12);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "ci64", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "ci64", 4), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 4);
|
ASSERT_EQ(kv->keyLen, 4);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BIGINT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BIGINT);
|
||||||
|
@ -409,7 +409,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// bigint
|
// bigint
|
||||||
kv = taosArrayGetP(cols, 13);
|
kv = (SSmlKv *)taosArrayGetP(cols, 13);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "ci", 2), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "ci", 2), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 2);
|
ASSERT_EQ(kv->keyLen, 2);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BIGINT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BIGINT);
|
||||||
|
@ -418,7 +418,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// unsigned bigint
|
// unsigned bigint
|
||||||
kv = taosArrayGetP(cols, 14);
|
kv = (SSmlKv *)taosArrayGetP(cols, 14);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cu64", 4), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cu64", 4), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 4);
|
ASSERT_EQ(kv->keyLen, 4);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_UBIGINT);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_UBIGINT);
|
||||||
|
@ -427,7 +427,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// bool
|
// bool
|
||||||
kv = taosArrayGetP(cols, 15);
|
kv = (SSmlKv *)taosArrayGetP(cols, 15);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cbooltrue", 9), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cbooltrue", 9), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 9);
|
ASSERT_EQ(kv->keyLen, 9);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BOOL);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BOOL);
|
||||||
|
@ -437,7 +437,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
|
|
||||||
|
|
||||||
// bool
|
// bool
|
||||||
kv = taosArrayGetP(cols, 16);
|
kv = (SSmlKv *)taosArrayGetP(cols, 16);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cboolt", 6), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cboolt", 6), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 6);
|
ASSERT_EQ(kv->keyLen, 6);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BOOL);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BOOL);
|
||||||
|
@ -446,7 +446,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// bool
|
// bool
|
||||||
kv = taosArrayGetP(cols, 17);
|
kv = (SSmlKv *)taosArrayGetP(cols, 17);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cboolf", 6), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cboolf", 6), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 6);
|
ASSERT_EQ(kv->keyLen, 6);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BOOL);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_BOOL);
|
||||||
|
@ -455,7 +455,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
taosMemoryFree(kv);
|
taosMemoryFree(kv);
|
||||||
|
|
||||||
// nchar
|
// nchar
|
||||||
kv = taosArrayGetP(cols, 18);
|
kv = (SSmlKv *)taosArrayGetP(cols, 18);
|
||||||
ASSERT_EQ(strncasecmp(kv->key, "cnch_", 5), 0);
|
ASSERT_EQ(strncasecmp(kv->key, "cnch_", 5), 0);
|
||||||
ASSERT_EQ(kv->keyLen, 5);
|
ASSERT_EQ(kv->keyLen, 5);
|
||||||
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_NCHAR);
|
ASSERT_EQ(kv->type, TSDB_DATA_TYPE_NCHAR);
|
||||||
|
@ -469,7 +469,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
|
|
||||||
TEST(testCase, smlParseLine_Test) {
|
TEST(testCase, smlParseLine_Test) {
|
||||||
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
ASSERT_NE(taos, NULL);
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db");
|
TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db");
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
@ -477,11 +477,11 @@ TEST(testCase, smlParseLine_Test) {
|
||||||
pRes = taos_query(taos, "use sml_db");
|
pRes = taos_query(taos, "use sml_db");
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
SRequestObj *request = createRequest(taos, NULL, NULL, TSDB_SQL_INSERT);
|
SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
ASSERT_NE(request, NULL);
|
ASSERT_NE(request, nullptr);
|
||||||
|
|
||||||
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
ASSERT_NE(info, NULL);
|
ASSERT_NE(info, nullptr);
|
||||||
|
|
||||||
const char *sql[9] = {
|
const char *sql[9] = {
|
||||||
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0 1451606400000000000",
|
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0 1451606400000000000",
|
||||||
|
@ -494,7 +494,7 @@ TEST(testCase, smlParseLine_Test) {
|
||||||
"readings,name=truck_2,fleet=North,driver=Derek,model=F-150 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=428,velocity=0,heading=304,grade=0,fuel_consumption=25 1451609400000000000",
|
"readings,name=truck_2,fleet=North,driver=Derek,model=F-150 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=428,velocity=0,heading=304,grade=0,fuel_consumption=25 1451609400000000000",
|
||||||
"readings,fleet=South,name=truck_0,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 1451629400000000000"
|
"readings,fleet=South,name=truck_0,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 1451629400000000000"
|
||||||
};
|
};
|
||||||
smlInsertLines(info, sql, 9);
|
smlInsertLines(info, (char**)sql, 9);
|
||||||
// for (int i = 0; i < 3; i++) {
|
// for (int i = 0; i < 3; i++) {
|
||||||
// smlParseLine(info, sql[i]);
|
// smlParseLine(info, sql[i]);
|
||||||
// }
|
// }
|
||||||
|
@ -502,7 +502,7 @@ TEST(testCase, smlParseLine_Test) {
|
||||||
|
|
||||||
TEST(testCase, smlParseLine_error_Test) {
|
TEST(testCase, smlParseLine_error_Test) {
|
||||||
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
ASSERT_NE(taos, NULL);
|
ASSERT_NE(taos, nullptr);
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db");
|
TAOS_RES* pRes = taos_query(taos, "create database if not exists sml_db");
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
@ -510,17 +510,17 @@ TEST(testCase, smlParseLine_error_Test) {
|
||||||
pRes = taos_query(taos, "use sml_db");
|
pRes = taos_query(taos, "use sml_db");
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
SRequestObj *request = createRequest(taos, NULL, NULL, TSDB_SQL_INSERT);
|
SRequestObj *request = (SRequestObj *)createRequest((STscObj*)taos, NULL, NULL, TSDB_SQL_INSERT);
|
||||||
ASSERT_NE(request, NULL);
|
ASSERT_NE(request, nullptr);
|
||||||
|
|
||||||
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
SSmlHandle *info = smlBuildSmlInfo(taos, request, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS, true);
|
||||||
ASSERT_NE(info, NULL);
|
ASSERT_NE(info, nullptr);
|
||||||
|
|
||||||
const char *sql[2] = {
|
const char *sql[2] = {
|
||||||
"measure,t1=3 c1=8",
|
"measure,t1=3 c1=8",
|
||||||
"measure,t2=3 c1=8u8"
|
"measure,t2=3 c1=8u8"
|
||||||
};
|
};
|
||||||
int ret = smlInsertLines(info, sql, 2);
|
int ret = smlInsertLines(info, (char **)sql, 2);
|
||||||
ASSERT_NE(ret, 0);
|
ASSERT_NE(ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,238 @@
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
|
|
||||||
|
#define TD_KV_ROW 0x1U
|
||||||
|
|
||||||
|
struct SKVIdx {
|
||||||
|
int32_t cid;
|
||||||
|
int32_t offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t tEncodeTSRow(SEncoder *pEncoder, const STSRow2 *pRow) {
|
||||||
|
if (tEncodeI64(pEncoder, pRow->ts) < 0) return -1;
|
||||||
|
if (tEncodeU32v(pEncoder, pRow->flags) < 0) return -1;
|
||||||
|
if (pRow->flags & TD_KV_ROW) {
|
||||||
|
if (tEncodeI32v(pEncoder, pRow->ncols) < 0) return -1;
|
||||||
|
} else {
|
||||||
|
if (tEncodeI32v(pEncoder, pRow->sver) < 0) return -1;
|
||||||
|
}
|
||||||
|
if (tEncodeBinary(pEncoder, pRow->pData, pRow->nData) < 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDecodeTSRow(SDecoder *pDecoder, STSRow2 *pRow) {
|
||||||
|
if (tDecodeI64(pDecoder, &pRow->ts) < 0) return -1;
|
||||||
|
if (tDecodeU32v(pDecoder, &pRow->flags) < 0) return -1;
|
||||||
|
if (pRow->flags & TD_KV_ROW) {
|
||||||
|
if (tDecodeI32v(pDecoder, &pRow->ncols) < 0) return -1;
|
||||||
|
} else {
|
||||||
|
if (tDecodeI32v(pDecoder, &pRow->sver) < 0) return -1;
|
||||||
|
}
|
||||||
|
if (tDecodeBinary(pDecoder, &pRow->pData, &pRow->nData) < 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t ncols, STSchema **ppTSchema) {
|
||||||
|
*ppTSchema = (STSchema *)taosMemoryMalloc(sizeof(STSchema) + sizeof(STColumn) * ncols);
|
||||||
|
if (*ppTSchema == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*ppTSchema)->numOfCols = ncols;
|
||||||
|
(*ppTSchema)->version = sver;
|
||||||
|
(*ppTSchema)->flen = 0;
|
||||||
|
(*ppTSchema)->vlen = 0;
|
||||||
|
(*ppTSchema)->tlen = 0;
|
||||||
|
|
||||||
|
for (int32_t iCol = 0; iCol < ncols; iCol++) {
|
||||||
|
SSchema *pColumn = &pSchema[iCol];
|
||||||
|
STColumn *pTColumn = &((*ppTSchema)->columns[iCol]);
|
||||||
|
|
||||||
|
pTColumn->colId = pColumn->colId;
|
||||||
|
pTColumn->type = pColumn->type;
|
||||||
|
pTColumn->flags = pColumn->flags;
|
||||||
|
pTColumn->bytes = pColumn->bytes;
|
||||||
|
pTColumn->offset = (*ppTSchema)->flen;
|
||||||
|
|
||||||
|
// skip first column
|
||||||
|
if (iCol) {
|
||||||
|
(*ppTSchema)->flen += TYPE_BYTES[pColumn->type];
|
||||||
|
if (IS_VAR_DATA_TYPE(pColumn->type)) {
|
||||||
|
(*ppTSchema)->vlen += (pColumn->bytes + 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tTSchemaDestroy(STSchema *pTSchema) { taosMemoryFree(pTSchema); }
|
||||||
|
|
||||||
|
int32_t tTSRowBuilderInit(STSRowBuilder *pBuilder, int32_t sver, SSchema *pSchema, int32_t nCols) {
|
||||||
|
int32_t kvBufLen;
|
||||||
|
int32_t tpBufLen;
|
||||||
|
uint8_t *p;
|
||||||
|
|
||||||
|
if (tTSchemaCreate(sver, pSchema, nCols, &pBuilder->pTSchema) < 0) return -1;
|
||||||
|
|
||||||
|
kvBufLen = sizeof(SKVIdx) * nCols + pBuilder->pTSchema->flen + pBuilder->pTSchema->vlen;
|
||||||
|
tpBufLen = pBuilder->pTSchema->flen + pBuilder->pTSchema->vlen;
|
||||||
|
|
||||||
|
if (pBuilder->szKVBuf < kvBufLen) {
|
||||||
|
p = taosMemoryRealloc(pBuilder->pKVBuf, kvBufLen);
|
||||||
|
if (p == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pBuilder->pKVBuf = p;
|
||||||
|
pBuilder->szKVBuf = kvBufLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pBuilder->szTPBuf < tpBufLen) {
|
||||||
|
p = taosMemoryRealloc(pBuilder->pTPBuf, tpBufLen);
|
||||||
|
if (p == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pBuilder->pTPBuf = p;
|
||||||
|
pBuilder->szTPBuf = tpBufLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
tTSRowBuilderReset(pBuilder);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tTSRowBuilderClear(STSRowBuilder *pBuilder) {
|
||||||
|
taosMemoryFree(pBuilder->pKVBuf);
|
||||||
|
taosMemoryFree(pBuilder->pTPBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tTSRowBuilderReset(STSRowBuilder *pBuilder) {
|
||||||
|
for (int32_t iCol = pBuilder->pTSchema->numOfCols - 1; iCol >= 0; iCol--) {
|
||||||
|
pBuilder->pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||||
|
|
||||||
|
pBuilder->pTColumn->flags &= (~COL_VAL_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
pBuilder->nCols = 0;
|
||||||
|
pBuilder->kvVLen = 0;
|
||||||
|
pBuilder->tpVLen = 0;
|
||||||
|
pBuilder->row.flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, const uint8_t *pData, uint32_t nData) {
|
||||||
|
int32_t iCol;
|
||||||
|
uint8_t *p;
|
||||||
|
|
||||||
|
// search column
|
||||||
|
if (pBuilder->pTColumn->colId < cid) {
|
||||||
|
iCol = (pBuilder->pTColumn - pBuilder->pTSchema->columns) / sizeof(STColumn) + 1;
|
||||||
|
for (; iCol < pBuilder->pTSchema->numOfCols; iCol++) {
|
||||||
|
pBuilder->pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||||
|
if (pBuilder->pTColumn->colId == cid) break;
|
||||||
|
}
|
||||||
|
} else if (pBuilder->pTColumn->colId > cid) {
|
||||||
|
iCol = (pBuilder->pTColumn - pBuilder->pTSchema->columns) / sizeof(STColumn) - 1;
|
||||||
|
for (; iCol >= 0; iCol--) {
|
||||||
|
pBuilder->pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||||
|
if (pBuilder->pTColumn->colId == cid) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check
|
||||||
|
if (pBuilder->pTColumn->colId != cid || pBuilder->pTColumn->flags & COL_VAL_SET) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set value
|
||||||
|
if (cid == 0) {
|
||||||
|
ASSERT(pData && nData == sizeof(TSKEY));
|
||||||
|
pBuilder->row.ts = *(TSKEY *)pData;
|
||||||
|
} else {
|
||||||
|
if (pData) {
|
||||||
|
// ASSERT(!IS_NULL(pData));
|
||||||
|
|
||||||
|
// set tuple data
|
||||||
|
p = pBuilder->pTPBuf + pBuilder->pTColumn->offset;
|
||||||
|
if (IS_VAR_DATA_TYPE(pBuilder->pTColumn->type)) {
|
||||||
|
*(int32_t *)p = pBuilder->tpVLen;
|
||||||
|
|
||||||
|
// encode the variant-length data
|
||||||
|
p = pBuilder->pTPBuf + pBuilder->pTSchema->flen + pBuilder->tpVLen;
|
||||||
|
pBuilder->tpVLen += tPutBinary(p, pData, nData);
|
||||||
|
} else {
|
||||||
|
memcpy(p, pData, nData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set kv data
|
||||||
|
p = pBuilder->pKVBuf + sizeof(SKVIdx) * pBuilder->nCols;
|
||||||
|
((SKVIdx *)p)->cid = cid;
|
||||||
|
((SKVIdx *)p)->offset = pBuilder->kvVLen;
|
||||||
|
|
||||||
|
p = pBuilder->pKVBuf + sizeof(SKVIdx) * pBuilder->pTSchema->numOfCols + pBuilder->kvVLen;
|
||||||
|
if (IS_VAR_DATA_TYPE(pBuilder->pTColumn->type)) {
|
||||||
|
pBuilder->kvVLen += tPutBinary(p, pData, nData);
|
||||||
|
} else {
|
||||||
|
memcpy(p, pData, nData);
|
||||||
|
pBuilder->kvVLen += nData;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// set NULL val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pBuilder->pTColumn->flags |= COL_VAL_SET;
|
||||||
|
pBuilder->nCols++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow) {
|
||||||
|
if ((pBuilder->pTSchema->columns[0].flags & COL_VAL_SET) == 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pBuilder->nCols * sizeof(SKVIdx) + pBuilder->kvVLen < pBuilder->pTSchema->flen + pBuilder->tpVLen) {
|
||||||
|
// encode as TD_KV_ROW
|
||||||
|
pBuilder->row.flags |= TD_KV_ROW;
|
||||||
|
pBuilder->row.ncols = pBuilder->nCols;
|
||||||
|
pBuilder->row.nData = pBuilder->nCols * sizeof(SKVIdx) + pBuilder->kvVLen;
|
||||||
|
pBuilder->row.pData = pBuilder->pKVBuf;
|
||||||
|
|
||||||
|
if (pBuilder->nCols < pBuilder->pTSchema->numOfCols) {
|
||||||
|
memmove(pBuilder->pKVBuf + sizeof(SKVIdx) * pBuilder->nCols,
|
||||||
|
pBuilder->pKVBuf + sizeof(SKVIdx) * pBuilder->pTSchema->numOfCols, pBuilder->kvVLen);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// encode as TD_TUPLE_ROW
|
||||||
|
pBuilder->row.flags &= (~TD_KV_ROW);
|
||||||
|
pBuilder->row.sver = pBuilder->pTSchema->version;
|
||||||
|
pBuilder->row.nData = pBuilder->pTSchema->flen + pBuilder->tpVLen;
|
||||||
|
pBuilder->row.pData = pBuilder->pTPBuf;
|
||||||
|
|
||||||
|
if (pBuilder->nCols < pBuilder->pTSchema->numOfCols) {
|
||||||
|
// set non-set cols as None
|
||||||
|
for (int32_t iCol = 1; iCol < pBuilder->pTSchema->numOfCols; iCol++) {
|
||||||
|
pBuilder->pTColumn = &pBuilder->pTSchema->columns[iCol];
|
||||||
|
if (pBuilder->pTColumn->flags & COL_VAL_SET) continue;
|
||||||
|
|
||||||
|
{
|
||||||
|
// set None (todo)
|
||||||
|
}
|
||||||
|
|
||||||
|
pBuilder->pTColumn->flags |= COL_VAL_SET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppRow = &pBuilder->row;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 1 // ====================
|
||||||
static void dataColSetNEleNull(SDataCol *pCol, int nEle);
|
static void dataColSetNEleNull(SDataCol *pCol, int nEle);
|
||||||
#if 0
|
int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
|
||||||
static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2,
|
|
||||||
int limit2, int tRows, bool forceSetNull);
|
|
||||||
#endif
|
|
||||||
int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
|
|
||||||
int spaceNeeded = pCol->bytes * maxPoints;
|
int spaceNeeded = pCol->bytes * maxPoints;
|
||||||
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||||
spaceNeeded += sizeof(VarDataOffsetT) * maxPoints;
|
spaceNeeded += sizeof(VarDataOffsetT) * maxPoints;
|
||||||
|
@ -504,3 +730,4 @@ SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder) {
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -351,7 +351,7 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t taosAddServerCfg(SConfig *pCfg) {
|
static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "supportVnodes", 256, 0, 4096, 0) != 0) return -1;
|
||||||
if (cfgAddDir(pCfg, "dataDir", tsDataDir, 0) != 0) return -1;
|
if (cfgAddDir(pCfg, "dataDir", tsDataDir, 0) != 0) return -1;
|
||||||
if (cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, 0) != 0) return -1;
|
if (cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, 0) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "maxNumOfDistinctRes", tsMaxNumOfDistinctResults, 10 * 10000, 10000 * 10000, 0) != 0) return -1;
|
||||||
|
|
|
@ -1159,7 +1159,7 @@ bool tdGetKvRowValOfColEx(STSRowIter *pIter, col_id_t colId, col_type_t colType,
|
||||||
|
|
||||||
#ifdef TD_SUPPORT_BITMAP
|
#ifdef TD_SUPPORT_BITMAP
|
||||||
int16_t colIdx = -1;
|
int16_t colIdx = -1;
|
||||||
if (pKvIdx) colIdx = POINTER_DISTANCE(TD_ROW_COL_IDX(pRow), pKvIdx) / sizeof(SKvRowIdx);
|
if (pKvIdx) colIdx = POINTER_DISTANCE(pKvIdx, TD_ROW_COL_IDX(pRow)) / sizeof(SKvRowIdx);
|
||||||
if (tdGetBitmapValType(pIter->pBitmap, colIdx, &pVal->valType, 0) != TSDB_CODE_SUCCESS) {
|
if (tdGetBitmapValType(pIter->pBitmap, colIdx, &pVal->valType, 0) != TSDB_CODE_SUCCESS) {
|
||||||
pVal->valType = TD_VTYPE_NONE;
|
pVal->valType = TD_VTYPE_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1226,7 +1226,7 @@ bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCell
|
||||||
compareKvRowColId, TD_EQ);
|
compareKvRowColId, TD_EQ);
|
||||||
#ifdef TD_SUPPORT_BITMAP
|
#ifdef TD_SUPPORT_BITMAP
|
||||||
if (pIdx) {
|
if (pIdx) {
|
||||||
colIdx = POINTER_DISTANCE(TD_ROW_COL_IDX(pRow), pIdx) / sizeof(SKvRowIdx);
|
colIdx = POINTER_DISTANCE(pIdx, TD_ROW_COL_IDX(pRow)) / sizeof(SKvRowIdx);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
tdGetKvRowValOfCol(pVal, pRow, pIter->pBitmap, pIdx ? pIdx->offset : -1, colIdx);
|
tdGetKvRowValOfCol(pVal, pRow, pIter->pBitmap, pIdx ? pIdx->offset : -1, colIdx);
|
||||||
|
|
|
@ -35,104 +35,36 @@
|
||||||
assert(0); \
|
assert(0); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value, bool *isSigned) {
|
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
char *endPtr = NULL;
|
char *endPtr = NULL;
|
||||||
|
|
||||||
int32_t index = 0;
|
*value = strtoll(z, &endPtr, base);
|
||||||
|
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||||
bool specifiedSign = (z[0] == '+' || z[0] == '-');
|
|
||||||
if (specifiedSign) {
|
|
||||||
*isSigned = true;
|
|
||||||
index = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t val = strtoull(&z[index], &endPtr, base);
|
|
||||||
if (errno == ERANGE || errno == EINVAL) {
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (specifiedSign && val > INT64_MAX) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endPtr - &z[index] != n - index) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*isSigned = specifiedSign || (val <= INT64_MAX);
|
|
||||||
if (*isSigned) {
|
|
||||||
*value = (z[0] == '-') ? -val : val;
|
|
||||||
} else {
|
|
||||||
*(uint64_t *)value = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosVariantCreate(SVariant *pVar, const char *z, int32_t n, int32_t type) {
|
int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value) {
|
||||||
int32_t ret = 0;
|
errno = 0;
|
||||||
memset(pVar, 0, sizeof(SVariant));
|
char *endPtr = NULL;
|
||||||
|
|
||||||
switch (type) {
|
const char *p = z;
|
||||||
case TSDB_DATA_TYPE_BOOL: {
|
while (*p != 0 && *p == ' ') p++;
|
||||||
if (strncasecmp(z, "true", 4) == 0) {
|
if (*p != 0 && *p == '-') {
|
||||||
pVar->i = TSDB_TRUE;
|
return -1;
|
||||||
} else if (strncasecmp(z, "false", 5) == 0) {
|
|
||||||
pVar->i = TSDB_FALSE;
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
|
||||||
case TSDB_DATA_TYPE_SMALLINT:
|
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
|
||||||
case TSDB_DATA_TYPE_INT: {
|
|
||||||
bool sign = true;
|
|
||||||
|
|
||||||
int32_t base = 10;
|
|
||||||
if (type == TK_NK_HEX) {
|
|
||||||
base = 16;
|
|
||||||
} else if (type == TK_NK_OCT) {
|
|
||||||
base = 8;
|
|
||||||
} else if (type == TK_NK_BIN) {
|
|
||||||
base = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = toInteger(z, n, base, &pVar->i, &sign);
|
|
||||||
if (ret != 0) {
|
|
||||||
pVar->nType = -1; // -1 means error type
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pVar->nType = (sign) ? TSDB_DATA_TYPE_BIGINT : TSDB_DATA_TYPE_UBIGINT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
|
||||||
pVar->d = strtod(z, NULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_BINARY: {
|
|
||||||
pVar->pz = strndup(z, n);
|
|
||||||
//pVar->nLen = strRmquote(pVar->pz, n);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP: {
|
|
||||||
assert(0);
|
|
||||||
pVar->i = taosGetTimestamp(TSDB_TIME_PRECISION_NANO);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: { // nType == 0 means the null value
|
|
||||||
type = TSDB_DATA_TYPE_NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pVar->nType = type;
|
*value = strtoull(z, &endPtr, base);
|
||||||
|
if (errno == ERANGE || errno == EINVAL || endPtr - z != n) {
|
||||||
|
errno = 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -461,7 +393,7 @@ static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
|
||||||
|
|
||||||
if (*pDest == pVariant->pz) {
|
if (*pDest == pVariant->pz) {
|
||||||
TdUcs4 *pWStr = taosMemoryCalloc(1, (nLen + 1) * TSDB_NCHAR_SIZE);
|
TdUcs4 *pWStr = taosMemoryCalloc(1, (nLen + 1) * TSDB_NCHAR_SIZE);
|
||||||
bool ret = taosMbsToUcs4(pDst, nLen, pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL);
|
bool ret = taosMbsToUcs4(pDst, nLen, pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
taosMemoryFreeClear(pWStr);
|
taosMemoryFreeClear(pWStr);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -483,7 +415,7 @@ static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
|
||||||
} else {
|
} else {
|
||||||
int32_t output = 0;
|
int32_t output = 0;
|
||||||
|
|
||||||
bool ret = taosMbsToUcs4(pDst, nLen, (TdUcs4*)*pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output);
|
bool ret = taosMbsToUcs4(pDst, nLen, (TdUcs4 *)*pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -518,9 +450,9 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
|
||||||
*result = pVariant->u;
|
*result = pVariant->u;
|
||||||
} else if (IS_FLOAT_TYPE(pVariant->nType)) {
|
} else if (IS_FLOAT_TYPE(pVariant->nType)) {
|
||||||
*result = (int64_t) pVariant->d;
|
*result = (int64_t)pVariant->d;
|
||||||
} else {
|
} else {
|
||||||
//TODO: handling var types
|
// TODO: handling var types
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
@ -909,7 +841,7 @@ int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool inc
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tasoUcs4Copy((TdUcs4*)payload, pVariant->ucs4, pVariant->nLen);
|
tasoUcs4Copy((TdUcs4 *)payload, pVariant->ucs4, pVariant->nLen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1026,7 +958,7 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * taosVariantGet(SVariant *pVar, int32_t type) {
|
char *taosVariantGet(SVariant *pVar, int32_t type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
|
|
|
@ -8,12 +8,11 @@
|
||||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
|
#include "taos.h"
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
#include "tcommon.h"
|
|
||||||
#include "taos.h"
|
|
||||||
#include "tvariant.h"
|
|
||||||
#include "tdef.h"
|
#include "tdef.h"
|
||||||
|
#include "tvariant.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
//
|
//
|
||||||
|
@ -29,72 +28,62 @@ TEST(testCase, toInteger_test) {
|
||||||
uint32_t type = 0;
|
uint32_t type = 0;
|
||||||
|
|
||||||
int64_t val = 0;
|
int64_t val = 0;
|
||||||
bool sign = true;
|
|
||||||
|
|
||||||
int32_t ret = toInteger(s, strlen(s), 10, &val, &sign);
|
int32_t ret = toInteger(s, strlen(s), 10, &val);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(val, 123);
|
ASSERT_EQ(val, 123);
|
||||||
ASSERT_EQ(sign, true);
|
|
||||||
|
|
||||||
s = "9223372036854775807";
|
s = "9223372036854775807";
|
||||||
ret = toInteger(s, strlen(s), 10, &val, &sign);
|
ret = toInteger(s, strlen(s), 10, &val);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(val, 9223372036854775807);
|
ASSERT_EQ(val, 9223372036854775807);
|
||||||
ASSERT_EQ(sign, true);
|
|
||||||
|
|
||||||
s = "9323372036854775807";
|
s = "9323372036854775807";
|
||||||
ret = toInteger(s, strlen(s), 10, &val, &sign);
|
ret = toInteger(s, strlen(s), 10, &val);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(val, 9323372036854775807u);
|
ASSERT_EQ(val, 9323372036854775807u);
|
||||||
ASSERT_EQ(sign, false);
|
|
||||||
|
|
||||||
s = "-9323372036854775807";
|
s = "-9323372036854775807";
|
||||||
ret = toInteger(s, strlen(s), 10, &val, &sign);
|
ret = toInteger(s, strlen(s), 10, &val);
|
||||||
ASSERT_EQ(ret, -1);
|
ASSERT_EQ(ret, -1);
|
||||||
|
|
||||||
s = "-1";
|
s = "-1";
|
||||||
ret = toInteger(s, strlen(s), 10, &val, &sign);
|
ret = toInteger(s, strlen(s), 10, &val);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(val, -1);
|
ASSERT_EQ(val, -1);
|
||||||
ASSERT_EQ(sign, true);
|
|
||||||
|
|
||||||
s = "-9223372036854775807";
|
s = "-9223372036854775807";
|
||||||
ret = toInteger(s, strlen(s), 10, &val, &sign);
|
ret = toInteger(s, strlen(s), 10, &val);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(val, -9223372036854775807);
|
ASSERT_EQ(val, -9223372036854775807);
|
||||||
ASSERT_EQ(sign, true);
|
|
||||||
|
|
||||||
s = "1000u";
|
s = "1000u";
|
||||||
ret = toInteger(s, strlen(s), 10, &val, &sign);
|
ret = toInteger(s, strlen(s), 10, &val);
|
||||||
ASSERT_EQ(ret, -1);
|
ASSERT_EQ(ret, -1);
|
||||||
|
|
||||||
s = "0x10";
|
s = "0x10";
|
||||||
ret = toInteger(s, strlen(s), 16, &val, &sign);
|
ret = toInteger(s, strlen(s), 16, &val);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(val, 16);
|
ASSERT_EQ(val, 16);
|
||||||
ASSERT_EQ(sign, true);
|
|
||||||
|
|
||||||
s = "110";
|
s = "110";
|
||||||
ret = toInteger(s, strlen(s), 2, &val, &sign);
|
ret = toInteger(s, strlen(s), 2, &val);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(val, 6);
|
ASSERT_EQ(val, 6);
|
||||||
ASSERT_EQ(sign, true);
|
|
||||||
|
|
||||||
s = "110";
|
s = "110";
|
||||||
ret = toInteger(s, strlen(s), 8, &val, &sign);
|
ret = toInteger(s, strlen(s), 8, &val);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(val, 72);
|
ASSERT_EQ(val, 72);
|
||||||
ASSERT_EQ(sign, true);
|
|
||||||
|
|
||||||
//18446744073709551615 UINT64_MAX
|
// 18446744073709551615 UINT64_MAX
|
||||||
s = "18446744073709551615";
|
s = "18446744073709551615";
|
||||||
ret = toInteger(s, strlen(s), 10, &val, &sign);
|
ret = toInteger(s, strlen(s), 10, &val);
|
||||||
ASSERT_EQ(ret, 0);
|
ASSERT_EQ(ret, 0);
|
||||||
ASSERT_EQ(val, 18446744073709551615u);
|
ASSERT_EQ(val, 18446744073709551615u);
|
||||||
ASSERT_EQ(sign, false);
|
|
||||||
|
|
||||||
s = "18446744073709551616";
|
s = "18446744073709551616";
|
||||||
ret = toInteger(s, strlen(s), 10, &val, &sign);
|
ret = toInteger(s, strlen(s), 10, &val);
|
||||||
ASSERT_EQ(ret, -1);
|
ASSERT_EQ(ret, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,8 +97,8 @@ TEST(testCase, Datablock_test) {
|
||||||
infoData.info.type = TSDB_DATA_TYPE_INT;
|
infoData.info.type = TSDB_DATA_TYPE_INT;
|
||||||
infoData.info.colId = 1;
|
infoData.info.colId = 1;
|
||||||
|
|
||||||
infoData.pData = (char*) taosMemoryCalloc(40, infoData.info.bytes);
|
infoData.pData = (char*)taosMemoryCalloc(40, infoData.info.bytes);
|
||||||
infoData.nullbitmap = (char*) taosMemoryCalloc(1, sizeof(char) * (40/8));
|
infoData.nullbitmap = (char*)taosMemoryCalloc(1, sizeof(char) * (40 / 8));
|
||||||
taosArrayPush(b->pDataBlock, &infoData);
|
taosArrayPush(b->pDataBlock, &infoData);
|
||||||
|
|
||||||
SColumnInfoData infoData1 = {0};
|
SColumnInfoData infoData1 = {0};
|
||||||
|
@ -117,36 +106,36 @@ TEST(testCase, Datablock_test) {
|
||||||
infoData1.info.type = TSDB_DATA_TYPE_BINARY;
|
infoData1.info.type = TSDB_DATA_TYPE_BINARY;
|
||||||
infoData1.info.colId = 2;
|
infoData1.info.colId = 2;
|
||||||
|
|
||||||
infoData1.varmeta.offset = (int32_t*) taosMemoryCalloc(40, sizeof(uint32_t));
|
infoData1.varmeta.offset = (int32_t*)taosMemoryCalloc(40, sizeof(uint32_t));
|
||||||
taosArrayPush(b->pDataBlock, &infoData1);
|
taosArrayPush(b->pDataBlock, &infoData1);
|
||||||
|
|
||||||
char* str = "the value of: %d";
|
char* str = "the value of: %d";
|
||||||
char buf[128] = {0};
|
char buf[128] = {0};
|
||||||
char varbuf[128] = {0};
|
char varbuf[128] = {0};
|
||||||
|
|
||||||
for(int32_t i = 0; i < 40; ++i) {
|
for (int32_t i = 0; i < 40; ++i) {
|
||||||
SColumnInfoData* p0 = (SColumnInfoData *) taosArrayGet(b->pDataBlock, 0);
|
SColumnInfoData* p0 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 0);
|
||||||
SColumnInfoData* p1 = (SColumnInfoData *) taosArrayGet(b->pDataBlock, 1);
|
SColumnInfoData* p1 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 1);
|
||||||
|
|
||||||
if (i&0x01) {
|
if (i & 0x01) {
|
||||||
int32_t len = sprintf(buf, str, i);
|
int32_t len = sprintf(buf, str, i);
|
||||||
STR_TO_VARSTR(varbuf, buf)
|
STR_TO_VARSTR(varbuf, buf)
|
||||||
colDataAppend(p0, i, (const char*) &i, false);
|
colDataAppend(p0, i, (const char*)&i, false);
|
||||||
colDataAppend(p1, i, (const char*) varbuf, false);
|
colDataAppend(p1, i, (const char*)varbuf, false);
|
||||||
|
|
||||||
memset(varbuf, 0, sizeof(varbuf));
|
memset(varbuf, 0, sizeof(varbuf));
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(p0, i, (const char*) &i, true);
|
colDataAppend(p0, i, (const char*)&i, true);
|
||||||
colDataAppend(p1, i, (const char*) varbuf, true);
|
colDataAppend(p1, i, (const char*)varbuf, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
b->info.rows++;
|
b->info.rows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumnInfoData* p0 = (SColumnInfoData *) taosArrayGet(b->pDataBlock, 0);
|
SColumnInfoData* p0 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 0);
|
||||||
SColumnInfoData* p1 = (SColumnInfoData *) taosArrayGet(b->pDataBlock, 1);
|
SColumnInfoData* p1 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 1);
|
||||||
for(int32_t i = 0; i < 40; ++i) {
|
for (int32_t i = 0; i < 40; ++i) {
|
||||||
if (i & 0x01) {
|
if (i & 0x01) {
|
||||||
ASSERT_EQ(colDataIsNull_f(p0->nullbitmap, i), false);
|
ASSERT_EQ(colDataIsNull_f(p0->nullbitmap, i), false);
|
||||||
ASSERT_EQ(colDataIsNull(p1, b->info.rows, i, nullptr), false);
|
ASSERT_EQ(colDataIsNull(p1, b->info.rows, i, nullptr), false);
|
||||||
|
@ -158,7 +147,7 @@ TEST(testCase, Datablock_test) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("binary column length:%d\n", *(int32_t*) p1->pData);
|
printf("binary column length:%d\n", *(int32_t*)p1->pData);
|
||||||
|
|
||||||
ASSERT_EQ(blockDataGetNumOfCols(b), 2);
|
ASSERT_EQ(blockDataGetNumOfCols(b), 2);
|
||||||
ASSERT_EQ(blockDataGetNumOfRows(b), 40);
|
ASSERT_EQ(blockDataGetNumOfRows(b), 40);
|
||||||
|
@ -166,8 +155,8 @@ TEST(testCase, Datablock_test) {
|
||||||
char* pData = colDataGetData(p1, 3);
|
char* pData = colDataGetData(p1, 3);
|
||||||
printf("the second row of binary:%s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
|
printf("the second row of binary:%s, length:%d\n", (char*)varDataVal(pData), varDataLen(pData));
|
||||||
|
|
||||||
SArray* pOrderInfo = taosArrayInit(3, sizeof(SBlockOrderInfo));
|
SArray* pOrderInfo = taosArrayInit(3, sizeof(SBlockOrderInfo));
|
||||||
SBlockOrderInfo order = { true, TSDB_ORDER_ASC, 0, NULL };
|
SBlockOrderInfo order = {true, TSDB_ORDER_ASC, 0, NULL};
|
||||||
taosArrayPush(pOrderInfo, &order);
|
taosArrayPush(pOrderInfo, &order);
|
||||||
|
|
||||||
blockDataSort(b, pOrderInfo);
|
blockDataSort(b, pOrderInfo);
|
||||||
|
@ -244,8 +233,8 @@ TEST(testCase, var_dataBlock_split_test) {
|
||||||
infoData.info.type = TSDB_DATA_TYPE_INT;
|
infoData.info.type = TSDB_DATA_TYPE_INT;
|
||||||
infoData.info.colId = 1;
|
infoData.info.colId = 1;
|
||||||
|
|
||||||
infoData.pData = (char*) taosMemoryCalloc(numOfRows, infoData.info.bytes);
|
infoData.pData = (char*)taosMemoryCalloc(numOfRows, infoData.info.bytes);
|
||||||
infoData.nullbitmap = (char*) taosMemoryCalloc(1, sizeof(char) * (numOfRows/8));
|
infoData.nullbitmap = (char*)taosMemoryCalloc(1, sizeof(char) * (numOfRows / 8));
|
||||||
taosArrayPush(b->pDataBlock, &infoData);
|
taosArrayPush(b->pDataBlock, &infoData);
|
||||||
|
|
||||||
SColumnInfoData infoData1 = {0};
|
SColumnInfoData infoData1 = {0};
|
||||||
|
@ -253,13 +242,13 @@ TEST(testCase, var_dataBlock_split_test) {
|
||||||
infoData1.info.type = TSDB_DATA_TYPE_BINARY;
|
infoData1.info.type = TSDB_DATA_TYPE_BINARY;
|
||||||
infoData1.info.colId = 2;
|
infoData1.info.colId = 2;
|
||||||
|
|
||||||
infoData1.varmeta.offset = (int32_t*) taosMemoryCalloc(numOfRows, sizeof(uint32_t));
|
infoData1.varmeta.offset = (int32_t*)taosMemoryCalloc(numOfRows, sizeof(uint32_t));
|
||||||
taosArrayPush(b->pDataBlock, &infoData1);
|
taosArrayPush(b->pDataBlock, &infoData1);
|
||||||
|
|
||||||
char buf[41] = {0};
|
char buf[41] = {0};
|
||||||
char buf1[100] = {0};
|
char buf1[100] = {0};
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfRows; ++i) {
|
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||||
SColumnInfoData* p0 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 0);
|
SColumnInfoData* p0 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 0);
|
||||||
SColumnInfoData* p1 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 1);
|
SColumnInfoData* p1 = (SColumnInfoData*)taosArrayGet(b->pDataBlock, 1);
|
||||||
|
|
||||||
|
@ -278,10 +267,10 @@ TEST(testCase, var_dataBlock_split_test) {
|
||||||
|
|
||||||
int32_t pageSize = 64 * 1024;
|
int32_t pageSize = 64 * 1024;
|
||||||
|
|
||||||
int32_t startIndex= 0;
|
int32_t startIndex = 0;
|
||||||
int32_t stopIndex = 0;
|
int32_t stopIndex = 0;
|
||||||
int32_t count = 1;
|
int32_t count = 1;
|
||||||
while(1) {
|
while (1) {
|
||||||
blockDataSplitRows(b, true, startIndex, &stopIndex, pageSize);
|
blockDataSplitRows(b, true, startIndex, &stopIndex, pageSize);
|
||||||
printf("the %d split, from: %d to %d\n", count++, startIndex, stopIndex);
|
printf("the %d split, from: %d to %d\n", count++, startIndex, stopIndex);
|
||||||
|
|
||||||
|
|
|
@ -140,11 +140,17 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
pCfg->vgId = pCreate->vgId;
|
pCfg->vgId = pCreate->vgId;
|
||||||
tstrncpy(pCfg->dbname, pCreate->db, sizeof(pCfg->dbname));
|
tstrncpy(pCfg->dbname, pCreate->db, sizeof(pCfg->dbname));
|
||||||
pCfg->dbId = pCreate->dbUid;
|
pCfg->dbId = pCreate->dbUid;
|
||||||
|
pCfg->szPage = pCreate->pageSize * 1024;
|
||||||
|
pCfg->szCache = pCreate->pages;
|
||||||
|
pCfg->szBuf = pCreate->buffer * 1024 * 1024;
|
||||||
pCfg->isWeak = true;
|
pCfg->isWeak = true;
|
||||||
|
pCfg->tsdbCfg.precision = pCreate->precision;
|
||||||
pCfg->tsdbCfg.days = 10;
|
pCfg->tsdbCfg.days = 10;
|
||||||
pCfg->tsdbCfg.keep0 = 3650;
|
pCfg->tsdbCfg.keep0 = 3650;
|
||||||
pCfg->tsdbCfg.keep1 = 3650;
|
pCfg->tsdbCfg.keep1 = 3650;
|
||||||
pCfg->tsdbCfg.keep2 = 3650;
|
pCfg->tsdbCfg.keep2 = 3650;
|
||||||
|
pCfg->tsdbCfg.minRows = pCreate->minRows;
|
||||||
|
pCfg->tsdbCfg.maxRows = pCreate->maxRows;
|
||||||
for (size_t i = 0; i < taosArrayGetSize(pCreate->pRetensions); ++i) {
|
for (size_t i = 0; i < taosArrayGetSize(pCreate->pRetensions); ++i) {
|
||||||
memcpy(&pCfg->tsdbCfg.retentions[i], taosArrayGet(pCreate->pRetensions, i), sizeof(SRetention));
|
memcpy(&pCfg->tsdbCfg.retentions[i], taosArrayGet(pCreate->pRetensions, i), sizeof(SRetention));
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,6 +452,7 @@ typedef struct {
|
||||||
int8_t withSchema;
|
int8_t withSchema;
|
||||||
int8_t withTag;
|
int8_t withTag;
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
|
int32_t consumerCnt;
|
||||||
int32_t sqlLen;
|
int32_t sqlLen;
|
||||||
int32_t astLen;
|
int32_t astLen;
|
||||||
char* sql;
|
char* sql;
|
||||||
|
|
|
@ -412,8 +412,8 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
||||||
if (pCfg->numOfVgroups < 0) pCfg->numOfVgroups = TSDB_DEFAULT_VN_PER_DB;
|
if (pCfg->numOfVgroups < 0) pCfg->numOfVgroups = TSDB_DEFAULT_VN_PER_DB;
|
||||||
if (pCfg->numOfStables < 0) pCfg->numOfStables = TSDB_DEFAULT_DB_SINGLE_STABLE;
|
if (pCfg->numOfStables < 0) pCfg->numOfStables = TSDB_DEFAULT_DB_SINGLE_STABLE;
|
||||||
if (pCfg->buffer < 0) pCfg->buffer = TSDB_DEFAULT_BUFFER_PER_VNODE;
|
if (pCfg->buffer < 0) pCfg->buffer = TSDB_DEFAULT_BUFFER_PER_VNODE;
|
||||||
if (pCfg->pageSize < 0) pCfg->pageSize = TSDB_DEFAULT_PAGES_PER_VNODE;
|
if (pCfg->pageSize < 0) pCfg->pageSize = TSDB_DEFAULT_PAGESIZE_PER_VNODE;
|
||||||
if (pCfg->pages < 0) pCfg->pages = TSDB_MAX_PAGESIZE_PER_VNODE;
|
if (pCfg->pages < 0) pCfg->pages = TSDB_DEFAULT_PAGES_PER_VNODE;
|
||||||
if (pCfg->daysPerFile < 0) pCfg->daysPerFile = TSDB_DEFAULT_DURATION_PER_FILE;
|
if (pCfg->daysPerFile < 0) pCfg->daysPerFile = TSDB_DEFAULT_DURATION_PER_FILE;
|
||||||
if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP;
|
if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP;
|
||||||
if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0;
|
if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0;
|
||||||
|
|
|
@ -832,6 +832,8 @@ static int32_t mndProcessVCreateStbRsp(SNodeMsg *pRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
||||||
|
if (pAlter->commentLen != 0) return 0;
|
||||||
|
|
||||||
if (pAlter->numOfFields < 1 || pAlter->numOfFields != (int32_t)taosArrayGetSize(pAlter->pFields)) {
|
if (pAlter->numOfFields < 1 || pAlter->numOfFields != (int32_t)taosArrayGetSize(pAlter->pFields)) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -839,15 +841,6 @@ static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < pAlter->numOfFields; ++i) {
|
for (int32_t i = 0; i < pAlter->numOfFields; ++i) {
|
||||||
SField *pField = taosArrayGet(pAlter->pFields, i);
|
SField *pField = taosArrayGet(pAlter->pFields, i);
|
||||||
|
|
||||||
if (pField->type <= 0) {
|
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (pField->bytes <= 0) {
|
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (pField->name[0] == 0) {
|
if (pField->name[0] == 0) {
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -890,6 +883,23 @@ static int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndUpdateStbComment(const SStbObj *pOld, SStbObj *pNew, char *pComment, int32_t commentLen) {
|
||||||
|
if (commentLen > 0) {
|
||||||
|
pNew->commentLen = commentLen;
|
||||||
|
pNew->comment = taosMemoryCalloc(1, commentLen);
|
||||||
|
if (pNew->comment == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memcpy(pNew->comment, pComment, commentLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, SArray *pFields, int32_t ntags) {
|
static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, SArray *pFields, int32_t ntags) {
|
||||||
if (pOld->numOfTags + ntags > TSDB_MAX_TAGS) {
|
if (pOld->numOfTags + ntags > TSDB_MAX_TAGS) {
|
||||||
terrno = TSDB_CODE_MND_TOO_MANY_TAGS;
|
terrno = TSDB_CODE_MND_TOO_MANY_TAGS;
|
||||||
|
@ -908,12 +918,12 @@ static int32_t mndAddSuperTableTag(const SStbObj *pOld, SStbObj *pNew, SArray *p
|
||||||
|
|
||||||
for (int32_t i = 0; i < ntags; i++) {
|
for (int32_t i = 0; i < ntags; i++) {
|
||||||
SField *pField = taosArrayGet(pFields, i);
|
SField *pField = taosArrayGet(pFields, i);
|
||||||
if (mndFindSuperTableColumnIndex(pOld, pField->name) > 0) {
|
if (mndFindSuperTableColumnIndex(pOld, pField->name) >= 0) {
|
||||||
terrno = TSDB_CODE_MND_COLUMN_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_COLUMN_ALREADY_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndFindSuperTableTagIndex(pOld, pField->name) > 0) {
|
if (mndFindSuperTableTagIndex(pOld, pField->name) >= 0) {
|
||||||
terrno = TSDB_CODE_MND_TAG_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_TAG_ALREADY_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1034,12 +1044,12 @@ static int32_t mndAddSuperTableColumn(const SStbObj *pOld, SStbObj *pNew, SArray
|
||||||
|
|
||||||
for (int32_t i = 0; i < ncols; i++) {
|
for (int32_t i = 0; i < ncols; i++) {
|
||||||
SField *pField = taosArrayGet(pFields, i);
|
SField *pField = taosArrayGet(pFields, i);
|
||||||
if (mndFindSuperTableColumnIndex(pOld, pField->name) > 0) {
|
if (mndFindSuperTableColumnIndex(pOld, pField->name) >= 0) {
|
||||||
terrno = TSDB_CODE_MND_COLUMN_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_COLUMN_ALREADY_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndFindSuperTableTagIndex(pOld, pField->name) > 0) {
|
if (mndFindSuperTableTagIndex(pOld, pField->name) >= 0) {
|
||||||
terrno = TSDB_CODE_MND_TAG_ALREADY_EXIST;
|
terrno = TSDB_CODE_MND_TAG_ALREADY_EXIST;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1193,32 +1203,39 @@ static int32_t mndAlterStb(SMnode *pMnode, SNodeMsg *pReq, const SMAlterStbReq *
|
||||||
|
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
SField *pField0 = taosArrayGet(pAlter->pFields, 0);
|
SField *pField0 = NULL;
|
||||||
|
|
||||||
switch (pAlter->alterType) {
|
switch (pAlter->alterType) {
|
||||||
case TSDB_ALTER_TABLE_ADD_TAG:
|
case TSDB_ALTER_TABLE_ADD_TAG:
|
||||||
code = mndAddSuperTableTag(pOld, &stbObj, pAlter->pFields, pAlter->numOfFields);
|
code = mndAddSuperTableTag(pOld, &stbObj, pAlter->pFields, pAlter->numOfFields);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_DROP_TAG:
|
case TSDB_ALTER_TABLE_DROP_TAG:
|
||||||
|
pField0 = taosArrayGet(pAlter->pFields, 0);
|
||||||
code = mndDropSuperTableTag(pOld, &stbObj, pField0->name);
|
code = mndDropSuperTableTag(pOld, &stbObj, pField0->name);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_TAG_NAME:
|
case TSDB_ALTER_TABLE_UPDATE_TAG_NAME:
|
||||||
code = mndAlterStbTagName(pOld, &stbObj, pAlter->pFields);
|
code = mndAlterStbTagName(pOld, &stbObj, pAlter->pFields);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES:
|
case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES:
|
||||||
|
pField0 = taosArrayGet(pAlter->pFields, 0);
|
||||||
code = mndAlterStbTagBytes(pOld, &stbObj, pField0);
|
code = mndAlterStbTagBytes(pOld, &stbObj, pField0);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||||
code = mndAddSuperTableColumn(pOld, &stbObj, pAlter->pFields, pAlter->numOfFields);
|
code = mndAddSuperTableColumn(pOld, &stbObj, pAlter->pFields, pAlter->numOfFields);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||||
|
pField0 = taosArrayGet(pAlter->pFields, 0);
|
||||||
code = mndDropSuperTableColumn(pOld, &stbObj, pField0->name);
|
code = mndDropSuperTableColumn(pOld, &stbObj, pField0->name);
|
||||||
break;
|
break;
|
||||||
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES:
|
||||||
|
pField0 = taosArrayGet(pAlter->pFields, 0);
|
||||||
code = mndAlterStbColumnBytes(pOld, &stbObj, pField0);
|
code = mndAlterStbColumnBytes(pOld, &stbObj, pField0);
|
||||||
break;
|
break;
|
||||||
|
case TSDB_ALTER_TABLE_UPDATE_OPTIONS:
|
||||||
|
code = mndUpdateStbComment(pOld, &stbObj, pAlter->comment, pAlter->commentLen);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_MND_INVALID_STB_OPTION;
|
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -787,6 +787,8 @@ static int32_t mndRetrieveSubscribe(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do not show for cleared subscription
|
||||||
|
#if 0
|
||||||
int32_t sz = taosArrayGetSize(pSub->unassignedVgs);
|
int32_t sz = taosArrayGetSize(pSub->unassignedVgs);
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SMqVgEp *pVgEp = taosArrayGetP(pSub->unassignedVgs, i);
|
SMqVgEp *pVgEp = taosArrayGetP(pSub->unassignedVgs, i);
|
||||||
|
@ -829,6 +831,7 @@ static int32_t mndRetrieveSubscribe(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
taosRUnLockLatch(&pSub->lock);
|
taosRUnLockLatch(&pSub->lock);
|
||||||
sdbRelease(pSdb, pSub);
|
sdbRelease(pSdb, pSub);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,8 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
|
||||||
SDB_SET_INT8(pRaw, dataPos, pTopic->withTbName, TOPIC_ENCODE_OVER);
|
SDB_SET_INT8(pRaw, dataPos, pTopic->withTbName, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_INT8(pRaw, dataPos, pTopic->withSchema, TOPIC_ENCODE_OVER);
|
SDB_SET_INT8(pRaw, dataPos, pTopic->withSchema, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_INT8(pRaw, dataPos, pTopic->withTag, TOPIC_ENCODE_OVER);
|
SDB_SET_INT8(pRaw, dataPos, pTopic->withTag, TOPIC_ENCODE_OVER);
|
||||||
|
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, pTopic->consumerCnt, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen, TOPIC_ENCODE_OVER);
|
SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_ENCODE_OVER);
|
SDB_SET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_ENCODE_OVER);
|
||||||
SDB_SET_INT32(pRaw, dataPos, pTopic->astLen, TOPIC_ENCODE_OVER);
|
SDB_SET_INT32(pRaw, dataPos, pTopic->astLen, TOPIC_ENCODE_OVER);
|
||||||
|
@ -152,6 +154,8 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pTopic->withSchema, TOPIC_DECODE_OVER);
|
SDB_GET_INT8(pRaw, dataPos, &pTopic->withSchema, TOPIC_DECODE_OVER);
|
||||||
SDB_GET_INT8(pRaw, dataPos, &pTopic->withTag, TOPIC_DECODE_OVER);
|
SDB_GET_INT8(pRaw, dataPos, &pTopic->withTag, TOPIC_DECODE_OVER);
|
||||||
|
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &pTopic->consumerCnt, TOPIC_DECODE_OVER);
|
||||||
|
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER);
|
SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER);
|
||||||
pTopic->sql = taosMemoryCalloc(pTopic->sqlLen, sizeof(char));
|
pTopic->sql = taosMemoryCalloc(pTopic->sqlLen, sizeof(char));
|
||||||
if (pTopic->sql == NULL) {
|
if (pTopic->sql == NULL) {
|
||||||
|
|
|
@ -507,7 +507,7 @@ static int32_t mndProcessAlterUserReq(SNodeMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_READ_DB || alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_DB) {
|
if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_READ_DB || alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_DB) {
|
||||||
if (strcmp(alterReq.dbname, "*") != 0) {
|
if (strcmp(alterReq.dbname, "1.*") != 0) {
|
||||||
int32_t len = strlen(alterReq.dbname) + 1;
|
int32_t len = strlen(alterReq.dbname) + 1;
|
||||||
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname);
|
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
|
@ -521,7 +521,7 @@ static int32_t mndProcessAlterUserReq(SNodeMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_WRITE_DB || alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_DB) {
|
if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_WRITE_DB || alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_DB) {
|
||||||
if (strcmp(alterReq.dbname, "*") != 0) {
|
if (strcmp(alterReq.dbname, "1.*") != 0) {
|
||||||
int32_t len = strlen(alterReq.dbname) + 1;
|
int32_t len = strlen(alterReq.dbname) + 1;
|
||||||
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname);
|
SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
|
|
|
@ -241,7 +241,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
alterReq.alterType = TSDB_ALTER_USER_REMOVE_ALL_DB;
|
alterReq.alterType = TSDB_ALTER_USER_REMOVE_ALL_DB;
|
||||||
strcpy(alterReq.user, "u3");
|
strcpy(alterReq.user, "u3");
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
strcpy(alterReq.dbname, "*");
|
strcpy(alterReq.dbname, "1.*");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
@ -257,7 +257,7 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
||||||
alterReq.alterType = TSDB_ALTER_USER_REMOVE_ALL_DB;
|
alterReq.alterType = TSDB_ALTER_USER_REMOVE_ALL_DB;
|
||||||
strcpy(alterReq.user, "u3");
|
strcpy(alterReq.user, "u3");
|
||||||
strcpy(alterReq.pass, "1");
|
strcpy(alterReq.pass, "1");
|
||||||
strcpy(alterReq.dbname, "*");
|
strcpy(alterReq.dbname, "1.*");
|
||||||
|
|
||||||
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
|
|
|
@ -37,6 +37,9 @@ typedef struct SMSmaCursor SMSmaCursor;
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
// metaOpen ==================
|
// metaOpen ==================
|
||||||
|
int32_t metaRLock(SMeta* pMeta);
|
||||||
|
int32_t metaWLock(SMeta* pMeta);
|
||||||
|
int32_t metaULock(SMeta* pMeta);
|
||||||
|
|
||||||
// metaEntry ==================
|
// metaEntry ==================
|
||||||
int metaEncodeEntry(SEncoder* pCoder, const SMetaEntry* pME);
|
int metaEncodeEntry(SEncoder* pCoder, const SMetaEntry* pME);
|
||||||
|
@ -57,6 +60,8 @@ int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid);
|
||||||
static FORCE_INLINE tb_uid_t metaGenerateUid(SMeta* pMeta) { return tGenIdPI64(); }
|
static FORCE_INLINE tb_uid_t metaGenerateUid(SMeta* pMeta) { return tGenIdPI64(); }
|
||||||
|
|
||||||
struct SMeta {
|
struct SMeta {
|
||||||
|
TdThreadRwlock lock;
|
||||||
|
|
||||||
char* path;
|
char* path;
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
TENV* pEnv;
|
TENV* pEnv;
|
||||||
|
|
|
@ -22,6 +22,9 @@ static int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
|
||||||
static int ttlIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
|
static int ttlIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
|
||||||
static int uidIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
|
static int uidIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2);
|
||||||
|
|
||||||
|
static int32_t metaInitLock(SMeta *pMeta) { return taosThreadRwlockInit(&pMeta->lock, NULL); }
|
||||||
|
static int32_t metaDestroyLock(SMeta *pMeta) { return taosThreadRwlockDestroy(&pMeta->lock); }
|
||||||
|
|
||||||
int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
SMeta *pMeta = NULL;
|
SMeta *pMeta = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -36,6 +39,7 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
metaInitLock(pMeta);
|
||||||
pMeta->path = (char *)&pMeta[1];
|
pMeta->path = (char *)&pMeta[1];
|
||||||
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
||||||
VNODE_META_DIR);
|
VNODE_META_DIR);
|
||||||
|
@ -121,6 +125,7 @@ _err:
|
||||||
if (pMeta->pSkmDb) tdbDbClose(pMeta->pSkmDb);
|
if (pMeta->pSkmDb) tdbDbClose(pMeta->pSkmDb);
|
||||||
if (pMeta->pTbDb) tdbDbClose(pMeta->pTbDb);
|
if (pMeta->pTbDb) tdbDbClose(pMeta->pTbDb);
|
||||||
if (pMeta->pEnv) tdbEnvClose(pMeta->pEnv);
|
if (pMeta->pEnv) tdbEnvClose(pMeta->pEnv);
|
||||||
|
metaDestroyLock(pMeta);
|
||||||
taosMemoryFree(pMeta);
|
taosMemoryFree(pMeta);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -136,12 +141,19 @@ int metaClose(SMeta *pMeta) {
|
||||||
if (pMeta->pSkmDb) tdbDbClose(pMeta->pSkmDb);
|
if (pMeta->pSkmDb) tdbDbClose(pMeta->pSkmDb);
|
||||||
if (pMeta->pTbDb) tdbDbClose(pMeta->pTbDb);
|
if (pMeta->pTbDb) tdbDbClose(pMeta->pTbDb);
|
||||||
if (pMeta->pEnv) tdbEnvClose(pMeta->pEnv);
|
if (pMeta->pEnv) tdbEnvClose(pMeta->pEnv);
|
||||||
|
metaDestroyLock(pMeta);
|
||||||
taosMemoryFree(pMeta);
|
taosMemoryFree(pMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t metaRLock(SMeta *pMeta) { return taosThreadRwlockRdlock(&pMeta->lock); }
|
||||||
|
|
||||||
|
int32_t metaWLock(SMeta *pMeta) { return taosThreadRwlockWrlock(&pMeta->lock); }
|
||||||
|
|
||||||
|
int32_t metaULock(SMeta *pMeta) { return taosThreadRwlockUnlock(&pMeta->lock); }
|
||||||
|
|
||||||
static int tbDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) {
|
static int tbDbKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) {
|
||||||
STbDbKey *pTbDbKey1 = (STbDbKey *)pKey1;
|
STbDbKey *pTbDbKey1 = (STbDbKey *)pKey1;
|
||||||
STbDbKey *pTbDbKey2 = (STbDbKey *)pKey2;
|
STbDbKey *pTbDbKey2 = (STbDbKey *)pKey2;
|
||||||
|
|
|
@ -19,9 +19,13 @@ void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) {
|
||||||
memset(pReader, 0, sizeof(*pReader));
|
memset(pReader, 0, sizeof(*pReader));
|
||||||
pReader->flags = flags;
|
pReader->flags = flags;
|
||||||
pReader->pMeta = pMeta;
|
pReader->pMeta = pMeta;
|
||||||
|
metaRLock(pMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void metaReaderClear(SMetaReader *pReader) {
|
void metaReaderClear(SMetaReader *pReader) {
|
||||||
|
if (pReader->pMeta) {
|
||||||
|
metaULock(pReader->pMeta);
|
||||||
|
}
|
||||||
tDecoderClear(&pReader->coder);
|
tDecoderClear(&pReader->coder);
|
||||||
tdbFree(pReader->pBuf);
|
tdbFree(pReader->pBuf);
|
||||||
}
|
}
|
||||||
|
@ -264,6 +268,8 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
|
|
||||||
pSW = metaGetTableSchema(pMeta, quid, sver, 0);
|
pSW = metaGetTableSchema(pMeta, quid, sver, 0);
|
||||||
|
if (!pSW) return NULL;
|
||||||
|
|
||||||
tdInitTSchemaBuilder(&sb, 0);
|
tdInitTSchemaBuilder(&sb, 0);
|
||||||
for (int i = 0; i < pSW->nCols; i++) {
|
for (int i = 0; i < pSW->nCols; i++) {
|
||||||
pSchema = pSW->pSchema + i;
|
pSchema = pSW->pSchema + i;
|
||||||
|
|
|
@ -439,29 +439,36 @@ _exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
metaWLock(pMeta);
|
||||||
|
|
||||||
// save to table.db
|
// save to table.db
|
||||||
if (metaSaveToTbDb(pMeta, pME) < 0) return -1;
|
if (metaSaveToTbDb(pMeta, pME) < 0) goto _err;
|
||||||
|
|
||||||
// update uid.idx
|
// update uid.idx
|
||||||
if (metaUpdateUidIdx(pMeta, pME) < 0) return -1;
|
if (metaUpdateUidIdx(pMeta, pME) < 0) goto _err;
|
||||||
|
|
||||||
// update name.idx
|
// update name.idx
|
||||||
if (metaUpdateNameIdx(pMeta, pME) < 0) return -1;
|
if (metaUpdateNameIdx(pMeta, pME) < 0) goto _err;
|
||||||
|
|
||||||
if (pME->type == TSDB_CHILD_TABLE) {
|
if (pME->type == TSDB_CHILD_TABLE) {
|
||||||
// update ctb.idx
|
// update ctb.idx
|
||||||
if (metaUpdateCtbIdx(pMeta, pME) < 0) return -1;
|
if (metaUpdateCtbIdx(pMeta, pME) < 0) goto _err;
|
||||||
|
|
||||||
// update tag.idx
|
// update tag.idx
|
||||||
if (metaUpdateTagIdx(pMeta, pME) < 0) return -1;
|
if (metaUpdateTagIdx(pMeta, pME) < 0) goto _err;
|
||||||
} else {
|
} else {
|
||||||
// update schema.db
|
// update schema.db
|
||||||
if (metaSaveToSkmDb(pMeta, pME) < 0) return -1;
|
if (metaSaveToSkmDb(pMeta, pME) < 0) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pME->type != TSDB_SUPER_TABLE) {
|
if (pME->type != TSDB_SUPER_TABLE) {
|
||||||
if (metaUpdateTtlIdx(pMeta, pME) < 0) return -1;
|
if (metaUpdateTtlIdx(pMeta, pME) < 0) goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
metaULock(pMeta);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
metaULock(pMeta);
|
||||||
|
return -1;
|
||||||
}
|
}
|
|
@ -66,9 +66,9 @@ static void tdSRowDemo() {
|
||||||
SRowBuilder rb = {0};
|
SRowBuilder rb = {0};
|
||||||
|
|
||||||
SSchema schema[DEMO_N_COLS] = {
|
SSchema schema[DEMO_N_COLS] = {
|
||||||
{.type = TSDB_DATA_TYPE_TIMESTAMP, .colId = 1, .name = "ts", .bytes = 8, .flags = SCHEMA_SMA_ON},
|
{.type = TSDB_DATA_TYPE_TIMESTAMP, .colId = 1, .name = "ts", .bytes = 8, .flags = COL_SMA_ON},
|
||||||
{.type = TSDB_DATA_TYPE_INT, .colId = 2, .name = "c1", .bytes = 4, .flags = SCHEMA_SMA_ON},
|
{.type = TSDB_DATA_TYPE_INT, .colId = 2, .name = "c1", .bytes = 4, .flags = COL_SMA_ON},
|
||||||
{.type = TSDB_DATA_TYPE_INT, .colId = 3, .name = "c2", .bytes = 4, .flags = SCHEMA_SMA_ON}};
|
{.type = TSDB_DATA_TYPE_INT, .colId = 3, .name = "c2", .bytes = 4, .flags = COL_SMA_ON}};
|
||||||
|
|
||||||
SSchema* pSchema = schema;
|
SSchema* pSchema = schema;
|
||||||
STSchema* pTSChema = tdGetSTSChemaFromSSChema(&pSchema, numOfCols);
|
STSchema* pTSChema = tdGetSTSChemaFromSSChema(&pSchema, numOfCols);
|
||||||
|
@ -401,7 +401,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__EARLIEAST) {
|
if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__EARLIEAST) {
|
||||||
fetchOffset = walGetFirstVer(pTq->pWal);
|
fetchOffset = walGetFirstVer(pTq->pWal);
|
||||||
} else if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__LATEST) {
|
} else if (pReq->currentOffset == TMQ_CONF__RESET_OFFSET__LATEST) {
|
||||||
fetchOffset = walGetLastVer(pTq->pWal);
|
fetchOffset = walGetCommittedVer(pTq->pWal);
|
||||||
} else {
|
} else {
|
||||||
fetchOffset = pReq->currentOffset + 1;
|
fetchOffset = pReq->currentOffset + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,6 +382,7 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) {
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pIter && pIter->pTable && (!pIdx || (pIter->pTable->uid <= pIdx->uid))) {
|
if (pIter && pIter->pTable && (!pIdx || (pIter->pTable->uid <= pIdx->uid))) {
|
||||||
if (tsdbCommitToTable(pCommith, mIter) < 0) {
|
if (tsdbCommitToTable(pCommith, mIter) < 0) {
|
||||||
tsdbCloseCommitFile(pCommith, true);
|
tsdbCloseCommitFile(pCommith, true);
|
||||||
|
@ -394,6 +395,9 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) {
|
||||||
++fIter;
|
++fIter;
|
||||||
}
|
}
|
||||||
++mIter;
|
++mIter;
|
||||||
|
} else if (pIter && !pIter->pTable) {
|
||||||
|
// When table already dropped during commit, pIter is not NULL but pIter->pTable is NULL.
|
||||||
|
++mIter; // skip the table and do nothing
|
||||||
} else if (pIdx) {
|
} else if (pIdx) {
|
||||||
if (tsdbMoveBlkIdx(pCommith, pIdx) < 0) {
|
if (tsdbMoveBlkIdx(pCommith, pIdx) < 0) {
|
||||||
tsdbCloseCommitFile(pCommith, true);
|
tsdbCloseCommitFile(pCommith, true);
|
||||||
|
@ -439,6 +443,7 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) {
|
||||||
SCommitIter *pCommitIter;
|
SCommitIter *pCommitIter;
|
||||||
SSkipListNode *pNode;
|
SSkipListNode *pNode;
|
||||||
STbData *pTbData;
|
STbData *pTbData;
|
||||||
|
STSchema *pTSchema = NULL;
|
||||||
|
|
||||||
pCommith->niters = SL_SIZE(pMem->pSlIdx);
|
pCommith->niters = SL_SIZE(pMem->pSlIdx);
|
||||||
pCommith->iters = (SCommitIter *)taosMemoryCalloc(pCommith->niters, sizeof(SCommitIter));
|
pCommith->iters = (SCommitIter *)taosMemoryCalloc(pCommith->niters, sizeof(SCommitIter));
|
||||||
|
@ -459,13 +464,17 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) {
|
||||||
pTbData = (STbData *)pNode->pData;
|
pTbData = (STbData *)pNode->pData;
|
||||||
|
|
||||||
pCommitIter = pCommith->iters + i;
|
pCommitIter = pCommith->iters + i;
|
||||||
pCommitIter->pIter = tSkipListCreateIter(pTbData->pData);
|
pTSchema = metaGetTbTSchema(REPO_META(pRepo), pTbData->uid, 0); // TODO: schema version
|
||||||
tSkipListIterNext(pCommitIter->pIter);
|
|
||||||
|
|
||||||
pCommitIter->pTable = (STable *)taosMemoryMalloc(sizeof(STable));
|
if (pTSchema) {
|
||||||
pCommitIter->pTable->uid = pTbData->uid;
|
pCommitIter->pIter = tSkipListCreateIter(pTbData->pData);
|
||||||
pCommitIter->pTable->tid = pTbData->uid;
|
tSkipListIterNext(pCommitIter->pIter);
|
||||||
pCommitIter->pTable->pSchema = metaGetTbTSchema(REPO_META(pRepo), pTbData->uid, 0);
|
|
||||||
|
pCommitIter->pTable = (STable *)taosMemoryMalloc(sizeof(STable));
|
||||||
|
pCommitIter->pTable->uid = pTbData->uid;
|
||||||
|
pCommitIter->pTable->tid = pTbData->uid;
|
||||||
|
pCommitIter->pTable->pSchema = pTSchema; // metaGetTbTSchema(REPO_META(pRepo), pTbData->uid, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct SMemTable {
|
||||||
|
|
||||||
struct SMemSkipListNode {
|
struct SMemSkipListNode {
|
||||||
int8_t level;
|
int8_t level;
|
||||||
SMemSkipListNode *forwards[];
|
SMemSkipListNode *forwards[1]; // Windows does not allow 0
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMemSkipList {
|
struct SMemSkipList {
|
||||||
|
@ -46,7 +46,7 @@ struct SMemSkipList {
|
||||||
int8_t maxLevel;
|
int8_t maxLevel;
|
||||||
int8_t level;
|
int8_t level;
|
||||||
int32_t size;
|
int32_t size;
|
||||||
SMemSkipListNode pHead[];
|
SMemSkipListNode pHead[1]; // Windows does not allow 0
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMemData {
|
struct SMemData {
|
||||||
|
|
|
@ -3870,6 +3870,7 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch
|
||||||
|
|
||||||
if (metaGetTableEntryByUid(&mr, uid) < 0) {
|
if (metaGetTableEntryByUid(&mr, uid) < 0) {
|
||||||
tsdbError("%p failed to get stable, uid:%" PRIu64 ", TID:0x%" PRIx64 " QID:0x%" PRIx64, pMeta, uid, taskId, reqId);
|
tsdbError("%p failed to get stable, uid:%" PRIu64 ", TID:0x%" PRIx64 " QID:0x%" PRIx64, pMeta, uid, taskId, reqId);
|
||||||
|
metaReaderClear(&mr);
|
||||||
terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||||
goto _error;
|
goto _error;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3880,6 +3881,7 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch
|
||||||
tsdbError("%p query normal tag not allowed, uid:%" PRIu64 ", TID:0x%" PRIx64 " QID:0x%" PRIx64, pMeta, uid, taskId,
|
tsdbError("%p query normal tag not allowed, uid:%" PRIu64 ", TID:0x%" PRIx64 " QID:0x%" PRIx64, pMeta, uid, taskId,
|
||||||
reqId);
|
reqId);
|
||||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT; // basically, this error is caused by invalid sql issued by client
|
terrno = TSDB_CODE_OPS_NOT_SUPPORT; // basically, this error is caused by invalid sql issued by client
|
||||||
|
metaReaderClear(&mr);
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq,
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
taosArrayClear(rsp.pArray);
|
taosArrayDestroy(rsp.pArray);
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return rcode;
|
return rcode;
|
||||||
|
@ -454,6 +454,7 @@ static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
SVDropTbBatchReq req = {0};
|
SVDropTbBatchReq req = {0};
|
||||||
SVDropTbBatchRsp rsp = {0};
|
SVDropTbBatchRsp rsp = {0};
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
|
SEncoder encoder = {0};
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pRsp->msgType = TDMT_VND_DROP_TABLE_RSP;
|
pRsp->msgType = TDMT_VND_DROP_TABLE_RSP;
|
||||||
|
@ -471,7 +472,7 @@ static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
}
|
}
|
||||||
|
|
||||||
// process req
|
// process req
|
||||||
rsp.pArray = taosArrayInit(sizeof(SVDropTbRsp), req.nReqs);
|
rsp.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbRsp));
|
||||||
for (int iReq = 0; iReq < req.nReqs; iReq++) {
|
for (int iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
SVDropTbReq *pDropTbReq = req.pReqs + iReq;
|
SVDropTbReq *pDropTbReq = req.pReqs + iReq;
|
||||||
SVDropTbRsp dropTbRsp = {0};
|
SVDropTbRsp dropTbRsp = {0};
|
||||||
|
@ -493,7 +494,11 @@ static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
// encode rsp (TODO)
|
tEncodeSize(tEncodeSVDropTbBatchRsp, &rsp, pRsp->contLen, ret);
|
||||||
|
pRsp->pCont = rpcMallocCont(pRsp->contLen);
|
||||||
|
tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen);
|
||||||
|
tEncodeSVDropTbBatchRsp(&encoder, &rsp);
|
||||||
|
tEncoderClear(&encoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,7 +544,7 @@ static int vnodeDebugPrintSubmitMsg(SVnode *pVnode, SSubmitReq *pMsg, const char
|
||||||
while (true) {
|
while (true) {
|
||||||
if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) return -1;
|
if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) return -1;
|
||||||
if (pBlock == NULL) break;
|
if (pBlock == NULL) break;
|
||||||
|
|
||||||
vnodeDebugPrintSingleSubmitMsg(pMeta, pBlock, &msgIter, tags);
|
vnodeDebugPrintSingleSubmitMsg(pMeta, pBlock, &msgIter, tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,23 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "filter.h"
|
#ifndef _INDEX_OPERATOR_H
|
||||||
|
#define _INDEX_OPERATOR_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#include "nodes.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
|
||||||
typedef enum { SFLT_NOT_INDEX, SFLT_COARSE_INDEX, SFLT_ACCURATE_INDEX } SIdxFltStatus;
|
typedef enum { SFLT_NOT_INDEX, SFLT_COARSE_INDEX, SFLT_ACCURATE_INDEX } SIdxFltStatus;
|
||||||
|
|
||||||
SIdxFltStatus idxGetFltStatus(SNode *pFilterNode);
|
SIdxFltStatus idxGetFltStatus(SNode *pFilterNode);
|
||||||
// construct tag filter operator later
|
// construct tag filter operator later
|
||||||
int32_t doFilterTag(const SNode *pFilterNode, SArray *resutl);
|
int32_t doFilterTag(const SNode *pFilterNode, SArray *result);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*INDEX_OPERATOR_*/
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
|
|
||||||
typedef struct SIFCtx {
|
typedef struct SIFCtx {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
SHashObj *pRes; /* element is SScalarParam */
|
SHashObj *pRes; /* element is SScalarParam */
|
||||||
|
bool noExec; // true: just iterate condition tree, and add hint to executor plan
|
||||||
|
// SIdxFltStatus st;
|
||||||
} SIFCtx;
|
} SIFCtx;
|
||||||
|
|
||||||
#define SIF_ERR_RET(c) \
|
#define SIF_ERR_RET(c) \
|
||||||
|
@ -55,11 +57,12 @@ typedef struct SIFParam {
|
||||||
SArray *result;
|
SArray *result;
|
||||||
char * condValue;
|
char * condValue;
|
||||||
|
|
||||||
uint8_t colValType;
|
SIdxFltStatus status;
|
||||||
col_id_t colId;
|
uint8_t colValType;
|
||||||
int64_t suid; // add later
|
col_id_t colId;
|
||||||
char dbName[TSDB_DB_NAME_LEN];
|
int64_t suid; // add later
|
||||||
char colName[TSDB_COL_NAME_LEN];
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
|
char colName[TSDB_COL_NAME_LEN];
|
||||||
} SIFParam;
|
} SIFParam;
|
||||||
|
|
||||||
static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
|
static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
|
||||||
|
@ -82,6 +85,9 @@ static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef int32_t (*sif_func_t)(SIFParam *left, SIFParam *rigth, SIFParam *output);
|
typedef int32_t (*sif_func_t)(SIFParam *left, SIFParam *rigth, SIFParam *output);
|
||||||
|
|
||||||
|
static sif_func_t sifNullFunc = NULL;
|
||||||
|
// typedef struct SIFWalkParm
|
||||||
// construct tag filter operator later
|
// construct tag filter operator later
|
||||||
static void destroyTagFilterOperatorInfo(void *param) {
|
static void destroyTagFilterOperatorInfo(void *param) {
|
||||||
STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param;
|
STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param;
|
||||||
|
@ -114,6 +120,24 @@ static int32_t sifValidateColumn(SColumnNode *cn) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SIdxFltStatus sifMergeCond(ELogicConditionType type, SIdxFltStatus ls, SIdxFltStatus rs) {
|
||||||
|
// enh rule later
|
||||||
|
if (type == LOGIC_COND_TYPE_AND) {
|
||||||
|
if (ls == SFLT_NOT_INDEX || rs == SFLT_NOT_INDEX) {
|
||||||
|
if (ls == SFLT_NOT_INDEX)
|
||||||
|
return rs;
|
||||||
|
else
|
||||||
|
return ls;
|
||||||
|
}
|
||||||
|
return SFLT_COARSE_INDEX;
|
||||||
|
} else if (type == LOGIC_COND_TYPE_OR) {
|
||||||
|
return SFLT_COARSE_INDEX;
|
||||||
|
} else if (type == LOGIC_COND_TYPE_NOT) {
|
||||||
|
return SFLT_NOT_INDEX;
|
||||||
|
}
|
||||||
|
return SFLT_NOT_INDEX;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t sifGetValueFromNode(SNode *node, char **value) {
|
static int32_t sifGetValueFromNode(SNode *node, char **value) {
|
||||||
// covert data From snode;
|
// covert data From snode;
|
||||||
SValueNode *vn = (SValueNode *)node;
|
SValueNode *vn = (SValueNode *)node;
|
||||||
|
@ -257,11 +281,11 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP
|
||||||
if (tm == NULL) {
|
if (tm == NULL) {
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
SIndexMultiTermQuery *mtm = indexMultiTermQueryCreate(MUST);
|
|
||||||
|
|
||||||
EIndexQueryType qtype = 0;
|
EIndexQueryType qtype = 0;
|
||||||
SIF_ERR_RET(sifGetFuncFromSql(operType, &qtype));
|
SIF_ERR_RET(sifGetFuncFromSql(operType, &qtype));
|
||||||
|
|
||||||
|
SIndexMultiTermQuery *mtm = indexMultiTermQueryCreate(MUST);
|
||||||
indexMultiTermQueryAdd(mtm, tm, qtype);
|
indexMultiTermQueryAdd(mtm, tm, qtype);
|
||||||
int ret = indexSearch(NULL, mtm, output->result);
|
int ret = indexSearch(NULL, mtm, output->result);
|
||||||
indexMultiTermQueryDestroy(mtm);
|
indexMultiTermQueryDestroy(mtm);
|
||||||
|
@ -319,6 +343,7 @@ static int32_t sifNotMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output
|
||||||
int id = OP_TYPE_NMATCH;
|
int id = OP_TYPE_NMATCH;
|
||||||
return sifDoIndex(left, right, id, output);
|
return sifDoIndex(left, right, id, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sifDefaultFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
static int32_t sifDefaultFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
// add more except
|
// add more except
|
||||||
return TSDB_CODE_QRY_INVALID_INPUT;
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
@ -352,9 +377,9 @@ static sif_func_t sifGetOperFn(int32_t funcId) {
|
||||||
case OP_TYPE_NMATCH:
|
case OP_TYPE_NMATCH:
|
||||||
return sifNotMatchFunc;
|
return sifNotMatchFunc;
|
||||||
default:
|
default:
|
||||||
return sifDefaultFunc;
|
return sifNullFunc;
|
||||||
}
|
}
|
||||||
return sifDefaultFunc;
|
return sifNullFunc;
|
||||||
}
|
}
|
||||||
static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -367,6 +392,11 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx));
|
SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx));
|
||||||
|
|
||||||
sif_func_t operFn = sifGetOperFn(node->opType);
|
sif_func_t operFn = sifGetOperFn(node->opType);
|
||||||
|
if (ctx->noExec && operFn == NULL) {
|
||||||
|
output->status = SFLT_NOT_INDEX;
|
||||||
|
} else {
|
||||||
|
output->status = SFLT_ACCURATE_INDEX;
|
||||||
|
}
|
||||||
|
|
||||||
return operFn(¶ms[0], nParam > 1 ? ¶ms[1] : NULL, output);
|
return operFn(¶ms[0], nParam > 1 ? ¶ms[1] : NULL, output);
|
||||||
_return:
|
_return:
|
||||||
|
@ -385,14 +415,20 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou
|
||||||
SIFParam *params = NULL;
|
SIFParam *params = NULL;
|
||||||
SIF_ERR_RET(sifInitParamList(¶ms, node->pParameterList, ctx));
|
SIF_ERR_RET(sifInitParamList(¶ms, node->pParameterList, ctx));
|
||||||
|
|
||||||
for (int32_t m = 0; m < node->pParameterList->length; m++) {
|
if (ctx->noExec == false) {
|
||||||
// add impl later
|
for (int32_t m = 0; m < node->pParameterList->length; m++) {
|
||||||
if (node->condType == LOGIC_COND_TYPE_AND) {
|
// add impl later
|
||||||
taosArrayAddAll(output->result, params[m].result);
|
if (node->condType == LOGIC_COND_TYPE_AND) {
|
||||||
} else if (node->condType == LOGIC_COND_TYPE_OR) {
|
taosArrayAddAll(output->result, params[m].result);
|
||||||
taosArrayAddAll(output->result, params[m].result);
|
} else if (node->condType == LOGIC_COND_TYPE_OR) {
|
||||||
} else if (node->condType == LOGIC_COND_TYPE_NOT) {
|
taosArrayAddAll(output->result, params[m].result);
|
||||||
taosArrayAddAll(output->result, params[m].result);
|
} else if (node->condType == LOGIC_COND_TYPE_NOT) {
|
||||||
|
taosArrayAddAll(output->result, params[m].result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int32_t m = 0; m < node->pParameterList->length; m++) {
|
||||||
|
output->status = sifMergeCond(node->condType, output->status, params[m].status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_return:
|
_return:
|
||||||
|
@ -486,7 +522,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
|
||||||
return TSDB_CODE_QRY_INVALID_INPUT;
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SIFCtx ctx = {.code = 0};
|
SIFCtx ctx = {.code = 0, .noExec = false};
|
||||||
ctx.pRes = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
ctx.pRes = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
if (NULL == ctx.pRes) {
|
if (NULL == ctx.pRes) {
|
||||||
qError("index-filter failed to taosHashInit");
|
qError("index-filter failed to taosHashInit");
|
||||||
|
@ -510,6 +546,36 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
|
||||||
SIF_RET(code);
|
SIF_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
if (pNode == NULL) {
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
SIFCtx ctx = {.code = 0, .noExec = true};
|
||||||
|
ctx.pRes = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
|
if (NULL == ctx.pRes) {
|
||||||
|
qError("index-filter failed to taosHashInit");
|
||||||
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx);
|
||||||
|
|
||||||
|
SIF_ERR_RET(ctx.code);
|
||||||
|
|
||||||
|
SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
||||||
|
if (res == NULL) {
|
||||||
|
qError("no valid res in hash, node:(%p), type(%d)", (void *)&pNode, nodeType(pNode));
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
|
}
|
||||||
|
*status = res->status;
|
||||||
|
|
||||||
|
sifFreeParam(res);
|
||||||
|
taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
||||||
|
|
||||||
|
SIF_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t doFilterTag(const SNode *pFilterNode, SArray *result) {
|
int32_t doFilterTag(const SNode *pFilterNode, SArray *result) {
|
||||||
if (pFilterNode == NULL) {
|
if (pFilterNode == NULL) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -517,7 +583,7 @@ int32_t doFilterTag(const SNode *pFilterNode, SArray *result) {
|
||||||
|
|
||||||
SFilterInfo *filter = NULL;
|
SFilterInfo *filter = NULL;
|
||||||
// todo move to the initialization function
|
// todo move to the initialization function
|
||||||
SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
|
// SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
|
||||||
|
|
||||||
SIFParam param = {0};
|
SIFParam param = {0};
|
||||||
SIF_ERR_RET(sifCalculate((SNode *)pFilterNode, ¶m));
|
SIF_ERR_RET(sifCalculate((SNode *)pFilterNode, ¶m));
|
||||||
|
@ -528,10 +594,14 @@ int32_t doFilterTag(const SNode *pFilterNode, SArray *result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) {
|
SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) {
|
||||||
|
SIdxFltStatus st = SFLT_NOT_INDEX;
|
||||||
if (pFilterNode == NULL) {
|
if (pFilterNode == NULL) {
|
||||||
return SFLT_NOT_INDEX;
|
return SFLT_NOT_INDEX;
|
||||||
}
|
}
|
||||||
|
// SFilterInfo *filter = NULL;
|
||||||
|
// todo move to the initialization function
|
||||||
|
// SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
|
||||||
|
|
||||||
// impl later
|
SIF_ERR_RET(sifGetFltHint((SNode *)pFilterNode, &st));
|
||||||
return SFLT_ACCURATE_INDEX;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
|
@ -948,10 +948,6 @@ TEST(testCase, build_executor_tree_Test) {
|
||||||
code = qCreateExecTask(&handle, 2, 1, plan, (void**)&pTaskInfo, &sinkHandle, OPTR_EXEC_MODEL_BATCH);
|
code = qCreateExecTask(&handle, 2, 1, plan, (void**)&pTaskInfo, &sinkHandle, OPTR_EXEC_MODEL_BATCH);
|
||||||
ASSERT_EQ(code, 0);
|
ASSERT_EQ(code, 0);
|
||||||
}
|
}
|
||||||
TEST(testCase, index_plan_test) {
|
|
||||||
// add later
|
|
||||||
EXPECT_EQ(0, 0);
|
|
||||||
}
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
TEST(testCase, inMem_sort_Test) {
|
TEST(testCase, inMem_sort_Test) {
|
||||||
|
|
|
@ -0,0 +1,253 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <tglobal.h>
|
||||||
|
#include <tsort.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
|
||||||
|
#include "executor.h"
|
||||||
|
#include "executorimpl.h"
|
||||||
|
#include "indexoperator.h"
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
|
#include "stub.h"
|
||||||
|
#include "taos.h"
|
||||||
|
#include "tcompare.h"
|
||||||
|
#include "tdatablock.h"
|
||||||
|
#include "tdef.h"
|
||||||
|
#include "trpc.h"
|
||||||
|
#include "tvariant.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
SColumnInfo createColumnInfo(int32_t colId, int32_t type, int32_t bytes) {
|
||||||
|
SColumnInfo info = {0};
|
||||||
|
info.colId = colId;
|
||||||
|
info.type = type;
|
||||||
|
info.bytes = bytes;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t sifLeftV = 21, sifRightV = 10;
|
||||||
|
double sifLeftVd = 21.0, sifRightVd = 10.0;
|
||||||
|
|
||||||
|
void sifFreeDataBlock(void *block) { blockDataDestroy(*(SSDataBlock **)block); }
|
||||||
|
|
||||||
|
void sifInitLogFile() {
|
||||||
|
const char * defaultLogFileNamePrefix = "taoslog";
|
||||||
|
const int32_t maxLogFileNum = 10;
|
||||||
|
|
||||||
|
tsAsyncLog = 0;
|
||||||
|
qDebugFlag = 159;
|
||||||
|
strcpy(tsLogDir, "/tmp/sif");
|
||||||
|
taosRemoveDir(tsLogDir);
|
||||||
|
taosMkDir(tsLogDir);
|
||||||
|
|
||||||
|
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
|
||||||
|
printf("failed to open log file in directory:%s\n", tsLogDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sifAppendReservedSlot(SArray *pBlockList, int16_t *dataBlockId, int16_t *slotId, bool newBlock, int32_t rows,
|
||||||
|
SColumnInfo *colInfo) {
|
||||||
|
if (newBlock) {
|
||||||
|
SSDataBlock *res = (SSDataBlock *)taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
|
res->info.numOfCols = 1;
|
||||||
|
res->info.rows = rows;
|
||||||
|
res->pDataBlock = taosArrayInit(1, sizeof(SColumnInfoData));
|
||||||
|
SColumnInfoData idata = {0};
|
||||||
|
idata.info = *colInfo;
|
||||||
|
|
||||||
|
taosArrayPush(res->pDataBlock, &idata);
|
||||||
|
taosArrayPush(pBlockList, &res);
|
||||||
|
|
||||||
|
blockDataEnsureCapacity(res, rows);
|
||||||
|
|
||||||
|
*dataBlockId = taosArrayGetSize(pBlockList) - 1;
|
||||||
|
res->info.blockId = *dataBlockId;
|
||||||
|
*slotId = 0;
|
||||||
|
} else {
|
||||||
|
SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(pBlockList);
|
||||||
|
res->info.numOfCols++;
|
||||||
|
SColumnInfoData idata = {0};
|
||||||
|
idata.info = *colInfo;
|
||||||
|
|
||||||
|
colInfoDataEnsureCapacity(&idata, 0, rows);
|
||||||
|
|
||||||
|
taosArrayPush(res->pDataBlock, &idata);
|
||||||
|
|
||||||
|
*dataBlockId = taosArrayGetSize(pBlockList) - 1;
|
||||||
|
*slotId = taosArrayGetSize(res->pDataBlock) - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sifMakeValueNode(SNode **pNode, int32_t dataType, void *value) {
|
||||||
|
SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||||
|
SValueNode *vnode = (SValueNode *)node;
|
||||||
|
vnode->node.resType.type = dataType;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(dataType)) {
|
||||||
|
vnode->datum.p = (char *)taosMemoryMalloc(varDataTLen(value));
|
||||||
|
varDataCopy(vnode->datum.p, value);
|
||||||
|
vnode->node.resType.bytes = varDataTLen(value);
|
||||||
|
} else {
|
||||||
|
vnode->node.resType.bytes = tDataTypes[dataType].bytes;
|
||||||
|
assignVal((char *)nodesGetValueFromNode(vnode), (const char *)value, 0, dataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
*pNode = (SNode *)vnode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sifMakeColumnNode(SNode **pNode, const char *db, const char *colName, EColumnType colType, uint8_t colValType) {
|
||||||
|
SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||||
|
SColumnNode *rnode = (SColumnNode *)node;
|
||||||
|
memcpy(rnode->dbName, db, strlen(db));
|
||||||
|
memcpy(rnode->colName, colName, strlen(colName));
|
||||||
|
|
||||||
|
rnode->colType = colType;
|
||||||
|
rnode->node.resType.type = colValType;
|
||||||
|
|
||||||
|
*pNode = (SNode *)rnode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sifMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight) {
|
||||||
|
SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||||
|
SOperatorNode *onode = (SOperatorNode *)node;
|
||||||
|
onode->node.resType.type = resType;
|
||||||
|
onode->node.resType.bytes = tDataTypes[resType].bytes;
|
||||||
|
|
||||||
|
onode->opType = opType;
|
||||||
|
onode->pLeft = pLeft;
|
||||||
|
onode->pRight = pRight;
|
||||||
|
|
||||||
|
*pNode = (SNode *)onode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sifMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||||
|
SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||||
|
SNodeListNode *lnode = (SNodeListNode *)node;
|
||||||
|
lnode->dataType.type = resType;
|
||||||
|
lnode->pNodeList = list;
|
||||||
|
|
||||||
|
*pNode = (SNode *)lnode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sifMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nodeList, int32_t nodeNum) {
|
||||||
|
SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||||
|
SLogicConditionNode *onode = (SLogicConditionNode *)node;
|
||||||
|
onode->condType = opType;
|
||||||
|
onode->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||||
|
onode->node.resType.bytes = sizeof(bool);
|
||||||
|
|
||||||
|
onode->pParameterList = nodesMakeList();
|
||||||
|
for (int32_t i = 0; i < nodeNum; ++i) {
|
||||||
|
nodesListAppend(onode->pParameterList, nodeList[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
*pNode = (SNode *)onode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sifMakeTargetNode(SNode **pNode, int16_t dataBlockId, int16_t slotId, SNode *snode) {
|
||||||
|
SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_TARGET);
|
||||||
|
STargetNode *onode = (STargetNode *)node;
|
||||||
|
onode->pExpr = snode;
|
||||||
|
onode->dataBlockId = dataBlockId;
|
||||||
|
onode->slotId = slotId;
|
||||||
|
|
||||||
|
*pNode = (SNode *)onode;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
TEST(testCase, index_filter) {
|
||||||
|
{
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
sifMakeColumnNode(&pLeft, "test", "col", COLUMN_TYPE_TAG, TSDB_DATA_TYPE_INT);
|
||||||
|
sifMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &sifRightV);
|
||||||
|
sifMakeOpNode(&opNode, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_INT, pLeft, pRight);
|
||||||
|
SArray *result = taosArrayInit(4, sizeof(uint64_t));
|
||||||
|
doFilterTag(opNode, result);
|
||||||
|
EXPECT_EQ(1, taosArrayGetSize(result));
|
||||||
|
taosArrayDestroy(result);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
sifMakeColumnNode(&pLeft, "test", "col", COLUMN_TYPE_TAG, TSDB_DATA_TYPE_INT);
|
||||||
|
sifMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &sifRightV);
|
||||||
|
sifMakeOpNode(&opNode, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight);
|
||||||
|
|
||||||
|
SArray *result = taosArrayInit(4, sizeof(uint64_t));
|
||||||
|
doFilterTag(opNode, result);
|
||||||
|
EXPECT_EQ(1, taosArrayGetSize(result));
|
||||||
|
|
||||||
|
taosArrayDestroy(result);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, index_filter_varify) {
|
||||||
|
{
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
sifMakeColumnNode(&pLeft, "test", "col", COLUMN_TYPE_TAG, TSDB_DATA_TYPE_INT);
|
||||||
|
sifMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &sifRightV);
|
||||||
|
sifMakeOpNode(&opNode, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_INT, pLeft, pRight);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
|
||||||
|
SIdxFltStatus st = idxGetFltStatus(opNode);
|
||||||
|
EXPECT_EQ(st, SFLT_ACCURATE_INDEX);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
sifMakeColumnNode(&pLeft, "test", "col", COLUMN_TYPE_TAG, TSDB_DATA_TYPE_INT);
|
||||||
|
sifMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &sifRightV);
|
||||||
|
sifMakeOpNode(&opNode, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight);
|
||||||
|
|
||||||
|
SIdxFltStatus st = idxGetFltStatus(opNode);
|
||||||
|
EXPECT_EQ(st, SFLT_COARSE_INDEX);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
sifMakeColumnNode(&pLeft, "test", "col", COLUMN_TYPE_TAG, TSDB_DATA_TYPE_INT);
|
||||||
|
sifMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &sifRightV);
|
||||||
|
sifMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_INT, pLeft, pRight);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
|
||||||
|
SIdxFltStatus st = idxGetFltStatus(opNode);
|
||||||
|
EXPECT_EQ(st, SFLT_ACCURATE_INDEX);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
sifMakeColumnNode(&pLeft, "test", "col", COLUMN_TYPE_TAG, TSDB_DATA_TYPE_INT);
|
||||||
|
sifMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &sifRightV);
|
||||||
|
sifMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight);
|
||||||
|
|
||||||
|
SIdxFltStatus st = idxGetFltStatus(opNode);
|
||||||
|
EXPECT_EQ(st, SFLT_COARSE_INDEX);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma GCC diagnostic pop
|
|
@ -93,6 +93,7 @@ int32_t histogramFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
bool getStateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getStateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
bool stateFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
bool stateFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
int32_t stateCountFunction(SqlFunctionCtx* pCtx);
|
int32_t stateCountFunction(SqlFunctionCtx* pCtx);
|
||||||
|
int32_t stateDurationFunction(SqlFunctionCtx* pCtx);
|
||||||
|
|
||||||
bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ static int32_t translateLeastSQR(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = 64, .type = TSDB_DATA_TYPE_BINARY };
|
pFunc->node.resType = (SDataType){.bytes = 64, .type = TSDB_DATA_TYPE_BINARY};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateState(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
if (3 != LIST_LENGTH(pFunc->pParameterList)) {
|
if (3 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
@ -283,6 +283,31 @@ static int32_t translateState(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
int32_t paraNum = LIST_LENGTH(pFunc->pParameterList);
|
||||||
|
if (3 != paraNum && 4 != paraNum) {
|
||||||
|
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t colType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||||
|
if (!IS_NUMERIC_TYPE(colType)) {
|
||||||
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type != TSDB_DATA_TYPE_BINARY ||
|
||||||
|
(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type != TSDB_DATA_TYPE_BIGINT &&
|
||||||
|
((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type != TSDB_DATA_TYPE_DOUBLE)) {
|
||||||
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paraNum == 4 && ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type != TSDB_DATA_TYPE_BIGINT) {
|
||||||
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT };
|
||||||
|
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;
|
||||||
|
@ -701,12 +726,22 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.name = "state_count",
|
.name = "state_count",
|
||||||
.type = FUNCTION_TYPE_STATE_COUNT,
|
.type = FUNCTION_TYPE_STATE_COUNT,
|
||||||
.classification = FUNC_MGT_NONSTANDARD_SQL_FUNC,
|
.classification = FUNC_MGT_NONSTANDARD_SQL_FUNC,
|
||||||
.translateFunc = translateState,
|
.translateFunc = translateStateCount,
|
||||||
.getEnvFunc = getStateFuncEnv,
|
.getEnvFunc = getStateFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = stateCountFunction,
|
.processFunc = stateCountFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "state_duration",
|
||||||
|
.type = FUNCTION_TYPE_STATE_DURATION,
|
||||||
|
.classification = FUNC_MGT_NONSTANDARD_SQL_FUNC | FUNC_MGT_TIMELINE_FUNC,
|
||||||
|
.translateFunc = translateStateDuration,
|
||||||
|
.getEnvFunc = getStateFuncEnv,
|
||||||
|
.initFunc = functionSetup,
|
||||||
|
.processFunc = stateDurationFunction,
|
||||||
|
.finalizeFunc = NULL
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "abs",
|
.name = "abs",
|
||||||
.type = FUNCTION_TYPE_ABS,
|
.type = FUNCTION_TYPE_ABS,
|
||||||
|
@ -1007,26 +1042,6 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.sprocessFunc = timezoneFunction,
|
.sprocessFunc = timezoneFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
|
||||||
.name = "_rowts",
|
|
||||||
.type = FUNCTION_TYPE_ROWTS,
|
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
|
||||||
.translateFunc = translateTimePseudoColumn,
|
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
|
||||||
.initFunc = NULL,
|
|
||||||
.sprocessFunc = NULL,
|
|
||||||
.finalizeFunc = NULL
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.name = "_c0",
|
|
||||||
.type = FUNCTION_TYPE_ROWTS,
|
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
|
||||||
.translateFunc = translateTimePseudoColumn,
|
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
|
||||||
.initFunc = NULL,
|
|
||||||
.sprocessFunc = NULL,
|
|
||||||
.finalizeFunc = NULL
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
.name = "tbname",
|
.name = "tbname",
|
||||||
.type = FUNCTION_TYPE_TBNAME,
|
.type = FUNCTION_TYPE_TBNAME,
|
||||||
|
|
|
@ -125,7 +125,10 @@ typedef enum {
|
||||||
} EHistoBinType;
|
} EHistoBinType;
|
||||||
|
|
||||||
typedef struct SStateInfo {
|
typedef struct SStateInfo {
|
||||||
int64_t count;
|
union {
|
||||||
|
int64_t count;
|
||||||
|
int64_t durationStart;
|
||||||
|
};
|
||||||
} SStateInfo;
|
} SStateInfo;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -2844,3 +2847,52 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
return numOfElems;
|
return numOfElems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t stateDurationFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
|
SStateInfo* 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;
|
||||||
|
|
||||||
|
int32_t numOfElems = 0;
|
||||||
|
SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput;
|
||||||
|
|
||||||
|
//TODO: process timeUnit for different db precisions
|
||||||
|
int32_t timeUnit = 1000;
|
||||||
|
if (pCtx->numOfParams == 5) { //TODO: param number incorrect
|
||||||
|
timeUnit = pCtx->param[3].param.i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t op = getStateOpType(varDataVal(pCtx->param[1].param.pz));
|
||||||
|
if (STATE_OPER_INVALID == op) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; i += 1) {
|
||||||
|
numOfElems++;
|
||||||
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
|
colDataAppendNULL(pOutput, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ret = checkStateOp(op, pInputCol, i, pCtx->param[2].param);
|
||||||
|
int64_t output = -1;
|
||||||
|
if (ret) {
|
||||||
|
if (pInfo->durationStart == 0) {
|
||||||
|
output = 0;
|
||||||
|
pInfo->durationStart = tsList[i];
|
||||||
|
} else {
|
||||||
|
output = (tsList[i] - pInfo->durationStart) / timeUnit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pInfo->durationStart = 0;
|
||||||
|
}
|
||||||
|
colDataAppend(pOutput, i, (char *)&output, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return numOfElems;
|
||||||
|
}
|
||||||
|
|
|
@ -350,7 +350,18 @@ SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft,
|
||||||
createOperatorNode(pCxt, OP_TYPE_GREATER_THAN, nodesCloneNode(pExpr), pRight));
|
createOperatorNode(pCxt, OP_TYPE_GREATER_THAN, nodesCloneNode(pExpr), pRight));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SNode* createPrimaryKeyCol(SAstCreateContext* pCxt) {
|
||||||
|
SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||||
|
CHECK_OUT_OF_MEM(pCol);
|
||||||
|
pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||||
|
strcpy(pCol->colName, PK_TS_COL_INTERNAL_NAME);
|
||||||
|
return (SNode*)pCol;
|
||||||
|
}
|
||||||
|
|
||||||
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList) {
|
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList) {
|
||||||
|
if (0 == strncasecmp("_rowts", pFuncName->z, pFuncName->n) || 0 == strncasecmp("_c0", pFuncName->z, pFuncName->n)) {
|
||||||
|
return createPrimaryKeyCol(pCxt);
|
||||||
|
}
|
||||||
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
CHECK_OUT_OF_MEM(func);
|
CHECK_OUT_OF_MEM(func);
|
||||||
strncpy(func->functionName, pFuncName->z, pFuncName->n);
|
strncpy(func->functionName, pFuncName->z, pFuncName->n);
|
||||||
|
@ -467,13 +478,11 @@ SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap
|
||||||
SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) {
|
SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) {
|
||||||
SStateWindowNode* state = (SStateWindowNode*)nodesMakeNode(QUERY_NODE_STATE_WINDOW);
|
SStateWindowNode* state = (SStateWindowNode*)nodesMakeNode(QUERY_NODE_STATE_WINDOW);
|
||||||
CHECK_OUT_OF_MEM(state);
|
CHECK_OUT_OF_MEM(state);
|
||||||
state->pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
state->pCol = createPrimaryKeyCol(pCxt);
|
||||||
if (NULL == state->pCol) {
|
if (NULL == state->pCol) {
|
||||||
nodesDestroyNode(state);
|
nodesDestroyNode(state);
|
||||||
CHECK_OUT_OF_MEM(state->pCol);
|
CHECK_OUT_OF_MEM(state->pCol);
|
||||||
}
|
}
|
||||||
((SColumnNode*)state->pCol)->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
|
||||||
strcpy(((SColumnNode*)state->pCol)->colName, PK_TS_COL_INTERNAL_NAME);
|
|
||||||
state->pExpr = pExpr;
|
state->pExpr = pExpr;
|
||||||
return (SNode*)state;
|
return (SNode*)state;
|
||||||
}
|
}
|
||||||
|
@ -482,13 +491,11 @@ SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode
|
||||||
SNode* pFill) {
|
SNode* pFill) {
|
||||||
SIntervalWindowNode* interval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW);
|
SIntervalWindowNode* interval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW);
|
||||||
CHECK_OUT_OF_MEM(interval);
|
CHECK_OUT_OF_MEM(interval);
|
||||||
interval->pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
interval->pCol = createPrimaryKeyCol(pCxt);
|
||||||
if (NULL == interval->pCol) {
|
if (NULL == interval->pCol) {
|
||||||
nodesDestroyNode(interval);
|
nodesDestroyNode(interval);
|
||||||
CHECK_OUT_OF_MEM(interval->pCol);
|
CHECK_OUT_OF_MEM(interval->pCol);
|
||||||
}
|
}
|
||||||
((SColumnNode*)interval->pCol)->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
|
||||||
strcpy(((SColumnNode*)interval->pCol)->colName, PK_TS_COL_INTERNAL_NAME);
|
|
||||||
interval->pInterval = pInterval;
|
interval->pInterval = pInterval;
|
||||||
interval->pOffset = pOffset;
|
interval->pOffset = pOffset;
|
||||||
interval->pSliding = pSliding;
|
interval->pSliding = pSliding;
|
||||||
|
@ -667,7 +674,7 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti
|
||||||
case DB_OPTION_DAYS: {
|
case DB_OPTION_DAYS: {
|
||||||
SToken* pToken = pVal;
|
SToken* pToken = pVal;
|
||||||
if (TK_NK_INTEGER == pToken->type) {
|
if (TK_NK_INTEGER == pToken->type) {
|
||||||
((SDatabaseOptions*)pOptions)->daysPerFile = strtol(pToken->z, NULL, 10);
|
((SDatabaseOptions*)pOptions)->daysPerFile = strtol(pToken->z, NULL, 10) * 1440;
|
||||||
} else {
|
} else {
|
||||||
((SDatabaseOptions*)pOptions)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, pToken);
|
((SDatabaseOptions*)pOptions)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, pToken);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,8 @@ static int32_t getTableMetaImpl(SInsertParseContext* pCxt, SName* name, char *db
|
||||||
SParseContext* pBasicCtx = pCxt->pComCxt;
|
SParseContext* pBasicCtx = pCxt->pComCxt;
|
||||||
|
|
||||||
bool pass = false;
|
bool pass = false;
|
||||||
CHECK_CODE(catalogChkAuth(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, pBasicCtx->pUser, dbFname, AUTH_TYPE_WRITE, &pass));
|
CHECK_CODE(catalogChkAuth(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, pBasicCtx->pUser,
|
||||||
|
dbFname, AUTH_TYPE_WRITE, &pass));
|
||||||
if (!pass) {
|
if (!pass) {
|
||||||
return TSDB_CODE_PAR_PERMISSION_DENIED;
|
return TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||||
}
|
}
|
||||||
|
@ -344,8 +345,7 @@ static int parseTime(char** end, SToken* pToken, int16_t timePrec, int64_t* time
|
||||||
} else if (pToken->type == TK_TODAY) {
|
} else if (pToken->type == TK_TODAY) {
|
||||||
ts = taosGetTimestampToday(timePrec);
|
ts = taosGetTimestampToday(timePrec);
|
||||||
} else if (pToken->type == TK_NK_INTEGER) {
|
} else if (pToken->type == TK_NK_INTEGER) {
|
||||||
bool isSigned = false;
|
toInteger(pToken->z, pToken->n, 10, &ts);
|
||||||
toInteger(pToken->z, pToken->n, 10, &ts, &isSigned);
|
|
||||||
} else { // parse the RFC-3339/ISO-8601 timestamp format string
|
} else { // parse the RFC-3339/ISO-8601 timestamp format string
|
||||||
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
|
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
|
||||||
|
@ -448,9 +448,9 @@ static FORCE_INLINE int32_t toDouble(SToken* pToken, double* value, char** endPt
|
||||||
|
|
||||||
static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int16_t timePrec, char* tmpTokenBuf,
|
static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int16_t timePrec, char* tmpTokenBuf,
|
||||||
_row_append_fn_t func, void* param, SMsgBuf* pMsgBuf) {
|
_row_append_fn_t func, void* param, SMsgBuf* pMsgBuf) {
|
||||||
int64_t iv;
|
int64_t iv;
|
||||||
char* endptr = NULL;
|
uint64_t uv;
|
||||||
bool isSigned = false;
|
char* endptr = NULL;
|
||||||
|
|
||||||
int32_t code = checkAndTrimValue(pToken, pSchema->type, tmpTokenBuf, pMsgBuf);
|
int32_t code = checkAndTrimValue(pToken, pSchema->type, tmpTokenBuf, pMsgBuf);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -485,7 +485,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_TINYINT: {
|
case TSDB_DATA_TYPE_TINYINT: {
|
||||||
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv, &isSigned)) {
|
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid tinyint data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid tinyint data", pToken->z);
|
||||||
} else if (!IS_VALID_TINYINT(iv)) {
|
} else if (!IS_VALID_TINYINT(iv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "tinyint data overflow", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "tinyint data overflow", pToken->z);
|
||||||
|
@ -496,17 +496,17 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UTINYINT: {
|
case TSDB_DATA_TYPE_UTINYINT: {
|
||||||
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv, &isSigned)) {
|
if (TSDB_CODE_SUCCESS != toUInteger(pToken->z, pToken->n, 10, &uv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned tinyint data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned tinyint data", pToken->z);
|
||||||
} else if (!IS_VALID_UTINYINT(iv)) {
|
} else if (!IS_VALID_UTINYINT(uv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "unsigned tinyint data overflow", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "unsigned tinyint data overflow", pToken->z);
|
||||||
}
|
}
|
||||||
uint8_t tmpVal = (uint8_t)iv;
|
uint8_t tmpVal = (uint8_t)uv;
|
||||||
return func(pMsgBuf, &tmpVal, pSchema->bytes, param);
|
return func(pMsgBuf, &tmpVal, pSchema->bytes, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_SMALLINT: {
|
case TSDB_DATA_TYPE_SMALLINT: {
|
||||||
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv, &isSigned)) {
|
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid smallint data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid smallint data", pToken->z);
|
||||||
} else if (!IS_VALID_SMALLINT(iv)) {
|
} else if (!IS_VALID_SMALLINT(iv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "smallint data overflow", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "smallint data overflow", pToken->z);
|
||||||
|
@ -516,17 +516,17 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_USMALLINT: {
|
case TSDB_DATA_TYPE_USMALLINT: {
|
||||||
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv, &isSigned)) {
|
if (TSDB_CODE_SUCCESS != toUInteger(pToken->z, pToken->n, 10, &uv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned smallint data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned smallint data", pToken->z);
|
||||||
} else if (!IS_VALID_USMALLINT(iv)) {
|
} else if (!IS_VALID_USMALLINT(uv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "unsigned smallint data overflow", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "unsigned smallint data overflow", pToken->z);
|
||||||
}
|
}
|
||||||
uint16_t tmpVal = (uint16_t)iv;
|
uint16_t tmpVal = (uint16_t)uv;
|
||||||
return func(pMsgBuf, &tmpVal, pSchema->bytes, param);
|
return func(pMsgBuf, &tmpVal, pSchema->bytes, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_INT: {
|
case TSDB_DATA_TYPE_INT: {
|
||||||
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv, &isSigned)) {
|
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid int data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid int data", pToken->z);
|
||||||
} else if (!IS_VALID_INT(iv)) {
|
} else if (!IS_VALID_INT(iv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "int data overflow", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "int data overflow", pToken->z);
|
||||||
|
@ -536,17 +536,17 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UINT: {
|
case TSDB_DATA_TYPE_UINT: {
|
||||||
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv, &isSigned)) {
|
if (TSDB_CODE_SUCCESS != toUInteger(pToken->z, pToken->n, 10, &uv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned int data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned int data", pToken->z);
|
||||||
} else if (!IS_VALID_UINT(iv)) {
|
} else if (!IS_VALID_UINT(uv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "unsigned int data overflow", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "unsigned int data overflow", pToken->z);
|
||||||
}
|
}
|
||||||
uint32_t tmpVal = (uint32_t)iv;
|
uint32_t tmpVal = (uint32_t)uv;
|
||||||
return func(pMsgBuf, &tmpVal, pSchema->bytes, param);
|
return func(pMsgBuf, &tmpVal, pSchema->bytes, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_BIGINT: {
|
case TSDB_DATA_TYPE_BIGINT: {
|
||||||
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv, &isSigned)) {
|
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid bigint data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid bigint data", pToken->z);
|
||||||
} else if (!IS_VALID_BIGINT(iv)) {
|
} else if (!IS_VALID_BIGINT(iv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "bigint data overflow", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "bigint data overflow", pToken->z);
|
||||||
|
@ -555,13 +555,12 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_UBIGINT: {
|
case TSDB_DATA_TYPE_UBIGINT: {
|
||||||
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv, &isSigned)) {
|
if (TSDB_CODE_SUCCESS != toUInteger(pToken->z, pToken->n, 10, &uv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned bigint data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned bigint data", pToken->z);
|
||||||
} else if (!IS_VALID_UBIGINT((uint64_t)iv)) {
|
} else if (!IS_VALID_UBIGINT(uv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "unsigned bigint data overflow", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "unsigned bigint data overflow", pToken->z);
|
||||||
}
|
}
|
||||||
uint64_t tmpVal = (uint64_t)iv;
|
return func(pMsgBuf, &uv, pSchema->bytes, param);
|
||||||
return func(pMsgBuf, &tmpVal, pSchema->bytes, param);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
|
@ -766,7 +765,7 @@ static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, voi
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildCreateTbReq(SVCreateTbReq *pTbReq, const char* tname, SKVRow row, int64_t suid) {
|
static int32_t buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, SKVRow row, int64_t suid) {
|
||||||
pTbReq->type = TD_CHILD_TABLE;
|
pTbReq->type = TD_CHILD_TABLE;
|
||||||
pTbReq->name = strdup(tname);
|
pTbReq->name = strdup(tname);
|
||||||
pTbReq->ctb.suid = suid;
|
pTbReq->ctb.suid = suid;
|
||||||
|
@ -1066,6 +1065,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
int32_t tbNum = 0;
|
int32_t tbNum = 0;
|
||||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||||
bool autoCreateTbl = false;
|
bool autoCreateTbl = false;
|
||||||
|
STableMeta *pMeta = NULL;
|
||||||
|
|
||||||
// for each table
|
// for each table
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -1120,10 +1120,12 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, tbFName, strlen(tbFName), TSDB_DEFAULT_PAYLOAD_SIZE,
|
CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, tbFName, strlen(tbFName), TSDB_DEFAULT_PAYLOAD_SIZE,
|
||||||
sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta,
|
sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta,
|
||||||
&dataBuf, NULL, &pCxt->createTblReq));
|
&dataBuf, NULL, &pCxt->createTblReq));
|
||||||
|
pMeta = pCxt->pTableMeta;
|
||||||
|
pCxt->pTableMeta = NULL;
|
||||||
|
|
||||||
if (TK_NK_LP == sToken.type) {
|
if (TK_NK_LP == sToken.type) {
|
||||||
// pSql -> field1_name, ...)
|
// pSql -> field1_name, ...)
|
||||||
CHECK_CODE(parseBoundColumns(pCxt, &dataBuf->boundColumnInfo, getTableColumnSchema(pCxt->pTableMeta)));
|
CHECK_CODE(parseBoundColumns(pCxt, &dataBuf->boundColumnInfo, getTableColumnSchema(pMeta)));
|
||||||
NEXT_TOKEN(pCxt->pSql, sToken);
|
NEXT_TOKEN(pCxt->pSql, sToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1159,7 +1161,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
memcpy(tags, &pCxt->tags, sizeof(pCxt->tags));
|
memcpy(tags, &pCxt->tags, sizeof(pCxt->tags));
|
||||||
(*pCxt->pStmtCb->setInfoFn)(pCxt->pStmtCb->pStmt, pCxt->pTableMeta, tags, tbFName, autoCreateTbl, pCxt->pVgroupsHashObj, pCxt->pTableBlockHashObj);
|
(*pCxt->pStmtCb->setInfoFn)(pCxt->pStmtCb->pStmt, pMeta, tags, tbFName, autoCreateTbl, pCxt->pVgroupsHashObj, pCxt->pTableBlockHashObj);
|
||||||
|
|
||||||
memset(&pCxt->tags, 0, sizeof(pCxt->tags));
|
memset(&pCxt->tags, 0, sizeof(pCxt->tags));
|
||||||
pCxt->pVgroupsHashObj = NULL;
|
pCxt->pVgroupsHashObj = NULL;
|
||||||
|
@ -1277,9 +1279,10 @@ int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qBindStmtTagsValue(void *pBlock, void *boundTags, int64_t suid, char *tName, TAOS_MULTI_BIND *bind, char *msgBuf, int32_t msgBufLen){
|
int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tName, TAOS_MULTI_BIND* bind,
|
||||||
STableDataBlocks *pDataBlock = (STableDataBlocks *)pBlock;
|
char* msgBuf, int32_t msgBufLen) {
|
||||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
||||||
|
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||||
SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags;
|
SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags;
|
||||||
if (NULL == tags) {
|
if (NULL == tags) {
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
@ -1393,7 +1396,6 @@ int32_t qBindStmtColsValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBuf, in
|
||||||
tdSRowPrint(row, pSTSchema, __func__);
|
tdSRowPrint(row, pSTSchema, __func__);
|
||||||
taosMemoryFree(pSTSchema);
|
taosMemoryFree(pSTSchema);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pDataBlock->size += extendedRowSize;
|
pDataBlock->size += extendedRowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1480,6 +1482,7 @@ int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBu
|
||||||
taosMemoryFree(pSTSchema);
|
taosMemoryFree(pSTSchema);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rowEnd) {
|
if (rowEnd) {
|
||||||
|
@ -1554,16 +1557,16 @@ int32_t qBuildStmtColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD** fields
|
||||||
// schemaless logic start
|
// schemaless logic start
|
||||||
|
|
||||||
typedef struct SmlExecHandle {
|
typedef struct SmlExecHandle {
|
||||||
SHashObj* pBlockHash;
|
SHashObj* pBlockHash;
|
||||||
|
|
||||||
SParsedDataColInfo tags; // each table
|
SParsedDataColInfo tags; // each table
|
||||||
SKVRowBuilder tagsBuilder; // each table
|
SKVRowBuilder tagsBuilder; // each table
|
||||||
SVCreateTbReq createTblReq; // each table
|
SVCreateTbReq createTblReq; // each table
|
||||||
|
|
||||||
SQuery* pQuery;
|
SQuery* pQuery;
|
||||||
} SSmlExecHandle;
|
} SSmlExecHandle;
|
||||||
|
|
||||||
static int32_t smlBoundColumnData(SArray *cols, SParsedDataColInfo* pColList, SSchema* pSchema) {
|
static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SSchema* pSchema) {
|
||||||
col_id_t nCols = pColList->numOfCols;
|
col_id_t nCols = pColList->numOfCols;
|
||||||
|
|
||||||
pColList->numOfBound = 0;
|
pColList->numOfBound = 0;
|
||||||
|
@ -1576,8 +1579,8 @@ static int32_t smlBoundColumnData(SArray *cols, SParsedDataColInfo* pColList, SS
|
||||||
bool isOrdered = true;
|
bool isOrdered = true;
|
||||||
col_id_t lastColIdx = -1; // last column found
|
col_id_t lastColIdx = -1; // last column found
|
||||||
for (int i = 0; i < taosArrayGetSize(cols); ++i) {
|
for (int i = 0; i < taosArrayGetSize(cols); ++i) {
|
||||||
SSmlKv *kv = taosArrayGetP(cols, i);
|
SSmlKv* kv = taosArrayGetP(cols, i);
|
||||||
SToken sToken = {.n=kv->keyLen, .z=(char*)kv->key};
|
SToken sToken = {.n = kv->keyLen, .z = (char*)kv->key};
|
||||||
col_id_t t = lastColIdx + 1;
|
col_id_t t = lastColIdx + 1;
|
||||||
col_id_t index = findCol(&sToken, t, nCols, pSchema);
|
col_id_t index = findCol(&sToken, t, nCols, pSchema);
|
||||||
if (index < 0 && t > 0) {
|
if (index < 0 && t > 0) {
|
||||||
|
@ -1626,7 +1629,7 @@ static int32_t smlBoundColumnData(SArray *cols, SParsedDataColInfo* pColList, SS
|
||||||
qsort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar);
|
qsort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pColList->numOfCols > pColList->numOfBound){
|
if (pColList->numOfCols > pColList->numOfBound) {
|
||||||
memset(&pColList->boundColumns[pColList->numOfBound], 0,
|
memset(&pColList->boundColumns[pColList->numOfBound], 0,
|
||||||
sizeof(col_id_t) * (pColList->numOfCols - pColList->numOfBound));
|
sizeof(col_id_t) * (pColList->numOfCols - pColList->numOfBound));
|
||||||
}
|
}
|
||||||
|
@ -1634,43 +1637,43 @@ static int32_t smlBoundColumnData(SArray *cols, SParsedDataColInfo* pColList, SS
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlBuildTagRow(SArray *cols, SKVRowBuilder *tagsBuilder, SParsedDataColInfo* tags, SSchema* pSchema, SKVRow *row, SMsgBuf *msg) {
|
static int32_t smlBuildTagRow(SArray* cols, SKVRowBuilder* tagsBuilder, SParsedDataColInfo* tags, SSchema* pSchema,
|
||||||
|
SKVRow* row, SMsgBuf* msg) {
|
||||||
if (tdInitKVRowBuilder(tagsBuilder) < 0) {
|
if (tdInitKVRowBuilder(tagsBuilder) < 0) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SKvParam param = {.builder = tagsBuilder};
|
SKvParam param = {.builder = tagsBuilder};
|
||||||
for (int i = 0; i < tags->numOfBound; ++i) {
|
for (int i = 0; i < tags->numOfBound; ++i) {
|
||||||
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) ;
|
KvRowAppend(msg, kv->value, kv->valueLen, ¶m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
*row = tdGetKVRowFromBuilder(tagsBuilder);
|
*row = tdGetKVRowFromBuilder(tagsBuilder);
|
||||||
if(*row == NULL){
|
if (*row == NULL) {
|
||||||
return TSDB_CODE_SML_INVALID_DATA;
|
return TSDB_CODE_SML_INVALID_DATA;
|
||||||
}
|
}
|
||||||
tdSortKVRowByColIdx(*row);
|
tdSortKVRowByColIdx(*row);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smlBindData(void *handle, SArray *tags, SArray *colsFormat, SArray *colsSchema, SArray *cols, bool format,
|
int32_t smlBindData(void* handle, SArray* tags, SArray* colsFormat, SArray* colsSchema, SArray* cols, bool format,
|
||||||
STableMeta *pTableMeta, char *tableName, char *msgBuf, int16_t msgBufLen) {
|
STableMeta* pTableMeta, char* tableName, char* msgBuf, int16_t msgBufLen) {
|
||||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||||
|
|
||||||
SSmlExecHandle *smlHandle = (SSmlExecHandle *)handle;
|
SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle;
|
||||||
SSchema* pTagsSchema = getTableTagSchema(pTableMeta);
|
SSchema* pTagsSchema = getTableTagSchema(pTableMeta);
|
||||||
setBoundColumnInfo(&smlHandle->tags, pTagsSchema, getNumOfTags(pTableMeta));
|
setBoundColumnInfo(&smlHandle->tags, pTagsSchema, getNumOfTags(pTableMeta));
|
||||||
int ret = smlBoundColumnData(tags, &smlHandle->tags, pTagsSchema);
|
int ret = smlBoundColumnData(tags, &smlHandle->tags, pTagsSchema);
|
||||||
if(ret != TSDB_CODE_SUCCESS){
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
buildInvalidOperationMsg(&pBuf, "bound tags error");
|
buildInvalidOperationMsg(&pBuf, "bound tags error");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
SKVRow row = NULL;
|
SKVRow row = NULL;
|
||||||
ret = smlBuildTagRow(tags, &smlHandle->tagsBuilder, &smlHandle->tags, pTagsSchema, &row, &pBuf);
|
ret = smlBuildTagRow(tags, &smlHandle->tagsBuilder, &smlHandle->tags, pTagsSchema, &row, &pBuf);
|
||||||
if(ret != TSDB_CODE_SUCCESS){
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1688,35 +1691,35 @@ int32_t smlBindData(void *handle, SArray *tags, SArray *colsFormat, SArray *cols
|
||||||
SSchema* pSchema = getTableColumnSchema(pTableMeta);
|
SSchema* pSchema = getTableColumnSchema(pTableMeta);
|
||||||
|
|
||||||
ret = smlBoundColumnData(colsSchema, &pDataBlock->boundColumnInfo, pSchema);
|
ret = smlBoundColumnData(colsSchema, &pDataBlock->boundColumnInfo, pSchema);
|
||||||
if(ret != TSDB_CODE_SUCCESS){
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
buildInvalidOperationMsg(&pBuf, "bound cols error");
|
buildInvalidOperationMsg(&pBuf, "bound cols error");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
int32_t extendedRowSize = getExtendedRowSize(pDataBlock);
|
int32_t extendedRowSize = getExtendedRowSize(pDataBlock);
|
||||||
SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo;
|
SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo;
|
||||||
SRowBuilder* pBuilder = &pDataBlock->rowBuilder;
|
SRowBuilder* pBuilder = &pDataBlock->rowBuilder;
|
||||||
SMemParam param = {.rb = pBuilder};
|
SMemParam param = {.rb = pBuilder};
|
||||||
|
|
||||||
initRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo);
|
initRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo);
|
||||||
|
|
||||||
int32_t rowNum = format ? taosArrayGetSize(colsFormat) : taosArrayGetSize(cols);
|
int32_t rowNum = format ? taosArrayGetSize(colsFormat) : taosArrayGetSize(cols);
|
||||||
if(rowNum <= 0) {
|
if (rowNum <= 0) {
|
||||||
return buildInvalidOperationMsg(&pBuf, "cols size <= 0");
|
return buildInvalidOperationMsg(&pBuf, "cols size <= 0");
|
||||||
}
|
}
|
||||||
ret = allocateMemForSize(pDataBlock, extendedRowSize * rowNum);
|
ret = allocateMemForSize(pDataBlock, extendedRowSize * rowNum);
|
||||||
if(ret != TSDB_CODE_SUCCESS){
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
buildInvalidOperationMsg(&pBuf, "allocate memory error");
|
buildInvalidOperationMsg(&pBuf, "allocate memory error");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
for (int32_t r = 0; r < rowNum; ++r) {
|
for (int32_t r = 0; r < rowNum; ++r) {
|
||||||
STSRow* row = (STSRow*)(pDataBlock->pData + pDataBlock->size); // skip the SSubmitBlk header
|
STSRow* row = (STSRow*)(pDataBlock->pData + pDataBlock->size); // skip the SSubmitBlk header
|
||||||
tdSRowResetBuf(pBuilder, row);
|
tdSRowResetBuf(pBuilder, row);
|
||||||
void *rowData = NULL;
|
void* rowData = NULL;
|
||||||
size_t rowDataSize = 0;
|
size_t rowDataSize = 0;
|
||||||
if(format){
|
if (format) {
|
||||||
rowData = taosArrayGetP(colsFormat, r);
|
rowData = taosArrayGetP(colsFormat, r);
|
||||||
rowDataSize = taosArrayGetSize(rowData);
|
rowDataSize = taosArrayGetSize(rowData);
|
||||||
}else{
|
} else {
|
||||||
rowData = taosArrayGetP(cols, r);
|
rowData = taosArrayGetP(cols, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1727,19 +1730,20 @@ int32_t smlBindData(void *handle, SArray *tags, SArray *colsFormat, SArray *cols
|
||||||
param.schema = pColSchema;
|
param.schema = pColSchema;
|
||||||
getSTSRowAppendInfo(pBuilder->rowType, spd, c, ¶m.toffset, ¶m.colIdx);
|
getSTSRowAppendInfo(pBuilder->rowType, spd, c, ¶m.toffset, ¶m.colIdx);
|
||||||
|
|
||||||
SSmlKv *kv = NULL;
|
SSmlKv* kv = NULL;
|
||||||
if(format){
|
if (format) {
|
||||||
if(j < rowDataSize){
|
if (j < rowDataSize) {
|
||||||
kv = taosArrayGetP(rowData, j);
|
kv = taosArrayGetP(rowData, j);
|
||||||
if (rowDataSize != spd->numOfBound && (kv->keyLen != strlen(pColSchema->name) || strncmp(kv->key, pColSchema->name, kv->keyLen) != 0)){
|
if (rowDataSize != spd->numOfBound &&
|
||||||
|
(kv->keyLen != strlen(pColSchema->name) || strncmp(kv->key, pColSchema->name, kv->keyLen) != 0)) {
|
||||||
kv = NULL;
|
kv = NULL;
|
||||||
}else{
|
} else {
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
void **p =taosHashGet(rowData, pColSchema->name, strlen(pColSchema->name));
|
void** p = taosHashGet(rowData, pColSchema->name, strlen(pColSchema->name));
|
||||||
if(p) kv = *p;
|
if (p) kv = *p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!kv || kv->length == 0) {
|
if (!kv || kv->length == 0) {
|
||||||
|
@ -1748,7 +1752,7 @@ int32_t smlBindData(void *handle, SArray *tags, SArray *colsFormat, SArray *cols
|
||||||
int32_t colLen = pColSchema->bytes;
|
int32_t colLen = pColSchema->bytes;
|
||||||
if (IS_VAR_DATA_TYPE(pColSchema->type)) {
|
if (IS_VAR_DATA_TYPE(pColSchema->type)) {
|
||||||
colLen = kv->length;
|
colLen = kv->length;
|
||||||
} else if(pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP){
|
} 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1757,7 +1761,7 @@ int32_t smlBindData(void *handle, SArray *tags, SArray *colsFormat, SArray *cols
|
||||||
|
|
||||||
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);
|
||||||
checkTimestamp(pDataBlock, (const char *)&tsKey);
|
checkTimestamp(pDataBlock, (const char*)&tsKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1774,7 +1778,7 @@ int32_t smlBindData(void *handle, SArray *tags, SArray *colsFormat, SArray *cols
|
||||||
pDataBlock->size += extendedRowSize;
|
pDataBlock->size += extendedRowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSubmitBlk *pBlocks = (SSubmitBlk *)(pDataBlock->pData);
|
SSubmitBlk* pBlocks = (SSubmitBlk*)(pDataBlock->pData);
|
||||||
if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, pDataBlock, rowNum)) {
|
if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, pDataBlock, rowNum)) {
|
||||||
return buildInvalidOperationMsg(&pBuf, "too many rows in sql, total number of rows should be less than 32767");
|
return buildInvalidOperationMsg(&pBuf, "too many rows in sql, total number of rows should be less than 32767");
|
||||||
}
|
}
|
||||||
|
@ -1782,25 +1786,24 @@ int32_t smlBindData(void *handle, SArray *tags, SArray *colsFormat, SArray *cols
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* smlInitHandle(SQuery *pQuery){
|
void* smlInitHandle(SQuery* pQuery) {
|
||||||
SSmlExecHandle *handle = taosMemoryCalloc(1, sizeof(SSmlExecHandle));
|
SSmlExecHandle* handle = taosMemoryCalloc(1, sizeof(SSmlExecHandle));
|
||||||
if(!handle) return NULL;
|
if (!handle) return NULL;
|
||||||
handle->pBlockHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
|
handle->pBlockHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
|
||||||
handle->pQuery = pQuery;
|
handle->pQuery = pQuery;
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void smlDestroyHandle(void *pHandle){
|
void smlDestroyHandle(void* pHandle) {
|
||||||
if(!pHandle) return;
|
if (!pHandle) return;
|
||||||
SSmlExecHandle *handle = (SSmlExecHandle *)pHandle;
|
SSmlExecHandle* handle = (SSmlExecHandle*)pHandle;
|
||||||
destroyBlockHashmap(handle->pBlockHash);
|
destroyBlockHashmap(handle->pBlockHash);
|
||||||
taosMemoryFree(handle);
|
taosMemoryFree(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smlBuildOutput(void* handle, SHashObj* pVgHash) {
|
int32_t smlBuildOutput(void* handle, SHashObj* pVgHash) {
|
||||||
SSmlExecHandle *smlHandle = (SSmlExecHandle *)handle;
|
SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle;
|
||||||
return qBuildStmtOutput(smlHandle->pQuery, pVgHash, smlHandle->pBlockHash);
|
return qBuildStmtOutput(smlHandle->pQuery, pVgHash, smlHandle->pBlockHash);
|
||||||
}
|
}
|
||||||
// schemaless logic end
|
// schemaless logic end
|
||||||
|
|
||||||
|
|
|
@ -1886,6 +1886,9 @@ static int32_t checkDbKeepOption(STranslateContext* pCxt, SDatabaseOptions* pOpt
|
||||||
TIME_UNIT_DAY != pVal->unit) {
|
TIME_UNIT_DAY != pVal->unit) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_KEEP_UNIT, pVal->unit);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_KEEP_UNIT, pVal->unit);
|
||||||
}
|
}
|
||||||
|
if (!pVal->isDuration) {
|
||||||
|
pVal->datum.i = pVal->datum.i * 1440;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pOptions->keep[0] = getBigintFromValueNode((SValueNode*)nodesListGetNode(pOptions->pKeep, 0));
|
pOptions->keep[0] = getBigintFromValueNode((SValueNode*)nodesListGetNode(pOptions->pKeep, 0));
|
||||||
|
@ -2138,7 +2141,7 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) {
|
||||||
SField field = {.type = pCol->dataType.type, .bytes = calcTypeBytes(pCol->dataType)};
|
SField field = {.type = pCol->dataType.type, .bytes = calcTypeBytes(pCol->dataType)};
|
||||||
strcpy(field.name, pCol->colName);
|
strcpy(field.name, pCol->colName);
|
||||||
if (pCol->sma) {
|
if (pCol->sma) {
|
||||||
field.flags |= SCHEMA_SMA_ON;
|
field.flags |= COL_SMA_ON;
|
||||||
}
|
}
|
||||||
taosArrayPush(*pArray, &field);
|
taosArrayPush(*pArray, &field);
|
||||||
}
|
}
|
||||||
|
@ -2321,7 +2324,7 @@ static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt
|
||||||
static void toSchema(const SColumnDefNode* pCol, col_id_t colId, SSchema* pSchema) {
|
static void toSchema(const SColumnDefNode* pCol, col_id_t colId, SSchema* pSchema) {
|
||||||
int8_t flags = 0;
|
int8_t flags = 0;
|
||||||
if (pCol->sma) {
|
if (pCol->sma) {
|
||||||
flags |= SCHEMA_SMA_ON;
|
flags |= COL_SMA_ON;
|
||||||
}
|
}
|
||||||
pSchema->colId = colId;
|
pSchema->colId = colId;
|
||||||
pSchema->type = pCol->dataType.type;
|
pSchema->type = pCol->dataType.type;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
* or later ("AGPL"), AS published by the Free Software Foundation.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "parTestUtil.h"
|
#include "parTestUtil.h"
|
||||||
|
#include "ttime.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -26,72 +27,226 @@ class ParserInitialCTest : public ParserDdlTest {};
|
||||||
TEST_F(ParserInitialCTest, createAccount) {
|
TEST_F(ParserInitialCTest, createAccount) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create account ac_wxy pass '123456'", TSDB_CODE_PAR_EXPRIE_STATEMENT);
|
run("CREATE ACCOUNT ac_wxy PASS '123456'", TSDB_CODE_PAR_EXPRIE_STATEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createBnode) {
|
TEST_F(ParserInitialCTest, createBnode) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create bnode on dnode 1");
|
run("CREATE BNODE ON DNODE 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CREATE DATABASE [IF NOT EXISTS] db_name [database_options]
|
||||||
|
*
|
||||||
|
* database_options:
|
||||||
|
* database_option ...
|
||||||
|
*
|
||||||
|
* database_option: {
|
||||||
|
* BUFFER value
|
||||||
|
* | CACHELAST value
|
||||||
|
* | COMP {0 | 1 | 2}
|
||||||
|
* | DAYS value
|
||||||
|
* | FSYNC value
|
||||||
|
* | MAXROWS value
|
||||||
|
* | MINROWS value
|
||||||
|
* | KEEP value
|
||||||
|
* | PAGES value
|
||||||
|
* | PAGESIZE value
|
||||||
|
* | PRECISION {'ms' | 'us' | 'ns'}
|
||||||
|
* | REPLICA value
|
||||||
|
* | RETENTIONS ingestion_duration:keep_duration ...
|
||||||
|
* | STRICT value
|
||||||
|
* | WAL value
|
||||||
|
* | VGROUPS value
|
||||||
|
* | SINGLE_STABLE {0 | 1}
|
||||||
|
* }
|
||||||
|
*/
|
||||||
TEST_F(ParserInitialCTest, createDatabase) {
|
TEST_F(ParserInitialCTest, createDatabase) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create database wxy_db");
|
SCreateDbReq expect = {0};
|
||||||
|
|
||||||
run("create database if not exists wxy_db "
|
auto setCreateDbReqFunc = [&](const char* pDbname, int8_t igExists = 0) {
|
||||||
"cachelast 2 "
|
memset(&expect, 0, sizeof(SCreateDbReq));
|
||||||
"comp 1 "
|
int32_t len = snprintf(expect.db, sizeof(expect.db), "0.%s", pDbname);
|
||||||
"days 100 "
|
expect.db[len] = '\0';
|
||||||
"fsync 100 "
|
expect.ignoreExist = igExists;
|
||||||
"maxrows 1000 "
|
expect.buffer = TSDB_DEFAULT_BUFFER_PER_VNODE;
|
||||||
"minrows 100 "
|
expect.cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW;
|
||||||
"keep 1440 "
|
expect.compression = TSDB_DEFAULT_COMP_LEVEL;
|
||||||
"precision 'ms' "
|
expect.daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE;
|
||||||
"replica 3 "
|
expect.fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
|
||||||
"wal 2 "
|
expect.maxRows = TSDB_DEFAULT_MAXROWS_FBLOCK;
|
||||||
"vgroups 100 "
|
expect.minRows = TSDB_DEFAULT_MINROWS_FBLOCK;
|
||||||
"single_stable 0 "
|
expect.daysToKeep0 = TSDB_DEFAULT_KEEP;
|
||||||
"retentions 15s:7d,1m:21d,15m:5y");
|
expect.daysToKeep1 = TSDB_DEFAULT_KEEP;
|
||||||
|
expect.daysToKeep2 = TSDB_DEFAULT_KEEP;
|
||||||
|
expect.pages = TSDB_DEFAULT_PAGES_PER_VNODE;
|
||||||
|
expect.pageSize = TSDB_DEFAULT_PAGESIZE_PER_VNODE;
|
||||||
|
expect.precision = TSDB_DEFAULT_PRECISION;
|
||||||
|
expect.replications = TSDB_DEFAULT_DB_REPLICA;
|
||||||
|
expect.strict = TSDB_DEFAULT_DB_STRICT;
|
||||||
|
expect.walLevel = TSDB_DEFAULT_WAL_LEVEL;
|
||||||
|
expect.numOfVgroups = TSDB_DEFAULT_VN_PER_DB;
|
||||||
|
expect.numOfStables = TSDB_DEFAULT_DB_SINGLE_STABLE;
|
||||||
|
};
|
||||||
|
|
||||||
run("create database if not exists wxy_db "
|
auto setDbBufferFunc = [&](int32_t buffer) { expect.buffer = buffer; };
|
||||||
"days 100m "
|
auto setDbCachelastFunc = [&](int8_t CACHELAST) { expect.cacheLastRow = CACHELAST; };
|
||||||
"keep 1440m,300h,400d ");
|
auto setDbCompressionFunc = [&](int8_t compressionLevel) { expect.compression = compressionLevel; };
|
||||||
|
auto setDbDaysFunc = [&](int32_t daysPerFile) { expect.daysPerFile = daysPerFile; };
|
||||||
|
auto setDbFsyncFunc = [&](int32_t fsyncPeriod) { expect.fsyncPeriod = fsyncPeriod; };
|
||||||
|
auto setDbMaxRowsFunc = [&](int32_t maxRowsPerBlock) { expect.maxRows = maxRowsPerBlock; };
|
||||||
|
auto setDbMinRowsFunc = [&](int32_t minRowsPerBlock) { expect.minRows = minRowsPerBlock; };
|
||||||
|
auto setDbKeepFunc = [&](int32_t keep0, int32_t keep1 = 0, int32_t keep2 = 0) {
|
||||||
|
expect.daysToKeep0 = keep0;
|
||||||
|
expect.daysToKeep1 = 0 == keep1 ? expect.daysToKeep0 : keep1;
|
||||||
|
expect.daysToKeep2 = 0 == keep2 ? expect.daysToKeep1 : keep2;
|
||||||
|
};
|
||||||
|
auto setDbPagesFunc = [&](int32_t pages) { expect.pages = pages; };
|
||||||
|
auto setDbPageSizeFunc = [&](int32_t pagesize) { expect.pageSize = pagesize; };
|
||||||
|
auto setDbPrecisionFunc = [&](int8_t precision) { expect.precision = precision; };
|
||||||
|
auto setDbReplicaFunc = [&](int8_t replica) { expect.replications = replica; };
|
||||||
|
auto setDbStrictaFunc = [&](int8_t strict) { expect.strict = strict; };
|
||||||
|
auto setDbWalLevelFunc = [&](int8_t walLevel) { expect.walLevel = walLevel; };
|
||||||
|
auto setDbVgroupsFunc = [&](int32_t numOfVgroups) { expect.numOfVgroups = numOfVgroups; };
|
||||||
|
auto setDbSingleStableFunc = [&](int8_t singleStable) { expect.numOfStables = singleStable; };
|
||||||
|
auto addDbRetentionFunc = [&](int64_t freq, int64_t keep, int8_t freqUnit, int8_t keepUnit) {
|
||||||
|
SRetention retention = {0};
|
||||||
|
retention.freq = freq;
|
||||||
|
retention.keep = keep;
|
||||||
|
retention.freqUnit = freqUnit;
|
||||||
|
retention.keepUnit = keepUnit;
|
||||||
|
if (NULL == expect.pRetensions) {
|
||||||
|
expect.pRetensions = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SRetention));
|
||||||
|
}
|
||||||
|
taosArrayPush(expect.pRetensions, &retention);
|
||||||
|
++expect.numOfRetensions;
|
||||||
|
};
|
||||||
|
|
||||||
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||||
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_DATABASE_STMT);
|
||||||
|
SCreateDbReq req = {0};
|
||||||
|
ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSCreateDbReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||||
|
|
||||||
|
ASSERT_EQ(std::string(req.db), std::string(expect.db));
|
||||||
|
ASSERT_EQ(req.numOfVgroups, expect.numOfVgroups);
|
||||||
|
ASSERT_EQ(req.numOfStables, expect.numOfStables);
|
||||||
|
ASSERT_EQ(req.buffer, expect.buffer);
|
||||||
|
ASSERT_EQ(req.pageSize, expect.pageSize);
|
||||||
|
ASSERT_EQ(req.pages, expect.pages);
|
||||||
|
ASSERT_EQ(req.daysPerFile, expect.daysPerFile);
|
||||||
|
ASSERT_EQ(req.daysToKeep0, expect.daysToKeep0);
|
||||||
|
ASSERT_EQ(req.daysToKeep1, expect.daysToKeep1);
|
||||||
|
ASSERT_EQ(req.daysToKeep2, expect.daysToKeep2);
|
||||||
|
ASSERT_EQ(req.minRows, expect.minRows);
|
||||||
|
ASSERT_EQ(req.maxRows, expect.maxRows);
|
||||||
|
ASSERT_EQ(req.fsyncPeriod, expect.fsyncPeriod);
|
||||||
|
ASSERT_EQ(req.walLevel, expect.walLevel);
|
||||||
|
ASSERT_EQ(req.precision, expect.precision);
|
||||||
|
ASSERT_EQ(req.compression, expect.compression);
|
||||||
|
ASSERT_EQ(req.replications, expect.replications);
|
||||||
|
ASSERT_EQ(req.strict, expect.strict);
|
||||||
|
ASSERT_EQ(req.cacheLastRow, expect.cacheLastRow);
|
||||||
|
ASSERT_EQ(req.ignoreExist, expect.ignoreExist);
|
||||||
|
ASSERT_EQ(req.numOfRetensions, expect.numOfRetensions);
|
||||||
|
if (expect.numOfRetensions > 0) {
|
||||||
|
ASSERT_EQ(taosArrayGetSize(req.pRetensions), expect.numOfRetensions);
|
||||||
|
ASSERT_EQ(taosArrayGetSize(req.pRetensions), taosArrayGetSize(expect.pRetensions));
|
||||||
|
for (int32_t i = 0; i < expect.numOfRetensions; ++i) {
|
||||||
|
SRetention* pReten = (SRetention*)taosArrayGet(req.pRetensions, i);
|
||||||
|
SRetention* pExpectReten = (SRetention*)taosArrayGet(expect.pRetensions, i);
|
||||||
|
ASSERT_EQ(pReten->freq, pExpectReten->freq);
|
||||||
|
ASSERT_EQ(pReten->keep, pExpectReten->keep);
|
||||||
|
ASSERT_EQ(pReten->freqUnit, pExpectReten->freqUnit);
|
||||||
|
ASSERT_EQ(pReten->keepUnit, pExpectReten->keepUnit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setCreateDbReqFunc("wxy_db");
|
||||||
|
run("CREATE DATABASE wxy_db");
|
||||||
|
|
||||||
|
setCreateDbReqFunc("wxy_db", 1);
|
||||||
|
setDbBufferFunc(64);
|
||||||
|
setDbCachelastFunc(2);
|
||||||
|
setDbCompressionFunc(1);
|
||||||
|
setDbDaysFunc(100 * 1440);
|
||||||
|
setDbFsyncFunc(100);
|
||||||
|
setDbMaxRowsFunc(1000);
|
||||||
|
setDbMinRowsFunc(100);
|
||||||
|
setDbKeepFunc(1440 * 1440);
|
||||||
|
setDbPagesFunc(96);
|
||||||
|
setDbPageSizeFunc(8);
|
||||||
|
setDbPrecisionFunc(TSDB_TIME_PRECISION_NANO);
|
||||||
|
setDbReplicaFunc(3);
|
||||||
|
addDbRetentionFunc(15 * MILLISECOND_PER_SECOND, 7 * MILLISECOND_PER_DAY, TIME_UNIT_SECOND, TIME_UNIT_DAY);
|
||||||
|
addDbRetentionFunc(1 * MILLISECOND_PER_MINUTE, 21 * MILLISECOND_PER_DAY, TIME_UNIT_MINUTE, TIME_UNIT_DAY);
|
||||||
|
addDbRetentionFunc(15 * MILLISECOND_PER_MINUTE, 5, TIME_UNIT_MINUTE, TIME_UNIT_YEAR);
|
||||||
|
setDbStrictaFunc(1);
|
||||||
|
setDbWalLevelFunc(2);
|
||||||
|
setDbVgroupsFunc(100);
|
||||||
|
setDbSingleStableFunc(1);
|
||||||
|
run("CREATE DATABASE IF NOT EXISTS wxy_db "
|
||||||
|
"BUFFER 64 "
|
||||||
|
"CACHELAST 2 "
|
||||||
|
"COMP 1 "
|
||||||
|
"DAYS 100 "
|
||||||
|
"FSYNC 100 "
|
||||||
|
"MAXROWS 1000 "
|
||||||
|
"MINROWS 100 "
|
||||||
|
"KEEP 1440 "
|
||||||
|
"PAGES 96 "
|
||||||
|
"PAGESIZE 8 "
|
||||||
|
"PRECISION 'ns' "
|
||||||
|
"REPLICA 3 "
|
||||||
|
"RETENTIONS 15s:7d,1m:21d,15m:5y "
|
||||||
|
"STRICT 1 "
|
||||||
|
"WAL 2 "
|
||||||
|
"VGROUPS 100 "
|
||||||
|
"SINGLE_STABLE 1 ");
|
||||||
|
|
||||||
|
setCreateDbReqFunc("wxy_db", 1);
|
||||||
|
setDbDaysFunc(100);
|
||||||
|
setDbKeepFunc(1440, 300 * 60, 400 * 1440);
|
||||||
|
run("CREATE DATABASE IF NOT EXISTS wxy_db "
|
||||||
|
"DAYS 100m "
|
||||||
|
"KEEP 1440m,300h,400d ");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createDnode) {
|
TEST_F(ParserInitialCTest, createDnode) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create dnode abc1 port 7000");
|
run("CREATE DNODE abc1 PORT 7000");
|
||||||
|
|
||||||
run("create dnode 1.1.1.1 port 9000");
|
run("CREATE DNODE 1.1.1.1 PORT 9000");
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo create function
|
// todo CREATE FUNCTION
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createIndexSma) {
|
TEST_F(ParserInitialCTest, createIndexSma) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)");
|
run("CREATE SMA INDEX index1 ON t1 FUNCTION(MAX(c1), MIN(c3 + 10), SUM(c4)) INTERVAL(10s)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createMnode) {
|
TEST_F(ParserInitialCTest, createMnode) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create mnode on dnode 1");
|
run("CREATE MNODE ON DNODE 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createQnode) {
|
TEST_F(ParserInitialCTest, createQnode) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create qnode on dnode 1");
|
run("CREATE QNODE ON DNODE 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createSnode) {
|
TEST_F(ParserInitialCTest, createSnode) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create snode on dnode 1");
|
run("CREATE SNODE ON DNODE 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createStable) {
|
TEST_F(ParserInitialCTest, createStable) {
|
||||||
|
@ -117,7 +272,7 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
};
|
};
|
||||||
|
|
||||||
auto addFieldToCreateStbReqFunc = [&](bool col, const char* pFieldName, uint8_t type, int32_t bytes = 0,
|
auto addFieldToCreateStbReqFunc = [&](bool col, const char* pFieldName, uint8_t type, int32_t bytes = 0,
|
||||||
int8_t flags = SCHEMA_SMA_ON) {
|
int8_t flags = COL_SMA_ON) {
|
||||||
SField field = {0};
|
SField field = {0};
|
||||||
strcpy(field.name, pFieldName);
|
strcpy(field.name, pFieldName);
|
||||||
field.type = type;
|
field.type = type;
|
||||||
|
@ -194,7 +349,7 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP);
|
addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP);
|
||||||
addFieldToCreateStbReqFunc(true, "c1", TSDB_DATA_TYPE_INT);
|
addFieldToCreateStbReqFunc(true, "c1", TSDB_DATA_TYPE_INT);
|
||||||
addFieldToCreateStbReqFunc(false, "id", TSDB_DATA_TYPE_INT);
|
addFieldToCreateStbReqFunc(false, "id", TSDB_DATA_TYPE_INT);
|
||||||
run("create stable t1(ts timestamp, c1 int) TAGS(id int)");
|
run("CREATE STABLE t1(ts TIMESTAMP, c1 INT) TAGS(id INT)");
|
||||||
|
|
||||||
setCreateStbReqFunc("t1", 1, 0.1, 2, 100, "test create table");
|
setCreateStbReqFunc("t1", 1, 0.1, 2, 100, "test create table");
|
||||||
addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
|
addFieldToCreateStbReqFunc(true, "ts", TSDB_DATA_TYPE_TIMESTAMP, 0, 0);
|
||||||
|
@ -227,80 +382,72 @@ TEST_F(ParserInitialCTest, createStable) {
|
||||||
addFieldToCreateStbReqFunc(false, "a13", TSDB_DATA_TYPE_BOOL);
|
addFieldToCreateStbReqFunc(false, "a13", TSDB_DATA_TYPE_BOOL);
|
||||||
addFieldToCreateStbReqFunc(false, "a14", TSDB_DATA_TYPE_NCHAR, 30 * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE);
|
addFieldToCreateStbReqFunc(false, "a14", TSDB_DATA_TYPE_NCHAR, 30 * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE);
|
||||||
addFieldToCreateStbReqFunc(false, "a15", TSDB_DATA_TYPE_VARCHAR, 50 + VARSTR_HEADER_SIZE);
|
addFieldToCreateStbReqFunc(false, "a15", TSDB_DATA_TYPE_VARCHAR, 50 + VARSTR_HEADER_SIZE);
|
||||||
run("create stable if not exists test.t1("
|
run("CREATE STABLE IF NOT EXISTS test.t1("
|
||||||
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), "
|
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), "
|
||||||
"c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, "
|
"c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, "
|
||||||
"c13 NCHAR(30), c14 VARCHAR(50)) "
|
"c13 NCHAR(30), c14 VARCHAR(50)) "
|
||||||
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, "
|
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, "
|
||||||
"a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, "
|
"a8 BINARY(20), a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, "
|
||||||
"a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) "
|
"a12 TINYINT UNSIGNED, a13 BOOL, a14 NCHAR(30), a15 VARCHAR(50)) "
|
||||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (min) FILE_FACTOR 0.1 DELAY 2");
|
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1 DELAY 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createStream) {
|
TEST_F(ParserInitialCTest, createStream) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create stream s1 as select * from t1");
|
run("CREATE STREAM s1 AS SELECT * FROM t1");
|
||||||
|
|
||||||
run("create stream if not exists s1 as select * from t1");
|
run("CREATE STREAM IF NOT EXISTS s1 AS SELECT * FROM t1");
|
||||||
|
|
||||||
run("create stream s1 into st1 as select * from t1");
|
run("CREATE STREAM s1 INTO st1 AS SELECT * FROM t1");
|
||||||
|
|
||||||
run("create stream if not exists s1 trigger window_close watermark 10s into st1 as select * from t1");
|
run("CREATE STREAM IF NOT EXISTS s1 TRIGGER WINDOW_CLOSE WATERMARK 10s INTO st1 AS SELECT * FROM t1");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createTable) {
|
TEST_F(ParserInitialCTest, createTable) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create table t1(ts timestamp, c1 int)");
|
run("CREATE TABLE t1(ts TIMESTAMP, c1 INT)");
|
||||||
|
|
||||||
run("create table if not exists test.t1("
|
run("CREATE TABLE IF NOT EXISTS test.t1("
|
||||||
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 "
|
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), "
|
||||||
"SMALLINT, "
|
"c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, "
|
||||||
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 "
|
"c13 NCHAR(30), c15 VARCHAR(50)) "
|
||||||
"NCHAR(30), "
|
|
||||||
"c15 VARCHAR(50)) "
|
|
||||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3)");
|
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3)");
|
||||||
|
|
||||||
run("create table if not exists test.t1("
|
run("CREATE TABLE IF NOT EXISTS test.t1("
|
||||||
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 "
|
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), "
|
||||||
"SMALLINT, "
|
"c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, "
|
||||||
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 "
|
"c13 NCHAR(30), c14 VARCHAR(50)) "
|
||||||
"NCHAR(30), "
|
"TAGS (a1 TIMESTAMP, a2 INT, a3 INT UNSIGNED, a4 BIGINT, a5 BIGINT UNSIGNED, a6 FLOAT, a7 DOUBLE, a8 BINARY(20), "
|
||||||
"c15 VARCHAR(50)) "
|
"a9 SMALLINT, a10 SMALLINT UNSIGNED COMMENT 'test column comment', a11 TINYINT, a12 TINYINT UNSIGNED, a13 BOOL, "
|
||||||
"TAGS (tsa TIMESTAMP, a1 INT, a2 INT UNSIGNED, a3 BIGINT, a4 BIGINT UNSIGNED, "
|
"a14 NCHAR(30), a15 VARCHAR(50)) "
|
||||||
"a5 FLOAT, a6 DOUBLE, a7 "
|
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1 DELAY 2");
|
||||||
"BINARY(20), a8 SMALLINT, "
|
|
||||||
"a9 SMALLINT UNSIGNED COMMENT 'test column comment', a10 "
|
|
||||||
"TINYINT, a11 TINYINT UNSIGNED, a12 BOOL, a13 NCHAR(30), "
|
|
||||||
"a15 VARCHAR(50)) "
|
|
||||||
"TTL 100 COMMENT 'test create "
|
|
||||||
"table' SMA(c1, c2, c3) ROLLUP (min) FILE_FACTOR 0.1 DELAY 2");
|
|
||||||
|
|
||||||
run("create table if not exists t1 using st1 tags(1, 'wxy')");
|
run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy')");
|
||||||
|
|
||||||
run("create table "
|
run("CREATE TABLE "
|
||||||
"if not exists test.t1 using test.st1 (tag1, tag2) tags(1, 'abc') "
|
"IF NOT EXISTS test.t1 USING test.st1 (tag1, tag2) TAGS(1, 'abc') "
|
||||||
"if not exists test.t2 using test.st1 (tag1, tag2) tags(2, 'abc') "
|
"IF NOT EXISTS test.t2 USING test.st1 (tag1, tag2) TAGS(2, 'abc') "
|
||||||
"if not exists test.t3 using test.st1 (tag1, tag2) tags(3, 'abc') ");
|
"IF NOT EXISTS test.t3 USING test.st1 (tag1, tag2) TAGS(3, 'abc') ");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createTopic) {
|
TEST_F(ParserInitialCTest, createTopic) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create topic tp1 as select * from t1");
|
run("CREATE TOPIC tp1 AS SELECT * FROM t1");
|
||||||
|
|
||||||
run("create topic if not exists tp1 as select * from t1");
|
run("CREATE TOPIC IF NOT EXISTS tp1 AS SELECT * FROM t1");
|
||||||
|
|
||||||
run("create topic tp1 as test");
|
run("CREATE TOPIC tp1 AS test");
|
||||||
|
|
||||||
run("create topic if not exists tp1 as test");
|
run("CREATE TOPIC IF NOT EXISTS tp1 AS test");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialCTest, createUser) {
|
TEST_F(ParserInitialCTest, createUser) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
||||||
run("create user wxy pass '123456'");
|
run("CREATE USER wxy PASS '123456'");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ParserTest
|
} // namespace ParserTest
|
||||||
|
|
|
@ -16,9 +16,10 @@
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
|
|
||||||
#include "planInt.h"
|
#include "planInt.h"
|
||||||
|
#include "scalar.h"
|
||||||
|
|
||||||
typedef struct SCollectPlaceholderValuesCxt {
|
typedef struct SCollectPlaceholderValuesCxt {
|
||||||
int32_t errCode;
|
int32_t errCode;
|
||||||
SArray* pValues;
|
SArray* pValues;
|
||||||
} SCollectPlaceholderValuesCxt;
|
} SCollectPlaceholderValuesCxt;
|
||||||
|
|
||||||
|
@ -144,9 +145,10 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
|
||||||
if (NULL == pVal->datum.p) {
|
if (NULL == pVal->datum.p) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t output = 0;
|
int32_t output = 0;
|
||||||
if (!taosMbsToUcs4(pParam->buffer, inputSize, (TdUcs4*)varDataVal(pVal->datum.p), pVal->node.resType.bytes, &output)) {
|
if (!taosMbsToUcs4(pParam->buffer, inputSize, (TdUcs4*)varDataVal(pVal->datum.p), pVal->node.resType.bytes,
|
||||||
|
&output)) {
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
varDataSetLen(pVal->datum.p, output);
|
varDataSetLen(pVal->datum.p, output);
|
||||||
|
@ -181,8 +183,8 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes updatePlanQueryId(SNode* pNode, void* pContext) {
|
static EDealRes updatePlanQueryId(SNode* pNode, void* pContext) {
|
||||||
int64_t queryId = *(uint64_t *)pContext;
|
int64_t queryId = *(uint64_t*)pContext;
|
||||||
|
|
||||||
if (QUERY_NODE_PHYSICAL_PLAN == nodeType(pNode)) {
|
if (QUERY_NODE_PHYSICAL_PLAN == nodeType(pNode)) {
|
||||||
SQueryPlan* planNode = (SQueryPlan*)pNode;
|
SQueryPlan* planNode = (SQueryPlan*)pNode;
|
||||||
planNode->queryId = queryId;
|
planNode->queryId = queryId;
|
||||||
|
@ -194,10 +196,130 @@ static EDealRes updatePlanQueryId(SNode* pNode, void* pContext) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_MULTI_BIND* pParams, int32_t colIdx, uint64_t queryId) {
|
static int32_t calcConstNode(SNode** pNode) {
|
||||||
|
if (NULL == *pNode) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* pNew = NULL;
|
||||||
|
int32_t code = scalarCalculateConstants(*pNode, &pNew);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
*pNode = pNew;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t calcConstList(SNodeList* pList) {
|
||||||
|
SNode* pNode = NULL;
|
||||||
|
FOREACH(pNode, pList) {
|
||||||
|
SNode* pNew = NULL;
|
||||||
|
int32_t code = scalarCalculateConstants(pNode, &pNew);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
REPLACE_NODE(pNew);
|
||||||
|
} else {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isEmptyResultCond(SNode** pCond) {
|
||||||
|
if (QUERY_NODE_VALUE != nodeType(*pCond)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (((SValueNode*)*pCond)->datum.b) {
|
||||||
|
nodesDestroyNode(*pCond);
|
||||||
|
*pCond = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t calcConstSpecificPhysiNode(SPhysiNode* pPhyNode) {
|
||||||
|
switch (nodeType(pPhyNode)) {
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_FILL:
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
|
||||||
|
return calcConstList(((SProjectPhysiNode*)pPhyNode)->pProjections);
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_JOIN:
|
||||||
|
return calcConstNode(&(((SJoinPhysiNode*)pPhyNode)->pOnConditions));
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_AGG:
|
||||||
|
return calcConstList(((SAggPhysiNode*)pPhyNode)->pExprs);
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
||||||
|
return calcConstList(((SSortPhysiNode*)pPhyNode)->pExprs);
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW:
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW:
|
||||||
|
return calcConstList(((SWinodwPhysiNode*)pPhyNode)->pExprs);
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
|
||||||
|
return calcConstList(((SPartitionPhysiNode*)pPhyNode)->pExprs);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t calcConstSubplan(SPhysiNode* pPhyNode, bool* pEmptyResult) {
|
||||||
|
int32_t code = calcConstNode(&pPhyNode->pConditions);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = calcConstSpecificPhysiNode(pPhyNode);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pEmptyResult = isEmptyResultCond(&pPhyNode->pConditions);
|
||||||
|
if (*pEmptyResult) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pEmptyResult = true;
|
||||||
|
|
||||||
|
bool subEmptyResult = false;
|
||||||
|
SNode* pChild = NULL;
|
||||||
|
FOREACH(pChild, pPhyNode->pChildren) {
|
||||||
|
code = calcConstSubplan((SPhysiNode*)pChild, &subEmptyResult);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
if (!subEmptyResult) {
|
||||||
|
*pEmptyResult = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t calcConstPhysiPlan(SQueryPlan* pPlan, bool* pEmptyResult) {
|
||||||
|
*pEmptyResult = true;
|
||||||
|
|
||||||
|
bool subEmptyResult = false;
|
||||||
|
SNodeListNode* pNode = nodesListGetNode(pPlan->pSubplans, 0);
|
||||||
|
SNode* pSubplan = NULL;
|
||||||
|
FOREACH(pSubplan, pNode->pNodeList) {
|
||||||
|
int32_t code = calcConstSubplan(((SSubplan*)pSubplan)->pNode, pEmptyResult);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
if (!subEmptyResult) {
|
||||||
|
*pEmptyResult = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_MULTI_BIND* pParams, int32_t colIdx, uint64_t queryId,
|
||||||
|
bool* pEmptyResult) {
|
||||||
int32_t size = taosArrayGetSize(pPlan->pPlaceholderValues);
|
int32_t size = taosArrayGetSize(pPlan->pPlaceholderValues);
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (colIdx < 0) {
|
if (colIdx < 0) {
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
code = setValueByBindParam((SValueNode*)taosArrayGetP(pPlan->pPlaceholderValues, i), pParams + i);
|
code = setValueByBindParam((SValueNode*)taosArrayGetP(pPlan->pPlaceholderValues, i), pParams + i);
|
||||||
|
@ -214,9 +336,10 @@ int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_MULTI_BIND* pParams, int32_t colI
|
||||||
|
|
||||||
if (colIdx < 0 || ((colIdx + 1) == size)) {
|
if (colIdx < 0 || ((colIdx + 1) == size)) {
|
||||||
nodesWalkPhysiPlan((SNode*)pPlan, updatePlanQueryId, &queryId);
|
nodesWalkPhysiPlan((SNode*)pPlan, updatePlanQueryId, &queryId);
|
||||||
|
code = calcConstPhysiPlan(pPlan, pEmptyResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) {
|
int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) {
|
||||||
|
|
|
@ -260,7 +260,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
|
||||||
comparFn = 20;
|
comparFn = 20;
|
||||||
} else if (optr == OP_TYPE_LIKE) {
|
} else if (optr == OP_TYPE_LIKE) {
|
||||||
comparFn = 9;
|
comparFn = 9;
|
||||||
} else if (optr == OP_TYPE_LIKE) {
|
} else if (optr == OP_TYPE_NOT_LIKE) {
|
||||||
comparFn = 27;
|
comparFn = 27;
|
||||||
} else if (optr == OP_TYPE_IN) {
|
} else if (optr == OP_TYPE_IN) {
|
||||||
comparFn = 8;
|
comparFn = 8;
|
||||||
|
|
|
@ -105,8 +105,9 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(type)) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
len = varDataLen(out.columnData->pData);
|
char* data = colDataGetVarData(out.columnData, 0);
|
||||||
buf = varDataVal(out.columnData->pData);
|
len = varDataLen(data);
|
||||||
|
buf = varDataVal(data);
|
||||||
} else {
|
} else {
|
||||||
len = tDataTypes[type].bytes;
|
len = tDataTypes[type].bytes;
|
||||||
buf = out.columnData->pData;
|
buf = out.columnData->pData;
|
||||||
|
@ -122,7 +123,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashPut(pObj, buf, (size_t)len, NULL, 0)) {
|
if (taosHashPut(pObj, buf, (size_t)len, NULL, 0)) {
|
||||||
sclError("taosHashPut failed");
|
sclError("taosHashPut to set failed");
|
||||||
SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -328,9 +328,10 @@ static FORCE_INLINE void varToBool(char *buf, SScalarParam* pOut, int32_t rowInd
|
||||||
static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIndex) {
|
static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIndex) {
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t inputLen = varDataLen(buf);
|
int32_t inputLen = varDataLen(buf);
|
||||||
|
int32_t outputMaxLen = (inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE;
|
||||||
|
|
||||||
char* t = taosMemoryCalloc(1,(inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE);
|
char* t = taosMemoryCalloc(1, outputMaxLen);
|
||||||
/*int32_t resLen = */taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4*) varDataVal(t), pOut->columnData->info.bytes, &len);
|
/*int32_t resLen = */taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4*) varDataVal(t), outputMaxLen, &len);
|
||||||
varDataSetLen(t, len);
|
varDataSetLen(t, len);
|
||||||
|
|
||||||
colDataAppend(pOut->columnData, rowIndex, t, false);
|
colDataAppend(pOut->columnData, rowIndex, t, false);
|
||||||
|
@ -512,7 +513,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
|
||||||
if (outType == TSDB_DATA_TYPE_NCHAR) {
|
if (outType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
varToNchar(tmp, pOut, i);
|
varToNchar(tmp, pOut, i);
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(pOutputCol, i, (char *)&value, false);
|
colDataAppend(pOutputCol, i, (char *)tmp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(inType)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(inType)) {
|
||||||
|
@ -529,7 +530,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
|
||||||
if (outType == TSDB_DATA_TYPE_NCHAR) {
|
if (outType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
varToNchar(tmp, pOut, i);
|
varToNchar(tmp, pOut, i);
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(pOutputCol, i, (char *)&value, false);
|
colDataAppend(pOutputCol, i, (char *)tmp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (IS_FLOAT_TYPE(inType)) {
|
} else if (IS_FLOAT_TYPE(inType)) {
|
||||||
|
@ -546,7 +547,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
|
||||||
if (outType == TSDB_DATA_TYPE_NCHAR) {
|
if (outType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
varToNchar(tmp, pOut, i);
|
varToNchar(tmp, pOut, i);
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(pOutputCol, i, (char *)&value, false);
|
colDataAppend(pOutputCol, i, (char *)tmp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -60,7 +60,9 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
int32_t err = terrno;
|
int32_t err = terrno;
|
||||||
const char *errStr = tstrerror(err);
|
const char *errStr = tstrerror(err);
|
||||||
sError("walWriteWithSyncInfo error, err:%d, msg:%s, linuxErr:%d, linuxErrMsg:%s", err, errStr, errno, strerror(errno));
|
int32_t linuxErr = errno;
|
||||||
|
const char *linuxErrMsg = strerror(errno);
|
||||||
|
sError("walWriteWithSyncInfo error, err:%d %X, msg:%s, linuxErr:%d, linuxErrMsg:%s", err, err, errStr, linuxErr, linuxErrMsg);
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
//assert(code == 0);
|
//assert(code == 0);
|
||||||
|
@ -79,7 +81,9 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
int32_t err = terrno;
|
int32_t err = terrno;
|
||||||
const char *errStr = tstrerror(err);
|
const char *errStr = tstrerror(err);
|
||||||
sError("walReadWithHandle error, err:%d, msg:%s, linuxErr:%d, linuxErrMsg:%s", err, errStr, errno, strerror(errno));
|
int32_t linuxErr = errno;
|
||||||
|
const char *linuxErrMsg = strerror(errno);
|
||||||
|
sError("walReadWithHandle error, err:%d %X, msg:%s, linuxErr:%d, linuxErrMsg:%s", err, err, errStr, linuxErr, linuxErrMsg);
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
//assert(walReadWithHandle(pWalHandle, index) == 0);
|
//assert(walReadWithHandle(pWalHandle, index) == 0);
|
||||||
|
@ -113,7 +117,9 @@ int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex fromIndex) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
int32_t err = terrno;
|
int32_t err = terrno;
|
||||||
const char *errStr = tstrerror(err);
|
const char *errStr = tstrerror(err);
|
||||||
sError("walRollback error, err:%d, msg:%s, linuxErr:%d, linuxErrMsg:%s", err, errStr, errno, strerror(errno));
|
int32_t linuxErr = errno;
|
||||||
|
const char *linuxErrMsg = strerror(errno);
|
||||||
|
sError("walRollback error, err:%d %X, msg:%s, linuxErr:%d, linuxErrMsg:%s", err, err, errStr, linuxErr, linuxErrMsg);
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
return 0; // to avoid compiler error
|
return 0; // to avoid compiler error
|
||||||
|
@ -144,7 +150,9 @@ int32_t logStoreUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
int32_t err = terrno;
|
int32_t err = terrno;
|
||||||
const char *errStr = tstrerror(err);
|
const char *errStr = tstrerror(err);
|
||||||
sError("walCommit error, err:%d, msg:%s, linuxErr:%d, linuxErrMsg:%s", err, errStr, errno, strerror(errno));
|
int32_t linuxErr = errno;
|
||||||
|
const char *linuxErrMsg = strerror(errno);
|
||||||
|
sError("walCommit error, err:%d %X, msg:%s, linuxErr:%d, linuxErrMsg:%s", err, err, errStr, linuxErr, linuxErrMsg);
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
return 0; // to avoid compiler error
|
return 0; // to avoid compiler error
|
||||||
|
|
|
@ -25,6 +25,8 @@ int64_t FORCE_INLINE walGetSnaphostVer(SWal* pWal) { return pWal->vers.snapshotV
|
||||||
|
|
||||||
int64_t FORCE_INLINE walGetLastVer(SWal* pWal) { return pWal->vers.lastVer; }
|
int64_t FORCE_INLINE walGetLastVer(SWal* pWal) { return pWal->vers.lastVer; }
|
||||||
|
|
||||||
|
int64_t FORCE_INLINE walGetCommittedVer(SWal* pWal) { return pWal->vers.commitVer; }
|
||||||
|
|
||||||
static FORCE_INLINE int walBuildMetaName(SWal* pWal, int metaVer, char* buf) {
|
static FORCE_INLINE int walBuildMetaName(SWal* pWal, int metaVer, char* buf) {
|
||||||
return sprintf(buf, "%s/meta-ver%d", pWal->path, metaVer);
|
return sprintf(buf, "%s/meta-ver%d", pWal->path, metaVer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,11 @@ void walSetReaderCapacity(SWalReadHandle *pRead, int32_t capacity) { pRead->capa
|
||||||
|
|
||||||
int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalHead *pHead) {
|
int32_t walFetchHead(SWalReadHandle *pRead, int64_t ver, SWalHead *pHead) {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
|
||||||
// TODO: valid ver
|
// TODO: valid ver
|
||||||
|
if (ver > pRead->pWal->vers.commitVer) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (pRead->curVersion != ver) {
|
if (pRead->curVersion != ver) {
|
||||||
code = walReadSeekVer(pRead, ver);
|
code = walReadSeekVer(pRead, ver);
|
||||||
|
|
|
@ -103,7 +103,8 @@ Dwarf_Debug tDbg;
|
||||||
static TdThreadOnce traceThreadInit = PTHREAD_ONCE_INIT;
|
static TdThreadOnce traceThreadInit = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
void endTrace() {
|
void endTrace() {
|
||||||
if (traceThreadInit != PTHREAD_ONCE_INIT) {
|
TdThreadOnce tmp = PTHREAD_ONCE_INIT;
|
||||||
|
if (memcmp(&traceThreadInit, &tmp, sizeof(TdThreadOnce)) != 0) {
|
||||||
delete_lookup_table(&lookup_table);
|
delete_lookup_table(&lookup_table);
|
||||||
dwarf_finish(tDbg);
|
dwarf_finish(tDbg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
||||||
strcpy(outTimezoneStr, tz);
|
strcpy(outTimezoneStr, tz);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#elif defined(_TD_DARWIN_64)
|
||||||
char buf[4096] = {0};
|
char buf[4096] = {0};
|
||||||
char *tz = NULL;
|
char *tz = NULL;
|
||||||
{
|
{
|
||||||
|
@ -170,5 +170,110 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
||||||
*/
|
*/
|
||||||
snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %+03ld00)", tz, tm1.tm_isdst ? tzname[daylight] : tzname[0],
|
snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %+03ld00)", tz, tm1.tm_isdst ? tzname[daylight] : tzname[0],
|
||||||
-timezone / 3600);
|
-timezone / 3600);
|
||||||
|
#else
|
||||||
|
|
||||||
|
char buf[4096] = {0};
|
||||||
|
char *tz = NULL;
|
||||||
|
{
|
||||||
|
int n = readlink("/etc/localtime", buf, sizeof(buf));
|
||||||
|
if (n < 0) {
|
||||||
|
printf("read /etc/localtime error, reason:%s", strerror(errno));
|
||||||
|
|
||||||
|
if (taosCheckExistFile("/etc/timezone")) {
|
||||||
|
/*
|
||||||
|
* NOTE: do not remove it.
|
||||||
|
* Enforce set the correct daylight saving time(DST) flag according
|
||||||
|
* to current time
|
||||||
|
*/
|
||||||
|
time_t tx1 = taosGetTimestampSec();
|
||||||
|
struct tm tm1;
|
||||||
|
taosLocalTime(&tx1, &tm1);
|
||||||
|
/* load time zone string from /etc/timezone */
|
||||||
|
// FILE *f = fopen("/etc/timezone", "r");
|
||||||
|
errno = 0;
|
||||||
|
TdFilePtr pFile = taosOpenFile("/etc/timezone", TD_FILE_READ);
|
||||||
|
char buf[68] = {0};
|
||||||
|
if (pFile != NULL) {
|
||||||
|
int len = taosReadFile(pFile, buf, 64);
|
||||||
|
if (len < 64 && taosGetErrorFile(pFile)) {
|
||||||
|
taosCloseFile(&pFile);
|
||||||
|
printf("read /etc/timezone error, reason:%s", strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosCloseFile(&pFile);
|
||||||
|
|
||||||
|
buf[sizeof(buf) - 1] = 0;
|
||||||
|
char *lineEnd = strstr(buf, "\n");
|
||||||
|
if (lineEnd != NULL) {
|
||||||
|
*lineEnd = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for CentOS system, /etc/timezone does not exist. Ignore the TZ environment variables
|
||||||
|
if (strlen(buf) > 0) {
|
||||||
|
setenv("TZ", buf, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// get and set default timezone
|
||||||
|
tzset();
|
||||||
|
/*
|
||||||
|
* get CURRENT time zone.
|
||||||
|
* system current time zone is affected by daylight saving time(DST)
|
||||||
|
*
|
||||||
|
* e.g., the local time zone of London in DST is GMT+01:00,
|
||||||
|
* otherwise is GMT+00:00
|
||||||
|
*/
|
||||||
|
int32_t tz = (-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR;
|
||||||
|
*tsTimezone = tz;
|
||||||
|
tz += daylight;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* format example:
|
||||||
|
*
|
||||||
|
* Asia/Shanghai (CST, +0800)
|
||||||
|
* Europe/London (BST, +0100)
|
||||||
|
*/
|
||||||
|
snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz));
|
||||||
|
} else {
|
||||||
|
printf("There is not /etc/timezone.\n");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
buf[n] = '\0';
|
||||||
|
for (int i = n - 1; i >= 0; --i) {
|
||||||
|
if (buf[i] == '/') {
|
||||||
|
if (tz) {
|
||||||
|
tz = buf + i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tz = buf + i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!tz || 0 == strchr(tz, '/')) {
|
||||||
|
printf("parsing /etc/localtime failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setenv("TZ", tz, 1);
|
||||||
|
tzset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: do not remove it.
|
||||||
|
* Enforce set the correct daylight saving time(DST) flag according
|
||||||
|
* to current time
|
||||||
|
*/
|
||||||
|
time_t tx1 = taosGetTimestampSec();
|
||||||
|
struct tm tm1;
|
||||||
|
taosLocalTime(&tx1, &tm1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* format example:
|
||||||
|
*
|
||||||
|
* Asia/Shanghai (CST, +0800)
|
||||||
|
* Europe/London (BST, +0100)
|
||||||
|
*/
|
||||||
|
snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %+03ld00)", tz, tm1.tm_isdst ? tzname[daylight] : tzname[0],
|
||||||
|
-timezone / 3600);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -911,7 +911,8 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_trav_fn_t fp, void *param1)
|
||||||
|
|
||||||
void taosStopCacheRefreshWorker(void) {
|
void taosStopCacheRefreshWorker(void) {
|
||||||
stopRefreshWorker = true;
|
stopRefreshWorker = true;
|
||||||
if(cacheThreadInit != PTHREAD_ONCE_INIT) taosThreadJoin(cacheRefreshWorker, NULL);
|
TdThreadOnce tmp = PTHREAD_ONCE_INIT;
|
||||||
|
if (memcmp(&cacheRefreshWorker, &tmp, sizeof(TdThreadOnce)) != 0) taosThreadJoin(cacheRefreshWorker, NULL);
|
||||||
taosArrayDestroy(pCacheArrayList);
|
taosArrayDestroy(pCacheArrayList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,6 +6,8 @@
|
||||||
./test.sh -f tsim/user/pass_alter.sim
|
./test.sh -f tsim/user/pass_alter.sim
|
||||||
./test.sh -f tsim/user/pass_len.sim
|
./test.sh -f tsim/user/pass_len.sim
|
||||||
./test.sh -f tsim/user/user_len.sim
|
./test.sh -f tsim/user/user_len.sim
|
||||||
|
./test.sh -f tsim/user/privilege1.sim
|
||||||
|
./test.sh -f tsim/user/privilege2.sim
|
||||||
|
|
||||||
# ---- db
|
# ---- db
|
||||||
./test.sh -f tsim/db/create_all_options.sim
|
./test.sh -f tsim/db/create_all_options.sim
|
||||||
|
@ -75,8 +77,10 @@
|
||||||
./test.sh -f tsim/tmq/basic3Of2Cons.sim
|
./test.sh -f tsim/tmq/basic3Of2Cons.sim
|
||||||
./test.sh -f tsim/tmq/basic4Of2Cons.sim
|
./test.sh -f tsim/tmq/basic4Of2Cons.sim
|
||||||
./test.sh -f tsim/tmq/basic2Of2ConsOverlap.sim
|
./test.sh -f tsim/tmq/basic2Of2ConsOverlap.sim
|
||||||
|
./test.sh -f tsim/tmq/topic.sim
|
||||||
|
|
||||||
# --- stable
|
# --- stable
|
||||||
|
./test.sh -f tsim/stable/alter1.sim
|
||||||
./test.sh -f tsim/stable/disk.sim
|
./test.sh -f tsim/stable/disk.sim
|
||||||
./test.sh -f tsim/stable/dnode3.sim
|
./test.sh -f tsim/stable/dnode3.sim
|
||||||
./test.sh -f tsim/stable/metrics.sim
|
./test.sh -f tsim/stable/metrics.sim
|
||||||
|
|
|
@ -66,7 +66,7 @@ print ============= create database
|
||||||
# | REPLICA value [1 | 3]
|
# | REPLICA value [1 | 3]
|
||||||
# | WAL value [1 | 2]
|
# | WAL value [1 | 2]
|
||||||
|
|
||||||
sql create database db CACHELAST 3 COMP 0 DAYS 345600 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1440000 PRECISION 'ns' REPLICA 3 WAL 2 VGROUPS 6 SINGLE_STABLE 1
|
sql create database db CACHELAST 3 COMP 0 DAYS 240 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1000 PRECISION 'ns' REPLICA 3 WAL 2 VGROUPS 6 SINGLE_STABLE 1
|
||||||
sql show databases
|
sql show databases
|
||||||
print rows: $rows
|
print rows: $rows
|
||||||
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
@ -229,7 +229,7 @@ sql_error alter database db days 0
|
||||||
sql_error alter database db days 14400 # set over than keep
|
sql_error alter database db days 14400 # set over than keep
|
||||||
|
|
||||||
print ============== modify keep
|
print ============== modify keep
|
||||||
sql alter database db keep 3456000
|
sql alter database db keep 2400
|
||||||
sql show databases
|
sql show databases
|
||||||
print keep $data7_db
|
print keep $data7_db
|
||||||
if $data7_db != 3456000,3456000,3456000 then
|
if $data7_db != 3456000,3456000,3456000 then
|
||||||
|
|
|
@ -15,8 +15,7 @@ $tb = $tbPrefix . $i
|
||||||
|
|
||||||
print =============== step1
|
print =============== step1
|
||||||
# quorum presicion
|
# quorum presicion
|
||||||
#sql create database $db vgroups 8 replica 1 days 2880 keep 3650 cache 32 blocks 12 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us'
|
sql create database $db vgroups 8 replica 1 days 2 keep 10 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us'
|
||||||
sql create database $db vgroups 8 replica 1 days 2880 keep 3650 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us'
|
|
||||||
sql show databases
|
sql show databases
|
||||||
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ endi
|
||||||
if $data26 != 2880 then
|
if $data26 != 2880 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data27 != 3650,3650,3650 then
|
if $data27 != 14400,14400,14400 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
#if $data28 != 32 then
|
#if $data28 != 32 then
|
||||||
|
@ -67,7 +66,7 @@ print =============== step4
|
||||||
sql_error drop database $db
|
sql_error drop database $db
|
||||||
|
|
||||||
print =============== step5
|
print =============== step5
|
||||||
sql create database $db replica 1 days 21600 keep 2160000
|
sql create database $db replica 1 days 15 keep 1500
|
||||||
sql show databases
|
sql show databases
|
||||||
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07
|
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07
|
||||||
if $data20 != $db then
|
if $data20 != $db then
|
||||||
|
|
|
@ -0,0 +1,168 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print ========== create stable
|
||||||
|
sql create database db
|
||||||
|
sql use db
|
||||||
|
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd"
|
||||||
|
|
||||||
|
sql show db.stables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][3] != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][4] != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][6] != abd then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========== add column
|
||||||
|
sql_error alter table db.stb add column ts int
|
||||||
|
sql_error alter table db.stb add column c1 int
|
||||||
|
sql_error alter table db.stb add column c2 int
|
||||||
|
sql_error alter table db.stb add column t1 int
|
||||||
|
sql_error alter table db.stb add column t2 int
|
||||||
|
sql_error alter table db.stb add column t3 int
|
||||||
|
sql alter table db.stb add column c3 int
|
||||||
|
sql alter table db.stb add column c4 bigint
|
||||||
|
sql alter table db.stb add column c5 binary(12)
|
||||||
|
|
||||||
|
sql show db.stables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][3] != 6 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][4] != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========== drop column
|
||||||
|
sql_error alter table db.stb drop column ts
|
||||||
|
sql_error alter table db.stb drop column c6
|
||||||
|
sql_error alter table db.stb drop column c7
|
||||||
|
sql_error alter table db.stb drop column t1
|
||||||
|
sql_error alter table db.stb drop column t2
|
||||||
|
sql_error alter table db.stb drop column t3
|
||||||
|
sql alter table db.stb drop column c1
|
||||||
|
sql alter table db.stb drop column c4
|
||||||
|
|
||||||
|
sql show db.stables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][3] != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][4] != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========== update column
|
||||||
|
sql_error alter table db.stb MODIFY column ts binary(20)
|
||||||
|
sql_error alter table db.stb MODIFY column c6 binary(20)
|
||||||
|
sql_error alter table db.stb MODIFY column t1 binary(20)
|
||||||
|
sql_error alter table db.stb MODIFY column t3 binary(20)
|
||||||
|
sql_error alter table db.stb MODIFY column c2 binary(3)
|
||||||
|
sql alter table db.stb MODIFY column c2 binary(32)
|
||||||
|
|
||||||
|
sql show db.stables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][3] != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][4] != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========== rename column
|
||||||
|
sql_error alter table db.stb rename column ts tx
|
||||||
|
sql_error alter table db.stb rename column c2 cx
|
||||||
|
|
||||||
|
print ========== add tag
|
||||||
|
sql_error alter table db.stb add tag ts int
|
||||||
|
sql_error alter table db.stb add tag c2 int
|
||||||
|
sql_error alter table db.stb add tag t1 int
|
||||||
|
sql_error alter table db.stb add tag t2 int
|
||||||
|
sql_error alter table db.stb add tag t3 int
|
||||||
|
sql alter table db.stb add tag t4 bigint
|
||||||
|
sql alter table db.stb add tag c1 int
|
||||||
|
sql alter table db.stb add tag t5 binary(12)
|
||||||
|
|
||||||
|
sql show db.stables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
#ts c2 c3 c5
|
||||||
|
if $data[0][3] != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
#t1 t2 t3 t4 c1 t5
|
||||||
|
if $data[0][4] != 6 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========== drop tag
|
||||||
|
sql_error alter table db.stb drop tag ts
|
||||||
|
sql_error alter table db.stb drop tag c2
|
||||||
|
sql_error alter table db.stb drop tag c3
|
||||||
|
sql_error alter table db.stb drop tag tx
|
||||||
|
sql alter table db.stb drop tag c1
|
||||||
|
sql alter table db.stb drop tag t5
|
||||||
|
|
||||||
|
sql show db.stables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
#ts c2 c3 c5
|
||||||
|
if $data[0][3] != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
#t1 t2 t3 t4
|
||||||
|
if $data[0][4] != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========== update tag
|
||||||
|
sql_error alter table db.stb MODIFY tag ts binary(20)
|
||||||
|
sql_error alter table db.stb MODIFY tag c2 binary(20)
|
||||||
|
sql_error alter table db.stb MODIFY tag t1 binary(20)
|
||||||
|
sql_error alter table db.stb MODIFY tag tx binary(20)
|
||||||
|
sql alter table db.stb MODIFY tag t3 binary(32)
|
||||||
|
|
||||||
|
sql show db.stables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][3] != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data[0][4] != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ========== rename tag
|
||||||
|
#t1 t2 t3 t4
|
||||||
|
|
||||||
|
sql_error alter table db.stb rename tag ts tx
|
||||||
|
sql_error alter table db.stb rename tag c2 cx
|
||||||
|
sql alter table db.stb rename tag t1 tx
|
||||||
|
|
||||||
|
print ========== alter common
|
||||||
|
sql alter table db.stb comment 'abcde' ;
|
||||||
|
|
||||||
|
sql show db.stables;
|
||||||
|
if $data[0][6] != abcde then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -1,337 +1,347 @@
|
||||||
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
|
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
|
||||||
#basic1Of2Cons.sim: vgroups=1, one topic for 2 consumers, firstly insert data, then start consume. Include six topics
|
#basic1Of2Cons.sim: vgroups=1, one topic for 2 consumers, firstly insert data, then start consume. Include six topics
|
||||||
#basic2Of2ConsOverlap.sim: vgroups=1, multi topics for 2 consumers, firstly insert data, then start consume. Include six topics
|
#basic2Of2ConsOverlap.sim: vgroups=1, multi topics for 2 consumers, firstly insert data, then start consume. Include six topics
|
||||||
#basic3Of2Cons.sim: vgroups=4, one topic for 2 consumers, firstly insert data, then start consume. Include six topics
|
#basic3Of2Cons.sim: vgroups=4, one topic for 2 consumers, firstly insert data, then start consume. Include six topics
|
||||||
#basic4Of2Cons.sim: vgroups=4, multi topics for 2 consumers, firstly insert data, then start consume. Include six topics
|
#basic4Of2Cons.sim: vgroups=4, multi topics for 2 consumers, firstly insert data, then start consume. Include six topics
|
||||||
|
|
||||||
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
|
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
|
||||||
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
|
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
|
||||||
#
|
#
|
||||||
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
|
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
|
||||||
#
|
#
|
||||||
|
|
||||||
run tsim/tmq/prepareBasicEnv-1vgrp.sim
|
run tsim/tmq/prepareBasicEnv-1vgrp.sim
|
||||||
|
|
||||||
#---- global parameters start ----#
|
#---- global parameters start ----#
|
||||||
$dbName = db
|
$dbName = db
|
||||||
$vgroups = 1
|
$vgroups = 1
|
||||||
$stbPrefix = stb
|
$stbPrefix = stb
|
||||||
$ctbPrefix = ctb
|
$ctbPrefix = ctb
|
||||||
$ntbPrefix = ntb
|
$ntbPrefix = ntb
|
||||||
$stbNum = 1
|
$stbNum = 1
|
||||||
$ctbNum = 10
|
$ctbNum = 10
|
||||||
$ntbNum = 10
|
$ntbNum = 10
|
||||||
$rowsPerCtb = 10
|
$rowsPerCtb = 10
|
||||||
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||||
#---- global parameters end ----#
|
#---- global parameters end ----#
|
||||||
|
|
||||||
$pullDelay = 5
|
$pullDelay = 5
|
||||||
$ifcheckdata = 1
|
$ifcheckdata = 1
|
||||||
$showMsg = 1
|
$showMsg = 1
|
||||||
$showRow = 0
|
$showRow = 0
|
||||||
|
|
||||||
sql connect
|
sql connect
|
||||||
sql use $dbName
|
sql use $dbName
|
||||||
|
|
||||||
print == create topics from super table
|
print == create topics from super table
|
||||||
sql create topic topic_stb_column as select ts, c3 from stb
|
sql create topic topic_stb_column as select ts, c3 from stb
|
||||||
sql create topic topic_stb_all as select ts, c1, c2, c3 from stb
|
sql create topic topic_stb_all as select ts, c1, c2, c3 from stb
|
||||||
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
|
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
|
||||||
|
|
||||||
print == create topics from child table
|
print == create topics from child table
|
||||||
sql create topic topic_ctb_column as select ts, c3 from ctb0
|
sql create topic topic_ctb_column as select ts, c3 from ctb0
|
||||||
sql create topic topic_ctb_all as select * from ctb0
|
sql create topic topic_ctb_all as select * from ctb0
|
||||||
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ctb0
|
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ctb0
|
||||||
|
|
||||||
print == create topics from normal table
|
print == create topics from normal table
|
||||||
sql create topic topic_ntb_column as select ts, c3 from ntb0
|
sql create topic topic_ntb_column as select ts, c3 from ntb0
|
||||||
sql create topic topic_ntb_all as select * from ntb0
|
sql create topic topic_ntb_all as select * from ntb0
|
||||||
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb0
|
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb0
|
||||||
|
|
||||||
#sql show topics
|
#sql show topics
|
||||||
#if $rows != 9 then
|
#if $rows != 9 then
|
||||||
# return -1
|
# return -1
|
||||||
#endi
|
#endi
|
||||||
|
|
||||||
$keyList = ' . group.id:cgrp1
|
$keyList = ' . group.id:cgrp1
|
||||||
$keyList = $keyList . '
|
$keyList = $keyList . '
|
||||||
|
|
||||||
$topicNum = 2
|
$topicNum = 2
|
||||||
|
|
||||||
#=============================== start consume =============================#
|
#=============================== start consume =============================#
|
||||||
|
|
||||||
|
|
||||||
print ================ test consume from stb
|
print ================ test consume from stb
|
||||||
print == overlap toipcs: topic_stb_column + topic_stb_all, topic_stb_function + topic_stb_all
|
print == overlap toipcs: topic_stb_column + topic_stb_all, topic_stb_function + topic_stb_all
|
||||||
$topicList = ' . topic_stb_column
|
$topicList = ' . topic_stb_column
|
||||||
$topicList = $topicList . ,
|
$topicList = $topicList . ,
|
||||||
$topicList = $topicList . topic_stb_all
|
$topicList = $topicList . topic_stb_all
|
||||||
$topicList = $topicList . '
|
$topicList = $topicList . '
|
||||||
|
|
||||||
$consumerId = 0
|
$consumerId = 0
|
||||||
$totalMsgOfOneTopic = $ctbNum * $rowsPerCtb
|
$totalMsgOfOneTopic = $ctbNum * $rowsPerCtb
|
||||||
$totalMsgOfStb = $totalMsgOfOneTopic * $topicNum
|
$totalMsgOfStb = $totalMsgOfOneTopic * $topicNum
|
||||||
$expectmsgcnt = $totalMsgOfStb
|
$expectmsgcnt = $totalMsgOfStb
|
||||||
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
||||||
|
|
||||||
|
|
||||||
$topicList = ' . topic_stb_all
|
$topicList = ' . topic_stb_all
|
||||||
$topicList = $topicList . ,
|
$topicList = $topicList . ,
|
||||||
$topicList = $topicList . topic_stb_function
|
$topicList = $topicList . topic_stb_function
|
||||||
$topicList = $topicList . '
|
$topicList = $topicList . '
|
||||||
$consumerId = 1
|
$consumerId = 1
|
||||||
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
||||||
|
|
||||||
print == start consumer to pull msgs from stb
|
print == start consumer to pull msgs from stb
|
||||||
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start
|
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start
|
||||||
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start
|
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $dbName -s start
|
||||||
|
|
||||||
print == check consume result
|
print == check consume result
|
||||||
wait_consumer_end_from_stb:
|
wait_consumer_end_from_stb:
|
||||||
sql select * from consumeresult
|
sql select * from consumeresult
|
||||||
print ==> rows: $rows
|
print ==> rows: $rows
|
||||||
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
|
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
|
||||||
print ==> rows[1]: $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]
|
print ==> rows[1]: $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]
|
||||||
if $rows != 2 then
|
if $rows != 2 then
|
||||||
sleep 1000
|
sleep 1000
|
||||||
goto wait_consumer_end_from_stb
|
goto wait_consumer_end_from_stb
|
||||||
endi
|
endi
|
||||||
if $data[0][1] == 0 then
|
if $data[0][1] == 0 then
|
||||||
if $data[1][1] != 1 then
|
if $data[1][1] != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
endi
|
endi
|
||||||
if $data[0][1] == 1 then
|
if $data[0][1] == 1 then
|
||||||
if $data[1][1] != 0 then
|
if $data[1][1] != 0 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
endi
|
endi
|
||||||
|
|
||||||
# $data[0][2]/$data[1][2] should be between $totalMsgOfOneTopic and $totalMsgOfStb.
|
# $data[0][2]/$data[1][2] should be between $totalMsgOfOneTopic and $totalMsgOfStb.
|
||||||
|
|
||||||
if $data[0][2] < $totalMsgOfOneTopic then
|
if $data[0][2] < $totalMsgOfOneTopic then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][2] > $totalMsgOfStb then
|
if $data[0][2] > $totalMsgOfStb then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[1][2] < $totalMsgOfOneTopic then
|
if $data[1][2] < $totalMsgOfOneTopic then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[1][2] > $totalMsgOfStb then
|
if $data[1][2] > $totalMsgOfStb then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
$totalMsgCons = $totalMsgOfOneTopic + $totalMsgOfStb
|
$totalMsgCons = $totalMsgOfOneTopic + $totalMsgOfStb
|
||||||
$sumOfMsgCnt = $data[0][2] + $data[1][2]
|
$sumOfMsgCnt = $data[0][2] + $data[1][2]
|
||||||
if $sumOfMsgCnt != $totalMsgCons then
|
if $sumOfMsgCnt != $totalMsgCons then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
# $data[0][3]/$data[1][3] should be between $totalMsgOfOneTopic and $totalMsgOfStb.
|
# $data[0][3]/$data[1][3] should be between $totalMsgOfOneTopic and $totalMsgOfStb.
|
||||||
if $data[0][3] < $totalMsgOfOneTopic then
|
if $data[0][3] < $totalMsgOfOneTopic then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][3] > $totalMsgOfStb then
|
if $data[0][3] > $totalMsgOfStb then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[1][3] < $totalMsgOfOneTopic then
|
if $data[1][3] < $totalMsgOfOneTopic then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[1][3] > $totalMsgOfStb then
|
if $data[1][3] > $totalMsgOfStb then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
$totalMsgCons = $totalMsgOfOneTopic + $totalMsgOfStb
|
$totalMsgCons = $totalMsgOfOneTopic + $totalMsgOfStb
|
||||||
$sumOfRows = $data[0][3] + $data[1][3]
|
$sumOfRows = $data[0][3] + $data[1][3]
|
||||||
if $sumOfRows != $totalMsgCons then
|
if $sumOfRows != $totalMsgCons then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
# clear consume info and consume result
|
# clear consume info and consume result
|
||||||
#run tsim/tmq/clearConsume.sim
|
#run tsim/tmq/clearConsume.sim
|
||||||
# because drop table function no stable, so by create new db for consume info and result. Modify it later
|
# because drop table function no stable, so by create new db for consume info and result. Modify it later
|
||||||
$cdbName = cdb1
|
$cdbName = cdb1
|
||||||
sql create database $cdbName vgroups 1
|
sql create database $cdbName vgroups 1
|
||||||
sleep 500
|
sleep 500
|
||||||
sql use $cdbName
|
sql use $cdbName
|
||||||
|
|
||||||
print == create consume info table and consume result table for ctb
|
print == create consume info table and consume result table for ctb
|
||||||
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
|
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
|
||||||
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
|
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
|
||||||
|
|
||||||
sql show tables
|
sql show tables
|
||||||
if $rows != 2 then
|
if $rows != 2 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
|
|
||||||
print ================ test consume from ctb
|
print ================ test consume from ctb
|
||||||
print == overlap toipcs: topic_ctb_column + topic_ctb_all, topic_ctb_function + topic_ctb_all
|
print == overlap toipcs: topic_ctb_column + topic_ctb_all, topic_ctb_function + topic_ctb_all
|
||||||
$topicList = ' . topic_ctb_column
|
$topicList = ' . topic_ctb_column
|
||||||
$topicList = $topicList . ,
|
$topicList = $topicList . ,
|
||||||
$topicList = $topicList . topic_ctb_all
|
$topicList = $topicList . topic_ctb_all
|
||||||
$topicList = $topicList . '
|
$topicList = $topicList . '
|
||||||
$consumerId = 0
|
$consumerId = 0
|
||||||
|
|
||||||
$totalMsgOfOneTopic = $rowsPerCtb
|
$totalMsgOfOneTopic = $rowsPerCtb
|
||||||
$totalMsgOfCtb = $totalMsgOfOneTopic * $topicNum
|
$totalMsgOfCtb = $totalMsgOfOneTopic * $topicNum
|
||||||
$expectmsgcnt = $totalMsgOfCtb
|
$expectmsgcnt = $totalMsgOfCtb
|
||||||
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
||||||
|
|
||||||
$topicList = ' . topic_ctb_function
|
$topicList = ' . topic_ctb_function
|
||||||
$topicList = $topicList . ,
|
$topicList = $topicList . ,
|
||||||
$topicList = $topicList . topic_ctb_all
|
$topicList = $topicList . topic_ctb_all
|
||||||
$topicList = $topicList . '
|
$topicList = $topicList . '
|
||||||
$consumerId = 1
|
$consumerId = 1
|
||||||
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
||||||
|
|
||||||
print == start consumer to pull msgs from ctb
|
print == start consumer to pull msgs from ctb
|
||||||
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
|
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
|
||||||
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
|
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
|
||||||
|
|
||||||
print == check consume result
|
print == check consume result
|
||||||
wait_consumer_end_from_ctb:
|
wait_consumer_end_from_ctb:
|
||||||
sql select * from consumeresult
|
sql select * from consumeresult
|
||||||
print ==> rows: $rows
|
print ==> rows: $rows
|
||||||
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
|
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
|
||||||
print ==> rows[1]: $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]
|
print ==> rows[1]: $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]
|
||||||
if $rows != 2 then
|
if $rows != 2 then
|
||||||
sleep 1000
|
sleep 1000
|
||||||
goto wait_consumer_end_from_ctb
|
goto wait_consumer_end_from_ctb
|
||||||
endi
|
endi
|
||||||
if $data[0][1] == 0 then
|
if $data[0][1] == 0 then
|
||||||
if $data[1][1] != 1 then
|
if $data[1][1] != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
endi
|
endi
|
||||||
if $data[0][1] == 1 then
|
if $data[0][1] == 1 then
|
||||||
if $data[1][1] != 0 then
|
if $data[1][1] != 0 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
endi
|
endi
|
||||||
|
|
||||||
# either $data[0][2] $totalMsgOfOneTopic and $data[1][2] == $totalMsgOfCtb
|
# either $data[0][2] $totalMsgOfOneTopic and $data[1][2] == $totalMsgOfCtb
|
||||||
# or $data[0][2] $totalMsgOfCtb and $data[1][2] == $totalMsgOfOneTopic
|
# or $data[0][2] $totalMsgOfCtb and $data[1][2] == $totalMsgOfOneTopic
|
||||||
if $data[0][2] == $totalMsgOfOneTopic then
|
if $data[0][2] == $totalMsgOfOneTopic then
|
||||||
if $data[1][2] == $totalMsgOfCtb then
|
if $data[1][2] == $totalMsgOfCtb then
|
||||||
goto check_ok_0
|
goto check_ok_0
|
||||||
endi
|
endi
|
||||||
elif $data[1][2] == $totalMsgOfOneTopic then
|
elif $data[1][2] == $totalMsgOfOneTopic then
|
||||||
if $data[0][2] == $totalMsgOfCtb then
|
if $data[0][2] == $totalMsgOfCtb then
|
||||||
goto check_ok_0
|
goto check_ok_0
|
||||||
endi
|
endi
|
||||||
endi
|
endi
|
||||||
return -1
|
return -1
|
||||||
check_ok_0:
|
check_ok_0:
|
||||||
|
|
||||||
if $data[0][3] == $totalMsgOfOneTopic then
|
if $data[0][3] == $totalMsgOfOneTopic then
|
||||||
if $data[1][3] == $totalMsgOfCtb then
|
if $data[1][3] == $totalMsgOfCtb then
|
||||||
goto check_ok_1
|
goto check_ok_1
|
||||||
endi
|
endi
|
||||||
elif $data[1][3] == $totalMsgOfOneTopic then
|
elif $data[1][3] == $totalMsgOfOneTopic then
|
||||||
if $data[0][3] == $totalMsgOfCtb then
|
if $data[0][3] == $totalMsgOfCtb then
|
||||||
goto check_ok_1
|
goto check_ok_1
|
||||||
endi
|
endi
|
||||||
endi
|
endi
|
||||||
return -1
|
return -1
|
||||||
check_ok_1:
|
check_ok_1:
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
# clear consume info and consume result
|
# clear consume info and consume result
|
||||||
#run tsim/tmq/clearConsume.sim
|
#run tsim/tmq/clearConsume.sim
|
||||||
# because drop table function no stable, so by create new db for consume info and result. Modify it later
|
# because drop table function no stable, so by create new db for consume info and result. Modify it later
|
||||||
$cdbName = cdb2
|
$cdbName = cdb2
|
||||||
sql create database $cdbName vgroups 1
|
sql create database $cdbName vgroups 1
|
||||||
sleep 500
|
sleep 500
|
||||||
sql use $cdbName
|
sql use $cdbName
|
||||||
|
|
||||||
print == create consume info table and consume result table for ntb
|
print == create consume info table and consume result table for ntb
|
||||||
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
|
sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int)
|
||||||
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
|
sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)
|
||||||
|
|
||||||
sql show tables
|
sql show tables
|
||||||
if $rows != 2 then
|
if $rows != 2 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
|
|
||||||
|
|
||||||
print ================ test consume from ntb
|
print ================ test consume from ntb
|
||||||
print == overlap toipcs: topic_ntb_column + topic_ntb_all, topic_ntb_function + topic_ntb_all
|
print == overlap toipcs: topic_ntb_column + topic_ntb_all, topic_ntb_function + topic_ntb_all
|
||||||
$topicList = ' . topic_ntb_column
|
$topicList = ' . topic_ntb_column
|
||||||
$topicList = $topicList . ,
|
$topicList = $topicList . ,
|
||||||
$topicList = $topicList . topic_ntb_all
|
$topicList = $topicList . topic_ntb_all
|
||||||
$topicList = $topicList . '
|
$topicList = $topicList . '
|
||||||
|
|
||||||
$consumerId = 0
|
$consumerId = 0
|
||||||
$totalMsgOfOneTopic = $rowsPerCtb
|
$totalMsgOfOneTopic = $rowsPerCtb
|
||||||
$totalMsgOfNtb = $totalMsgOfOneTopic * $topicNum
|
$totalMsgOfNtb = $totalMsgOfOneTopic * $topicNum
|
||||||
$expectmsgcnt = $totalMsgOfNtb
|
$expectmsgcnt = $totalMsgOfNtb
|
||||||
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
||||||
|
|
||||||
|
|
||||||
$topicList = ' . topic_ntb_function
|
$topicList = ' . topic_ntb_function
|
||||||
$topicList = $topicList . ,
|
$topicList = $topicList . ,
|
||||||
$topicList = $topicList . topic_ntb_all
|
$topicList = $topicList . topic_ntb_all
|
||||||
$topicList = $topicList . '
|
$topicList = $topicList . '
|
||||||
$consumerId = 1
|
$consumerId = 1
|
||||||
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
sql insert into consumeinfo values (now , $consumerId , $topicList , $keyList , $expectmsgcnt , $ifcheckdata )
|
||||||
|
|
||||||
print == start consumer to pull msgs from ntb
|
print == start consumer to pull msgs from ntb
|
||||||
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start
|
print == tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -s start
|
||||||
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
|
system tsim/tmq/consume.sh -d $dbName -y $pullDelay -g $showMsg -r $showRow -w $cdbName -s start
|
||||||
|
|
||||||
print == check consume result from ntb
|
print == check consume result from ntb
|
||||||
wait_consumer_end_from_ntb:
|
wait_consumer_end_from_ntb:
|
||||||
sql select * from consumeresult
|
sql select * from consumeresult
|
||||||
print ==> rows: $rows
|
print ==> rows: $rows
|
||||||
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
|
print ==> rows[0]: $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
|
||||||
print ==> rows[1]: $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]
|
print ==> rows[1]: $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]
|
||||||
if $rows != 2 then
|
if $rows != 2 then
|
||||||
sleep 1000
|
sleep 1000
|
||||||
goto wait_consumer_end_from_ntb
|
goto wait_consumer_end_from_ntb
|
||||||
endi
|
endi
|
||||||
if $data[0][1] == 0 then
|
if $data[0][1] == 0 then
|
||||||
if $data[1][1] != 1 then
|
if $data[1][1] != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
endi
|
endi
|
||||||
if $data[0][1] == 1 then
|
if $data[0][1] == 1 then
|
||||||
if $data[1][1] != 0 then
|
if $data[1][1] != 0 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
endi
|
endi
|
||||||
|
|
||||||
# either $data[0][2] $totalMsgOfOneTopic and $data[1][2] == $totalMsgOfNtb
|
# either $data[0][2] $totalMsgOfOneTopic and $data[1][2] == $totalMsgOfNtb
|
||||||
# or $data[0][2] $totalMsgOfNtb and $data[1][2] == $totalMsgOfOneTopic
|
# or $data[0][2] $totalMsgOfNtb and $data[1][2] == $totalMsgOfOneTopic
|
||||||
if $data[0][2] == $totalMsgOfOneTopic then
|
if $data[0][2] == $totalMsgOfOneTopic then
|
||||||
if $data[1][2] == $totalMsgOfNtb then
|
if $data[1][2] == $totalMsgOfNtb then
|
||||||
goto check_ok_2
|
goto check_ok_2
|
||||||
endi
|
endi
|
||||||
elif $data[1][2] == $totalMsgOfOneTopic then
|
elif $data[1][2] == $totalMsgOfOneTopic then
|
||||||
if $data[0][2] == $totalMsgOfNtb then
|
if $data[0][2] == $totalMsgOfNtb then
|
||||||
goto check_ok_2
|
goto check_ok_2
|
||||||
endi
|
endi
|
||||||
endi
|
endi
|
||||||
return -1
|
return -1
|
||||||
check_ok_2:
|
check_ok_2:
|
||||||
|
|
||||||
if $data[0][3] == $totalMsgOfOneTopic then
|
if $data[0][3] == $totalMsgOfOneTopic then
|
||||||
if $data[1][3] == $totalMsgOfNtb then
|
if $data[1][3] == $totalMsgOfNtb then
|
||||||
goto check_ok_3
|
goto check_ok_3
|
||||||
endi
|
endi
|
||||||
elif $data[1][3] == $totalMsgOfOneTopic then
|
elif $data[1][3] == $totalMsgOfOneTopic then
|
||||||
if $data[0][3] == $totalMsgOfNtb then
|
if $data[0][3] == $totalMsgOfNtb then
|
||||||
goto check_ok_3
|
goto check_ok_3
|
||||||
endi
|
endi
|
||||||
endi
|
endi
|
||||||
return -1
|
return -1
|
||||||
check_ok_3:
|
check_ok_3:
|
||||||
|
|
||||||
#------ not need stop consumer, because it exit after pull msg overthan expect msg
|
sql select * from performance_schema.`consumers`
|
||||||
#system tsim/tmq/consume.sh -s stop -x SIGINT
|
if $rows != 0 then
|
||||||
|
return -1
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
endi
|
||||||
|
|
||||||
|
#sql select * from performance_schema.`subscriptions`
|
||||||
|
#if $rows != 0 then
|
||||||
|
# return -1
|
||||||
|
#endi
|
||||||
|
|
||||||
|
#------ not need stop consumer, because it exit after pull msg overthan expect msg
|
||||||
|
#system tsim/tmq/consume.sh -s stop -x SIGINT
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
#system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
|
#---- global parameters start ----#
|
||||||
|
$dbName = db
|
||||||
|
$vgroups = 1
|
||||||
|
$stbPrefix = stb
|
||||||
|
$ctbPrefix = ctb
|
||||||
|
$ntbPrefix = ntb
|
||||||
|
$stbNum = 1
|
||||||
|
$ctbNum = 10
|
||||||
|
$ntbNum = 10
|
||||||
|
$rowsPerCtb = 10
|
||||||
|
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||||
|
#---- global parameters end ----#
|
||||||
|
|
||||||
|
sql connect
|
||||||
|
print == create database $dbName vgroups $vgroups
|
||||||
|
sql create database $dbName vgroups $vgroups
|
||||||
|
|
||||||
|
#wait database ready
|
||||||
|
$loop_cnt = 0
|
||||||
|
check_db_ready:
|
||||||
|
if $loop_cnt == 10 then
|
||||||
|
print ====> database not ready!
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql show databases
|
||||||
|
print ==> rows: $rows
|
||||||
|
print ==> $data(db)[0] $data(db)[1] $data(db)[2] $data(db)[3] $data(db)[4] $data(db)[5] $data(db)[6] $data(db)[7] $data(db)[8] $data(db)[9] $data(db)[10] $data(db)[11] $data(db)[12]
|
||||||
|
print $data(db)[13] $data(db)[14] $data(db)[15] $data(db)[16] $data(db)[17] $data(db)[18] $data(db)[19] $data(db)[20]
|
||||||
|
if $data(db)[19] != nostrict then
|
||||||
|
sleep 100
|
||||||
|
$loop_cnt = $loop_cnt + 1
|
||||||
|
goto check_db_ready
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql use $dbName
|
||||||
|
|
||||||
|
|
||||||
|
print == create super table
|
||||||
|
sql create table $stbPrefix (ts timestamp, c1 int, c2 float, c3 binary(16)) tags (t1 int)
|
||||||
|
sql show stables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print == create child table, normal table and insert data
|
||||||
|
$i = 0
|
||||||
|
while $i < $ctbNum
|
||||||
|
$ctb = $ctbPrefix . $i
|
||||||
|
$ntb = $ntbPrefix . $i
|
||||||
|
sql create table $ctb using $stbPrefix tags( $i )
|
||||||
|
sql create table $ntb (ts timestamp, c1 int, c2 float, c3 binary(16))
|
||||||
|
$i = $i + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
print == create topics from super table
|
||||||
|
sql create topic topic_stb_column as select ts, c3 from stb
|
||||||
|
sql create topic topic_stb_all as select ts, c1, c2, c3 from stb
|
||||||
|
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
|
||||||
|
|
||||||
|
print == create topics from child table
|
||||||
|
sql create topic topic_ctb_column as select ts, c3 from ctb0
|
||||||
|
sql create topic topic_ctb_all as select * from ctb0
|
||||||
|
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ctb0
|
||||||
|
|
||||||
|
print == create topics from normal table
|
||||||
|
sql create topic topic_ntb_column as select ts, c3 from ntb0
|
||||||
|
sql create topic topic_ntb_all as select * from ntb0
|
||||||
|
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb0
|
||||||
|
|
||||||
|
|
||||||
|
print == show topics
|
||||||
|
sql show topics
|
||||||
|
if $rows != 9 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print == drop topic
|
||||||
|
sql drop topic topic_stb_column
|
||||||
|
sql drop topic topic_ctb_column
|
||||||
|
sql drop topic topic_ntb_column
|
||||||
|
|
||||||
|
print == show topics
|
||||||
|
sql show topics
|
||||||
|
if $rows != 6 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print =============== show users
|
||||||
|
sql create database d1 vgroups 1;
|
||||||
|
sql create database d2 vgroups 1;
|
||||||
|
sql create database d3 vgroups 1;
|
||||||
|
sql show databases
|
||||||
|
if $rows != 5 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== create users
|
||||||
|
sql create user user1 PASS 'taosdata'
|
||||||
|
sql create user user2 PASS 'taosdata'
|
||||||
|
sql show users
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql GRANT read ON d1.* to user1;
|
||||||
|
sql GRANT write ON d2.* to user1;
|
||||||
|
|
||||||
|
print =============== re connect
|
||||||
|
sql close
|
||||||
|
sleep 2500
|
||||||
|
print user user1 login
|
||||||
|
sql connect user1
|
||||||
|
|
||||||
|
sql_error drop database d1;
|
||||||
|
sql_error drop database d2;
|
||||||
|
|
||||||
|
sql_error create stable d1.st (ts timestamp, i int) tags (j int)
|
||||||
|
sql create stable d2.st (ts timestamp, i int) tags (j int)
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,141 @@
|
||||||
|
|
||||||
|
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 create_tables(self,dbName,vgroups,stbName,ctbNum,rowsPerTbl):
|
||||||
|
tdSql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups))
|
||||||
|
tdSql.execute("use %s" %dbName)
|
||||||
|
tdSql.execute("create table %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):
|
||||||
|
tdSql.execute(sql)
|
||||||
|
sql = pre_create
|
||||||
|
if sql != pre_create:
|
||||||
|
tdSql.execute(sql)
|
||||||
|
|
||||||
|
tdLog.debug("complete to create database[%s], stable[%s] and %d child tables" %(dbName, stbName, ctbNum))
|
||||||
|
return
|
||||||
|
|
||||||
|
def insert_data(self,dbName,stbName,ctbNum,rowsPerTbl,startTs):
|
||||||
|
tdLog.debug("start to insert data ............")
|
||||||
|
tdSql.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%2000 == 0):
|
||||||
|
tdSql.execute(sql)
|
||||||
|
sql = "insert into %s_%d values " %(stbName,i)
|
||||||
|
#end sql
|
||||||
|
if sql != pre_insert:
|
||||||
|
# print(sql)
|
||||||
|
print("sql:%s"%sql)
|
||||||
|
tdSql.execute(sql)
|
||||||
|
tdLog.debug("insert data ............ [OK]")
|
||||||
|
return
|
||||||
|
|
||||||
|
def prepareEnv(self, **parameterDict):
|
||||||
|
print ("input parameters:")
|
||||||
|
print (parameterDict)
|
||||||
|
self.create_tables(parameterDict["dbName"],\
|
||||||
|
parameterDict["vgroups"],\
|
||||||
|
parameterDict["stbName"],\
|
||||||
|
parameterDict["ctbNum"],\
|
||||||
|
parameterDict["rowsPerTbl"])
|
||||||
|
|
||||||
|
self.insert_data(parameterDict["dbName"],\
|
||||||
|
parameterDict["stbName"],\
|
||||||
|
parameterDict["ctbNum"],\
|
||||||
|
parameterDict["rowsPerTbl"],\
|
||||||
|
parameterDict["startTs"])
|
||||||
|
return
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test scenario 1: ")
|
||||||
|
tdLog.info("step 1: create database, stb, ctb and insert data")
|
||||||
|
# create and start thread
|
||||||
|
parameterDict = {'dbName': 'db', \
|
||||||
|
'vgroups': 1, \
|
||||||
|
'stbName': 'stb', \
|
||||||
|
'ctbNum': 10, \
|
||||||
|
'rowsPerTbl': 10, \
|
||||||
|
'startTs': 1640966400000} # 2022-01-01 00:00:00.000
|
||||||
|
prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict)
|
||||||
|
prepareEnvThread.start()
|
||||||
|
|
||||||
|
# wait for data ready
|
||||||
|
prepareEnvThread.join()
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test scenario 2: ")
|
||||||
|
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test scenario 3: ")
|
||||||
|
|
||||||
|
#os.system('pkill tmq_sim')
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
Loading…
Reference in New Issue