Merge branch '3.0' into feature/tq
This commit is contained in:
commit
5efa53e11f
|
@ -14,9 +14,24 @@ if(${BUILD_PTHREAD})
|
||||||
cat("${TD_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# gnu regex
|
# iconv
|
||||||
if(${BUILD_GNUREGEX})
|
if(${BUILD_WITH_ICONV})
|
||||||
cat("${TD_SUPPORT_DIR}/gnuregex_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
cat("${TD_SUPPORT_DIR}/iconv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# msvc regex
|
||||||
|
if(${BUILD_MSVCREGEX})
|
||||||
|
cat("${TD_SUPPORT_DIR}/msvcregex_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# wcwidth
|
||||||
|
if(${BUILD_WCWIDTH})
|
||||||
|
cat("${TD_SUPPORT_DIR}/wcwidth_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# wingetopt
|
||||||
|
if(${BUILD_WINGETOPT})
|
||||||
|
cat("${TD_SUPPORT_DIR}/wingetopt_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# googletest
|
# googletest
|
||||||
|
@ -99,8 +114,27 @@ if(${BUILD_TEST})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
gtest
|
gtest
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src>
|
||||||
|
)
|
||||||
|
if(${TD_WINDOWS})
|
||||||
|
target_include_directories(
|
||||||
|
gtest
|
||||||
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_win>
|
||||||
|
)
|
||||||
|
endif(${TD_WINDOWS})
|
||||||
|
if(${TD_LINUX})
|
||||||
|
target_include_directories(
|
||||||
|
gtest
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_linux>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_linux>
|
||||||
)
|
)
|
||||||
|
endif(${TD_LINUX})
|
||||||
|
if(${TD_DARWIN})
|
||||||
|
target_include_directories(
|
||||||
|
gtest
|
||||||
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cpp-stub/src_darwin>
|
||||||
|
)
|
||||||
|
endif(${TD_DARWIN})
|
||||||
|
|
||||||
|
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
|
|
||||||
# cJson
|
# cJson
|
||||||
|
@ -182,6 +216,53 @@ if(${BUILD_WITH_NURAFT})
|
||||||
add_subdirectory(nuraft)
|
add_subdirectory(nuraft)
|
||||||
endif(${BUILD_WITH_NURAFT})
|
endif(${BUILD_WITH_NURAFT})
|
||||||
|
|
||||||
|
# pthread
|
||||||
|
if(${BUILD_PTHREAD})
|
||||||
|
set(CMAKE_BUILD_TYPE release)
|
||||||
|
add_definitions(-DPTW32_STATIC_LIB)
|
||||||
|
add_subdirectory(pthread)
|
||||||
|
set_target_properties(libpthreadVC3 PROPERTIES OUTPUT_NAME pthread)
|
||||||
|
add_library(pthread STATIC IMPORTED GLOBAL)
|
||||||
|
SET_PROPERTY(TARGET pthread PROPERTY IMPORTED_LOCATION ${LIBRARY_OUTPUT_PATH}/pthread.lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# iconv
|
||||||
|
if(${BUILD_WITH_ICONV})
|
||||||
|
add_subdirectory(iconv)
|
||||||
|
endif(${BUILD_WITH_ICONV})
|
||||||
|
|
||||||
|
# wingetopt
|
||||||
|
if(${BUILD_WINGETOPT})
|
||||||
|
add_subdirectory(wingetopt)
|
||||||
|
endif(${BUILD_WINGETOPT})
|
||||||
|
|
||||||
|
# msvcregex
|
||||||
|
if(${BUILD_MSVCREGEX})
|
||||||
|
add_library(msvcregex STATIC "")
|
||||||
|
target_sources(msvcregex
|
||||||
|
PRIVATE "msvcregex/regex.c"
|
||||||
|
)
|
||||||
|
target_include_directories(msvcregex
|
||||||
|
PRIVATE "msvcregex"
|
||||||
|
)
|
||||||
|
target_link_libraries(msvcregex
|
||||||
|
INTERFACE Shell32
|
||||||
|
)
|
||||||
|
SET_TARGET_PROPERTIES(msvcregex PROPERTIES OUTPUT_NAME msvcregex)
|
||||||
|
endif(${BUILD_MSVCREGEX})
|
||||||
|
|
||||||
|
# msvcregex
|
||||||
|
if(${BUILD_WCWIDTH})
|
||||||
|
add_library(wcwidth STATIC "")
|
||||||
|
target_sources(wcwidth
|
||||||
|
PRIVATE "wcwidth/wcwidth.c"
|
||||||
|
)
|
||||||
|
target_include_directories(wcwidth
|
||||||
|
PRIVATE "wcwidth"
|
||||||
|
)
|
||||||
|
SET_TARGET_PROPERTIES(wcwidth PROPERTIES OUTPUT_NAME wcwidth)
|
||||||
|
endif(${BUILD_WCWIDTH})
|
||||||
|
|
||||||
# CRAFT
|
# CRAFT
|
||||||
if(${BUILD_WITH_CRAFT})
|
if(${BUILD_WITH_CRAFT})
|
||||||
add_library(craft STATIC IMPORTED GLOBAL)
|
add_library(craft STATIC IMPORTED GLOBAL)
|
||||||
|
@ -238,8 +319,12 @@ if(${BUILD_WITH_SQLITE})
|
||||||
target_link_libraries(sqlite
|
target_link_libraries(sqlite
|
||||||
INTERFACE m
|
INTERFACE m
|
||||||
INTERFACE pthread
|
INTERFACE pthread
|
||||||
|
)
|
||||||
|
if(NOT TD_WINDOWS)
|
||||||
|
target_link_libraries(sqlite
|
||||||
INTERFACE dl
|
INTERFACE dl
|
||||||
)
|
)
|
||||||
|
endif(NOT TD_WINDOWS)
|
||||||
endif(${BUILD_WITH_SQLITE})
|
endif(${BUILD_WITH_SQLITE})
|
||||||
|
|
||||||
# pthread
|
# pthread
|
||||||
|
|
|
@ -1,2 +1,9 @@
|
||||||
add_executable(simulate_vnode "simulate_vnode.c")
|
add_executable(simulate_vnode "simulate_vnode.c")
|
||||||
target_link_libraries(simulate_vnode PUBLIC craft lz4 uv_a)
|
target_link_libraries(simulate_vnode PUBLIC craft lz4 uv_a)
|
||||||
|
if(${BUILD_WINGETOPT})
|
||||||
|
target_link_libraries(simulate_vnode PUBLIC wingetopt)
|
||||||
|
target_include_directories(
|
||||||
|
simulate_vnode
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/contrib/wingetopt/src"
|
||||||
|
)
|
||||||
|
endif()
|
|
@ -6,43 +6,39 @@
|
||||||
#define POINTER_SHIFT(ptr, s) ((void *)(((char *)ptr) + (s)))
|
#define POINTER_SHIFT(ptr, s) ((void *)(((char *)ptr) + (s)))
|
||||||
#define POINTER_DISTANCE(pa, pb) ((char *)(pb) - (char *)(pa))
|
#define POINTER_DISTANCE(pa, pb) ((char *)(pb) - (char *)(pa))
|
||||||
|
|
||||||
#define tPutA(buf, val) \
|
static inline void tPutA(void **buf, uint64_t val) {
|
||||||
({ \
|
memcpy(buf, &val, sizeof(val));
|
||||||
memcpy(buf, &val, sizeof(val)); \
|
*buf = POINTER_SHIFT(buf, sizeof(val));
|
||||||
POINTER_SHIFT(buf, sizeof(val)); \
|
}
|
||||||
})
|
|
||||||
|
|
||||||
#define tPutB(buf, val) \
|
static inline void tPutB(void **buf, uint64_t val) {
|
||||||
({ \
|
((uint8_t *)buf)[7] = ((val) >> 56) & 0xff;
|
||||||
((uint8_t *)buf)[7] = ((val) >> 56) & 0xff; \
|
((uint8_t *)buf)[6] = ((val) >> 48) & 0xff;
|
||||||
((uint8_t *)buf)[6] = ((val) >> 48) & 0xff; \
|
((uint8_t *)buf)[5] = ((val) >> 40) & 0xff;
|
||||||
((uint8_t *)buf)[5] = ((val) >> 40) & 0xff; \
|
((uint8_t *)buf)[4] = ((val) >> 32) & 0xff;
|
||||||
((uint8_t *)buf)[4] = ((val) >> 32) & 0xff; \
|
((uint8_t *)buf)[3] = ((val) >> 24) & 0xff;
|
||||||
((uint8_t *)buf)[3] = ((val) >> 24) & 0xff; \
|
((uint8_t *)buf)[2] = ((val) >> 16) & 0xff;
|
||||||
((uint8_t *)buf)[2] = ((val) >> 16) & 0xff; \
|
((uint8_t *)buf)[1] = ((val) >> 8) & 0xff;
|
||||||
((uint8_t *)buf)[1] = ((val) >> 8) & 0xff; \
|
((uint8_t *)buf)[0] = (val)&0xff;
|
||||||
((uint8_t *)buf)[0] = (val)&0xff; \
|
*buf = POINTER_SHIFT(buf, sizeof(val));
|
||||||
POINTER_SHIFT(buf, sizeof(val)); \
|
}
|
||||||
})
|
|
||||||
|
|
||||||
#define tPutC(buf, val) \
|
static inline void tPutC(void **buf, uint64_t val) {
|
||||||
({ \
|
if (buf) {
|
||||||
if (buf) { \
|
((uint64_t *)buf)[0] = (val);
|
||||||
((uint64_t *)buf)[0] = (val); \
|
POINTER_SHIFT(buf, sizeof(val));
|
||||||
POINTER_SHIFT(buf, sizeof(val)); \
|
}
|
||||||
} \
|
*buf = NULL;
|
||||||
NULL; \
|
}
|
||||||
})
|
|
||||||
|
|
||||||
#define tPutD(buf, val) \
|
static inline void tPutD(void **buf, uint64_t val) {
|
||||||
({ \
|
uint64_t tmp = val;
|
||||||
uint64_t tmp = val; \
|
for (size_t i = 0; i < sizeof(val); i++) {
|
||||||
for (size_t i = 0; i < sizeof(val); i++) { \
|
((uint8_t *)buf)[i] = tmp & 0xff;
|
||||||
((uint8_t *)buf)[i] = tmp & 0xff; \
|
tmp >>= 8;
|
||||||
tmp >>= 8; \
|
}
|
||||||
} \
|
*buf = POINTER_SHIFT(buf, sizeof(val));
|
||||||
POINTER_SHIFT(buf, sizeof(val)); \
|
}
|
||||||
})
|
|
||||||
|
|
||||||
static inline void tPutE(void **buf, uint64_t val) {
|
static inline void tPutE(void **buf, uint64_t val) {
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
@ -61,7 +57,7 @@ static void func(T t) {
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case A:
|
case A:
|
||||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||||
pBuf = tPutA(pBuf, val);
|
tPutA(pBuf, val);
|
||||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||||
pBuf = buf;
|
pBuf = buf;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +65,7 @@ static void func(T t) {
|
||||||
break;
|
break;
|
||||||
case B:
|
case B:
|
||||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||||
pBuf = tPutB(pBuf, val);
|
tPutB(pBuf, val);
|
||||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||||
pBuf = buf;
|
pBuf = buf;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +73,7 @@ static void func(T t) {
|
||||||
break;
|
break;
|
||||||
case C:
|
case C:
|
||||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||||
pBuf = tPutC(pBuf, val);
|
tPutC(pBuf, val);
|
||||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||||
pBuf = buf;
|
pBuf = buf;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +81,7 @@ static void func(T t) {
|
||||||
break;
|
break;
|
||||||
case D:
|
case D:
|
||||||
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) {
|
||||||
pBuf = tPutD(pBuf, val);
|
tPutD(pBuf, val);
|
||||||
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
if (POINTER_DISTANCE(buf, pBuf) == 1024) {
|
||||||
pBuf = buf;
|
pBuf = buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ target_link_libraries(demoapi
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(tmq
|
target_include_directories(tmq
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/os"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
|
#include "osSleep.h"
|
||||||
|
|
||||||
static int running = 1;
|
static int running = 1;
|
||||||
static void msg_process(TAOS_RES* msg) {
|
static void msg_process(TAOS_RES* msg) {
|
||||||
|
|
|
@ -85,7 +85,11 @@ typedef struct taosField {
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
} TAOS_FIELD;
|
} TAOS_FIELD;
|
||||||
|
|
||||||
#define DLL_EXPORT
|
#ifdef WINDOWS
|
||||||
|
#define DLL_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define DLL_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *, int code);
|
typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *, int code);
|
||||||
|
|
||||||
|
|
|
@ -230,12 +230,12 @@ typedef struct {
|
||||||
int32_t totalLen;
|
int32_t totalLen;
|
||||||
int32_t len;
|
int32_t len;
|
||||||
// head of SSubmitBlk
|
// head of SSubmitBlk
|
||||||
// int64_t uid; // table unique id
|
int64_t uid; // table unique id
|
||||||
// int64_t suid; // stable id
|
int64_t suid; // stable id
|
||||||
// int32_t sversion; // data schema version
|
int32_t sversion; // data schema version
|
||||||
// int32_t dataLen; // data part length, not including the SSubmitBlk head
|
int32_t dataLen; // data part length, not including the SSubmitBlk head
|
||||||
// int32_t schemaLen; // schema length, if length is 0, no schema exists
|
int32_t schemaLen; // schema length, if length is 0, no schema exists
|
||||||
// int16_t numOfRows; // total number of rows in current submit block
|
int16_t numOfRows; // total number of rows in current submit block
|
||||||
// head of SSubmitBlk
|
// head of SSubmitBlk
|
||||||
const void* pMsg;
|
const void* pMsg;
|
||||||
} SSubmitMsgIter;
|
} SSubmitMsgIter;
|
||||||
|
@ -249,10 +249,10 @@ STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
|
||||||
// 1) use tInitSubmitMsgIterEx firstly as not decrease the merge conflicts
|
// 1) use tInitSubmitMsgIterEx firstly as not decrease the merge conflicts
|
||||||
// 2) replace tInitSubmitMsgIterEx with tInitSubmitMsgIter later
|
// 2) replace tInitSubmitMsgIterEx with tInitSubmitMsgIter later
|
||||||
// 3) finally, rename tInitSubmitMsgIterEx to tInitSubmitMsgIter
|
// 3) finally, rename tInitSubmitMsgIterEx to tInitSubmitMsgIter
|
||||||
// int32_t tInitSubmitMsgIterEx(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
int32_t tInitSubmitMsgIterEx(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
||||||
// int32_t tGetSubmitMsgNextEx(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
|
int32_t tGetSubmitMsgNextEx(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
|
||||||
// int32_t tInitSubmitBlkIterEx(SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
|
int32_t tInitSubmitBlkIterEx(SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
|
||||||
// STSRow* tGetSubmitBlkNextEx(SSubmitBlkIter* pIter);
|
STSRow* tGetSubmitBlkNextEx(SSubmitBlkIter* pIter);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t index; // index of failed block in submit blocks
|
int32_t index; // index of failed block in submit blocks
|
||||||
|
|
|
@ -25,8 +25,10 @@ extern "C" {
|
||||||
#include "tvariant.h"
|
#include "tvariant.h"
|
||||||
|
|
||||||
#define TABLE_TOTAL_COL_NUM(pMeta) ((pMeta)->tableInfo.numOfColumns + (pMeta)->tableInfo.numOfTags)
|
#define TABLE_TOTAL_COL_NUM(pMeta) ((pMeta)->tableInfo.numOfColumns + (pMeta)->tableInfo.numOfTags)
|
||||||
#define TABLE_META_SIZE(pMeta) (NULL == (pMeta) ? 0 : (sizeof(STableMeta) + TABLE_TOTAL_COL_NUM((pMeta)) * sizeof(SSchema)))
|
#define TABLE_META_SIZE(pMeta) \
|
||||||
#define VGROUPS_INFO_SIZE(pInfo) (NULL == (pInfo) ? 0 : (sizeof(SVgroupsInfo) + (pInfo)->numOfVgroups * sizeof(SVgroupInfo)))
|
(NULL == (pMeta) ? 0 : (sizeof(STableMeta) + TABLE_TOTAL_COL_NUM((pMeta)) * sizeof(SSchema)))
|
||||||
|
#define VGROUPS_INFO_SIZE(pInfo) \
|
||||||
|
(NULL == (pInfo) ? 0 : (sizeof(SVgroupsInfo) + (pInfo)->numOfVgroups * sizeof(SVgroupInfo)))
|
||||||
|
|
||||||
typedef struct SRawExprNode {
|
typedef struct SRawExprNode {
|
||||||
ENodeType nodeType;
|
ENodeType nodeType;
|
||||||
|
@ -49,10 +51,7 @@ typedef struct SExprNode {
|
||||||
SArray* pAssociation;
|
SArray* pAssociation;
|
||||||
} SExprNode;
|
} SExprNode;
|
||||||
|
|
||||||
typedef enum EColumnType {
|
typedef enum EColumnType { COLUMN_TYPE_COLUMN = 1, COLUMN_TYPE_TAG } EColumnType;
|
||||||
COLUMN_TYPE_COLUMN = 1,
|
|
||||||
COLUMN_TYPE_TAG
|
|
||||||
} EColumnType;
|
|
||||||
|
|
||||||
typedef struct SColumnNode {
|
typedef struct SColumnNode {
|
||||||
SExprNode node; // QUERY_NODE_COLUMN
|
SExprNode node; // QUERY_NODE_COLUMN
|
||||||
|
@ -99,7 +98,6 @@ typedef struct SOperatorNode {
|
||||||
SNode* pRight;
|
SNode* pRight;
|
||||||
} SOperatorNode;
|
} SOperatorNode;
|
||||||
|
|
||||||
|
|
||||||
typedef struct SLogicConditionNode {
|
typedef struct SLogicConditionNode {
|
||||||
SExprNode node; // QUERY_NODE_LOGIC_CONDITION
|
SExprNode node; // QUERY_NODE_LOGIC_CONDITION
|
||||||
ELogicConditionType condType;
|
ELogicConditionType condType;
|
||||||
|
@ -144,9 +142,7 @@ typedef struct STempTableNode {
|
||||||
SNode* pSubquery;
|
SNode* pSubquery;
|
||||||
} STempTableNode;
|
} STempTableNode;
|
||||||
|
|
||||||
typedef enum EJoinType {
|
typedef enum EJoinType { JOIN_TYPE_INNER = 1 } EJoinType;
|
||||||
JOIN_TYPE_INNER = 1
|
|
||||||
} EJoinType;
|
|
||||||
|
|
||||||
typedef struct SJoinTableNode {
|
typedef struct SJoinTableNode {
|
||||||
STableNode table; // QUERY_NODE_JOIN_TABLE
|
STableNode table; // QUERY_NODE_JOIN_TABLE
|
||||||
|
@ -156,9 +152,7 @@ typedef struct SJoinTableNode {
|
||||||
SNode* pOnCond;
|
SNode* pOnCond;
|
||||||
} SJoinTableNode;
|
} SJoinTableNode;
|
||||||
|
|
||||||
typedef enum EGroupingSetType {
|
typedef enum EGroupingSetType { GP_TYPE_NORMAL = 1 } EGroupingSetType;
|
||||||
GP_TYPE_NORMAL = 1
|
|
||||||
} EGroupingSetType;
|
|
||||||
|
|
||||||
typedef struct SGroupingSetNode {
|
typedef struct SGroupingSetNode {
|
||||||
ENodeType type; // QUERY_NODE_GROUPING_SET
|
ENodeType type; // QUERY_NODE_GROUPING_SET
|
||||||
|
@ -166,16 +160,9 @@ typedef struct SGroupingSetNode {
|
||||||
SNodeList* pParameterList;
|
SNodeList* pParameterList;
|
||||||
} SGroupingSetNode;
|
} SGroupingSetNode;
|
||||||
|
|
||||||
typedef enum EOrder {
|
typedef enum EOrder { ORDER_ASC = 1, ORDER_DESC } EOrder;
|
||||||
ORDER_ASC = 1,
|
|
||||||
ORDER_DESC
|
|
||||||
} EOrder;
|
|
||||||
|
|
||||||
typedef enum ENullOrder {
|
typedef enum ENullOrder { NULL_ORDER_DEFAULT = 1, NULL_ORDER_FIRST, NULL_ORDER_LAST } ENullOrder;
|
||||||
NULL_ORDER_DEFAULT = 1,
|
|
||||||
NULL_ORDER_FIRST,
|
|
||||||
NULL_ORDER_LAST
|
|
||||||
} ENullOrder;
|
|
||||||
|
|
||||||
typedef struct SOrderByExprNode {
|
typedef struct SOrderByExprNode {
|
||||||
ENodeType type; // QUERY_NODE_ORDER_BY_EXPR
|
ENodeType type; // QUERY_NODE_ORDER_BY_EXPR
|
||||||
|
@ -242,12 +229,10 @@ typedef struct SSelectStmt {
|
||||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||||
uint8_t precision;
|
uint8_t precision;
|
||||||
bool isEmptyResult;
|
bool isEmptyResult;
|
||||||
|
bool hasAggFuncs;
|
||||||
} SSelectStmt;
|
} SSelectStmt;
|
||||||
|
|
||||||
typedef enum ESetOperatorType {
|
typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType;
|
||||||
SET_OP_TYPE_UNION_ALL = 1,
|
|
||||||
SET_OP_TYPE_UNION
|
|
||||||
} ESetOperatorType;
|
|
||||||
|
|
||||||
typedef struct SSetOperator {
|
typedef struct SSetOperator {
|
||||||
ENodeType type; // QUERY_NODE_SET_OPERATOR
|
ENodeType type; // QUERY_NODE_SET_OPERATOR
|
||||||
|
@ -271,7 +256,6 @@ typedef enum ESqlClause {
|
||||||
SQL_CLAUSE_ORDER_BY
|
SQL_CLAUSE_ORDER_BY
|
||||||
} ESqlClause;
|
} ESqlClause;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PAYLOAD_TYPE_KV = 0,
|
PAYLOAD_TYPE_KV = 0,
|
||||||
PAYLOAD_TYPE_RAW = 1,
|
PAYLOAD_TYPE_RAW = 1,
|
||||||
|
@ -281,7 +265,7 @@ typedef struct SVgDataBlocks {
|
||||||
SVgroupInfo vg;
|
SVgroupInfo vg;
|
||||||
int32_t numOfTables; // number of tables in current submit block
|
int32_t numOfTables; // number of tables in current submit block
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
char *pData; // SMsgDesc + SSubmitReq + SSubmitBlk + ...
|
char* pData; // SMsgDesc + SSubmitReq + SSubmitBlk + ...
|
||||||
} SVgDataBlocks;
|
} SVgDataBlocks;
|
||||||
|
|
||||||
typedef struct SVnodeModifOpStmt {
|
typedef struct SVnodeModifOpStmt {
|
||||||
|
@ -324,9 +308,9 @@ bool nodesIsJsonOp(const SOperatorNode* pOp);
|
||||||
bool nodesIsTimeorderQuery(const SNode* pQuery);
|
bool nodesIsTimeorderQuery(const SNode* pQuery);
|
||||||
bool nodesIsTimelineQuery(const SNode* pQuery);
|
bool nodesIsTimelineQuery(const SNode* pQuery);
|
||||||
|
|
||||||
void* nodesGetValueFromNode(SValueNode *pNode);
|
void* nodesGetValueFromNode(SValueNode* pNode);
|
||||||
char* nodesGetStrValueFromNode(SValueNode *pNode);
|
char* nodesGetStrValueFromNode(SValueNode* pNode);
|
||||||
char *getFillModeString(EFillMode mode);
|
char* getFillModeString(EFillMode mode);
|
||||||
void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
|
void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
aux_source_directory(src CLIENT_SRC)
|
aux_source_directory(src CLIENT_SRC)
|
||||||
add_library(taos SHARED ${CLIENT_SRC})
|
if(TD_WINDOWS)
|
||||||
|
add_library(taos SHARED ${CLIENT_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/src/taos.rc.in)
|
||||||
|
else()
|
||||||
|
add_library(taos SHARED ${CLIENT_SRC})
|
||||||
|
endif ()
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
taos
|
taos
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
||||||
|
@ -10,6 +14,13 @@ target_link_libraries(
|
||||||
INTERFACE api
|
INTERFACE api
|
||||||
PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom
|
PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom
|
||||||
)
|
)
|
||||||
|
if(TD_WINDOWS)
|
||||||
|
set_target_properties(taos
|
||||||
|
PROPERTIES
|
||||||
|
LINK_FLAGS
|
||||||
|
/DEF:${CMAKE_CURRENT_SOURCE_DIR}/src/taos.def
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
set_target_properties(
|
set_target_properties(
|
||||||
taos
|
taos
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
taos_cleanup
|
||||||
|
taos_options
|
||||||
|
taos_set_config
|
||||||
|
taos_connect
|
||||||
|
taos_connect_l
|
||||||
|
taos_connect_auth
|
||||||
|
taos_close
|
||||||
|
taos_data_type
|
||||||
|
taos_stmt_init
|
||||||
|
taos_stmt_prepare
|
||||||
|
taos_stmt_set_tbname_tags
|
||||||
|
taos_stmt_set_tbname
|
||||||
|
taos_stmt_set_sub_tbname
|
||||||
|
taos_stmt_is_insert
|
||||||
|
taos_stmt_num_params
|
||||||
|
taos_stmt_get_param
|
||||||
|
taos_stmt_bind_param
|
||||||
|
taos_stmt_bind_param_batch
|
||||||
|
taos_stmt_bind_single_param_batch
|
||||||
|
taos_stmt_add_batch
|
||||||
|
taos_stmt_execute
|
||||||
|
taos_stmt_use_result
|
||||||
|
taos_stmt_close
|
||||||
|
taos_stmt_errstr
|
||||||
|
taos_stmt_affected_rows
|
||||||
|
taos_stmt_affected_rows_once
|
||||||
|
taos_query
|
||||||
|
taos_query_l
|
||||||
|
taos_fetch_row
|
||||||
|
taos_result_precision
|
||||||
|
taos_free_result
|
||||||
|
taos_field_count
|
||||||
|
taos_num_fields
|
||||||
|
taos_affected_rows
|
||||||
|
taos_fetch_fields
|
||||||
|
taos_select_db
|
||||||
|
taos_print_row
|
||||||
|
taos_stop_query
|
||||||
|
taos_is_null
|
||||||
|
taos_is_update_query
|
||||||
|
taos_fetch_block
|
||||||
|
taos_fetch_block_s
|
||||||
|
taos_fetch_raw_block
|
||||||
|
taos_get_column_data_offset
|
||||||
|
taos_validate_sql
|
||||||
|
taos_reset_current_db
|
||||||
|
taos_fetch_lengths
|
||||||
|
taos_result_block
|
||||||
|
taos_get_server_info
|
||||||
|
taos_get_client_info
|
||||||
|
taos_errstr
|
||||||
|
taos_errno
|
||||||
|
taos_query_a
|
||||||
|
taos_fetch_rows_a
|
||||||
|
taos_subscribe
|
||||||
|
taos_consume
|
||||||
|
taos_unsubscribe
|
||||||
|
taos_load_table_info
|
||||||
|
taos_schemaless_insert
|
||||||
|
tmq_list_new
|
||||||
|
tmq_list_append
|
||||||
|
tmq_list_destroy
|
||||||
|
tmq_list_get_size
|
||||||
|
tmq_list_to_c_array
|
||||||
|
tmq_consumer_new
|
||||||
|
tmq_err2str
|
||||||
|
tmq_subscribe
|
||||||
|
tmq_unsubscribe
|
||||||
|
tmq_subscription
|
||||||
|
tmq_consumer_poll
|
||||||
|
tmq_consumer_close
|
||||||
|
tmq_commit
|
||||||
|
tmq_conf_new
|
||||||
|
tmq_conf_set
|
||||||
|
tmq_conf_destroy
|
||||||
|
tmq_conf_set_offset_commit_cb
|
||||||
|
tmq_get_topic_name
|
||||||
|
tmq_get_vgroup_id
|
||||||
|
tmq_create_stream
|
||||||
|
taos_check_server_status
|
|
@ -0,0 +1,31 @@
|
||||||
|
1 VERSIONINFO
|
||||||
|
FILEVERSION ${TD_VER_NUMBER}
|
||||||
|
PRODUCTVERSION ${TD_VER_NUMBER}
|
||||||
|
FILEFLAGSMASK 0x17L
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x4L
|
||||||
|
FILETYPE 0x0L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "040904b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "FileDescription", "Native C Driver for TDengine"
|
||||||
|
VALUE "FileVersion", "${TD_VER_NUMBER}"
|
||||||
|
VALUE "InternalName", "taos.dll(${TD_VER_CPUTYPE})"
|
||||||
|
VALUE "LegalCopyright", "Copyright (C) 2020 TAOS Data"
|
||||||
|
VALUE "OriginalFilename", ""
|
||||||
|
VALUE "ProductName", "taos.dll(${TD_VER_CPUTYPE})"
|
||||||
|
VALUE "ProductVersion", "${TD_VER_NUMBER}"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x409, 1200
|
||||||
|
END
|
||||||
|
END
|
|
@ -93,7 +93,7 @@ STSRow *tGetSubmitBlkNext(SSubmitBlkIter *pIter) {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
// TODO: KEEP one suite of iterator API finally.
|
// TODO: KEEP one suite of iterator API finally.
|
||||||
// 1) use tInitSubmitMsgIterEx firstly as not decrease the merge conflicts
|
// 1) use tInitSubmitMsgIterEx firstly as not decrease the merge conflicts
|
||||||
// 2) replace tInitSubmitMsgIterEx with tInitSubmitMsgIter later
|
// 2) replace tInitSubmitMsgIterEx with tInitSubmitMsgIter later
|
||||||
|
@ -173,7 +173,7 @@ STSRow *tGetSubmitBlkNextEx(SSubmitBlkIter *pIter) {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
int32_t tEncodeSEpSet(SCoder *pEncoder, const SEpSet *pEp) {
|
int32_t tEncodeSEpSet(SCoder *pEncoder, const SEpSet *pEp) {
|
||||||
if (tEncodeI8(pEncoder, pEp->inUse) < 0) return -1;
|
if (tEncodeI8(pEncoder, pEp->inUse) < 0) return -1;
|
||||||
if (tEncodeI8(pEncoder, pEp->numOfEps) < 0) return -1;
|
if (tEncodeI8(pEncoder, pEp->numOfEps) < 0) return -1;
|
||||||
|
|
|
@ -17,11 +17,21 @@
|
||||||
#include "dmImp.h"
|
#include "dmImp.h"
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
|
|
||||||
|
#define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'."
|
||||||
|
#define DM_CFG_DIR "Configuration directory."
|
||||||
|
#define DM_DMP_CFG "Dump configuration."
|
||||||
|
#define DM_ENV_CMD "The env cmd variable string to use when configuring the server, such as: -e 'TAOS_FQDN=td1'."
|
||||||
|
#define DM_ENV_FILE "The env variable file path to use when configuring the server, default is './.env', .env text can be 'TAOS_FQDN=td1'."
|
||||||
|
#define DM_NODE_TYPE "Startup type of the node, default is 0."
|
||||||
|
#define DM_MACHINE_CODE "Get machine code."
|
||||||
|
#define DM_VERSION "Print program version."
|
||||||
|
#define DM_EMAIL "<support@taosdata.com>"
|
||||||
static struct {
|
static struct {
|
||||||
bool dumpConfig;
|
bool dumpConfig;
|
||||||
bool generateGrant;
|
bool generateGrant;
|
||||||
bool printAuth;
|
bool printAuth;
|
||||||
bool printVersion;
|
bool printVersion;
|
||||||
|
bool printHelp;
|
||||||
char envFile[PATH_MAX];
|
char envFile[PATH_MAX];
|
||||||
char apolloUrl[PATH_MAX];
|
char apolloUrl[PATH_MAX];
|
||||||
const char **envCmd;
|
const char **envCmd;
|
||||||
|
@ -91,6 +101,8 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
||||||
} else if (strcmp(argv[i], "-e") == 0) {
|
} else if (strcmp(argv[i], "-e") == 0) {
|
||||||
global.envCmd[cmdEnvIndex] = argv[++i];
|
global.envCmd[cmdEnvIndex] = argv[++i];
|
||||||
cmdEnvIndex++;
|
cmdEnvIndex++;
|
||||||
|
} else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--usage") == 0 || strcmp(argv[i], "-?")) {
|
||||||
|
global.printHelp = true;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +123,21 @@ static void dmPrintVersion() {
|
||||||
printf("buildInfo: %s\n", buildinfo);
|
printf("buildInfo: %s\n", buildinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dmPrintHelp() {
|
||||||
|
char indent[] = " ";
|
||||||
|
printf("Usage: taosd [OPTION...] \n\n");
|
||||||
|
printf("%s%s%s%s\n", indent, "-a,", indent, DM_APOLLO_URL);
|
||||||
|
printf("%s%s%s%s\n", indent, "-c,", indent, DM_CFG_DIR);
|
||||||
|
printf("%s%s%s%s\n", indent, "-C,", indent, DM_DMP_CFG);
|
||||||
|
printf("%s%s%s%s\n", indent, "-e,", indent, DM_ENV_CMD);
|
||||||
|
printf("%s%s%s%s\n", indent, "-E,", indent, DM_ENV_FILE);
|
||||||
|
printf("%s%s%s%s\n", indent, "-n,", indent, DM_NODE_TYPE);
|
||||||
|
printf("%s%s%s%s\n", indent, "-k,", indent, DM_MACHINE_CODE);
|
||||||
|
printf("%s%s%s%s\n", indent, "-V,", indent, DM_VERSION);
|
||||||
|
|
||||||
|
printf("\n\nReport bugs to %s.\n", DM_EMAIL);
|
||||||
|
}
|
||||||
|
|
||||||
static void dmDumpCfg() {
|
static void dmDumpCfg() {
|
||||||
SConfig *pCfg = taosGetCfg();
|
SConfig *pCfg = taosGetCfg();
|
||||||
cfgDumpCfg(pCfg, 0, true);
|
cfgDumpCfg(pCfg, 0, true);
|
||||||
|
@ -197,6 +224,12 @@ int main(int argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (global.printHelp) {
|
||||||
|
dmPrintHelp();
|
||||||
|
taosCleanupArgs();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (global.printVersion) {
|
if (global.printVersion) {
|
||||||
dmPrintVersion();
|
dmPrintVersion();
|
||||||
taosCleanupArgs();
|
taosCleanupArgs();
|
||||||
|
|
|
@ -30,7 +30,6 @@ SSdbRaw *mndVgroupActionEncode(SVgObj *pVgroup);
|
||||||
int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups);
|
int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups);
|
||||||
SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup);
|
SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup);
|
||||||
int32_t mndGetVnodesNum(SMnode *pMnode, int32_t dnodeId);
|
int32_t mndGetVnodesNum(SMnode *pMnode, int32_t dnodeId);
|
||||||
int32_t mndGetGlobalVgroupVersion(int32_t *vgId);
|
|
||||||
|
|
||||||
void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
||||||
void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
||||||
|
|
|
@ -234,6 +234,8 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndGetGlobalVgroupVersion(SMnode *pMnode) { return sdbGetTableVer(pMnode->pSdb, SDB_VGROUP); }
|
||||||
|
|
||||||
SDbObj *mndAcquireDb(SMnode *pMnode, const char *db) {
|
SDbObj *mndAcquireDb(SMnode *pMnode, const char *db) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SDbObj *pDb = sdbAcquire(pSdb, SDB_DB, db);
|
SDbObj *pDb = sdbAcquire(pSdb, SDB_DB, db);
|
||||||
|
@ -1191,8 +1193,7 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) {
|
||||||
char *p = strchr(usedbReq.db, '.');
|
char *p = strchr(usedbReq.db, '.');
|
||||||
if (p && 0 == strcmp(p + 1, TSDB_INFORMATION_SCHEMA_DB)) {
|
if (p && 0 == strcmp(p + 1, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||||
memcpy(usedbRsp.db, usedbReq.db, TSDB_DB_FNAME_LEN);
|
memcpy(usedbRsp.db, usedbReq.db, TSDB_DB_FNAME_LEN);
|
||||||
//mndGetGlobalVgroupVersion(); TODO
|
int32_t vgVersion = mndGetGlobalVgroupVersion(pMnode);
|
||||||
static int32_t vgVersion = 1;
|
|
||||||
if (usedbReq.vgVersion < vgVersion) {
|
if (usedbReq.vgVersion < vgVersion) {
|
||||||
usedbRsp.pVgroupInfos = taosArrayInit(10, sizeof(SVgroupInfo));
|
usedbRsp.pVgroupInfos = taosArrayInit(10, sizeof(SVgroupInfo));
|
||||||
if (usedbRsp.pVgroupInfos == NULL) {
|
if (usedbRsp.pVgroupInfos == NULL) {
|
||||||
|
|
|
@ -89,7 +89,6 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
||||||
void* pReq = rpcMallocCont(contLen);
|
void* pReq = rpcMallocCont(contLen);
|
||||||
tSerializeSAlterDbReq(pReq, contLen, &alterdbReq);
|
tSerializeSAlterDbReq(pReq, contLen, &alterdbReq);
|
||||||
|
|
||||||
taosMsleep(1000); // Wait for the vnode to become the leader
|
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
|
|
|
@ -258,7 +258,6 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) {
|
||||||
pReq = BuildCreateDbReq(dbname, &contLen);
|
pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
taosMsleep(1000); // Wait for the vnode to become the leader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -304,7 +304,6 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
taosMsleep(2000); // Wait for the vnode to become the leader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -439,7 +438,6 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) {
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
taosMsleep(2000); // Wait for the vnode to become the leader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -499,7 +497,6 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) {
|
||||||
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
taosMsleep(2000); // Wait for the vnode to become the leader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -541,7 +538,6 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) {
|
||||||
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
taosMsleep(2000); // Wait for the vnode to become the leader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -606,7 +602,6 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) {
|
||||||
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
taosMsleep(2000); // Wait for the vnode to become the leader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -660,7 +655,6 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) {
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_NE(pRsp, nullptr);
|
ASSERT_NE(pRsp, nullptr);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
taosMsleep(2000); // Wait for the vnode to become the leader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -721,7 +715,6 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) {
|
||||||
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
taosMsleep(2000); // Wait for the vnode to become the leader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -782,7 +775,6 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
|
||||||
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
void* pReq = BuildCreateDbReq(dbname, &contLen);
|
||||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen);
|
||||||
ASSERT_EQ(pRsp->code, 0);
|
ASSERT_EQ(pRsp->code, 0);
|
||||||
taosMsleep(2000); // Wait for the vnode to become the leader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,6 @@ int32_t tsdbInsertTSmaData(STsdb *pTsdb, int64_t indexUid, const char *msg);
|
||||||
int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid);
|
int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid);
|
||||||
int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg);
|
int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg);
|
||||||
void tsdbCleanupReadHandle(tsdbReaderT queryHandle);
|
void tsdbCleanupReadHandle(tsdbReaderT queryHandle);
|
||||||
int32_t tdScanAndConvertSubmitMsg(SSubmitReq *pMsg);
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_FILE_HEAD = 0, // .head
|
TSDB_FILE_HEAD = 0, // .head
|
||||||
TSDB_FILE_DATA, // .data
|
TSDB_FILE_DATA, // .data
|
||||||
|
|
|
@ -197,11 +197,10 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
||||||
}
|
}
|
||||||
memcpy(data, msg, msgLen);
|
memcpy(data, msg, msgLen);
|
||||||
|
|
||||||
if (msgType == TDMT_VND_SUBMIT) {
|
// make sure msgType == TDMT_VND_SUBMIT
|
||||||
if (tsdbUpdateSmaWindow(pTq->pVnode->pTsdb, msg, ver) != 0) {
|
if (tsdbUpdateSmaWindow(pTq->pVnode->pTsdb, msg, ver) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SRpcMsg req = {
|
SRpcMsg req = {
|
||||||
.msgType = TDMT_VND_STREAM_TRIGGER,
|
.msgType = TDMT_VND_STREAM_TRIGGER,
|
||||||
|
|
|
@ -33,24 +33,24 @@ STqReadHandle* tqInitSubmitMsgScanner(SMeta* pMeta) {
|
||||||
|
|
||||||
int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t ver) {
|
int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t ver) {
|
||||||
pReadHandle->pMsg = pMsg;
|
pReadHandle->pMsg = pMsg;
|
||||||
pMsg->length = htonl(pMsg->length);
|
// pMsg->length = htonl(pMsg->length);
|
||||||
pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
// pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
||||||
|
|
||||||
// iterate and convert
|
// iterate and convert
|
||||||
if (tInitSubmitMsgIter(pMsg, &pReadHandle->msgIter) < 0) return -1;
|
if (tInitSubmitMsgIterEx(pMsg, &pReadHandle->msgIter) < 0) return -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (tGetSubmitMsgNext(&pReadHandle->msgIter, &pReadHandle->pBlock) < 0) return -1;
|
if (tGetSubmitMsgNextEx(&pReadHandle->msgIter, &pReadHandle->pBlock) < 0) return -1;
|
||||||
if (pReadHandle->pBlock == NULL) break;
|
if (pReadHandle->pBlock == NULL) break;
|
||||||
|
|
||||||
pReadHandle->pBlock->uid = htobe64(pReadHandle->pBlock->uid);
|
// pReadHandle->pBlock->uid = htobe64(pReadHandle->pBlock->uid);
|
||||||
pReadHandle->pBlock->suid = htobe64(pReadHandle->pBlock->suid);
|
// pReadHandle->pBlock->suid = htobe64(pReadHandle->pBlock->suid);
|
||||||
pReadHandle->pBlock->sversion = htonl(pReadHandle->pBlock->sversion);
|
// pReadHandle->pBlock->sversion = htonl(pReadHandle->pBlock->sversion);
|
||||||
pReadHandle->pBlock->dataLen = htonl(pReadHandle->pBlock->dataLen);
|
// pReadHandle->pBlock->dataLen = htonl(pReadHandle->pBlock->dataLen);
|
||||||
pReadHandle->pBlock->schemaLen = htonl(pReadHandle->pBlock->schemaLen);
|
// pReadHandle->pBlock->schemaLen = htonl(pReadHandle->pBlock->schemaLen);
|
||||||
pReadHandle->pBlock->numOfRows = htons(pReadHandle->pBlock->numOfRows);
|
// pReadHandle->pBlock->numOfRows = htons(pReadHandle->pBlock->numOfRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tInitSubmitMsgIter(pMsg, &pReadHandle->msgIter) < 0) return -1;
|
if (tInitSubmitMsgIterEx(pMsg, &pReadHandle->msgIter) < 0) return -1;
|
||||||
pReadHandle->ver = ver;
|
pReadHandle->ver = ver;
|
||||||
memset(&pReadHandle->blkIter, 0, sizeof(SSubmitBlkIter));
|
memset(&pReadHandle->blkIter, 0, sizeof(SSubmitBlkIter));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -58,7 +58,7 @@ int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t
|
||||||
|
|
||||||
bool tqNextDataBlock(STqReadHandle* pHandle) {
|
bool tqNextDataBlock(STqReadHandle* pHandle) {
|
||||||
while (1) {
|
while (1) {
|
||||||
if (tGetSubmitMsgNext(&pHandle->msgIter, &pHandle->pBlock) < 0) {
|
if (tGetSubmitMsgNextEx(&pHandle->msgIter, &pHandle->pBlock) < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pHandle->pBlock == NULL) return false;
|
if (pHandle->pBlock == NULL) return false;
|
||||||
|
@ -68,7 +68,7 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
|
||||||
if (pHandle->tbIdHash == NULL) {
|
if (pHandle->tbIdHash == NULL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void* ret = taosHashGet(pHandle->tbIdHash, &pHandle->pBlock->uid, sizeof(int64_t));
|
void* ret = taosHashGet(pHandle->tbIdHash, &pHandle->msgIter.uid, sizeof(int64_t));
|
||||||
if (ret != NULL) {
|
if (ret != NULL) {
|
||||||
/*printf("retrieve one tb %ld\n", pHandle->pBlock->uid);*/
|
/*printf("retrieve one tb %ld\n", pHandle->pBlock->uid);*/
|
||||||
/*pHandle->pBlock->tid = htonl(pHandle->pBlock->tid);*/
|
/*pHandle->pBlock->tid = htonl(pHandle->pBlock->tid);*/
|
||||||
|
@ -90,23 +90,25 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
|
||||||
// TODO set to real sversion
|
// TODO set to real sversion
|
||||||
int32_t sversion = 0;
|
int32_t sversion = 0;
|
||||||
if (pHandle->sver != sversion) {
|
if (pHandle->sver != sversion) {
|
||||||
pHandle->pSchema = metaGetTbTSchema(pHandle->pVnodeMeta, pHandle->pBlock->uid, sversion);
|
pHandle->pSchema = metaGetTbTSchema(pHandle->pVnodeMeta, pHandle->msgIter.uid, sversion);
|
||||||
|
#if 0
|
||||||
tb_uid_t quid;
|
tb_uid_t quid;
|
||||||
STbCfg* pTbCfg = metaGetTbInfoByUid(pHandle->pVnodeMeta, pHandle->pBlock->uid);
|
STbCfg* pTbCfg = metaGetTbInfoByUid(pHandle->pVnodeMeta, pHandle->msgIter.uid);
|
||||||
if (pTbCfg->type == META_CHILD_TABLE) {
|
if (pTbCfg->type == META_CHILD_TABLE) {
|
||||||
quid = pTbCfg->ctbCfg.suid;
|
quid = pTbCfg->ctbCfg.suid;
|
||||||
} else {
|
} else {
|
||||||
quid = pHandle->pBlock->uid;
|
quid = pHandle->msgIter.uid;
|
||||||
}
|
}
|
||||||
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, quid, sversion, true);
|
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, quid, sversion, true);
|
||||||
|
#endif
|
||||||
|
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, pHandle->msgIter.suid, sversion, true);
|
||||||
pHandle->sver = sversion;
|
pHandle->sver = sversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
STSchema* pTschema = pHandle->pSchema;
|
STSchema* pTschema = pHandle->pSchema;
|
||||||
SSchemaWrapper* pSchemaWrapper = pHandle->pSchemaWrapper;
|
SSchemaWrapper* pSchemaWrapper = pHandle->pSchemaWrapper;
|
||||||
|
|
||||||
*pNumOfRows = pHandle->pBlock->numOfRows;
|
*pNumOfRows = pHandle->msgIter.numOfRows;
|
||||||
int32_t colNumNeed = taosArrayGetSize(pHandle->pColIdList);
|
int32_t colNumNeed = taosArrayGetSize(pHandle->pColIdList);
|
||||||
|
|
||||||
if (colNumNeed == 0) {
|
if (colNumNeed == 0) {
|
||||||
|
@ -175,8 +177,8 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
|
||||||
tdSTSRowIterInit(&iter, pTschema);
|
tdSTSRowIterInit(&iter, pTschema);
|
||||||
STSRow* row;
|
STSRow* row;
|
||||||
int32_t curRow = 0;
|
int32_t curRow = 0;
|
||||||
tInitSubmitBlkIter(pHandle->pBlock, &pHandle->blkIter);
|
tInitSubmitBlkIterEx(&pHandle->msgIter, pHandle->pBlock, &pHandle->blkIter);
|
||||||
while ((row = tGetSubmitBlkNext(&pHandle->blkIter)) != NULL) {
|
while ((row = tGetSubmitBlkNextEx(&pHandle->blkIter)) != NULL) {
|
||||||
tdSTSRowIterReset(&iter, row);
|
tdSTSRowIterReset(&iter, row);
|
||||||
// get all wanted col of that block
|
// get all wanted col of that block
|
||||||
for (int32_t i = 0; i < colActual; i++) {
|
for (int32_t i = 0; i < colActual; i++) {
|
||||||
|
|
|
@ -678,9 +678,6 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdScanAndConvertSubmitMsg(pMsg) != TSDB_CODE_SUCCESS) {
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tsdbCheckAndInitSmaEnv(pTsdb, TSDB_SMA_TYPE_TIME_RANGE) != TSDB_CODE_SUCCESS) {
|
if (tsdbCheckAndInitSmaEnv(pTsdb, TSDB_SMA_TYPE_TIME_RANGE) != TSDB_CODE_SUCCESS) {
|
||||||
terrno = TSDB_CODE_TDB_INIT_FAILED;
|
terrno = TSDB_CODE_TDB_INIT_FAILED;
|
||||||
|
@ -705,25 +702,25 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
|
||||||
SInterval interval = {0};
|
SInterval interval = {0};
|
||||||
TSKEY lastWinSKey = INT64_MIN;
|
TSKEY lastWinSKey = INT64_MIN;
|
||||||
|
|
||||||
if (tInitSubmitMsgIter(pMsg, &msgIter) != TSDB_CODE_SUCCESS) {
|
if (tInitSubmitMsgIterEx(pMsg, &msgIter) != TSDB_CODE_SUCCESS) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
tGetSubmitMsgNext(&msgIter, &pBlock);
|
tGetSubmitMsgNextEx(&msgIter, &pBlock);
|
||||||
if (!pBlock) break;
|
if (!pBlock) break;
|
||||||
|
|
||||||
STSmaWrapper *pSW = NULL;
|
STSmaWrapper *pSW = NULL;
|
||||||
STSma *pTSma = NULL;
|
STSma *pTSma = NULL;
|
||||||
|
|
||||||
SSubmitBlkIter blkIter = {0};
|
SSubmitBlkIter blkIter = {0};
|
||||||
if (tInitSubmitBlkIter(pBlock, &blkIter) != TSDB_CODE_SUCCESS) {
|
if (tInitSubmitBlkIterEx(&msgIter, pBlock, &blkIter) != TSDB_CODE_SUCCESS) {
|
||||||
pSW = tdFreeTSmaWrapper(pSW);
|
pSW = tdFreeTSmaWrapper(pSW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
STSRow *row = tGetSubmitBlkNext(&blkIter);
|
STSRow *row = tGetSubmitBlkNextEx(&blkIter);
|
||||||
if (!row) {
|
if (!row) {
|
||||||
tdFreeTSmaWrapper(pSW);
|
tdFreeTSmaWrapper(pSW);
|
||||||
break;
|
break;
|
||||||
|
@ -1791,7 +1788,7 @@ int32_t tsdbUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!taosArrayPush(pStore->tbUids, &uid)) {
|
if (!taosArrayPush(pStore->tbUids, uid)) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1806,14 +1803,14 @@ int32_t tsdbUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid) {
|
||||||
if (uid) {
|
if (uid) {
|
||||||
SArray *uidArray = taosHashGet(pStore->uidHash, &suid, sizeof(tb_uid_t));
|
SArray *uidArray = taosHashGet(pStore->uidHash, &suid, sizeof(tb_uid_t));
|
||||||
if (uidArray && ((uidArray = *(SArray **)uidArray))) {
|
if (uidArray && ((uidArray = *(SArray **)uidArray))) {
|
||||||
taosArrayPush(uidArray, &uid);
|
taosArrayPush(uidArray, uid);
|
||||||
} else {
|
} else {
|
||||||
SArray *pUidArray = taosArrayInit(1, sizeof(tb_uid_t));
|
SArray *pUidArray = taosArrayInit(1, sizeof(tb_uid_t));
|
||||||
if (!pUidArray) {
|
if (!pUidArray) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
if (!taosArrayPush(pUidArray, &uid)) {
|
if (!taosArrayPush(pUidArray, uid)) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -1975,12 +1972,12 @@ static int32_t tsdbFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) {
|
||||||
// pMsg->length = htonl(pMsg->length);
|
// pMsg->length = htonl(pMsg->length);
|
||||||
// pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
// pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
||||||
|
|
||||||
if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) return -1;
|
if (tInitSubmitMsgIterEx(pMsg, &msgIter) < 0) return -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) return -1;
|
if (tGetSubmitMsgNextEx(&msgIter, &pBlock) < 0) return -1;
|
||||||
|
|
||||||
if (!pBlock) break;
|
if (!pBlock) break;
|
||||||
tsdbUidStorePut(pStore, pBlock->suid, NULL);
|
tsdbUidStorePut(pStore, msgIter.suid, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terrno != TSDB_CODE_SUCCESS) return -1;
|
if (terrno != TSDB_CODE_SUCCESS) return -1;
|
||||||
|
@ -2014,6 +2011,8 @@ int32_t tsdbExecuteRSma(STsdb *pTsdb, SMeta *pMeta, const void *pMsg, int32_t in
|
||||||
|
|
||||||
if (inputType == STREAM_DATA_TYPE_SUBMIT_BLOCK) {
|
if (inputType == STREAM_DATA_TYPE_SUBMIT_BLOCK) {
|
||||||
if (pRSmaInfo->taskInfo[0]) {
|
if (pRSmaInfo->taskInfo[0]) {
|
||||||
|
tsdbDebug("vgId:%d execute rsma task for qTaskInfo:%p suid:%" PRIu64, REPO_ID(pTsdb), pRSmaInfo->taskInfo[0],
|
||||||
|
*suid);
|
||||||
qSetStreamInput(pRSmaInfo->taskInfo[0], pMsg, inputType);
|
qSetStreamInput(pRSmaInfo->taskInfo[0], pMsg, inputType);
|
||||||
while (1) {
|
while (1) {
|
||||||
SSDataBlock *output;
|
SSDataBlock *output;
|
||||||
|
@ -2026,7 +2025,11 @@ int32_t tsdbExecuteRSma(STsdb *pTsdb, SMeta *pMeta, const void *pMsg, int32_t in
|
||||||
}
|
}
|
||||||
taosArrayPush(pResult, output);
|
taosArrayPush(pResult, output);
|
||||||
}
|
}
|
||||||
|
if (taosArrayGetSize(pResult) > 0) {
|
||||||
blockDebugShowData(pResult);
|
blockDebugShowData(pResult);
|
||||||
|
} else {
|
||||||
|
tsdbWarn("vgId:%d no sma data generated since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (pRSmaInfo->taskInfo[1]) {
|
// if (pRSmaInfo->taskInfo[1]) {
|
||||||
|
|
|
@ -81,9 +81,9 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
|
||||||
case TDMT_VND_DROP_TABLE:
|
case TDMT_VND_DROP_TABLE:
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_SUBMIT:
|
case TDMT_VND_SUBMIT:
|
||||||
|
tsdbTriggerRSma(pVnode->pTsdb, pVnode->pMeta, ptr, STREAM_DATA_TYPE_SUBMIT_BLOCK);
|
||||||
pRsp->msgType = TDMT_VND_SUBMIT_RSP;
|
pRsp->msgType = TDMT_VND_SUBMIT_RSP;
|
||||||
vnodeProcessSubmitReq(pVnode, ptr, pRsp);
|
vnodeProcessSubmitReq(pVnode, ptr, pRsp);
|
||||||
tsdbTriggerRSma(pVnode->pTsdb, pVnode->pMeta, ptr, STREAM_DATA_TYPE_SUBMIT_BLOCK);
|
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_MQ_VG_CHANGE:
|
case TDMT_VND_MQ_VG_CHANGE:
|
||||||
if (tqProcessVgChangeReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
if (tqProcessVgChangeReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)),
|
||||||
|
|
|
@ -221,7 +221,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, boo
|
||||||
|
|
||||||
p->groupId = *(uint64_t*) key;
|
p->groupId = *(uint64_t*) key;
|
||||||
p->pos = *(SResultRowPosition*) pData;
|
p->pos = *(SResultRowPosition*) pData;
|
||||||
memcpy(p->key, key + sizeof(uint64_t), keyLen - sizeof(uint64_t));
|
memcpy(p->key, (char*)key + sizeof(uint64_t), keyLen - sizeof(uint64_t));
|
||||||
|
|
||||||
taosArrayPush(pGroupResInfo->pRows, &p);
|
taosArrayPush(pGroupResInfo->pRows, &p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ static int32_t translateInOutNum(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType };
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[paraType].bytes, .type = paraType};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ static int32_t translateInNumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE };
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ static int32_t translateIn2NumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE };
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ static int32_t translateInOutStr(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = pPara1->resType.bytes, .type = pPara1->resType.type };
|
pFunc->node.resType = (SDataType){.bytes = pPara1->resType.bytes, .type = pPara1->resType.type};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ static int32_t translateSum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
} else if (IS_FLOAT_TYPE(paraType)) {
|
} else if (IS_FLOAT_TYPE(paraType)) {
|
||||||
resType = TSDB_DATA_TYPE_DOUBLE;
|
resType = TSDB_DATA_TYPE_DOUBLE;
|
||||||
}
|
}
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[resType].bytes, .type = resType };
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[resType].bytes, .type = resType};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,9 +143,7 @@ static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, in
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateTimezone(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateTimezone(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
SExprNode* pPara1 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
pFunc->node.resType = (SDataType){.bytes = TD_TIMEZONE_LEN, .type = TSDB_DATA_TYPE_BINARY};
|
||||||
pFunc->node.resType = (SDataType){.bytes = pPara1->resType.bytes, .type = pPara1->resType.type};
|
|
||||||
//pFunc->node.resType = (SDataType){.bytes = TD_TIMEZONE_LEN, .type = TSDB_DATA_TYPE_BINARY};
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +158,7 @@ static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE };
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +166,8 @@ static bool validAperventileAlgo(const SValueNode* pVal) {
|
||||||
if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) {
|
if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (0 == strcasecmp(varDataVal(pVal->datum.p), "default") || 0 == strcasecmp(varDataVal(pVal->datum.p), "t-digest"));
|
return (0 == strcasecmp(varDataVal(pVal->datum.p), "default") ||
|
||||||
|
0 == strcasecmp(varDataVal(pVal->datum.p), "t-digest"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
@ -185,17 +184,19 @@ static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
||||||
if (3 == paraNum) {
|
if (3 == paraNum) {
|
||||||
SNode* pPara3 = nodesListGetNode(pFunc->pParameterList, 2);
|
SNode* pPara3 = nodesListGetNode(pFunc->pParameterList, 2);
|
||||||
if (QUERY_NODE_VALUE != nodeType(pPara3) || !validAperventileAlgo((SValueNode*)pPara3)) {
|
if (QUERY_NODE_VALUE != nodeType(pPara3) || !validAperventileAlgo((SValueNode*)pPara3)) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "Third parameter algorithm of apercentile must be 'default' or 't-digest'");
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
|
"Third parameter algorithm of apercentile must be 'default' or 't-digest'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE };
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateTbnameColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translateTbnameColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
// pseudo column do not need to check parameters
|
// pseudo column do not need to check parameters
|
||||||
pFunc->node.resType = (SDataType){.bytes = TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR};
|
pFunc->node.resType =
|
||||||
|
(SDataType){.bytes = TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,11 +229,12 @@ static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
||||||
|
|
||||||
SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0);
|
SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
if (QUERY_NODE_COLUMN != nodeType(pPara)) {
|
if (QUERY_NODE_COLUMN != nodeType(pPara)) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "The parameters of first/last can only be columns");
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
|
"The parameters of first/last can only be columns");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType };
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[paraType].bytes, .type = paraType};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,11 +247,13 @@ static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_SMALLINT].bytes, .type = TSDB_DATA_TYPE_SMALLINT };
|
pFunc->node.resType =
|
||||||
|
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_SMALLINT].bytes, .type = TSDB_DATA_TYPE_SMALLINT};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, int32_t minParaNum, int32_t maxParaNum, bool hasSep) {
|
static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, int32_t minParaNum,
|
||||||
|
int32_t maxParaNum, bool hasSep) {
|
||||||
int32_t paraNum = LIST_LENGTH(pFunc->pParameterList);
|
int32_t paraNum = LIST_LENGTH(pFunc->pParameterList);
|
||||||
if (paraNum < minParaNum || paraNum > maxParaNum) {
|
if (paraNum < minParaNum || paraNum > maxParaNum) {
|
||||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
@ -290,7 +294,7 @@ static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
||||||
resultBytes += sepBytes * (paraNum - 3);
|
resultBytes += sepBytes * (paraNum - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = resultBytes, .type = resultType };
|
pFunc->node.resType = (SDataType){.bytes = resultBytes, .type = resultType};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +324,7 @@ static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = pPara1->resType.bytes, .type = pPara1->resType.type };
|
pFunc->node.resType = (SDataType){.bytes = pPara1->resType.bytes, .type = pPara1->resType.type};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +343,7 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
int32_t para2Bytes = pFunc->node.resType.bytes;
|
int32_t para2Bytes = pFunc->node.resType.bytes;
|
||||||
if (para2Bytes <= 0 || para2Bytes > 1000) { //cast dst var type length limits to 1000
|
if (para2Bytes <= 0 || para2Bytes > 1000) { // cast dst var type length limits to 1000
|
||||||
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -355,7 +359,7 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +372,7 @@ static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,11 +383,13 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
|
||||||
|
|
||||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||||
if ((!IS_VAR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) || !IS_INTEGER_TYPE(para2Type)) {
|
if ((!IS_VAR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) ||
|
||||||
|
!IS_INTEGER_TYPE(para2Type)) {
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP};
|
pFunc->node.resType =
|
||||||
|
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +412,7 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,13 +426,12 @@ static int32_t translateToJson(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
||||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BINARY].bytes, .type = TSDB_DATA_TYPE_BINARY};
|
pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BINARY].bytes, .type = TSDB_DATA_TYPE_BINARY};
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{.name = "count",
|
||||||
.name = "count",
|
|
||||||
.type = FUNCTION_TYPE_COUNT,
|
.type = FUNCTION_TYPE_COUNT,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.translateFunc = translateCount,
|
.translateFunc = translateCount,
|
||||||
|
@ -434,10 +439,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getCountFuncEnv,
|
.getEnvFunc = getCountFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = countFunction,
|
.processFunc = countFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
{.name = "sum",
|
||||||
{
|
|
||||||
.name = "sum",
|
|
||||||
.type = FUNCTION_TYPE_SUM,
|
.type = FUNCTION_TYPE_SUM,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.translateFunc = translateSum,
|
.translateFunc = translateSum,
|
||||||
|
@ -445,10 +448,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getSumFuncEnv,
|
.getEnvFunc = getSumFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = sumFunction,
|
.processFunc = sumFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
{.name = "min",
|
||||||
{
|
|
||||||
.name = "min",
|
|
||||||
.type = FUNCTION_TYPE_MIN,
|
.type = FUNCTION_TYPE_MIN,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
|
@ -456,10 +457,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
.initFunc = minFunctionSetup,
|
.initFunc = minFunctionSetup,
|
||||||
.processFunc = minFunction,
|
.processFunc = minFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
{.name = "max",
|
||||||
{
|
|
||||||
.name = "max",
|
|
||||||
.type = FUNCTION_TYPE_MAX,
|
.type = FUNCTION_TYPE_MAX,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
|
@ -467,48 +466,39 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
.initFunc = maxFunctionSetup,
|
.initFunc = maxFunctionSetup,
|
||||||
.processFunc = maxFunction,
|
.processFunc = maxFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
{.name = "stddev",
|
||||||
{
|
|
||||||
.name = "stddev",
|
|
||||||
.type = FUNCTION_TYPE_STDDEV,
|
.type = FUNCTION_TYPE_STDDEV,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
.getEnvFunc = getStddevFuncEnv,
|
.getEnvFunc = getStddevFuncEnv,
|
||||||
.initFunc = stddevFunctionSetup,
|
.initFunc = stddevFunctionSetup,
|
||||||
.processFunc = stddevFunction,
|
.processFunc = stddevFunction,
|
||||||
.finalizeFunc = stddevFinalize
|
.finalizeFunc = stddevFinalize},
|
||||||
},
|
{.name = "avg",
|
||||||
{
|
|
||||||
.name = "avg",
|
|
||||||
.type = FUNCTION_TYPE_AVG,
|
.type = FUNCTION_TYPE_AVG,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
.getEnvFunc = getAvgFuncEnv,
|
.getEnvFunc = getAvgFuncEnv,
|
||||||
.initFunc = avgFunctionSetup,
|
.initFunc = avgFunctionSetup,
|
||||||
.processFunc = avgFunction,
|
.processFunc = avgFunction,
|
||||||
.finalizeFunc = avgFinalize
|
.finalizeFunc = avgFinalize},
|
||||||
},
|
{.name = "percentile",
|
||||||
{
|
|
||||||
.name = "percentile",
|
|
||||||
.type = FUNCTION_TYPE_PERCENTILE,
|
.type = FUNCTION_TYPE_PERCENTILE,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC,
|
||||||
.translateFunc = translatePercentile,
|
.translateFunc = translatePercentile,
|
||||||
.getEnvFunc = getPercentileFuncEnv,
|
.getEnvFunc = getPercentileFuncEnv,
|
||||||
.initFunc = percentileFunctionSetup,
|
.initFunc = percentileFunctionSetup,
|
||||||
.processFunc = percentileFunction,
|
.processFunc = percentileFunction,
|
||||||
.finalizeFunc = percentileFinalize
|
.finalizeFunc = percentileFinalize},
|
||||||
},
|
{.name = "apercentile",
|
||||||
{
|
|
||||||
.name = "apercentile",
|
|
||||||
.type = FUNCTION_TYPE_APERCENTILE,
|
.type = FUNCTION_TYPE_APERCENTILE,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC,
|
||||||
.translateFunc = translateApercentile,
|
.translateFunc = translateApercentile,
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
.initFunc = maxFunctionSetup,
|
.initFunc = maxFunctionSetup,
|
||||||
.processFunc = maxFunction,
|
.processFunc = maxFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
.name = "top",
|
.name = "top",
|
||||||
.type = FUNCTION_TYPE_TOP,
|
.type = FUNCTION_TYPE_TOP,
|
||||||
|
@ -519,446 +509,357 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.processFunc = topFunction,
|
.processFunc = topFunction,
|
||||||
.finalizeFunc = topBotFinalize,
|
.finalizeFunc = topBotFinalize,
|
||||||
},
|
},
|
||||||
{
|
{.name = "bottom",
|
||||||
.name = "bottom",
|
|
||||||
.type = FUNCTION_TYPE_BOTTOM,
|
.type = FUNCTION_TYPE_BOTTOM,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC,
|
||||||
.translateFunc = translateBottom,
|
.translateFunc = translateBottom,
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
.initFunc = maxFunctionSetup,
|
.initFunc = maxFunctionSetup,
|
||||||
.processFunc = maxFunction,
|
.processFunc = maxFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
{.name = "spread",
|
||||||
{
|
|
||||||
.name = "spread",
|
|
||||||
.type = FUNCTION_TYPE_SPREAD,
|
.type = FUNCTION_TYPE_SPREAD,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC,
|
||||||
.translateFunc = translateSpread,
|
.translateFunc = translateSpread,
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
.initFunc = maxFunctionSetup,
|
.initFunc = maxFunctionSetup,
|
||||||
.processFunc = maxFunction,
|
.processFunc = maxFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
{.name = "last_row",
|
||||||
{
|
|
||||||
.name = "last_row",
|
|
||||||
.type = FUNCTION_TYPE_LAST_ROW,
|
.type = FUNCTION_TYPE_LAST_ROW,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
||||||
.translateFunc = translateLastRow,
|
.translateFunc = translateLastRow,
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
.initFunc = maxFunctionSetup,
|
.initFunc = maxFunctionSetup,
|
||||||
.processFunc = maxFunction,
|
.processFunc = maxFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
{.name = "first",
|
||||||
{
|
|
||||||
.name = "first",
|
|
||||||
.type = FUNCTION_TYPE_FIRST,
|
.type = FUNCTION_TYPE_FIRST,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
||||||
.translateFunc = translateFirstLast,
|
.translateFunc = translateFirstLast,
|
||||||
.getEnvFunc = getFirstLastFuncEnv,
|
.getEnvFunc = getFirstLastFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = firstFunction,
|
.processFunc = firstFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
{.name = "last",
|
||||||
{
|
|
||||||
.name = "last",
|
|
||||||
.type = FUNCTION_TYPE_LAST,
|
.type = FUNCTION_TYPE_LAST,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
||||||
.translateFunc = translateFirstLast,
|
.translateFunc = translateFirstLast,
|
||||||
.getEnvFunc = getFirstLastFuncEnv,
|
.getEnvFunc = getFirstLastFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = lastFunction,
|
.processFunc = lastFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
{.name = "diff",
|
||||||
{
|
|
||||||
.name = "diff",
|
|
||||||
.type = FUNCTION_TYPE_DIFF,
|
.type = FUNCTION_TYPE_DIFF,
|
||||||
.classification = FUNC_MGT_NONSTANDARD_SQL_FUNC,
|
.classification = FUNC_MGT_NONSTANDARD_SQL_FUNC,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
.getEnvFunc = getDiffFuncEnv,
|
.getEnvFunc = getDiffFuncEnv,
|
||||||
.initFunc = diffFunctionSetup,
|
.initFunc = diffFunctionSetup,
|
||||||
.processFunc = diffFunction,
|
.processFunc = diffFunction,
|
||||||
.finalizeFunc = functionFinalize
|
.finalizeFunc = functionFinalize},
|
||||||
},
|
{.name = "abs",
|
||||||
{
|
|
||||||
.name = "abs",
|
|
||||||
.type = FUNCTION_TYPE_ABS,
|
.type = FUNCTION_TYPE_ABS,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = absFunction,
|
.sprocessFunc = absFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "log",
|
||||||
{
|
|
||||||
.name = "log",
|
|
||||||
.type = FUNCTION_TYPE_LOG,
|
.type = FUNCTION_TYPE_LOG,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateIn2NumOutDou,
|
.translateFunc = translateIn2NumOutDou,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = logFunction,
|
.sprocessFunc = logFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "pow",
|
||||||
{
|
|
||||||
.name = "pow",
|
|
||||||
.type = FUNCTION_TYPE_POW,
|
.type = FUNCTION_TYPE_POW,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateIn2NumOutDou,
|
.translateFunc = translateIn2NumOutDou,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = powFunction,
|
.sprocessFunc = powFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "sqrt",
|
||||||
{
|
|
||||||
.name = "sqrt",
|
|
||||||
.type = FUNCTION_TYPE_SQRT,
|
.type = FUNCTION_TYPE_SQRT,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = sqrtFunction,
|
.sprocessFunc = sqrtFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "ceil",
|
||||||
{
|
|
||||||
.name = "ceil",
|
|
||||||
.type = FUNCTION_TYPE_CEIL,
|
.type = FUNCTION_TYPE_CEIL,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = ceilFunction,
|
.sprocessFunc = ceilFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "floor",
|
||||||
{
|
|
||||||
.name = "floor",
|
|
||||||
.type = FUNCTION_TYPE_FLOOR,
|
.type = FUNCTION_TYPE_FLOOR,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = floorFunction,
|
.sprocessFunc = floorFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "round",
|
||||||
{
|
|
||||||
.name = "round",
|
|
||||||
.type = FUNCTION_TYPE_ROUND,
|
.type = FUNCTION_TYPE_ROUND,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = roundFunction,
|
.sprocessFunc = roundFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "sin",
|
||||||
{
|
|
||||||
.name = "sin",
|
|
||||||
.type = FUNCTION_TYPE_SIN,
|
.type = FUNCTION_TYPE_SIN,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = sinFunction,
|
.sprocessFunc = sinFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "cos",
|
||||||
{
|
|
||||||
.name = "cos",
|
|
||||||
.type = FUNCTION_TYPE_COS,
|
.type = FUNCTION_TYPE_COS,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = cosFunction,
|
.sprocessFunc = cosFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "tan",
|
||||||
{
|
|
||||||
.name = "tan",
|
|
||||||
.type = FUNCTION_TYPE_TAN,
|
.type = FUNCTION_TYPE_TAN,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = tanFunction,
|
.sprocessFunc = tanFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "asin",
|
||||||
{
|
|
||||||
.name = "asin",
|
|
||||||
.type = FUNCTION_TYPE_ASIN,
|
.type = FUNCTION_TYPE_ASIN,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = asinFunction,
|
.sprocessFunc = asinFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "acos",
|
||||||
{
|
|
||||||
.name = "acos",
|
|
||||||
.type = FUNCTION_TYPE_ACOS,
|
.type = FUNCTION_TYPE_ACOS,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = acosFunction,
|
.sprocessFunc = acosFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "atan",
|
||||||
{
|
|
||||||
.name = "atan",
|
|
||||||
.type = FUNCTION_TYPE_ATAN,
|
.type = FUNCTION_TYPE_ATAN,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateInNumOutDou,
|
.translateFunc = translateInNumOutDou,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = atanFunction,
|
.sprocessFunc = atanFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "length",
|
||||||
{
|
|
||||||
.name = "length",
|
|
||||||
.type = FUNCTION_TYPE_LENGTH,
|
.type = FUNCTION_TYPE_LENGTH,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||||
.translateFunc = translateLength,
|
.translateFunc = translateLength,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = lengthFunction,
|
.sprocessFunc = lengthFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "char_length",
|
||||||
{
|
|
||||||
.name = "char_length",
|
|
||||||
.type = FUNCTION_TYPE_CHAR_LENGTH,
|
.type = FUNCTION_TYPE_CHAR_LENGTH,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||||
.translateFunc = translateLength,
|
.translateFunc = translateLength,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = charLengthFunction,
|
.sprocessFunc = charLengthFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "concat",
|
||||||
{
|
|
||||||
.name = "concat",
|
|
||||||
.type = FUNCTION_TYPE_CONCAT,
|
.type = FUNCTION_TYPE_CONCAT,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||||
.translateFunc = translateConcat,
|
.translateFunc = translateConcat,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = concatFunction,
|
.sprocessFunc = concatFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "concat_ws",
|
||||||
{
|
|
||||||
.name = "concat_ws",
|
|
||||||
.type = FUNCTION_TYPE_CONCAT_WS,
|
.type = FUNCTION_TYPE_CONCAT_WS,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||||
.translateFunc = translateConcatWs,
|
.translateFunc = translateConcatWs,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = concatWsFunction,
|
.sprocessFunc = concatWsFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "lower",
|
||||||
{
|
|
||||||
.name = "lower",
|
|
||||||
.type = FUNCTION_TYPE_LOWER,
|
.type = FUNCTION_TYPE_LOWER,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||||
.translateFunc = translateInOutStr,
|
.translateFunc = translateInOutStr,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = lowerFunction,
|
.sprocessFunc = lowerFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "upper",
|
||||||
{
|
|
||||||
.name = "upper",
|
|
||||||
.type = FUNCTION_TYPE_UPPER,
|
.type = FUNCTION_TYPE_UPPER,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||||
.translateFunc = translateInOutStr,
|
.translateFunc = translateInOutStr,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = upperFunction,
|
.sprocessFunc = upperFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "ltrim",
|
||||||
{
|
|
||||||
.name = "ltrim",
|
|
||||||
.type = FUNCTION_TYPE_LTRIM,
|
.type = FUNCTION_TYPE_LTRIM,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||||
.translateFunc = translateInOutStr,
|
.translateFunc = translateInOutStr,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = ltrimFunction,
|
.sprocessFunc = ltrimFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "rtrim",
|
||||||
{
|
|
||||||
.name = "rtrim",
|
|
||||||
.type = FUNCTION_TYPE_RTRIM,
|
.type = FUNCTION_TYPE_RTRIM,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||||
.translateFunc = translateInOutStr,
|
.translateFunc = translateInOutStr,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = rtrimFunction,
|
.sprocessFunc = rtrimFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "substr",
|
||||||
{
|
|
||||||
.name = "substr",
|
|
||||||
.type = FUNCTION_TYPE_SUBSTR,
|
.type = FUNCTION_TYPE_SUBSTR,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||||
.translateFunc = translateSubstr,
|
.translateFunc = translateSubstr,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = substrFunction,
|
.sprocessFunc = substrFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "cast",
|
||||||
{
|
|
||||||
.name = "cast",
|
|
||||||
.type = FUNCTION_TYPE_CAST,
|
.type = FUNCTION_TYPE_CAST,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateCast,
|
.translateFunc = translateCast,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = castFunction,
|
.sprocessFunc = castFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "to_iso8601",
|
||||||
{
|
|
||||||
.name = "to_iso8601",
|
|
||||||
.type = FUNCTION_TYPE_TO_ISO8601,
|
.type = FUNCTION_TYPE_TO_ISO8601,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateToIso8601,
|
.translateFunc = translateToIso8601,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = toISO8601Function,
|
.sprocessFunc = toISO8601Function,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "to_unixtimestamp",
|
||||||
{
|
|
||||||
.name = "to_unixtimestamp",
|
|
||||||
.type = FUNCTION_TYPE_TO_UNIXTIMESTAMP,
|
.type = FUNCTION_TYPE_TO_UNIXTIMESTAMP,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateToUnixtimestamp,
|
.translateFunc = translateToUnixtimestamp,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = toUnixtimestampFunction,
|
.sprocessFunc = toUnixtimestampFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "timetruncate",
|
||||||
{
|
|
||||||
.name = "timetruncate",
|
|
||||||
.type = FUNCTION_TYPE_TIMETRUNCATE,
|
.type = FUNCTION_TYPE_TIMETRUNCATE,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateTimeTruncate,
|
.translateFunc = translateTimeTruncate,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = timeTruncateFunction,
|
.sprocessFunc = timeTruncateFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "timediff",
|
||||||
{
|
|
||||||
.name = "timediff",
|
|
||||||
.type = FUNCTION_TYPE_TIMEDIFF,
|
.type = FUNCTION_TYPE_TIMEDIFF,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateTimeDiff,
|
.translateFunc = translateTimeDiff,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = timeDiffFunction,
|
.sprocessFunc = timeDiffFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "now",
|
||||||
{
|
|
||||||
.name = "now",
|
|
||||||
.type = FUNCTION_TYPE_NOW,
|
.type = FUNCTION_TYPE_NOW,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = nowFunction,
|
.sprocessFunc = nowFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "today",
|
||||||
{
|
|
||||||
.name = "today",
|
|
||||||
.type = FUNCTION_TYPE_TODAY,
|
.type = FUNCTION_TYPE_TODAY,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = todayFunction,
|
.sprocessFunc = todayFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "timezone",
|
||||||
{
|
|
||||||
.name = "timezone",
|
|
||||||
.type = FUNCTION_TYPE_TIMEZONE,
|
.type = FUNCTION_TYPE_TIMEZONE,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateTimezone,
|
.translateFunc = translateTimezone,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = timezoneFunction,
|
.sprocessFunc = timezoneFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "_rowts",
|
||||||
{
|
|
||||||
.name = "_rowts",
|
|
||||||
.type = FUNCTION_TYPE_ROWTS,
|
.type = FUNCTION_TYPE_ROWTS,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
.getEnvFunc = getTimePseudoFuncEnv,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = NULL,
|
.sprocessFunc = NULL,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "tbname",
|
||||||
{
|
|
||||||
.name = "tbname",
|
|
||||||
.type = FUNCTION_TYPE_TBNAME,
|
.type = FUNCTION_TYPE_TBNAME,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
||||||
.translateFunc = translateTbnameColumn,
|
.translateFunc = translateTbnameColumn,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = NULL,
|
.sprocessFunc = NULL,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "_qstartts",
|
||||||
{
|
|
||||||
.name = "_qstartts",
|
|
||||||
.type = FUNCTION_TYPE_QSTARTTS,
|
.type = FUNCTION_TYPE_QSTARTTS,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
.getEnvFunc = getTimePseudoFuncEnv,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = qStartTsFunction,
|
.sprocessFunc = qStartTsFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "_qendts",
|
||||||
{
|
|
||||||
.name = "_qendts",
|
|
||||||
.type = FUNCTION_TYPE_QENDTS,
|
.type = FUNCTION_TYPE_QENDTS,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
.getEnvFunc = getTimePseudoFuncEnv,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = qEndTsFunction,
|
.sprocessFunc = qEndTsFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "_wstartts",
|
||||||
{
|
|
||||||
.name = "_wstartts",
|
|
||||||
.type = FUNCTION_TYPE_WSTARTTS,
|
.type = FUNCTION_TYPE_WSTARTTS,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
.getEnvFunc = getTimePseudoFuncEnv,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = winStartTsFunction,
|
.sprocessFunc = winStartTsFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "_wendts",
|
||||||
{
|
|
||||||
.name = "_wendts",
|
|
||||||
.type = FUNCTION_TYPE_WENDTS,
|
.type = FUNCTION_TYPE_WENDTS,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||||
.translateFunc = translateTimePseudoColumn,
|
.translateFunc = translateTimePseudoColumn,
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
.getEnvFunc = getTimePseudoFuncEnv,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = winEndTsFunction,
|
.sprocessFunc = winEndTsFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "_wduration",
|
||||||
{
|
|
||||||
.name = "_wduration",
|
|
||||||
.type = FUNCTION_TYPE_WDURATION,
|
.type = FUNCTION_TYPE_WDURATION,
|
||||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||||
.translateFunc = translateWduration,
|
.translateFunc = translateWduration,
|
||||||
.getEnvFunc = getTimePseudoFuncEnv,
|
.getEnvFunc = getTimePseudoFuncEnv,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = winDurFunction,
|
.sprocessFunc = winDurFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL},
|
||||||
},
|
{.name = "to_json",
|
||||||
{
|
|
||||||
.name = "to_json",
|
|
||||||
.type = FUNCTION_TYPE_TO_JSON,
|
.type = FUNCTION_TYPE_TO_JSON,
|
||||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
.translateFunc = translateToJson,
|
.translateFunc = translateToJson,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = toJsonFunction,
|
.sprocessFunc = toJsonFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL}};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFuncDefinition));
|
const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFuncDefinition));
|
||||||
|
|
|
@ -27,10 +27,32 @@ extern "C" {
|
||||||
#define nodesDebug(...) qDebug("NODES: " __VA_ARGS__)
|
#define nodesDebug(...) qDebug("NODES: " __VA_ARGS__)
|
||||||
#define nodesTrace(...) qTrace("NODES: " __VA_ARGS__)
|
#define nodesTrace(...) qTrace("NODES: " __VA_ARGS__)
|
||||||
|
|
||||||
#define NODES_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
|
#define NODES_ERR_RET(c) \
|
||||||
#define NODES_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
|
do { \
|
||||||
#define NODES_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
|
int32_t _code = c; \
|
||||||
|
if (_code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = _code; \
|
||||||
|
return _code; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define NODES_RET(c) \
|
||||||
|
do { \
|
||||||
|
int32_t _code = c; \
|
||||||
|
if (_code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = _code; \
|
||||||
|
} \
|
||||||
|
return _code; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define NODES_ERR_JRET(c) \
|
||||||
|
do { \
|
||||||
|
code = c; \
|
||||||
|
if (code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = code; \
|
||||||
|
goto _return; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
#include "cmdnodes.h"
|
#include "cmdnodes.h"
|
||||||
#include "nodesUtil.h"
|
#include "nodesUtil.h"
|
||||||
#include "plannodes.h"
|
#include "plannodes.h"
|
||||||
#include "querynodes.h"
|
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
#include "querynodes.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tjson.h"
|
#include "tjson.h"
|
||||||
|
|
||||||
|
@ -398,7 +398,8 @@ static int32_t tableMetaToJson(const void* pObj, SJson* pJson) {
|
||||||
code = tjsonAddObject(pJson, jkTableMetaComInfo, tableComInfoToJson, &pNode->tableInfo);
|
code = tjsonAddObject(pJson, jkTableMetaComInfo, tableComInfoToJson, &pNode->tableInfo);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddArray(pJson, jkTableMetaColSchemas, schemaToJson, pNode->schema, sizeof(SSchema), TABLE_TOTAL_COL_NUM(pNode));
|
code = tjsonAddArray(pJson, jkTableMetaColSchemas, schemaToJson, pNode->schema, sizeof(SSchema),
|
||||||
|
TABLE_TOTAL_COL_NUM(pNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -713,13 +714,9 @@ static int32_t jsonToPhysiScanNode(const SJson* pJson, void* pObj) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t physiTagScanNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiTagScanNodeToJson(const void* pObj, SJson* pJson) { return physiScanNodeToJson(pObj, pJson); }
|
||||||
return physiScanNodeToJson(pObj, pJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t jsonToPhysiTagScanNode(const SJson* pJson, void* pObj) {
|
static int32_t jsonToPhysiTagScanNode(const SJson* pJson, void* pObj) { return jsonToPhysiScanNode(pJson, pObj); }
|
||||||
return jsonToPhysiScanNode(pJson, pObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* jkTableScanPhysiPlanScanCount = "ScanCount";
|
static const char* jkTableScanPhysiPlanScanCount = "ScanCount";
|
||||||
static const char* jkTableScanPhysiPlanReverseScanCount = "ReverseScanCount";
|
static const char* jkTableScanPhysiPlanReverseScanCount = "ReverseScanCount";
|
||||||
|
@ -822,13 +819,9 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t physiStreamScanNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiStreamScanNodeToJson(const void* pObj, SJson* pJson) { return physiScanNodeToJson(pObj, pJson); }
|
||||||
return physiScanNodeToJson(pObj, pJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t jsonToPhysiStreamScanNode(const SJson* pJson, void* pObj) {
|
static int32_t jsonToPhysiStreamScanNode(const SJson* pJson, void* pObj) { return jsonToPhysiScanNode(pJson, pObj); }
|
||||||
return jsonToPhysiScanNode(pJson, pObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* jkEndPointFqdn = "Fqdn";
|
static const char* jkEndPointFqdn = "Fqdn";
|
||||||
static const char* jkEndPointPort = "Port";
|
static const char* jkEndPointPort = "Port";
|
||||||
|
@ -1331,13 +1324,9 @@ static int32_t jsonToPhysicDataSinkNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToNodeObject(pJson, jkDataSinkInputDataBlockDesc, (SNode**)&pNode->pInputDataBlockDesc);
|
return jsonToNodeObject(pJson, jkDataSinkInputDataBlockDesc, (SNode**)&pNode->pInputDataBlockDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t physiDispatchNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiDispatchNodeToJson(const void* pObj, SJson* pJson) { return physicDataSinkNodeToJson(pObj, pJson); }
|
||||||
return physicDataSinkNodeToJson(pObj, pJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t jsonToPhysiDispatchNode(const SJson* pJson, void* pObj) {
|
static int32_t jsonToPhysiDispatchNode(const SJson* pJson, void* pObj) { return jsonToPhysicDataSinkNode(pJson, pObj); }
|
||||||
return jsonToPhysicDataSinkNode(pJson, pObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* jkSubplanIdQueryId = "QueryId";
|
static const char* jkSubplanIdQueryId = "QueryId";
|
||||||
static const char* jkSubplanIdGroupId = "GroupId";
|
static const char* jkSubplanIdGroupId = "GroupId";
|
||||||
|
@ -1709,7 +1698,7 @@ static int32_t datumToJson(const void* pObj, SJson* pJson) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code ;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t valueNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t valueNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
|
@ -2015,7 +2004,8 @@ static int32_t vgroupsInfoToJson(const void* pObj, SJson* pJson) {
|
||||||
|
|
||||||
int32_t code = tjsonAddIntegerToObject(pJson, jkVgroupsInfoNum, pNode->numOfVgroups);
|
int32_t code = tjsonAddIntegerToObject(pJson, jkVgroupsInfoNum, pNode->numOfVgroups);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddArray(pJson, jkVgroupsInfoVgroups, vgroupInfoToJson, pNode->vgroups, sizeof(SVgroupInfo), pNode->numOfVgroups);
|
code = tjsonAddArray(pJson, jkVgroupsInfoVgroups, vgroupInfoToJson, pNode->vgroups, sizeof(SVgroupInfo),
|
||||||
|
pNode->numOfVgroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -2381,6 +2371,7 @@ static const char* jkSelectStmtOrderBy = "OrderBy";
|
||||||
static const char* jkSelectStmtLimit = "Limit";
|
static const char* jkSelectStmtLimit = "Limit";
|
||||||
static const char* jkSelectStmtSlimit = "Slimit";
|
static const char* jkSelectStmtSlimit = "Slimit";
|
||||||
static const char* jkSelectStmtStmtName = "StmtName";
|
static const char* jkSelectStmtStmtName = "StmtName";
|
||||||
|
static const char* jkSelectStmtHasAggFuncs = "HasAggFuncs";
|
||||||
|
|
||||||
static int32_t selectStmtTojson(const void* pObj, SJson* pJson) {
|
static int32_t selectStmtTojson(const void* pObj, SJson* pJson) {
|
||||||
const SSelectStmt* pNode = (const SSelectStmt*)pObj;
|
const SSelectStmt* pNode = (const SSelectStmt*)pObj;
|
||||||
|
@ -2419,6 +2410,9 @@ static int32_t selectStmtTojson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddStringToObject(pJson, jkSelectStmtStmtName, pNode->stmtName);
|
code = tjsonAddStringToObject(pJson, jkSelectStmtStmtName, pNode->stmtName);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddBoolToObject(pJson, jkSelectStmtHasAggFuncs, pNode->hasAggFuncs);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2460,6 +2454,9 @@ static int32_t jsonToSelectStmt(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetStringValue(pJson, jkSelectStmtStmtName, pNode->stmtName);
|
code = tjsonGetStringValue(pJson, jkSelectStmtStmtName, pNode->stmtName);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBoolValue(pJson, jkSelectStmtHasAggFuncs, &pNode->hasAggFuncs);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,29 +17,24 @@
|
||||||
|
|
||||||
#define COMPARE_SCALAR_FIELD(fldname) \
|
#define COMPARE_SCALAR_FIELD(fldname) \
|
||||||
do { \
|
do { \
|
||||||
if (a->fldname != b->fldname) \
|
if (a->fldname != b->fldname) return false; \
|
||||||
return false; \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define COMPARE_STRING(a, b) \
|
#define COMPARE_STRING(a, b) (((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
|
||||||
(((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
|
|
||||||
|
|
||||||
#define COMPARE_STRING_FIELD(fldname) \
|
#define COMPARE_STRING_FIELD(fldname) \
|
||||||
do { \
|
do { \
|
||||||
if (!COMPARE_STRING(a->fldname, b->fldname)) \
|
if (!COMPARE_STRING(a->fldname, b->fldname)) return false; \
|
||||||
return false; \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define COMPARE_NODE_FIELD(fldname) \
|
#define COMPARE_NODE_FIELD(fldname) \
|
||||||
do { \
|
do { \
|
||||||
if (!nodesEqualNode(a->fldname, b->fldname)) \
|
if (!nodesEqualNode(a->fldname, b->fldname)) return false; \
|
||||||
return false; \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define COMPARE_NODE_LIST_FIELD(fldname) \
|
#define COMPARE_NODE_LIST_FIELD(fldname) \
|
||||||
do { \
|
do { \
|
||||||
if (!nodeNodeListEqual(a->fldname, b->fldname)) \
|
if (!nodeNodeListEqual(a->fldname, b->fldname)) return false; \
|
||||||
return false; \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static bool nodeNodeListEqual(const SNodeList* a, const SNodeList* b) {
|
static bool nodeNodeListEqual(const SNodeList* a, const SNodeList* b) {
|
||||||
|
@ -55,7 +50,7 @@ static bool nodeNodeListEqual(const SNodeList* a, const SNodeList* b) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* na, *nb;
|
SNode *na, *nb;
|
||||||
FORBOTH(na, a, nb, b) {
|
FORBOTH(na, a, nb, b) {
|
||||||
if (!nodesEqualNode(na, nb)) {
|
if (!nodesEqualNode(na, nb)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -21,9 +21,35 @@
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
|
|
||||||
char *gOperatorStr[] = {NULL, "+", "-", "*", "/", "%", "-", "&", "|", ">", ">=", "<", "<=", "=", "<>",
|
char *gOperatorStr[] = {NULL,
|
||||||
"IN", "NOT IN", "LIKE", "NOT LIKE", "MATCH", "NMATCH", "IS NULL", "IS NOT NULL",
|
"+",
|
||||||
"IS TRUE", "IS FALSE", "IS UNKNOWN", "IS NOT TRUE", "IS NOT FALSE", "IS NOT UNKNOWN"};
|
"-",
|
||||||
|
"*",
|
||||||
|
"/",
|
||||||
|
"%",
|
||||||
|
"-",
|
||||||
|
"&",
|
||||||
|
"|",
|
||||||
|
">",
|
||||||
|
">=",
|
||||||
|
"<",
|
||||||
|
"<=",
|
||||||
|
"=",
|
||||||
|
"<>",
|
||||||
|
"IN",
|
||||||
|
"NOT IN",
|
||||||
|
"LIKE",
|
||||||
|
"NOT LIKE",
|
||||||
|
"MATCH",
|
||||||
|
"NMATCH",
|
||||||
|
"IS NULL",
|
||||||
|
"IS NOT NULL",
|
||||||
|
"IS TRUE",
|
||||||
|
"IS FALSE",
|
||||||
|
"IS UNKNOWN",
|
||||||
|
"IS NOT TRUE",
|
||||||
|
"IS NOT FALSE",
|
||||||
|
"IS NOT UNKNOWN"};
|
||||||
char *gLogicConditionStr[] = {"AND", "OR", "NOT"};
|
char *gLogicConditionStr[] = {"AND", "OR", "NOT"};
|
||||||
|
|
||||||
int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
||||||
|
@ -48,7 +74,7 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_VALUE:{
|
case QUERY_NODE_VALUE: {
|
||||||
SValueNode *colNode = (SValueNode *)pNode;
|
SValueNode *colNode = (SValueNode *)pNode;
|
||||||
char *t = nodesGetStrValueFromNode(colNode);
|
char *t = nodesGetStrValueFromNode(colNode);
|
||||||
if (NULL == t) {
|
if (NULL == t) {
|
||||||
|
@ -62,7 +88,7 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_OPERATOR: {
|
case QUERY_NODE_OPERATOR: {
|
||||||
SOperatorNode* pOpNode = (SOperatorNode*)pNode;
|
SOperatorNode *pOpNode = (SOperatorNode *)pNode;
|
||||||
*len += snprintf(buf + *len, bufSize - *len, "(");
|
*len += snprintf(buf + *len, bufSize - *len, "(");
|
||||||
if (pOpNode->pLeft) {
|
if (pOpNode->pLeft) {
|
||||||
NODES_ERR_RET(nodesNodeToSQL(pOpNode->pLeft, buf, bufSize, len));
|
NODES_ERR_RET(nodesNodeToSQL(pOpNode->pLeft, buf, bufSize, len));
|
||||||
|
@ -83,9 +109,9 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_LOGIC_CONDITION:{
|
case QUERY_NODE_LOGIC_CONDITION: {
|
||||||
SLogicConditionNode* pLogicNode = (SLogicConditionNode*)pNode;
|
SLogicConditionNode *pLogicNode = (SLogicConditionNode *)pNode;
|
||||||
SNode* node = NULL;
|
SNode *node = NULL;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
*len += snprintf(buf + *len, bufSize - *len, "(");
|
*len += snprintf(buf + *len, bufSize - *len, "(");
|
||||||
|
@ -102,9 +128,9 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_FUNCTION:{
|
case QUERY_NODE_FUNCTION: {
|
||||||
SFunctionNode* pFuncNode = (SFunctionNode*)pNode;
|
SFunctionNode *pFuncNode = (SFunctionNode *)pNode;
|
||||||
SNode* node = NULL;
|
SNode *node = NULL;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
*len += snprintf(buf + *len, bufSize - *len, "%s(", pFuncNode->functionName);
|
*len += snprintf(buf + *len, bufSize - *len, "%s(", pFuncNode->functionName);
|
||||||
|
@ -121,9 +147,9 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_NODE_LIST:{
|
case QUERY_NODE_NODE_LIST: {
|
||||||
SNodeListNode* pListNode = (SNodeListNode *)pNode;
|
SNodeListNode *pListNode = (SNodeListNode *)pNode;
|
||||||
SNode* node = NULL;
|
SNode *node = NULL;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
*len += snprintf(buf + *len, bufSize - *len, "(");
|
*len += snprintf(buf + *len, bufSize - *len, "(");
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* 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 "querynodes.h"
|
|
||||||
#include "plannodes.h"
|
#include "plannodes.h"
|
||||||
|
#include "querynodes.h"
|
||||||
|
|
||||||
typedef enum ETraversalOrder {
|
typedef enum ETraversalOrder {
|
||||||
TRAVERSAL_PREORDER = 1,
|
TRAVERSAL_PREORDER = 1,
|
||||||
|
@ -29,7 +29,8 @@ static EDealRes walkExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeWalk
|
||||||
static EDealRes walkPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext);
|
static EDealRes walkPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext);
|
||||||
static EDealRes walkPhysiPlans(SNodeList* pNodeList, ETraversalOrder order, FNodeWalker walker, void* pContext);
|
static EDealRes walkPhysiPlans(SNodeList* pNodeList, ETraversalOrder order, FNodeWalker walker, void* pContext);
|
||||||
|
|
||||||
static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext, FNodeDispatcher dispatcher) {
|
static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker, void* pContext,
|
||||||
|
FNodeDispatcher dispatcher) {
|
||||||
if (NULL == pNode) {
|
if (NULL == pNode) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -395,7 +396,8 @@ static EDealRes walkScanPhysi(SScanPhysiNode* pScan, ETraversalOrder order, FNod
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes walkTableScanPhysi(STableScanPhysiNode* pScan, ETraversalOrder order, FNodeWalker walker, void* pContext) {
|
static EDealRes walkTableScanPhysi(STableScanPhysiNode* pScan, ETraversalOrder order, FNodeWalker walker,
|
||||||
|
void* pContext) {
|
||||||
EDealRes res = walkScanPhysi((SScanPhysiNode*)pScan, order, walker, pContext);
|
EDealRes res = walkScanPhysi((SScanPhysiNode*)pScan, order, walker, pContext);
|
||||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||||
res = walkPhysiPlans(pScan->pDynamicScanFuncs, order, walker, pContext);
|
res = walkPhysiPlans(pScan->pDynamicScanFuncs, order, walker, pContext);
|
||||||
|
|
|
@ -298,9 +298,7 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
|
||||||
nodesDestroyList(pNode->pScanCols);
|
nodesDestroyList(pNode->pScanCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyDataSinkNode(SDataSinkNode* pNode) {
|
static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode(pNode->pInputDataBlockDesc); }
|
||||||
nodesDestroyNode(pNode->pInputDataBlockDesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void nodesDestroyNode(SNodeptr pNode) {
|
void nodesDestroyNode(SNodeptr pNode) {
|
||||||
if (NULL == pNode) {
|
if (NULL == pNode) {
|
||||||
|
@ -866,7 +864,7 @@ void nodesClearList(SNodeList* pList) {
|
||||||
taosMemoryFreeClear(pList);
|
taosMemoryFreeClear(pList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* nodesGetValueFromNode(SValueNode *pNode) {
|
void* nodesGetValueFromNode(SValueNode* pNode) {
|
||||||
switch (pNode->node.resType.type) {
|
switch (pNode->node.resType.type) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
return (void*)&pNode->datum.b;
|
return (void*)&pNode->datum.b;
|
||||||
|
@ -895,10 +893,10 @@ void* nodesGetValueFromNode(SValueNode *pNode) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* nodesGetStrValueFromNode(SValueNode *pNode) {
|
char* nodesGetStrValueFromNode(SValueNode* pNode) {
|
||||||
switch (pNode->node.resType.type) {
|
switch (pNode->node.resType.type) {
|
||||||
case TSDB_DATA_TYPE_BOOL: {
|
case TSDB_DATA_TYPE_BOOL: {
|
||||||
void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE);
|
void* buf = taosMemoryMalloc(MAX_NUM_STR_SIZE);
|
||||||
if (NULL == buf) {
|
if (NULL == buf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -911,7 +909,7 @@ char* nodesGetStrValueFromNode(SValueNode *pNode) {
|
||||||
case TSDB_DATA_TYPE_INT:
|
case TSDB_DATA_TYPE_INT:
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP: {
|
case TSDB_DATA_TYPE_TIMESTAMP: {
|
||||||
void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE);
|
void* buf = taosMemoryMalloc(MAX_NUM_STR_SIZE);
|
||||||
if (NULL == buf) {
|
if (NULL == buf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -923,7 +921,7 @@ char* nodesGetStrValueFromNode(SValueNode *pNode) {
|
||||||
case TSDB_DATA_TYPE_USMALLINT:
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
case TSDB_DATA_TYPE_UINT:
|
case TSDB_DATA_TYPE_UINT:
|
||||||
case TSDB_DATA_TYPE_UBIGINT: {
|
case TSDB_DATA_TYPE_UBIGINT: {
|
||||||
void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE);
|
void* buf = taosMemoryMalloc(MAX_NUM_STR_SIZE);
|
||||||
if (NULL == buf) {
|
if (NULL == buf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -933,7 +931,7 @@ char* nodesGetStrValueFromNode(SValueNode *pNode) {
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE);
|
void* buf = taosMemoryMalloc(MAX_NUM_STR_SIZE);
|
||||||
if (NULL == buf) {
|
if (NULL == buf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -945,7 +943,7 @@ char* nodesGetStrValueFromNode(SValueNode *pNode) {
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY: {
|
case TSDB_DATA_TYPE_VARBINARY: {
|
||||||
int32_t bufSize = varDataLen(pNode->datum.p) + 2 + 1;
|
int32_t bufSize = varDataLen(pNode->datum.p) + 2 + 1;
|
||||||
void *buf = taosMemoryMalloc(bufSize);
|
void* buf = taosMemoryMalloc(bufSize);
|
||||||
if (NULL == buf) {
|
if (NULL == buf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -962,7 +960,8 @@ char* nodesGetStrValueFromNode(SValueNode *pNode) {
|
||||||
|
|
||||||
bool nodesIsExprNode(const SNode* pNode) {
|
bool nodesIsExprNode(const SNode* pNode) {
|
||||||
ENodeType type = nodeType(pNode);
|
ENodeType type = nodeType(pNode);
|
||||||
return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type || QUERY_NODE_FUNCTION == type);
|
return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type ||
|
||||||
|
QUERY_NODE_FUNCTION == type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nodesIsUnaryOp(const SOperatorNode* pOp) {
|
bool nodesIsUnaryOp(const SOperatorNode* pOp) {
|
||||||
|
@ -1037,13 +1036,9 @@ bool nodesIsJsonOp(const SOperatorNode* pOp) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nodesIsTimeorderQuery(const SNode* pQuery) {
|
bool nodesIsTimeorderQuery(const SNode* pQuery) { return false; }
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool nodesIsTimelineQuery(const SNode* pQuery) {
|
bool nodesIsTimelineQuery(const SNode* pQuery) { return false; }
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct SCollectColumnsCxt {
|
typedef struct SCollectColumnsCxt {
|
||||||
int32_t errCode;
|
int32_t errCode;
|
||||||
|
@ -1089,8 +1084,7 @@ int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char*
|
||||||
.errCode = TSDB_CODE_SUCCESS,
|
.errCode = TSDB_CODE_SUCCESS,
|
||||||
.pTableAlias = pTableAlias,
|
.pTableAlias = pTableAlias,
|
||||||
.pCols = nodesMakeList(),
|
.pCols = nodesMakeList(),
|
||||||
.pColHash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK)
|
.pColHash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK)};
|
||||||
};
|
|
||||||
if (NULL == cxt.pCols || NULL == cxt.pColHash) {
|
if (NULL == cxt.pCols || NULL == cxt.pColHash) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1129,11 +1123,7 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCollectFuncsCxt cxt = {
|
SCollectFuncsCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .classifier = classifier, .pFuncs = nodesMakeList()};
|
||||||
.errCode = TSDB_CODE_SUCCESS,
|
|
||||||
.classifier = classifier,
|
|
||||||
.pFuncs = nodesMakeList()
|
|
||||||
};
|
|
||||||
if (NULL == cxt.pFuncs) {
|
if (NULL == cxt.pFuncs) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1152,8 +1142,7 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* getFillModeString(EFillMode mode) {
|
||||||
char *getFillModeString(EFillMode mode) {
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case FILL_MODE_NONE:
|
case FILL_MODE_NONE:
|
||||||
return "none";
|
return "none";
|
||||||
|
@ -1172,12 +1161,12 @@ char *getFillModeString(EFillMode mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *nodesGetNameFromColumnNode(SNode *pNode) {
|
char* nodesGetNameFromColumnNode(SNode* pNode) {
|
||||||
if (NULL == pNode || QUERY_NODE_COLUMN != pNode->type) {
|
if (NULL == pNode || QUERY_NODE_COLUMN != pNode->type) {
|
||||||
return "NULL";
|
return "NULL";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((SColumnNode *)pNode)->colName;
|
return ((SColumnNode*)pNode)->colName;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots) {
|
int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots) {
|
||||||
|
@ -1192,7 +1181,7 @@ int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSlotDescNode *descNode = (SSlotDescNode *)pNode;
|
SSlotDescNode* descNode = (SSlotDescNode*)pNode;
|
||||||
if (descNode->output) {
|
if (descNode->output) {
|
||||||
++num;
|
++num;
|
||||||
}
|
}
|
||||||
|
@ -1201,7 +1190,6 @@ int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots) {
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
||||||
pVal->nType = pNode->node.resType.type;
|
pVal->nType = pNode->node.resType.type;
|
||||||
pVal->nLen = pNode->node.resType.bytes;
|
pVal->nLen = pNode->node.resType.bytes;
|
||||||
|
@ -1241,6 +1229,3 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "cmdnodes.h"
|
#include "cmdnodes.h"
|
||||||
#include "parser.h"
|
|
||||||
#include "parToken.h"
|
#include "parToken.h"
|
||||||
#include "parUtil.h"
|
#include "parUtil.h"
|
||||||
|
#include "parser.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
|
|
||||||
typedef struct SAstCreateContext {
|
typedef struct SAstCreateContext {
|
||||||
|
@ -105,7 +105,8 @@ SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const STok
|
||||||
SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order, ENullOrder nullOrder);
|
SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order, ENullOrder nullOrder);
|
||||||
SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap);
|
SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap);
|
||||||
SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr);
|
SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr);
|
||||||
SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding, SNode* pFill);
|
SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding,
|
||||||
|
SNode* pFill);
|
||||||
SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues);
|
SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues);
|
||||||
SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode);
|
SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode);
|
||||||
|
|
||||||
|
@ -130,16 +131,20 @@ SNode* setTableAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOptio
|
||||||
SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment);
|
SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment);
|
||||||
SDataType createDataType(uint8_t type);
|
SDataType createDataType(uint8_t type);
|
||||||
SDataType createVarLenDataType(uint8_t type, const SToken* pLen);
|
SDataType createVarLenDataType(uint8_t type, const SToken* pLen);
|
||||||
SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions);
|
SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols,
|
||||||
SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable, SNodeList* pSpecificTags, SNodeList* pValsOfTags);
|
SNodeList* pTags, SNode* pOptions);
|
||||||
|
SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable,
|
||||||
|
SNodeList* pSpecificTags, SNodeList* pValsOfTags);
|
||||||
SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables);
|
SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables);
|
||||||
SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable);
|
SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable);
|
||||||
SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables);
|
SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables);
|
||||||
SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable);
|
SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable);
|
||||||
SNode* createAlterTableOption(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions);
|
SNode* createAlterTableOption(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions);
|
||||||
SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName, SDataType dataType);
|
SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
||||||
|
const SToken* pColName, SDataType dataType);
|
||||||
SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName);
|
SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName);
|
||||||
SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pOldColName, const SToken* pNewColName);
|
SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
||||||
|
const SToken* pOldColName, const SToken* pNewColName);
|
||||||
SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const SToken* pTagName, SNode* pVal);
|
SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const SToken* pTagName, SNode* pVal);
|
||||||
SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
||||||
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern);
|
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern);
|
||||||
|
@ -151,13 +156,15 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
|
||||||
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
|
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
|
||||||
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode);
|
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode);
|
||||||
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
||||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName, SToken* pTableName, SNodeList* pCols, SNode* pOptions);
|
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName,
|
||||||
|
SToken* pTableName, SNodeList* pCols, SNode* pOptions);
|
||||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding);
|
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding);
|
||||||
SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName, SToken* pTableName);
|
SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName, SToken* pTableName);
|
||||||
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
||||||
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId);
|
||||||
SNode* createTopicOptions(SAstCreateContext* pCxt);
|
SNode* createTopicOptions(SAstCreateContext* pCxt);
|
||||||
SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName, SNode* pOptions);
|
SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery,
|
||||||
|
const SToken* pSubscribeDbName, SNode* pOptions);
|
||||||
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName);
|
SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName);
|
||||||
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue);
|
SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue);
|
||||||
SNode* createDefaultExplainOptions(SAstCreateContext* pCxt);
|
SNode* createDefaultExplainOptions(SAstCreateContext* pCxt);
|
||||||
|
@ -167,10 +174,12 @@ SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions,
|
||||||
SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable);
|
SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable);
|
||||||
SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt);
|
SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt);
|
||||||
SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups);
|
SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups);
|
||||||
SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName, const SToken* pLibPath, SDataType dataType, int32_t bufSize);
|
SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName,
|
||||||
|
const SToken* pLibPath, SDataType dataType, int32_t bufSize);
|
||||||
SNode* createDropFunctionStmt(SAstCreateContext* pCxt, const SToken* pFuncName);
|
SNode* createDropFunctionStmt(SAstCreateContext* pCxt, const SToken* pFuncName);
|
||||||
SNode* createStreamOptions(SAstCreateContext* pCxt);
|
SNode* createStreamOptions(SAstCreateContext* pCxt);
|
||||||
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, SNode* pOptions, SNode* pQuery);
|
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable,
|
||||||
|
SNode* pOptions, SNode* pQuery);
|
||||||
SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName);
|
SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName);
|
||||||
SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId);
|
SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId);
|
||||||
SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2);
|
SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2);
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "ttypes.h"
|
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
|
#include "ttypes.h"
|
||||||
|
|
||||||
#define IS_DATA_COL_ORDERED(spd) ((spd->orderStatus) == (int8_t)ORDER_STATUS_ORDERED)
|
#define IS_DATA_COL_ORDERED(spd) ((spd->orderStatus) == (int8_t)ORDER_STATUS_ORDERED)
|
||||||
|
|
||||||
|
@ -74,7 +74,8 @@ typedef struct STableDataBlocks {
|
||||||
uint32_t nAllocSize;
|
uint32_t nAllocSize;
|
||||||
uint32_t headerSize; // header for table info (uid, tid, submit metadata)
|
uint32_t headerSize; // header for table info (uid, tid, submit metadata)
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
STableMeta *pTableMeta; // the tableMeta of current table, the table meta will be used during submit, keep a ref to avoid to be removed from cache
|
STableMeta *pTableMeta; // the tableMeta of current table, the table meta will be used during submit, keep a ref to
|
||||||
|
// avoid to be removed from cache
|
||||||
char *pData;
|
char *pData;
|
||||||
bool cloned;
|
bool cloned;
|
||||||
int32_t createTbReqLen;
|
int32_t createTbReqLen;
|
||||||
|
@ -89,8 +90,8 @@ static FORCE_INLINE int32_t getExtendedRowSize(STableDataBlocks *pBlock) {
|
||||||
(int32_t)TD_BITMAP_BYTES(pTableInfo->numOfColumns - 1);
|
(int32_t)TD_BITMAP_BYTES(pTableInfo->numOfColumns - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void getSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo *spd, col_id_t idx,
|
static FORCE_INLINE void getSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo *spd, col_id_t idx, int32_t *toffset,
|
||||||
int32_t *toffset, col_id_t *colIdx) {
|
col_id_t *colIdx) {
|
||||||
col_id_t schemaIdx = 0;
|
col_id_t schemaIdx = 0;
|
||||||
if (IS_DATA_COL_ORDERED(spd)) {
|
if (IS_DATA_COL_ORDERED(spd)) {
|
||||||
schemaIdx = spd->boundColumns[idx] - PRIMARYKEY_TIMESTAMP_COL_ID;
|
schemaIdx = spd->boundColumns[idx] - PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||||
|
@ -114,8 +115,9 @@ static FORCE_INLINE void getSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t setBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks* dataBuf, int32_t numOfRows) {
|
static FORCE_INLINE int32_t setBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks *dataBuf, int32_t numOfRows) {
|
||||||
pBlocks->suid = (TSDB_NORMAL_TABLE == dataBuf->pTableMeta->tableType ? dataBuf->pTableMeta->uid : dataBuf->pTableMeta->suid);
|
pBlocks->suid =
|
||||||
|
(TSDB_NORMAL_TABLE == dataBuf->pTableMeta->tableType ? dataBuf->pTableMeta->uid : dataBuf->pTableMeta->suid);
|
||||||
pBlocks->uid = dataBuf->pTableMeta->uid;
|
pBlocks->uid = dataBuf->pTableMeta->uid;
|
||||||
pBlocks->sversion = dataBuf->pTableMeta->sversion;
|
pBlocks->sversion = dataBuf->pTableMeta->sversion;
|
||||||
pBlocks->schemaLen = dataBuf->createTbReqLen;
|
pBlocks->schemaLen = dataBuf->createTbReqLen;
|
||||||
|
@ -131,14 +133,15 @@ static FORCE_INLINE int32_t setBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks*
|
||||||
int32_t schemaIdxCompar(const void *lhs, const void *rhs);
|
int32_t schemaIdxCompar(const void *lhs, const void *rhs);
|
||||||
int32_t boundIdxCompar(const void *lhs, const void *rhs);
|
int32_t boundIdxCompar(const void *lhs, const void *rhs);
|
||||||
void setBoundColumnInfo(SParsedDataColInfo *pColList, SSchema *pSchema, col_id_t numOfCols);
|
void setBoundColumnInfo(SParsedDataColInfo *pColList, SSchema *pSchema, col_id_t numOfCols);
|
||||||
void destroyBlockArrayList(SArray* pDataBlockList);
|
void destroyBlockArrayList(SArray *pDataBlockList);
|
||||||
void destroyBlockHashmap(SHashObj* pDataBlockHash);
|
void destroyBlockHashmap(SHashObj *pDataBlockHash);
|
||||||
int initRowBuilder(SRowBuilder *pBuilder, int16_t schemaVer, SParsedDataColInfo *pColInfo);
|
int initRowBuilder(SRowBuilder *pBuilder, int16_t schemaVer, SParsedDataColInfo *pColInfo);
|
||||||
int32_t allocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t * numOfRows);
|
int32_t allocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t *numOfRows);
|
||||||
int32_t getDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize,
|
int32_t getDataBlockFromList(SHashObj *pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize,
|
||||||
const STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList, SVCreateTbReq* pCreateTbReq);
|
const STableMeta *pTableMeta, STableDataBlocks **dataBlocks, SArray *pBlockList,
|
||||||
int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** pVgDataBlocks);
|
SVCreateTbReq *pCreateTbReq);
|
||||||
int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq);
|
int32_t mergeTableDataBlocks(SHashObj *pHashObj, uint8_t payloadType, SArray **pVgDataBlocks);
|
||||||
|
int32_t buildCreateTbMsg(STableDataBlocks *pBlocks, SVCreateTbReq *pCreateTbReq);
|
||||||
int32_t allocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize);
|
int32_t allocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize);
|
||||||
|
|
||||||
#endif // TDENGINE_DATABLOCKMGT_H
|
#endif // TDENGINE_DATABLOCKMGT_H
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "parser.h"
|
|
||||||
#include "parToken.h"
|
#include "parToken.h"
|
||||||
#include "parUtil.h"
|
#include "parUtil.h"
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery);
|
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery);
|
||||||
int32_t parse(SParseContext* pParseCxt, SQuery** pQuery);
|
int32_t parse(SParseContext* pParseCxt, SQuery** pQuery);
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#include "ttokendef.h"
|
#include "ttokendef.h"
|
||||||
|
|
||||||
// used to denote the minimum unite in sql parsing
|
// used to denote the minimum unite in sql parsing
|
||||||
|
@ -35,7 +37,7 @@ typedef struct SToken {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
#define isNumber(tk) \
|
#define isNumber(tk) \
|
||||||
((tk)->type == TK_NK_INTEGER || (tk)->type == TK_NK_FLOAT || (tk)->type == TK_NK_HEX || (tk)->type == TK_NK_BIN)
|
((tk)->type == TK_NK_INTEGER || (tk)->type == TK_NK_FLOAT || (tk)->type == TK_NK_HEX || (tk)->type == TK_NK_BIN)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tokenizer for sql string
|
* tokenizer for sql string
|
||||||
|
@ -68,12 +70,12 @@ bool taosIsKeyWordToken(const char *z, int32_t len);
|
||||||
* @param pToken
|
* @param pToken
|
||||||
* @return token type, if it is not a number, TK_NK_ILLEGAL will return
|
* @return token type, if it is not a number, TK_NK_ILLEGAL will return
|
||||||
*/
|
*/
|
||||||
static FORCE_INLINE int32_t tGetNumericStringType(const SToken* pToken) {
|
static FORCE_INLINE int32_t tGetNumericStringType(const SToken *pToken) {
|
||||||
const char* z = pToken->z;
|
const char *z = pToken->z;
|
||||||
int32_t type = TK_NK_ILLEGAL;
|
int32_t type = TK_NK_ILLEGAL;
|
||||||
|
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
for(; i < pToken->n; ++i) {
|
for (; i < pToken->n; ++i) {
|
||||||
switch (z[i]) {
|
switch (z[i]) {
|
||||||
case '+':
|
case '+':
|
||||||
case '-': {
|
case '-': {
|
||||||
|
@ -86,7 +88,7 @@ static FORCE_INLINE int32_t tGetNumericStringType(const SToken* pToken) {
|
||||||
* .123
|
* .123
|
||||||
* .123e4
|
* .123e4
|
||||||
*/
|
*/
|
||||||
if (!isdigit(z[i+1])) {
|
if (!isdigit(z[i + 1])) {
|
||||||
return TK_NK_ILLEGAL;
|
return TK_NK_ILLEGAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +115,7 @@ static FORCE_INLINE int32_t tGetNumericStringType(const SToken* pToken) {
|
||||||
}
|
}
|
||||||
|
|
||||||
goto _end;
|
goto _end;
|
||||||
} else if (next == 'x') { //hex number
|
} else if (next == 'x') { // hex number
|
||||||
type = TK_NK_HEX;
|
type = TK_NK_HEX;
|
||||||
for (i += 2; isdigit(z[i]) || (z[i] >= 'a' && z[i] <= 'f') || (z[i] >= 'A' && z[i] <= 'F'); ++i) {
|
for (i += 2; isdigit(z[i]) || (z[i] >= 'a' && z[i] <= 'f') || (z[i] >= 'A' && z[i] <= 'F'); ++i) {
|
||||||
}
|
}
|
||||||
|
@ -167,15 +169,15 @@ static FORCE_INLINE int32_t tGetNumericStringType(const SToken* pToken) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
return (i < pToken->n)? TK_NK_ILLEGAL:type;
|
return (i < pToken->n) ? TK_NK_ILLEGAL : type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosCleanupKeywordsTable();
|
void taosCleanupKeywordsTable();
|
||||||
|
|
||||||
SToken tscReplaceStrToken(char **str, SToken *token, const char* newToken);
|
SToken tscReplaceStrToken(char **str, SToken *token, const char *newToken);
|
||||||
|
|
||||||
SToken taosTokenDup(SToken* pToken, char* buf, int32_t len);
|
SToken taosTokenDup(SToken *pToken, char *buf, int32_t len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct SMsgBuf {
|
typedef struct SMsgBuf {
|
||||||
int32_t len;
|
int32_t len;
|
||||||
char *buf;
|
char* buf;
|
||||||
} SMsgBuf;
|
} SMsgBuf;
|
||||||
|
|
||||||
int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...);
|
int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...);
|
||||||
|
@ -42,8 +42,8 @@ int32_t buildInvalidOperationMsg(SMsgBuf* pMsgBuf, const char* msg);
|
||||||
int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo, const char* sourceStr);
|
int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo, const char* sourceStr);
|
||||||
|
|
||||||
STableMeta* tableMetaDup(const STableMeta* pTableMeta);
|
STableMeta* tableMetaDup(const STableMeta* pTableMeta);
|
||||||
SSchema *getTableColumnSchema(const STableMeta *pTableMeta);
|
SSchema* getTableColumnSchema(const STableMeta* pTableMeta);
|
||||||
SSchema *getTableTagSchema(const STableMeta* pTableMeta);
|
SSchema* getTableTagSchema(const STableMeta* pTableMeta);
|
||||||
int32_t getNumOfColumns(const STableMeta* pTableMeta);
|
int32_t getNumOfColumns(const STableMeta* pTableMeta);
|
||||||
int32_t getNumOfTags(const STableMeta* pTableMeta);
|
int32_t getNumOfTags(const STableMeta* pTableMeta);
|
||||||
STableComInfo getTableInfo(const STableMeta* pTableMeta);
|
STableComInfo getTableInfo(const STableMeta* pTableMeta);
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
SToken nil_token = { .type = TK_NK_NIL, .n = 0, .z = NULL };
|
SToken nil_token = {.type = TK_NK_NIL, .n = 0, .z = NULL};
|
||||||
|
|
||||||
void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
|
void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
|
||||||
pCxt->pQueryCxt = pParseCxt;
|
pCxt->pQueryCxt = pParseCxt;
|
||||||
|
@ -222,7 +222,7 @@ SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
|
||||||
return nil_token;
|
return nil_token;
|
||||||
}
|
}
|
||||||
SRawExprNode* target = (SRawExprNode*)pNode;
|
SRawExprNode* target = (SRawExprNode*)pNode;
|
||||||
SToken t = { .type = 0, .z = target->p, .n = target->n};
|
SToken t = {.type = 0, .z = target->p, .n = target->n};
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,12 +352,13 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
|
||||||
|
|
||||||
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) {
|
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) {
|
||||||
return createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND,
|
return createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND,
|
||||||
createOperatorNode(pCxt, OP_TYPE_GREATER_EQUAL, pExpr, pLeft), createOperatorNode(pCxt, OP_TYPE_LOWER_EQUAL, nodesCloneNode(pExpr), pRight));
|
createOperatorNode(pCxt, OP_TYPE_GREATER_EQUAL, pExpr, pLeft),
|
||||||
|
createOperatorNode(pCxt, OP_TYPE_LOWER_EQUAL, nodesCloneNode(pExpr), pRight));
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) {
|
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) {
|
||||||
return createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR,
|
return createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, createOperatorNode(pCxt, OP_TYPE_LOWER_THAN, pExpr, pLeft),
|
||||||
createOperatorNode(pCxt, OP_TYPE_LOWER_THAN, pExpr, pLeft), createOperatorNode(pCxt, OP_TYPE_GREATER_THAN, nodesCloneNode(pExpr), pRight));
|
createOperatorNode(pCxt, OP_TYPE_GREATER_THAN, nodesCloneNode(pExpr), pRight));
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList) {
|
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList) {
|
||||||
|
@ -483,7 +484,8 @@ SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) {
|
||||||
return (SNode*)state;
|
return (SNode*)state;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding, SNode* pFill) {
|
SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding,
|
||||||
|
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 = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||||
|
@ -749,17 +751,17 @@ SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataType createDataType(uint8_t type) {
|
SDataType createDataType(uint8_t type) {
|
||||||
SDataType dt = { .type = type, .precision = 0, .scale = 0, .bytes = tDataTypes[type].bytes };
|
SDataType dt = {.type = type, .precision = 0, .scale = 0, .bytes = tDataTypes[type].bytes};
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
|
||||||
SDataType dt = { .type = type, .precision = 0, .scale = 0, .bytes = strtol(pLen->z, NULL, 10) };
|
SDataType dt = {.type = type, .precision = 0, .scale = 0, .bytes = strtol(pLen->z, NULL, 10)};
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateTableStmt(SAstCreateContext* pCxt,
|
SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols,
|
||||||
bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions) {
|
SNodeList* pTags, SNode* pOptions) {
|
||||||
if (NULL == pRealTable) {
|
if (NULL == pRealTable) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -775,8 +777,8 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt,
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateSubTableClause(SAstCreateContext* pCxt,
|
SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable,
|
||||||
bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable, SNodeList* pSpecificTags, SNodeList* pValsOfTags) {
|
SNodeList* pSpecificTags, SNodeList* pValsOfTags) {
|
||||||
if (NULL == pRealTable) {
|
if (NULL == pRealTable) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -842,7 +844,8 @@ SNode* createAlterTableOption(SAstCreateContext* pCxt, SNode* pRealTable, SNode*
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName, SDataType dataType) {
|
SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
||||||
|
const SToken* pColName, SDataType dataType) {
|
||||||
if (NULL == pRealTable) {
|
if (NULL == pRealTable) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -865,7 +868,8 @@ SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pOldColName, const SToken* pNewColName) {
|
SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
||||||
|
const SToken* pOldColName, const SToken* pNewColName) {
|
||||||
if (NULL == pRealTable) {
|
if (NULL == pRealTable) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -900,7 +904,8 @@ SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool needDbShowStmt(ENodeType type) {
|
static bool needDbShowStmt(ENodeType type) {
|
||||||
return QUERY_NODE_SHOW_TABLES_STMT == type || QUERY_NODE_SHOW_STABLES_STMT == type || QUERY_NODE_SHOW_VGROUPS_STMT == type;
|
return QUERY_NODE_SHOW_TABLES_STMT == type || QUERY_NODE_SHOW_STABLES_STMT == type ||
|
||||||
|
QUERY_NODE_SHOW_VGROUPS_STMT == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern) {
|
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern) {
|
||||||
|
@ -909,7 +914,8 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S
|
||||||
pCxt->valid = false;
|
pCxt->valid = false;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SShowStmt* pStmt = nodesMakeNode(type);;
|
SShowStmt* pStmt = nodesMakeNode(type);
|
||||||
|
;
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->pDbName = pDbName;
|
pStmt->pDbName = pDbName;
|
||||||
pStmt->pTbNamePattern = pTbNamePattern;
|
pStmt->pTbNamePattern = pTbNamePattern;
|
||||||
|
@ -1004,7 +1010,8 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) {
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue) {
|
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig,
|
||||||
|
const SToken* pValue) {
|
||||||
SAlterDnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT);
|
SAlterDnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->dnodeId = strtol(pDnode->z, NULL, 10);
|
pStmt->dnodeId = strtol(pDnode->z, NULL, 10);
|
||||||
|
@ -1015,7 +1022,8 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName, SToken* pTableName, SNodeList* pCols, SNode* pOptions) {
|
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName,
|
||||||
|
SToken* pTableName, SNodeList* pCols, SNode* pOptions) {
|
||||||
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) {
|
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1038,8 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding) {
|
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset,
|
||||||
|
SNode* pSliding) {
|
||||||
SIndexOptions* pOptions = nodesMakeNode(QUERY_NODE_INDEX_OPTIONS);
|
SIndexOptions* pOptions = nodesMakeNode(QUERY_NODE_INDEX_OPTIONS);
|
||||||
CHECK_OUT_OF_MEM(pOptions);
|
CHECK_OUT_OF_MEM(pOptions);
|
||||||
pOptions->pFuncs = pFuncs;
|
pOptions->pFuncs = pFuncs;
|
||||||
|
@ -1055,14 +1064,16 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken
|
||||||
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
|
SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
|
||||||
SCreateComponentNodeStmt* pStmt = nodesMakeNode(type);
|
SCreateComponentNodeStmt* pStmt = nodesMakeNode(type);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);;
|
pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);
|
||||||
|
;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
|
SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) {
|
||||||
SDropComponentNodeStmt* pStmt = nodesMakeNode(type);
|
SDropComponentNodeStmt* pStmt = nodesMakeNode(type);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);;
|
pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);
|
||||||
|
;
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1075,8 +1086,8 @@ SNode* createTopicOptions(SAstCreateContext* pCxt) {
|
||||||
return (SNode*)pOptions;
|
return (SNode*)pOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateTopicStmt(SAstCreateContext* pCxt,
|
SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery,
|
||||||
bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName, SNode* pOptions) {
|
const SToken* pSubscribeDbName, SNode* pOptions) {
|
||||||
SCreateTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
SCreateTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->topicName, pTopicName->z, pTopicName->n);
|
strncpy(pStmt->topicName, pTopicName->z, pTopicName->n);
|
||||||
|
@ -1158,8 +1169,8 @@ SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups) {
|
||||||
return pStmt;
|
return pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateFunctionStmt(SAstCreateContext* pCxt,
|
SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName,
|
||||||
bool ignoreExists, bool aggFunc, const SToken* pFuncName, const SToken* pLibPath, SDataType dataType, int32_t bufSize) {
|
const SToken* pLibPath, SDataType dataType, int32_t bufSize) {
|
||||||
if (pLibPath->n <= 2) {
|
if (pLibPath->n <= 2) {
|
||||||
pCxt->valid = false;
|
pCxt->valid = false;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1188,7 +1199,8 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) {
|
||||||
return (SNode*)pOptions;
|
return (SNode*)pOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, SNode* pOptions, SNode* pQuery) {
|
SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable,
|
||||||
|
SNode* pOptions, SNode* pQuery) {
|
||||||
SCreateStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT);
|
SCreateStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
strncpy(pStmt->streamName, pStreamName->z, pStreamName->n);
|
strncpy(pStmt->streamName, pStreamName->z, pStreamName->n);
|
||||||
|
|
|
@ -30,7 +30,7 @@ extern void ParseTrace(FILE*, char*);
|
||||||
int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
|
int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
|
||||||
SAstCreateContext cxt;
|
SAstCreateContext cxt;
|
||||||
initAstCreateContext(pParseCxt, &cxt);
|
initAstCreateContext(pParseCxt, &cxt);
|
||||||
void *pParser = ParseAlloc((FMalloc)taosMemoryMalloc);
|
void* pParser = ParseAlloc((FMalloc)taosMemoryMalloc);
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
SToken t0 = {0};
|
SToken t0 = {0};
|
||||||
|
@ -38,8 +38,8 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
|
||||||
Parse(pParser, 0, t0, &cxt);
|
Parse(pParser, 0, t0, &cxt);
|
||||||
goto abort_parse;
|
goto abort_parse;
|
||||||
}
|
}
|
||||||
t0.n = tGetToken((char *)&cxt.pQueryCxt->pSql[i], &t0.type);
|
t0.n = tGetToken((char*)&cxt.pQueryCxt->pSql[i], &t0.type);
|
||||||
t0.z = (char *)(cxt.pQueryCxt->pSql + i);
|
t0.z = (char*)(cxt.pQueryCxt->pSql + i);
|
||||||
i += t0.n;
|
i += t0.n;
|
||||||
|
|
||||||
switch (t0.type) {
|
switch (t0.type) {
|
||||||
|
|
|
@ -281,12 +281,10 @@ static bool isEmptyResultQuery(SNode* pStmt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery) {
|
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery) {
|
||||||
SCalcConstContext cxt = {
|
SCalcConstContext cxt = {.pParseCxt = pParseCxt,
|
||||||
.pParseCxt = pParseCxt,
|
|
||||||
.msgBuf.buf = pParseCxt->pMsg,
|
.msgBuf.buf = pParseCxt->pMsg,
|
||||||
.msgBuf.len = pParseCxt->msgLen,
|
.msgBuf.len = pParseCxt->msgLen,
|
||||||
.code = TSDB_CODE_SUCCESS
|
.code = TSDB_CODE_SUCCESS};
|
||||||
};
|
|
||||||
int32_t code = calcConstQuery(&cxt, pQuery->pRoot, false);
|
int32_t code = calcConstQuery(&cxt, pQuery->pRoot, false);
|
||||||
if (TSDB_CODE_SUCCESS == code && isEmptyResultQuery(pQuery->pRoot)) {
|
if (TSDB_CODE_SUCCESS == code && isEmptyResultQuery(pQuery->pRoot)) {
|
||||||
pQuery->execMode = QUERY_EXEC_MODE_EMPTY_RESULT;
|
pQuery->execMode = QUERY_EXEC_MODE_EMPTY_RESULT;
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
typedef struct SInsertParseContext {
|
typedef struct SInsertParseContext {
|
||||||
SParseContext* pComCxt; // input
|
SParseContext* pComCxt; // input
|
||||||
char *pSql; // input
|
char* pSql; // input
|
||||||
SMsgBuf msg; // input
|
SMsgBuf msg; // input
|
||||||
STableMeta* pTableMeta; // each table
|
STableMeta* pTableMeta; // each table
|
||||||
SParsedDataColInfo tags; // each table
|
SParsedDataColInfo tags; // each table
|
||||||
|
@ -64,8 +64,8 @@ static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE;
|
||||||
static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE;
|
static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE;
|
||||||
|
|
||||||
typedef struct SKvParam {
|
typedef struct SKvParam {
|
||||||
SKVRowBuilder *builder;
|
SKVRowBuilder* builder;
|
||||||
SSchema *schema;
|
SSchema* schema;
|
||||||
char buf[TSDB_MAX_TAGS_LEN];
|
char buf[TSDB_MAX_TAGS_LEN];
|
||||||
} SKvParam;
|
} SKvParam;
|
||||||
|
|
||||||
|
@ -76,7 +76,6 @@ typedef struct SMemParam {
|
||||||
col_id_t colIdx;
|
col_id_t colIdx;
|
||||||
} SMemParam;
|
} SMemParam;
|
||||||
|
|
||||||
|
|
||||||
#define CHECK_CODE(expr) \
|
#define CHECK_CODE(expr) \
|
||||||
do { \
|
do { \
|
||||||
int32_t code = expr; \
|
int32_t code = expr; \
|
||||||
|
@ -85,7 +84,6 @@ typedef struct SMemParam {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
static int32_t skipInsertInto(SInsertParseContext* pCxt) {
|
static int32_t skipInsertInto(SInsertParseContext* pCxt) {
|
||||||
SToken sToken;
|
SToken sToken;
|
||||||
NEXT_TOKEN(pCxt->pSql, sToken);
|
NEXT_TOKEN(pCxt->pSql, sToken);
|
||||||
|
@ -179,7 +177,6 @@ static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullD
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, const char* dbName, SMsgBuf* pMsgBuf) {
|
static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, const char* dbName, SMsgBuf* pMsgBuf) {
|
||||||
const char* msg1 = "name too long";
|
const char* msg1 = "name too long";
|
||||||
const char* msg2 = "invalid database name";
|
const char* msg2 = "invalid database name";
|
||||||
|
@ -316,7 +313,7 @@ static int32_t buildOutput(SInsertParseContext* pCxt) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t checkTimestamp(STableDataBlocks *pDataBlocks, const char *start) {
|
int32_t checkTimestamp(STableDataBlocks* pDataBlocks, const char* start) {
|
||||||
// once the data block is disordered, we do NOT keep previous timestamp any more
|
// once the data block is disordered, we do NOT keep previous timestamp any more
|
||||||
if (!pDataBlocks->ordered) {
|
if (!pDataBlocks->ordered) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -601,7 +598,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_DATA_TYPE_JSON: {
|
case TSDB_DATA_TYPE_JSON: {
|
||||||
if(pToken->n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE){
|
if (pToken->n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "json string too long than 4095", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "json string too long than 4095", pToken->z);
|
||||||
}
|
}
|
||||||
return func(pMsgBuf, pToken->z, pToken->n, param);
|
return func(pMsgBuf, pToken->z, pToken->n, param);
|
||||||
|
@ -720,7 +717,7 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
@ -728,18 +725,19 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void *value, int32_t len, void *param) {
|
static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param) {
|
||||||
SKvParam* pa = (SKvParam*) param;
|
SKvParam* pa = (SKvParam*)param;
|
||||||
|
|
||||||
int8_t type = pa->schema->type;
|
int8_t type = pa->schema->type;
|
||||||
int16_t colId = pa->schema->colId;
|
int16_t colId = pa->schema->colId;
|
||||||
|
|
||||||
if(TSDB_DATA_TYPE_JSON == type){
|
if (TSDB_DATA_TYPE_JSON == type) {
|
||||||
return parseJsontoTagData(value, pa->builder, pMsgBuf, colId);
|
return parseJsontoTagData(value, pa->builder, pMsgBuf, colId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == NULL) { // it is a null data
|
if (value == NULL) { // it is a null data
|
||||||
// tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NULL, value, false, pa->toffset, pa->colIdx);
|
// tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NULL, value, false, pa->toffset,
|
||||||
|
// pa->colIdx);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,7 +762,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 SName* pName, SKVRow row, int64_t suid) {
|
static int32_t buildCreateTbReq(SVCreateTbReq* pTbReq, const SName* pName, SKVRow row, int64_t suid) {
|
||||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||||
tNameGetFullDbName(pName, dbFName);
|
tNameGetFullDbName(pName, dbFName);
|
||||||
pTbReq->type = TD_CHILD_TABLE;
|
pTbReq->type = TD_CHILD_TABLE;
|
||||||
|
@ -886,7 +884,8 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, int16_t timePrec, bool* gotRow, char* tmpTokenBuf) {
|
static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, int16_t timePrec, bool* gotRow,
|
||||||
|
char* tmpTokenBuf) {
|
||||||
SParsedDataColInfo* spd = &pDataBlocks->boundColumnInfo;
|
SParsedDataColInfo* spd = &pDataBlocks->boundColumnInfo;
|
||||||
SRowBuilder* pBuilder = &pDataBlocks->rowBuilder;
|
SRowBuilder* pBuilder = &pDataBlocks->rowBuilder;
|
||||||
STSRow* row = (STSRow*)(pDataBlocks->pData + pDataBlocks->size); // skip the SSubmitBlk header
|
STSRow* row = (STSRow*)(pDataBlocks->pData + pDataBlocks->size); // skip the SSubmitBlk header
|
||||||
|
@ -970,7 +969,7 @@ static int32_t parseValues(SInsertParseContext* pCxt, STableDataBlocks* pDataBlo
|
||||||
bool gotRow = false;
|
bool gotRow = false;
|
||||||
CHECK_CODE(parseOneRow(pCxt, pDataBlock, tinfo.precision, &gotRow, tmpTokenBuf));
|
CHECK_CODE(parseOneRow(pCxt, pDataBlock, tinfo.precision, &gotRow, tmpTokenBuf));
|
||||||
if (gotRow) {
|
if (gotRow) {
|
||||||
pDataBlock->size += extendedRowSize; //len;
|
pDataBlock->size += extendedRowSize; // len;
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXT_TOKEN(pCxt->pSql, sToken);
|
NEXT_TOKEN(pCxt->pSql, sToken);
|
||||||
|
@ -1054,7 +1053,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
// for each table
|
// for each table
|
||||||
while (1) {
|
while (1) {
|
||||||
SToken sToken;
|
SToken sToken;
|
||||||
char *tbName = NULL;
|
char* tbName = NULL;
|
||||||
|
|
||||||
// pSql -> tb_name ...
|
// pSql -> tb_name ...
|
||||||
NEXT_TOKEN(pCxt->pSql, sToken);
|
NEXT_TOKEN(pCxt->pSql, sToken);
|
||||||
|
@ -1068,7 +1067,8 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_QUERY_HAS_TYPE(pCxt->pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT) && tbNum > 0) {
|
if (TSDB_QUERY_HAS_TYPE(pCxt->pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT) && tbNum > 0) {
|
||||||
return buildInvalidOperationMsg(&pCxt->msg, "single table allowed in one stmt");;
|
return buildInvalidOperationMsg(&pCxt->msg, "single table allowed in one stmt");
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyInsertParseContextForTable(pCxt);
|
destroyInsertParseContextForTable(pCxt);
|
||||||
|
@ -1133,7 +1133,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_QUERY_HAS_TYPE(pCxt->pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT)) {
|
if (TSDB_QUERY_HAS_TYPE(pCxt->pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT)) {
|
||||||
SParsedDataColInfo *tags = taosMemoryMalloc(sizeof(pCxt->tags));
|
SParsedDataColInfo* tags = taosMemoryMalloc(sizeof(pCxt->tags));
|
||||||
if (NULL == tags) {
|
if (NULL == tags) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1164,24 +1164,24 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
|
int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
|
||||||
SInsertParseContext context = {
|
SInsertParseContext context = {
|
||||||
.pComCxt = pContext,
|
.pComCxt = pContext,
|
||||||
.pSql = (char*) pContext->pSql,
|
.pSql = (char*)pContext->pSql,
|
||||||
.msg = {.buf = pContext->pMsg, .len = pContext->msgLen},
|
.msg = {.buf = pContext->pMsg, .len = pContext->msgLen},
|
||||||
.pTableMeta = NULL,
|
.pTableMeta = NULL,
|
||||||
.pSubTableHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, false),
|
.pSubTableHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, false),
|
||||||
.totalNum = 0,
|
.totalNum = 0,
|
||||||
.pOutput = (SVnodeModifOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT),
|
.pOutput = (SVnodeModifOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIF_STMT),
|
||||||
.pStmtCb = pContext->pStmtCb
|
.pStmtCb = pContext->pStmtCb};
|
||||||
};
|
|
||||||
|
|
||||||
if (pContext->pStmtCb && *pQuery) {
|
if (pContext->pStmtCb && *pQuery) {
|
||||||
(*pContext->pStmtCb->getExecInfoFn)(pContext->pStmtCb->pStmt, &context.pVgroupsHashObj, &context.pTableBlockHashObj);
|
(*pContext->pStmtCb->getExecInfoFn)(pContext->pStmtCb->pStmt, &context.pVgroupsHashObj,
|
||||||
|
&context.pTableBlockHashObj);
|
||||||
} else {
|
} else {
|
||||||
context.pVgroupsHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, false);
|
context.pVgroupsHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, false);
|
||||||
context.pTableBlockHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
|
context.pTableBlockHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == context.pVgroupsHashObj || NULL == context.pTableBlockHashObj ||
|
if (NULL == context.pVgroupsHashObj || NULL == context.pTableBlockHashObj || NULL == context.pSubTableHashObj ||
|
||||||
NULL == context.pSubTableHashObj || NULL == context.pOutput) {
|
NULL == context.pOutput) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1210,12 +1210,12 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf,
|
||||||
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char *msgBuf, int32_t msgBufLen) {
|
int32_t msgBufLen) {
|
||||||
SMsgBuf msg = {.buf = msgBuf, .len =msgBufLen};
|
SMsgBuf msg = {.buf = msgBuf, .len = msgBufLen};
|
||||||
SToken sToken;
|
SToken sToken;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
char *tbName = NULL;
|
char* tbName = NULL;
|
||||||
|
|
||||||
NEXT_TOKEN(pTableName, sToken);
|
NEXT_TOKEN(pTableName, sToken);
|
||||||
|
|
||||||
|
@ -1237,9 +1237,8 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash) {
|
int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash) {
|
||||||
SVnodeModifOpStmt *modifyNode = (SVnodeModifOpStmt *)pQuery->pRoot;
|
SVnodeModifOpStmt* modifyNode = (SVnodeModifOpStmt*)pQuery->pRoot;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SInsertParseContext insertCtx = {
|
SInsertParseContext insertCtx = {
|
||||||
.pVgroupsHashObj = pVgHash,
|
.pVgroupsHashObj = pVgHash,
|
||||||
|
@ -1257,8 +1256,9 @@ 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, SName *pName, TAOS_BIND_v2 *bind, char *msgBuf, int32_t msgBufLen){
|
int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, SName* pName, TAOS_BIND_v2* bind, char* msgBuf,
|
||||||
STableDataBlocks *pDataBlock = (STableDataBlocks *)pBlock;
|
int32_t msgBufLen) {
|
||||||
|
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
||||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||||
SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags;
|
SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags;
|
||||||
if (NULL == tags) {
|
if (NULL == tags) {
|
||||||
|
@ -1287,7 +1287,7 @@ int32_t qBindStmtTagsValue(void *pBlock, void *boundTags, int64_t suid, SName *p
|
||||||
colLen = bind[c].length[0];
|
colLen = bind[c].length[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_CODE(KvRowAppend(&pBuf, (char *)bind[c].buffer, colLen, ¶m));
|
CHECK_CODE(KvRowAppend(&pBuf, (char*)bind[c].buffer, colLen, ¶m));
|
||||||
}
|
}
|
||||||
|
|
||||||
SKVRow row = tdGetKVRowFromBuilder(&tagBuilder);
|
SKVRow row = tdGetKVRowFromBuilder(&tagBuilder);
|
||||||
|
@ -1307,9 +1307,8 @@ int32_t qBindStmtTagsValue(void *pBlock, void *boundTags, int64_t suid, SName *p
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t qBindStmtColsValue(void* pBlock, TAOS_BIND_v2* bind, char* msgBuf, int32_t msgBufLen) {
|
||||||
int32_t qBindStmtColsValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf, int32_t msgBufLen) {
|
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
||||||
STableDataBlocks *pDataBlock = (STableDataBlocks *)pBlock;
|
|
||||||
SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta);
|
SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta);
|
||||||
int32_t extendedRowSize = getExtendedRowSize(pDataBlock);
|
int32_t extendedRowSize = getExtendedRowSize(pDataBlock);
|
||||||
SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo;
|
SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo;
|
||||||
|
@ -1352,12 +1351,12 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf, int32
|
||||||
colLen = bind[c].length[r];
|
colLen = bind[c].length[r];
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_CODE(MemRowAppend(&pBuf, (char *)bind[c].buffer + bind[c].buffer_length * r, colLen, ¶m));
|
CHECK_CODE(MemRowAppend(&pBuf, (char*)bind[c].buffer + bind[c].buffer_length * r, colLen, ¶m));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) {
|
if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) {
|
||||||
TSKEY tsKey = TD_ROW_KEY(row);
|
TSKEY tsKey = TD_ROW_KEY(row);
|
||||||
checkTimestamp(pDataBlock, (const char *)&tsKey);
|
checkTimestamp(pDataBlock, (const char*)&tsKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1374,7 +1373,7 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf, int32
|
||||||
pDataBlock->size += extendedRowSize;
|
pDataBlock->size += extendedRowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSubmitBlk *pBlocks = (SSubmitBlk *)(pDataBlock->pData);
|
SSubmitBlk* pBlocks = (SSubmitBlk*)(pDataBlock->pData);
|
||||||
if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, pDataBlock, bind->num)) {
|
if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, pDataBlock, bind->num)) {
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
@ -1382,8 +1381,9 @@ int32_t qBindStmtColsValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf, int32
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qBindStmtSingleColValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf, int32_t msgBufLen, int32_t colIdx, int32_t rowNum) {
|
int32_t qBindStmtSingleColValue(void* pBlock, TAOS_BIND_v2* bind, char* msgBuf, int32_t msgBufLen, int32_t colIdx,
|
||||||
STableDataBlocks *pDataBlock = (STableDataBlocks *)pBlock;
|
int32_t rowNum) {
|
||||||
|
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
||||||
SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta);
|
SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta);
|
||||||
int32_t extendedRowSize = getExtendedRowSize(pDataBlock);
|
int32_t extendedRowSize = getExtendedRowSize(pDataBlock);
|
||||||
SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo;
|
SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo;
|
||||||
|
@ -1431,12 +1431,12 @@ int32_t qBindStmtSingleColValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf,
|
||||||
colLen = bind->length[r];
|
colLen = bind->length[r];
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_CODE(MemRowAppend(&pBuf, (char *)bind->buffer + bind->buffer_length * r, colLen, ¶m));
|
CHECK_CODE(MemRowAppend(&pBuf, (char*)bind->buffer + bind->buffer_length * r, colLen, ¶m));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) {
|
if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) {
|
||||||
TSKEY tsKey = TD_ROW_KEY(row);
|
TSKEY tsKey = TD_ROW_KEY(row);
|
||||||
checkTimestamp(pDataBlock, (const char *)&tsKey);
|
checkTimestamp(pDataBlock, (const char*)&tsKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the null value for the columns that do not assign values
|
// set the null value for the columns that do not assign values
|
||||||
|
@ -1453,7 +1453,7 @@ int32_t qBindStmtSingleColValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf,
|
||||||
if (rowEnd) {
|
if (rowEnd) {
|
||||||
pDataBlock->size += extendedRowSize * bind->num;
|
pDataBlock->size += extendedRowSize * bind->num;
|
||||||
|
|
||||||
SSubmitBlk *pBlocks = (SSubmitBlk *)(pDataBlock->pData);
|
SSubmitBlk* pBlocks = (SSubmitBlk*)(pDataBlock->pData);
|
||||||
if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, pDataBlock, bind->num)) {
|
if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, pDataBlock, bind->num)) {
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
@ -1462,8 +1462,7 @@ int32_t qBindStmtSingleColValue(void *pBlock, TAOS_BIND_v2 *bind, char *msgBuf,
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t buildBoundFields(SParsedDataColInfo* boundInfo, SSchema* pSchema, int32_t* fieldNum, TAOS_FIELD** fields) {
|
||||||
int32_t buildBoundFields(SParsedDataColInfo *boundInfo, SSchema *pSchema, int32_t *fieldNum, TAOS_FIELD** fields) {
|
|
||||||
if (fields) {
|
if (fields) {
|
||||||
*fields = taosMemoryCalloc(boundInfo->numOfBound, sizeof(TAOS_FIELD));
|
*fields = taosMemoryCalloc(boundInfo->numOfBound, sizeof(TAOS_FIELD));
|
||||||
if (NULL == *fields) {
|
if (NULL == *fields) {
|
||||||
|
@ -1483,9 +1482,8 @@ int32_t buildBoundFields(SParsedDataColInfo *boundInfo, SSchema *pSchema, int32_
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TAOS_FIELD** fields) {
|
||||||
int32_t qBuildStmtTagFields(void *pBlock, void *boundTags, int32_t *fieldNum, TAOS_FIELD** fields) {
|
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
||||||
STableDataBlocks *pDataBlock = (STableDataBlocks *)pBlock;
|
|
||||||
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;
|
||||||
|
@ -1504,8 +1502,8 @@ int32_t qBuildStmtTagFields(void *pBlock, void *boundTags, int32_t *fieldNum, TA
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qBuildStmtColFields(void *pBlock, int32_t *fieldNum, TAOS_FIELD** fields) {
|
int32_t qBuildStmtColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD** fields) {
|
||||||
STableDataBlocks *pDataBlock = (STableDataBlocks *)pBlock;
|
STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock;
|
||||||
SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta);
|
SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta);
|
||||||
if (pDataBlock->boundColumnInfo.numOfBound <= 0) {
|
if (pDataBlock->boundColumnInfo.numOfBound <= 0) {
|
||||||
*fieldNum = 0;
|
*fieldNum = 0;
|
||||||
|
@ -1520,6 +1518,3 @@ int32_t qBuildStmtColFields(void *pBlock, int32_t *fieldNum, TAOS_FIELD** fields
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
#include "parInsertData.h"
|
#include "parInsertData.h"
|
||||||
|
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
|
#include "parInt.h"
|
||||||
#include "parUtil.h"
|
#include "parUtil.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
#include "parInt.h"
|
|
||||||
|
|
||||||
#define IS_RAW_PAYLOAD(t) \
|
#define IS_RAW_PAYLOAD(t) \
|
||||||
(((int)(t)) == PAYLOAD_TYPE_RAW) // 0: K-V payload for non-prepare insert, 1: rawPayload for prepare insert
|
(((int)(t)) == PAYLOAD_TYPE_RAW) // 0: K-V payload for non-prepare insert, 1: rawPayload for prepare insert
|
||||||
|
@ -33,9 +33,9 @@ typedef struct SBlockKeyInfo {
|
||||||
SBlockKeyTuple* pKeyTuple;
|
SBlockKeyTuple* pKeyTuple;
|
||||||
} SBlockKeyInfo;
|
} SBlockKeyInfo;
|
||||||
|
|
||||||
static int32_t rowDataCompar(const void *lhs, const void *rhs) {
|
static int32_t rowDataCompar(const void* lhs, const void* rhs) {
|
||||||
TSKEY left = *(TSKEY *)lhs;
|
TSKEY left = *(TSKEY*)lhs;
|
||||||
TSKEY right = *(TSKEY *)rhs;
|
TSKEY right = *(TSKEY*)rhs;
|
||||||
|
|
||||||
if (left == right) {
|
if (left == right) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -81,9 +81,9 @@ void setBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, col_id_t
|
||||||
pColList->extendedVarLen = (uint16_t)(nVar * sizeof(VarDataOffsetT));
|
pColList->extendedVarLen = (uint16_t)(nVar * sizeof(VarDataOffsetT));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schemaIdxCompar(const void *lhs, const void *rhs) {
|
int32_t schemaIdxCompar(const void* lhs, const void* rhs) {
|
||||||
uint16_t left = *(uint16_t *)lhs;
|
uint16_t left = *(uint16_t*)lhs;
|
||||||
uint16_t right = *(uint16_t *)rhs;
|
uint16_t right = *(uint16_t*)rhs;
|
||||||
|
|
||||||
if (left == right) {
|
if (left == right) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -92,9 +92,9 @@ int32_t schemaIdxCompar(const void *lhs, const void *rhs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t boundIdxCompar(const void *lhs, const void *rhs) {
|
int32_t boundIdxCompar(const void* lhs, const void* rhs) {
|
||||||
uint16_t left = *(uint16_t *)POINTER_SHIFT(lhs, sizeof(uint16_t));
|
uint16_t left = *(uint16_t*)POINTER_SHIFT(lhs, sizeof(uint16_t));
|
||||||
uint16_t right = *(uint16_t *)POINTER_SHIFT(rhs, sizeof(uint16_t));
|
uint16_t right = *(uint16_t*)POINTER_SHIFT(rhs, sizeof(uint16_t));
|
||||||
|
|
||||||
if (left == right) {
|
if (left == right) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -115,8 +115,8 @@ void destroyBoundColumnInfo(void* pBoundInfo) {
|
||||||
taosMemoryFreeClear(pColList->colIdxInfo);
|
taosMemoryFreeClear(pColList->colIdxInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t startOffset,
|
static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t startOffset, const STableMeta* pTableMeta,
|
||||||
const STableMeta* pTableMeta, STableDataBlocks** dataBlocks) {
|
STableDataBlocks** dataBlocks) {
|
||||||
STableDataBlocks* dataBuf = (STableDataBlocks*)taosMemoryCalloc(1, sizeof(STableDataBlocks));
|
STableDataBlocks* dataBuf = (STableDataBlocks*)taosMemoryCalloc(1, sizeof(STableDataBlocks));
|
||||||
if (dataBuf == NULL) {
|
if (dataBuf == NULL) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
@ -137,7 +137,7 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star
|
||||||
}
|
}
|
||||||
memset(dataBuf->pData, 0, sizeof(SSubmitBlk));
|
memset(dataBuf->pData, 0, sizeof(SSubmitBlk));
|
||||||
|
|
||||||
//Here we keep the tableMeta to avoid it to be remove by other threads.
|
// Here we keep the tableMeta to avoid it to be remove by other threads.
|
||||||
dataBuf->pTableMeta = tableMetaDup(pTableMeta);
|
dataBuf->pTableMeta = tableMetaDup(pTableMeta);
|
||||||
|
|
||||||
SParsedDataColInfo* pColInfo = &dataBuf->boundColumnInfo;
|
SParsedDataColInfo* pColInfo = &dataBuf->boundColumnInfo;
|
||||||
|
@ -177,7 +177,8 @@ int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq)
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize,
|
int32_t getDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize,
|
||||||
const STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList, SVCreateTbReq* pCreateTbReq) {
|
const STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList,
|
||||||
|
SVCreateTbReq* pCreateTbReq) {
|
||||||
*dataBlocks = NULL;
|
*dataBlocks = NULL;
|
||||||
STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pHashList, (const char*)&id, sizeof(id));
|
STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pHashList, (const char*)&id, sizeof(id));
|
||||||
if (t1 != NULL) {
|
if (t1 != NULL) {
|
||||||
|
@ -267,14 +268,14 @@ void destroyBlockHashmap(SHashObj* pDataBlockHash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// data block is disordered, sort it in ascending order
|
// data block is disordered, sort it in ascending order
|
||||||
void sortRemoveDataBlockDupRowsRaw(STableDataBlocks *dataBuf) {
|
void sortRemoveDataBlockDupRowsRaw(STableDataBlocks* dataBuf) {
|
||||||
SSubmitBlk *pBlocks = (SSubmitBlk *)dataBuf->pData;
|
SSubmitBlk* pBlocks = (SSubmitBlk*)dataBuf->pData;
|
||||||
|
|
||||||
// size is less than the total size, since duplicated rows may be removed yet.
|
// size is less than the total size, since duplicated rows may be removed yet.
|
||||||
assert(pBlocks->numOfRows * dataBuf->rowSize + sizeof(SSubmitBlk) == dataBuf->size);
|
assert(pBlocks->numOfRows * dataBuf->rowSize + sizeof(SSubmitBlk) == dataBuf->size);
|
||||||
|
|
||||||
if (!dataBuf->ordered) {
|
if (!dataBuf->ordered) {
|
||||||
char *pBlockData = pBlocks->data;
|
char* pBlockData = pBlocks->data;
|
||||||
qsort(pBlockData, pBlocks->numOfRows, dataBuf->rowSize, rowDataCompar);
|
qsort(pBlockData, pBlocks->numOfRows, dataBuf->rowSize, rowDataCompar);
|
||||||
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
|
@ -282,8 +283,8 @@ void sortRemoveDataBlockDupRowsRaw(STableDataBlocks *dataBuf) {
|
||||||
|
|
||||||
// delete rows with timestamp conflicts
|
// delete rows with timestamp conflicts
|
||||||
while (j < pBlocks->numOfRows) {
|
while (j < pBlocks->numOfRows) {
|
||||||
TSKEY ti = *(TSKEY *)(pBlockData + dataBuf->rowSize * i);
|
TSKEY ti = *(TSKEY*)(pBlockData + dataBuf->rowSize * i);
|
||||||
TSKEY tj = *(TSKEY *)(pBlockData + dataBuf->rowSize * j);
|
TSKEY tj = *(TSKEY*)(pBlockData + dataBuf->rowSize * j);
|
||||||
|
|
||||||
if (ti == tj) {
|
if (ti == tj) {
|
||||||
++j;
|
++j;
|
||||||
|
@ -308,8 +309,8 @@ void sortRemoveDataBlockDupRowsRaw(STableDataBlocks *dataBuf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// data block is disordered, sort it in ascending order
|
// data block is disordered, sort it in ascending order
|
||||||
int sortRemoveDataBlockDupRows(STableDataBlocks *dataBuf, SBlockKeyInfo *pBlkKeyInfo) {
|
int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKeyInfo) {
|
||||||
SSubmitBlk *pBlocks = (SSubmitBlk *)dataBuf->pData;
|
SSubmitBlk* pBlocks = (SSubmitBlk*)dataBuf->pData;
|
||||||
int16_t nRows = pBlocks->numOfRows;
|
int16_t nRows = pBlocks->numOfRows;
|
||||||
|
|
||||||
// size is less than the total size, since duplicated rows may be removed yet.
|
// size is less than the total size, since duplicated rows may be removed yet.
|
||||||
|
@ -317,21 +318,21 @@ int sortRemoveDataBlockDupRows(STableDataBlocks *dataBuf, SBlockKeyInfo *pBlkKey
|
||||||
// allocate memory
|
// allocate memory
|
||||||
size_t nAlloc = nRows * sizeof(SBlockKeyTuple);
|
size_t nAlloc = nRows * sizeof(SBlockKeyTuple);
|
||||||
if (pBlkKeyInfo->pKeyTuple == NULL || pBlkKeyInfo->maxBytesAlloc < nAlloc) {
|
if (pBlkKeyInfo->pKeyTuple == NULL || pBlkKeyInfo->maxBytesAlloc < nAlloc) {
|
||||||
char *tmp = taosMemoryRealloc(pBlkKeyInfo->pKeyTuple, nAlloc);
|
char* tmp = taosMemoryRealloc(pBlkKeyInfo->pKeyTuple, nAlloc);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
pBlkKeyInfo->pKeyTuple = (SBlockKeyTuple *)tmp;
|
pBlkKeyInfo->pKeyTuple = (SBlockKeyTuple*)tmp;
|
||||||
pBlkKeyInfo->maxBytesAlloc = (int32_t)nAlloc;
|
pBlkKeyInfo->maxBytesAlloc = (int32_t)nAlloc;
|
||||||
}
|
}
|
||||||
memset(pBlkKeyInfo->pKeyTuple, 0, nAlloc);
|
memset(pBlkKeyInfo->pKeyTuple, 0, nAlloc);
|
||||||
|
|
||||||
int32_t extendedRowSize = getExtendedRowSize(dataBuf);
|
int32_t extendedRowSize = getExtendedRowSize(dataBuf);
|
||||||
SBlockKeyTuple *pBlkKeyTuple = pBlkKeyInfo->pKeyTuple;
|
SBlockKeyTuple* pBlkKeyTuple = pBlkKeyInfo->pKeyTuple;
|
||||||
char * pBlockData = pBlocks->data + pBlocks->schemaLen;
|
char* pBlockData = pBlocks->data + pBlocks->schemaLen;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
while (n < nRows) {
|
while (n < nRows) {
|
||||||
pBlkKeyTuple->skey = TD_ROW_KEY((STSRow *)pBlockData);
|
pBlkKeyTuple->skey = TD_ROW_KEY((STSRow*)pBlockData);
|
||||||
pBlkKeyTuple->payloadAddr = pBlockData;
|
pBlkKeyTuple->payloadAddr = pBlockData;
|
||||||
|
|
||||||
// next loop
|
// next loop
|
||||||
|
@ -374,7 +375,8 @@ int sortRemoveDataBlockDupRows(STableDataBlocks *dataBuf, SBlockKeyInfo *pBlkKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erase the empty space reserved for binary data
|
// Erase the empty space reserved for binary data
|
||||||
static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, SBlockKeyTuple* blkKeyTuple, bool isRawPayload) {
|
static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, SBlockKeyTuple* blkKeyTuple,
|
||||||
|
bool isRawPayload) {
|
||||||
// TODO: optimize this function, handle the case while binary is not presented
|
// TODO: optimize this function, handle the case while binary is not presented
|
||||||
STableMeta* pTableMeta = pTableDataBlock->pTableMeta;
|
STableMeta* pTableMeta = pTableDataBlock->pTableMeta;
|
||||||
STableComInfo tinfo = getTableInfo(pTableMeta);
|
STableComInfo tinfo = getTableInfo(pTableMeta);
|
||||||
|
@ -441,11 +443,12 @@ int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** p
|
||||||
STableDataBlocks* pOneTableBlock = *p;
|
STableDataBlocks* pOneTableBlock = *p;
|
||||||
SBlockKeyInfo blkKeyInfo = {0}; // share by pOneTableBlock
|
SBlockKeyInfo blkKeyInfo = {0}; // share by pOneTableBlock
|
||||||
while (pOneTableBlock) {
|
while (pOneTableBlock) {
|
||||||
SSubmitBlk* pBlocks = (SSubmitBlk*) pOneTableBlock->pData;
|
SSubmitBlk* pBlocks = (SSubmitBlk*)pOneTableBlock->pData;
|
||||||
if (pBlocks->numOfRows > 0) {
|
if (pBlocks->numOfRows > 0) {
|
||||||
STableDataBlocks* dataBuf = NULL;
|
STableDataBlocks* dataBuf = NULL;
|
||||||
int32_t ret = getDataBlockFromList(pVnodeDataBlockHashList, pOneTableBlock->vgId, TSDB_PAYLOAD_SIZE,
|
int32_t ret =
|
||||||
INSERT_HEAD_SIZE, 0, pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList, NULL);
|
getDataBlockFromList(pVnodeDataBlockHashList, pOneTableBlock->vgId, TSDB_PAYLOAD_SIZE, INSERT_HEAD_SIZE, 0,
|
||||||
|
pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList, NULL);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
taosHashCleanup(pVnodeDataBlockHashList);
|
taosHashCleanup(pVnodeDataBlockHashList);
|
||||||
destroyBlockArrayList(pVnodeDataBlockList);
|
destroyBlockArrayList(pVnodeDataBlockList);
|
||||||
|
@ -490,7 +493,8 @@ int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** p
|
||||||
sizeof(STColumn) * getNumOfColumns(pOneTableBlock->pTableMeta);
|
sizeof(STColumn) * getNumOfColumns(pOneTableBlock->pTableMeta);
|
||||||
|
|
||||||
// erase the empty space reserved for binary data
|
// erase the empty space reserved for binary data
|
||||||
int32_t finalLen = trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock, blkKeyInfo.pKeyTuple, isRawPayload);
|
int32_t finalLen =
|
||||||
|
trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock, blkKeyInfo.pKeyTuple, isRawPayload);
|
||||||
assert(finalLen <= len);
|
assert(finalLen <= len);
|
||||||
|
|
||||||
dataBuf->size += (finalLen + sizeof(SSubmitBlk));
|
dataBuf->size += (finalLen + sizeof(SSubmitBlk));
|
||||||
|
@ -513,7 +517,7 @@ int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** p
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t allocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize) {
|
int32_t allocateMemForSize(STableDataBlocks* pDataBlock, int32_t allSize) {
|
||||||
size_t remain = pDataBlock->nAllocSize - pDataBlock->size;
|
size_t remain = pDataBlock->nAllocSize - pDataBlock->size;
|
||||||
uint32_t nAllocSizeOld = pDataBlock->nAllocSize;
|
uint32_t nAllocSizeOld = pDataBlock->nAllocSize;
|
||||||
|
|
||||||
|
@ -521,7 +525,7 @@ int32_t allocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize) {
|
||||||
if (remain < allSize) {
|
if (remain < allSize) {
|
||||||
pDataBlock->nAllocSize = (pDataBlock->size + allSize) * 1.5;
|
pDataBlock->nAllocSize = (pDataBlock->size + allSize) * 1.5;
|
||||||
|
|
||||||
char *tmp = taosMemoryRealloc(pDataBlock->pData, (size_t)pDataBlock->nAllocSize);
|
char* tmp = taosMemoryRealloc(pDataBlock->pData, (size_t)pDataBlock->nAllocSize);
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
pDataBlock->pData = tmp;
|
pDataBlock->pData = tmp;
|
||||||
memset(pDataBlock->pData + pDataBlock->size, 0, pDataBlock->nAllocSize - pDataBlock->size);
|
memset(pDataBlock->pData + pDataBlock->size, 0, pDataBlock->nAllocSize - pDataBlock->size);
|
||||||
|
@ -535,7 +539,7 @@ int32_t allocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t allocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t * numOfRows) {
|
int32_t allocateMemIfNeed(STableDataBlocks* pDataBlock, int32_t rowSize, int32_t* numOfRows) {
|
||||||
size_t remain = pDataBlock->nAllocSize - pDataBlock->size;
|
size_t remain = pDataBlock->nAllocSize - pDataBlock->size;
|
||||||
const int factor = 5;
|
const int factor = 5;
|
||||||
uint32_t nAllocSizeOld = pDataBlock->nAllocSize;
|
uint32_t nAllocSizeOld = pDataBlock->nAllocSize;
|
||||||
|
@ -547,7 +551,7 @@ int32_t allocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t
|
||||||
remain = pDataBlock->nAllocSize - pDataBlock->size;
|
remain = pDataBlock->nAllocSize - pDataBlock->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *tmp = taosMemoryRealloc(pDataBlock->pData, (size_t)pDataBlock->nAllocSize);
|
char* tmp = taosMemoryRealloc(pDataBlock->pData, (size_t)pDataBlock->nAllocSize);
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
pDataBlock->pData = tmp;
|
pDataBlock->pData = tmp;
|
||||||
memset(pDataBlock->pData + pDataBlock->size, 0, pDataBlock->nAllocSize - pDataBlock->size);
|
memset(pDataBlock->pData + pDataBlock->size, 0, pDataBlock->nAllocSize - pDataBlock->size);
|
||||||
|
@ -563,7 +567,7 @@ int32_t allocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int initRowBuilder(SRowBuilder *pBuilder, int16_t schemaVer, SParsedDataColInfo *pColInfo) {
|
int initRowBuilder(SRowBuilder* pBuilder, int16_t schemaVer, SParsedDataColInfo* pColInfo) {
|
||||||
ASSERT(pColInfo->numOfCols > 0 && (pColInfo->numOfBound <= pColInfo->numOfCols));
|
ASSERT(pColInfo->numOfCols > 0 && (pColInfo->numOfBound <= pColInfo->numOfCols));
|
||||||
tdSRowInit(pBuilder, schemaVer);
|
tdSRowInit(pBuilder, schemaVer);
|
||||||
tdSRowSetExtendedInfo(pBuilder, pColInfo->numOfCols, pColInfo->numOfBound, pColInfo->flen, pColInfo->allNullLen,
|
tdSRowSetExtendedInfo(pBuilder, pColInfo->numOfCols, pColInfo->numOfBound, pColInfo->flen, pColInfo->allNullLen,
|
||||||
|
@ -571,7 +575,6 @@ int initRowBuilder(SRowBuilder *pBuilder, int16_t schemaVer, SParsedDataColInfo
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qResetStmtDataBlock(void* block, bool keepBuf) {
|
int32_t qResetStmtDataBlock(void* block, bool keepBuf) {
|
||||||
STableDataBlocks* pBlock = (STableDataBlocks*)block;
|
STableDataBlocks* pBlock = (STableDataBlocks*)block;
|
||||||
|
|
||||||
|
@ -599,7 +602,6 @@ int32_t qResetStmtDataBlock(void* block, bool keepBuf) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qCloneStmtDataBlock(void** pDst, void* pSrc) {
|
int32_t qCloneStmtDataBlock(void** pDst, void* pSrc) {
|
||||||
*pDst = taosMemoryMalloc(sizeof(STableDataBlocks));
|
*pDst = taosMemoryMalloc(sizeof(STableDataBlocks));
|
||||||
if (NULL == *pDst) {
|
if (NULL == *pDst) {
|
||||||
|
@ -618,7 +620,7 @@ int32_t qRebuildStmtDataBlock(void** pDst, void* pSrc) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableDataBlocks *pBlock = (STableDataBlocks*)*pDst;
|
STableDataBlocks* pBlock = (STableDataBlocks*)*pDst;
|
||||||
pBlock->pData = taosMemoryMalloc(pBlock->nAllocSize);
|
pBlock->pData = taosMemoryMalloc(pBlock->nAllocSize);
|
||||||
if (NULL == pBlock->pData) {
|
if (NULL == pBlock->pData) {
|
||||||
qFreeStmtDataBlock(pBlock);
|
qFreeStmtDataBlock(pBlock);
|
||||||
|
@ -630,7 +632,6 @@ int32_t qRebuildStmtDataBlock(void** pDst, void* pSrc) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void qFreeStmtDataBlock(void* pDataBlock) {
|
void qFreeStmtDataBlock(void* pDataBlock) {
|
||||||
if (pDataBlock == NULL) {
|
if (pDataBlock == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -650,4 +651,3 @@ void qDestroyStmtDataBlock(void* pBlock) {
|
||||||
pDataBlock->cloned = false;
|
pDataBlock->cloned = false;
|
||||||
destroyDataBlock(pDataBlock);
|
destroyDataBlock(pDataBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "parToken.h"
|
#include "parToken.h"
|
||||||
#include "thash.h"
|
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
#include "thash.h"
|
||||||
#include "ttokendef.h"
|
#include "ttokendef.h"
|
||||||
|
|
||||||
// All the keywords of the SQL language are stored in a hash table
|
// All the keywords of the SQL language are stored in a hash table
|
||||||
|
@ -325,7 +325,7 @@ static int32_t tKeywordCode(const char* z, int n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SKeyword** pKey = (SKeyword**)taosHashGet(keywordHashTable, key, n);
|
SKeyword** pKey = (SKeyword**)taosHashGet(keywordHashTable, key, n);
|
||||||
return (pKey != NULL)? (*pKey)->type:TK_NK_ID;
|
return (pKey != NULL) ? (*pKey)->type : TK_NK_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -486,7 +486,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
|
||||||
if (z[i]) i++;
|
if (z[i]) i++;
|
||||||
|
|
||||||
if (strEnd) {
|
if (strEnd) {
|
||||||
*tokenId = (delim == '`')? TK_NK_ID:TK_NK_STRING;
|
*tokenId = (delim == '`') ? TK_NK_ID : TK_NK_STRING;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
} else if (next == 'x') { //hex number
|
} else if (next == 'x') { // hex number
|
||||||
*tokenId = TK_NK_HEX;
|
*tokenId = TK_NK_HEX;
|
||||||
for (i = 2; isdigit(z[i]) || (z[i] >= 'a' && z[i] <= 'f') || (z[i] >= 'A' && z[i] <= 'F'); ++i) {
|
for (i = 2; isdigit(z[i]) || (z[i] >= 'a' && z[i] <= 'f') || (z[i] >= 'A' && z[i] <= 'F'); ++i) {
|
||||||
}
|
}
|
||||||
|
@ -557,10 +557,9 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* here is the 1u/1a/2s/3m/9y */
|
/* here is the 1u/1a/2s/3m/9y */
|
||||||
if ((z[i] == 'b' || z[i] == 'u' || z[i] == 'a' || z[i] == 's' || z[i] == 'm' || z[i] == 'h' || z[i] == 'd' || z[i] == 'n' ||
|
if ((z[i] == 'b' || z[i] == 'u' || z[i] == 'a' || z[i] == 's' || z[i] == 'm' || z[i] == 'h' || z[i] == 'd' ||
|
||||||
z[i] == 'y' || z[i] == 'w' ||
|
z[i] == 'n' || z[i] == 'y' || z[i] == 'w' || z[i] == 'B' || z[i] == 'U' || z[i] == 'A' || z[i] == 'S' ||
|
||||||
z[i] == 'B' || z[i] == 'U' || z[i] == 'A' || z[i] == 'S' || z[i] == 'M' || z[i] == 'H' || z[i] == 'D' || z[i] == 'N' ||
|
z[i] == 'M' || z[i] == 'H' || z[i] == 'D' || z[i] == 'N' || z[i] == 'Y' || z[i] == 'W') &&
|
||||||
z[i] == 'Y' || z[i] == 'W') &&
|
|
||||||
(isIdChar[(uint8_t)z[i + 1]] == 0)) {
|
(isIdChar[(uint8_t)z[i + 1]] == 0)) {
|
||||||
*tokenId = TK_NK_VARIABLE;
|
*tokenId = TK_NK_VARIABLE;
|
||||||
i += 1;
|
i += 1;
|
||||||
|
@ -602,7 +601,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
|
||||||
case 't':
|
case 't':
|
||||||
case 'F':
|
case 'F':
|
||||||
case 'f': {
|
case 'f': {
|
||||||
for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[(uint8_t) z[i]]; i++) {
|
for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[(uint8_t)z[i]]; i++) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i == 4 && strncasecmp(z, "true", 4) == 0) || (i == 5 && strncasecmp(z, "false", 5) == 0)) {
|
if ((i == 4 && strncasecmp(z, "true", 4) == 0) || (i == 5 && strncasecmp(z, "false", 5) == 0)) {
|
||||||
|
@ -611,10 +610,10 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
if (((*z & 0x80) != 0) || !isIdChar[(uint8_t) *z]) {
|
if (((*z & 0x80) != 0) || !isIdChar[(uint8_t)*z]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[(uint8_t) z[i]]; i++) {
|
for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[(uint8_t)z[i]]; i++) {
|
||||||
}
|
}
|
||||||
*tokenId = tKeywordCode(z, i);
|
*tokenId = tKeywordCode(z, i);
|
||||||
return i;
|
return i;
|
||||||
|
@ -625,8 +624,8 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SToken tscReplaceStrToken(char **str, SToken *token, const char* newToken) {
|
SToken tscReplaceStrToken(char** str, SToken* token, const char* newToken) {
|
||||||
char *src = *str;
|
char* src = *str;
|
||||||
size_t nsize = strlen(newToken);
|
size_t nsize = strlen(newToken);
|
||||||
int32_t size = (int32_t)strlen(*str) - token->n + (int32_t)nsize + 1;
|
int32_t size = (int32_t)strlen(*str) - token->n + (int32_t)nsize + 1;
|
||||||
int32_t bsize = (int32_t)((uint64_t)token->z - (uint64_t)src);
|
int32_t bsize = (int32_t)((uint64_t)token->z - (uint64_t)src);
|
||||||
|
@ -722,15 +721,13 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t0.z = (char*) str + (*i);
|
t0.z = (char*)str + (*i);
|
||||||
*i += t0.n;
|
*i += t0.n;
|
||||||
|
|
||||||
return t0;
|
return t0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosIsKeyWordToken(const char* z, int32_t len) {
|
bool taosIsKeyWordToken(const char* z, int32_t len) { return (tKeywordCode((char*)z, len) != TK_NK_ID); }
|
||||||
return (tKeywordCode((char*)z, len) != TK_NK_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
void taosCleanupKeywordsTable() {
|
void taosCleanupKeywordsTable() {
|
||||||
void* m = keywordHashTable;
|
void* m = keywordHashTable;
|
||||||
|
|
|
@ -591,18 +591,17 @@ static EDealRes haveAggFunction(SNode* pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
||||||
SFmGetFuncInfoParam param = {
|
SFmGetFuncInfoParam param = {.pCtg = pCxt->pParseCxt->pCatalog,
|
||||||
.pCtg = pCxt->pParseCxt->pCatalog,
|
|
||||||
.pRpc = pCxt->pParseCxt->pTransporter,
|
.pRpc = pCxt->pParseCxt->pTransporter,
|
||||||
.pMgmtEps = &pCxt->pParseCxt->mgmtEpSet,
|
.pMgmtEps = &pCxt->pParseCxt->mgmtEpSet,
|
||||||
.pErrBuf = pCxt->msgBuf.buf,
|
.pErrBuf = pCxt->msgBuf.buf,
|
||||||
.errBufLen = pCxt->msgBuf.len
|
.errBufLen = pCxt->msgBuf.len};
|
||||||
};
|
|
||||||
pCxt->errCode = fmGetFuncInfo(¶m, pFunc);
|
pCxt->errCode = fmGetFuncInfo(¶m, pFunc);
|
||||||
if (TSDB_CODE_SUCCESS != pCxt->errCode) {
|
if (TSDB_CODE_SUCCESS != pCxt->errCode) {
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
if (fmIsAggFunc(pFunc->funcId) && beforeHaving(pCxt->currClause)) {
|
if (fmIsAggFunc(pFunc->funcId)) {
|
||||||
|
if (beforeHaving(pCxt->currClause)) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION);
|
||||||
}
|
}
|
||||||
bool haveAggFunc = false;
|
bool haveAggFunc = false;
|
||||||
|
@ -610,6 +609,9 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
|
||||||
if (haveAggFunc) {
|
if (haveAggFunc) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_AGG_FUNC_NESTING);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_AGG_FUNC_NESTING);
|
||||||
}
|
}
|
||||||
|
pCxt->pCurrStmt->hasAggFuncs = true;
|
||||||
|
}
|
||||||
|
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,7 +773,7 @@ static int32_t addMnodeToVgroupList(const SEpSet* pEpSet, SArray** pVgroupList)
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SVgroupInfo vg = { .vgId = MNODE_HANDLE };
|
SVgroupInfo vg = {.vgId = MNODE_HANDLE};
|
||||||
memcpy(&vg.epSet, pEpSet, sizeof(SEpSet));
|
memcpy(&vg.epSet, pEpSet, sizeof(SEpSet));
|
||||||
taosArrayPush(*pVgroupList, &vg);
|
taosArrayPush(*pVgroupList, &vg);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -63,13 +63,13 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
case TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR:
|
case TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR:
|
||||||
return "Corresponding super table not in this db";
|
return "Corresponding super table not in this db";
|
||||||
case TSDB_CODE_PAR_INVALID_RANGE_OPTION:
|
case TSDB_CODE_PAR_INVALID_RANGE_OPTION:
|
||||||
return "Invalid option %s: %"PRId64" valid range: [%d, %d]";
|
return "Invalid option %s: %" PRId64 " valid range: [%d, %d]";
|
||||||
case TSDB_CODE_PAR_INVALID_STR_OPTION:
|
case TSDB_CODE_PAR_INVALID_STR_OPTION:
|
||||||
return "Invalid option %s: %s";
|
return "Invalid option %s: %s";
|
||||||
case TSDB_CODE_PAR_INVALID_ENUM_OPTION:
|
case TSDB_CODE_PAR_INVALID_ENUM_OPTION:
|
||||||
return "Invalid option %s: %"PRId64", only %d, %d allowed";
|
return "Invalid option %s: %" PRId64 ", only %d, %d allowed";
|
||||||
case TSDB_CODE_PAR_INVALID_TTL_OPTION:
|
case TSDB_CODE_PAR_INVALID_TTL_OPTION:
|
||||||
return "Invalid option ttl: %"PRId64", should be greater than or equal to %d";
|
return "Invalid option ttl: %" PRId64 ", should be greater than or equal to %d";
|
||||||
case TSDB_CODE_PAR_INVALID_KEEP_NUM:
|
case TSDB_CODE_PAR_INVALID_KEEP_NUM:
|
||||||
return "Invalid number of keep options";
|
return "Invalid number of keep options";
|
||||||
case TSDB_CODE_PAR_INVALID_KEEP_ORDER:
|
case TSDB_CODE_PAR_INVALID_KEEP_ORDER:
|
||||||
|
@ -194,20 +194,22 @@ STableMeta* tableMetaDup(const STableMeta* pTableMeta) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema *getTableColumnSchema(const STableMeta *pTableMeta) {
|
SSchema* getTableColumnSchema(const STableMeta* pTableMeta) {
|
||||||
assert(pTableMeta != NULL);
|
assert(pTableMeta != NULL);
|
||||||
return (SSchema*) pTableMeta->schema;
|
return (SSchema*)pTableMeta->schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSchema* getOneColumnSchema(const STableMeta* pTableMeta, int32_t colIndex) {
|
static SSchema* getOneColumnSchema(const STableMeta* pTableMeta, int32_t colIndex) {
|
||||||
assert(pTableMeta != NULL && pTableMeta->schema != NULL && colIndex >= 0 && colIndex < (getNumOfColumns(pTableMeta) + getNumOfTags(pTableMeta)));
|
assert(pTableMeta != NULL && pTableMeta->schema != NULL && colIndex >= 0 &&
|
||||||
|
colIndex < (getNumOfColumns(pTableMeta) + getNumOfTags(pTableMeta)));
|
||||||
|
|
||||||
SSchema* pSchema = (SSchema*) pTableMeta->schema;
|
SSchema* pSchema = (SSchema*)pTableMeta->schema;
|
||||||
return &pSchema[colIndex];
|
return &pSchema[colIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* getTableTagSchema(const STableMeta* pTableMeta) {
|
SSchema* getTableTagSchema(const STableMeta* pTableMeta) {
|
||||||
assert(pTableMeta != NULL && (pTableMeta->tableType == TSDB_SUPER_TABLE || pTableMeta->tableType == TSDB_CHILD_TABLE));
|
assert(pTableMeta != NULL &&
|
||||||
|
(pTableMeta->tableType == TSDB_SUPER_TABLE || pTableMeta->tableType == TSDB_CHILD_TABLE));
|
||||||
return getOneColumnSchema(pTableMeta, getTableInfo(pTableMeta).numOfColumns);
|
return getOneColumnSchema(pTableMeta, getTableInfo(pTableMeta).numOfColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +230,7 @@ STableComInfo getTableInfo(const STableMeta* pTableMeta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen) {
|
int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen) {
|
||||||
if (len <=0 || dlen <= 0) return 0;
|
if (len <= 0 || dlen <= 0) return 0;
|
||||||
|
|
||||||
char delim = src[0];
|
char delim = src[0];
|
||||||
int32_t j = 0;
|
int32_t j = 0;
|
||||||
|
@ -245,23 +247,23 @@ int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src[k] == '\\') { // deal with escape character
|
if (src[k] == '\\') { // deal with escape character
|
||||||
if(src[k+1] == 'n'){
|
if (src[k + 1] == 'n') {
|
||||||
dst[j] = '\n';
|
dst[j] = '\n';
|
||||||
}else if(src[k+1] == 'r'){
|
} else if (src[k + 1] == 'r') {
|
||||||
dst[j] = '\r';
|
dst[j] = '\r';
|
||||||
}else if(src[k+1] == 't'){
|
} else if (src[k + 1] == 't') {
|
||||||
dst[j] = '\t';
|
dst[j] = '\t';
|
||||||
}else if(src[k+1] == '\\'){
|
} else if (src[k + 1] == '\\') {
|
||||||
dst[j] = '\\';
|
dst[j] = '\\';
|
||||||
}else if(src[k+1] == '\''){
|
} else if (src[k + 1] == '\'') {
|
||||||
dst[j] = '\'';
|
dst[j] = '\'';
|
||||||
}else if(src[k+1] == '"'){
|
} else if (src[k + 1] == '"') {
|
||||||
dst[j] = '"';
|
dst[j] = '"';
|
||||||
}else if(src[k+1] == '%' || src[k+1] == '_'){
|
} else if (src[k + 1] == '%' || src[k + 1] == '_') {
|
||||||
dst[j++] = src[k];
|
dst[j++] = src[k];
|
||||||
dst[j] = src[k+1];
|
dst[j] = src[k + 1];
|
||||||
}else{
|
} else {
|
||||||
dst[j] = src[k+1];
|
dst[j] = src[k + 1];
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
k++;
|
k++;
|
||||||
|
@ -275,7 +277,7 @@ int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen) {
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isValidateTag(char *input) {
|
static bool isValidateTag(char* input) {
|
||||||
if (!input) return false;
|
if (!input) return false;
|
||||||
for (size_t i = 0; i < strlen(input); ++i) {
|
for (size_t i = 0; i < strlen(input); ++i) {
|
||||||
if (isprint(input[i]) == 0) return false;
|
if (isprint(input[i]) == 0) return false;
|
||||||
|
@ -283,30 +285,30 @@ static bool isValidateTag(char *input) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseJsontoTagData(const char* json, SKVRowBuilder* kvRowBuilder, SMsgBuf* pMsgBuf, int16_t startColId){
|
int parseJsontoTagData(const char* json, SKVRowBuilder* kvRowBuilder, SMsgBuf* pMsgBuf, int16_t startColId) {
|
||||||
// set json NULL data
|
// set json NULL data
|
||||||
uint8_t jsonNULL = TSDB_DATA_TYPE_NULL;
|
uint8_t jsonNULL = TSDB_DATA_TYPE_NULL;
|
||||||
int jsonIndex = startColId + 1;
|
int jsonIndex = startColId + 1;
|
||||||
if (!json || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0){
|
if (!json || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0) {
|
||||||
tdAddColToKVRow(kvRowBuilder, jsonIndex, &jsonNULL, CHAR_BYTES);
|
tdAddColToKVRow(kvRowBuilder, jsonIndex, &jsonNULL, CHAR_BYTES);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set json real data
|
// set json real data
|
||||||
cJSON *root = cJSON_Parse(json);
|
cJSON* root = cJSON_Parse(json);
|
||||||
if (root == NULL){
|
if (root == NULL) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "json parse error", json);
|
return buildSyntaxErrMsg(pMsgBuf, "json parse error", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = cJSON_GetArraySize(root);
|
int size = cJSON_GetArraySize(root);
|
||||||
if(!cJSON_IsObject(root)){
|
if (!cJSON_IsObject(root)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "json error invalide value", json);
|
return buildSyntaxErrMsg(pMsgBuf, "json error invalide value", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
int retCode = 0;
|
int retCode = 0;
|
||||||
char *tagKV = NULL;
|
char* tagKV = NULL;
|
||||||
SHashObj* keyHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, false);
|
SHashObj* keyHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, false);
|
||||||
for(int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
cJSON* item = cJSON_GetArrayItem(root, i);
|
cJSON* item = cJSON_GetArrayItem(root, i);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
qError("json inner error:%d", i);
|
qError("json inner error:%d", i);
|
||||||
|
@ -314,40 +316,41 @@ int parseJsontoTagData(const char* json, SKVRowBuilder* kvRowBuilder, SMsgBuf* p
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *jsonKey = item->string;
|
char* jsonKey = item->string;
|
||||||
if(!isValidateTag(jsonKey)){
|
if (!isValidateTag(jsonKey)) {
|
||||||
retCode = buildSyntaxErrMsg(pMsgBuf, "json key not validate", jsonKey);
|
retCode = buildSyntaxErrMsg(pMsgBuf, "json key not validate", jsonKey);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
// if(strlen(jsonKey) > TSDB_MAX_JSON_KEY_LEN){
|
// if(strlen(jsonKey) > TSDB_MAX_JSON_KEY_LEN){
|
||||||
// tscError("json key too long error");
|
// tscError("json key too long error");
|
||||||
// retCode = tscSQLSyntaxErrMsg(errMsg, "json key too long, more than 256", NULL);
|
// retCode = tscSQLSyntaxErrMsg(errMsg, "json key too long, more than 256", NULL);
|
||||||
// goto end;
|
// goto end;
|
||||||
// }
|
// }
|
||||||
size_t keyLen = strlen(jsonKey);
|
size_t keyLen = strlen(jsonKey);
|
||||||
if(keyLen == 0 || taosHashGet(keyHash, jsonKey, keyLen) != NULL){
|
if (keyLen == 0 || taosHashGet(keyHash, jsonKey, keyLen) != NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// key: keyLen + VARSTR_HEADER_SIZE, value type: CHAR_BYTES, value reserved: LONG_BYTES
|
// key: keyLen + VARSTR_HEADER_SIZE, value type: CHAR_BYTES, value reserved: LONG_BYTES
|
||||||
tagKV = taosMemoryCalloc(keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES + LONG_BYTES, 1);
|
tagKV = taosMemoryCalloc(keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES + LONG_BYTES, 1);
|
||||||
if(!tagKV) {
|
if (!tagKV) {
|
||||||
retCode = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
retCode = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
strncpy(varDataVal(tagKV), jsonKey, keyLen);
|
strncpy(varDataVal(tagKV), jsonKey, keyLen);
|
||||||
varDataSetLen(tagKV, keyLen);
|
varDataSetLen(tagKV, keyLen);
|
||||||
if(taosHashGetSize(keyHash) == 0){
|
if (taosHashGetSize(keyHash) == 0) {
|
||||||
uint8_t jsonNotNULL = TSDB_DATA_TYPE_JSON;
|
uint8_t jsonNotNULL = TSDB_DATA_TYPE_JSON;
|
||||||
tdAddColToKVRow(kvRowBuilder, jsonIndex++, &jsonNotNULL, CHAR_BYTES); // add json type
|
tdAddColToKVRow(kvRowBuilder, jsonIndex++, &jsonNotNULL, CHAR_BYTES); // add json type
|
||||||
}
|
}
|
||||||
taosHashPut(keyHash, jsonKey, keyLen, &keyLen, CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
taosHashPut(keyHash, jsonKey, keyLen, &keyLen,
|
||||||
|
CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
||||||
|
|
||||||
if(item->type == cJSON_String){ // add json value format: type|data
|
if (item->type == cJSON_String) { // add json value format: type|data
|
||||||
char *jsonValue = item->valuestring;
|
char* jsonValue = item->valuestring;
|
||||||
int32_t valLen = (int32_t)strlen(jsonValue);
|
int32_t valLen = (int32_t)strlen(jsonValue);
|
||||||
int32_t totalLen = keyLen + VARSTR_HEADER_SIZE + valLen * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE + CHAR_BYTES;
|
int32_t totalLen = keyLen + VARSTR_HEADER_SIZE + valLen * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE + CHAR_BYTES;
|
||||||
char *tmp = taosMemoryRealloc(tagKV, totalLen);
|
char* tmp = taosMemoryRealloc(tagKV, totalLen);
|
||||||
if(!tmp) {
|
if (!tmp) {
|
||||||
retCode = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
retCode = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -357,43 +360,46 @@ int parseJsontoTagData(const char* json, SKVRowBuilder* kvRowBuilder, SMsgBuf* p
|
||||||
*valueType = TSDB_DATA_TYPE_NCHAR;
|
*valueType = TSDB_DATA_TYPE_NCHAR;
|
||||||
if (valLen > 0 && !taosMbsToUcs4(jsonValue, valLen, (TdUcs4*)varDataVal(valueData),
|
if (valLen > 0 && !taosMbsToUcs4(jsonValue, valLen, (TdUcs4*)varDataVal(valueData),
|
||||||
(int32_t)(valLen * TSDB_NCHAR_SIZE), &valLen)) {
|
(int32_t)(valLen * TSDB_NCHAR_SIZE), &valLen)) {
|
||||||
qError("charset:%s to %s. val:%s, errno:%s, convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, jsonValue, strerror(errno));
|
qError("charset:%s to %s. val:%s, errno:%s, convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, jsonValue,
|
||||||
|
strerror(errno));
|
||||||
retCode = buildSyntaxErrMsg(pMsgBuf, "charset convert json error", jsonValue);
|
retCode = buildSyntaxErrMsg(pMsgBuf, "charset convert json error", jsonValue);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
varDataSetLen(valueData, valLen);
|
varDataSetLen(valueData, valLen);
|
||||||
tdAddColToKVRow(kvRowBuilder, jsonIndex++, tagKV, totalLen);
|
tdAddColToKVRow(kvRowBuilder, jsonIndex++, tagKV, totalLen);
|
||||||
}else if(item->type == cJSON_Number){
|
} else if (item->type == cJSON_Number) {
|
||||||
if(!isfinite(item->valuedouble)){
|
if (!isfinite(item->valuedouble)) {
|
||||||
qError("json value is invalidate");
|
qError("json value is invalidate");
|
||||||
retCode = buildSyntaxErrMsg(pMsgBuf, "json value number is illegal", json);
|
retCode = buildSyntaxErrMsg(pMsgBuf, "json value number is illegal", json);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
char* valueType = POINTER_SHIFT(tagKV, keyLen + VARSTR_HEADER_SIZE);
|
char* valueType = POINTER_SHIFT(tagKV, keyLen + VARSTR_HEADER_SIZE);
|
||||||
char* valueData = POINTER_SHIFT(tagKV, keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES);
|
char* valueData = POINTER_SHIFT(tagKV, keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES);
|
||||||
*valueType = (item->valuedouble - (int64_t)(item->valuedouble) == 0) ? TSDB_DATA_TYPE_BIGINT : TSDB_DATA_TYPE_DOUBLE;
|
*valueType =
|
||||||
if(*valueType== TSDB_DATA_TYPE_DOUBLE) *((double *)valueData) = item->valuedouble;
|
(item->valuedouble - (int64_t)(item->valuedouble) == 0) ? TSDB_DATA_TYPE_BIGINT : TSDB_DATA_TYPE_DOUBLE;
|
||||||
else if(*valueType == TSDB_DATA_TYPE_BIGINT) *((int64_t *)valueData) = item->valueint;
|
if (*valueType == TSDB_DATA_TYPE_DOUBLE)
|
||||||
tdAddColToKVRow(kvRowBuilder, jsonIndex++, tagKV, keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES +LONG_BYTES);
|
*((double*)valueData) = item->valuedouble;
|
||||||
}else if(item->type == cJSON_True || item->type == cJSON_False){
|
else if (*valueType == TSDB_DATA_TYPE_BIGINT)
|
||||||
|
*((int64_t*)valueData) = item->valueint;
|
||||||
|
tdAddColToKVRow(kvRowBuilder, jsonIndex++, tagKV, keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES + LONG_BYTES);
|
||||||
|
} else if (item->type == cJSON_True || item->type == cJSON_False) {
|
||||||
char* valueType = POINTER_SHIFT(tagKV, keyLen + VARSTR_HEADER_SIZE);
|
char* valueType = POINTER_SHIFT(tagKV, keyLen + VARSTR_HEADER_SIZE);
|
||||||
char* valueData = POINTER_SHIFT(tagKV, keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES);
|
char* valueData = POINTER_SHIFT(tagKV, keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES);
|
||||||
*valueType = TSDB_DATA_TYPE_BOOL;
|
*valueType = TSDB_DATA_TYPE_BOOL;
|
||||||
*valueData = (char)(item->valueint);
|
*valueData = (char)(item->valueint);
|
||||||
tdAddColToKVRow(kvRowBuilder, jsonIndex++, tagKV, keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES + CHAR_BYTES);
|
tdAddColToKVRow(kvRowBuilder, jsonIndex++, tagKV, keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES + CHAR_BYTES);
|
||||||
}else if(item->type == cJSON_NULL){
|
} else if (item->type == cJSON_NULL) {
|
||||||
char* valueType = POINTER_SHIFT(tagKV, keyLen + VARSTR_HEADER_SIZE);
|
char* valueType = POINTER_SHIFT(tagKV, keyLen + VARSTR_HEADER_SIZE);
|
||||||
*valueType = TSDB_DATA_TYPE_NULL;
|
*valueType = TSDB_DATA_TYPE_NULL;
|
||||||
tdAddColToKVRow(kvRowBuilder, jsonIndex++, tagKV, keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES);
|
tdAddColToKVRow(kvRowBuilder, jsonIndex++, tagKV, keyLen + VARSTR_HEADER_SIZE + CHAR_BYTES);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
retCode = buildSyntaxErrMsg(pMsgBuf, "invalidate json value", json);
|
retCode = buildSyntaxErrMsg(pMsgBuf, "invalidate json value", json);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(taosHashGetSize(keyHash) == 0){ // set json NULL true
|
if (taosHashGetSize(keyHash) == 0) { // set json NULL true
|
||||||
tdAddColToKVRow(kvRowBuilder, jsonIndex, &jsonNULL, CHAR_BYTES);
|
tdAddColToKVRow(kvRowBuilder, jsonIndex, &jsonNULL, CHAR_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* 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 "os.h"
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
#include "parInt.h"
|
#include "parInt.h"
|
||||||
#include "parToken.h"
|
#include "parToken.h"
|
||||||
|
@ -27,7 +27,7 @@ bool isInsertSql(const char* pStr, size_t length) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
SToken t0 = tStrGetToken((char*) pStr, &index, false);
|
SToken t0 = tStrGetToken((char*)pStr, &index, false);
|
||||||
if (t0.type != TK_NK_LP) {
|
if (t0.type != TK_NK_LP) {
|
||||||
return t0.type == TK_INSERT || t0.type == TK_IMPORT;
|
return t0.type == TK_INSERT || t0.type == TK_IMPORT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,103 +30,128 @@ namespace {
|
||||||
|
|
||||||
void generateInformationSchema(MockCatalogService* mcs) {
|
void generateInformationSchema(MockCatalogService* mcs) {
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnodes", TSDB_SYSTEM_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnodes", TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "mnodes", TSDB_SYSTEM_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "mnodes", TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "modules", TSDB_SYSTEM_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "modules", TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "qnodes", TSDB_SYSTEM_TABLE, 1).addColumn("id", TSDB_DATA_TYPE_INT);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "qnodes", TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("id", TSDB_DATA_TYPE_INT);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_databases", TSDB_SYSTEM_TABLE, 1).addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_databases", TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_functions", TSDB_SYSTEM_TABLE, 1).addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_functions", TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_indexes", TSDB_SYSTEM_TABLE, 2)
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_indexes", TSDB_SYSTEM_TABLE, 2)
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN).addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||||
|
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_stables", TSDB_SYSTEM_TABLE, 2)
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_stables", TSDB_SYSTEM_TABLE, 2)
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN).addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||||
|
.addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_streams", TSDB_SYSTEM_TABLE, 1).addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_streams", TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_tables", TSDB_SYSTEM_TABLE, 2)
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_tables", TSDB_SYSTEM_TABLE, 2)
|
||||||
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN).addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN)
|
||||||
|
.addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_table_distributed", TSDB_SYSTEM_TABLE, 1).addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
ITableBuilder& builder =
|
||||||
|
mcs->createTableBuilder("information_schema", "user_table_distributed", TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_users", TSDB_SYSTEM_TABLE, 1).addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_users", TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "vgroups", TSDB_SYSTEM_TABLE, 1).addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
ITableBuilder& builder = mcs->createTableBuilder("information_schema", "vgroups", TSDB_SYSTEM_TABLE, 1)
|
||||||
|
.addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateTestT1(MockCatalogService* mcs) {
|
void generateTestT1(MockCatalogService* mcs) {
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("test", "t1", TSDB_NORMAL_TABLE, 6)
|
ITableBuilder& builder = mcs->createTableBuilder("test", "t1", TSDB_NORMAL_TABLE, 6)
|
||||||
.setPrecision(TSDB_TIME_PRECISION_MILLI).setVgid(1).addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP)
|
.setPrecision(TSDB_TIME_PRECISION_MILLI)
|
||||||
.addColumn("c1", TSDB_DATA_TYPE_INT).addColumn("c2", TSDB_DATA_TYPE_BINARY, 20).addColumn("c3", TSDB_DATA_TYPE_BIGINT)
|
.setVgid(1)
|
||||||
.addColumn("c4", TSDB_DATA_TYPE_DOUBLE).addColumn("c5", TSDB_DATA_TYPE_DOUBLE);
|
.addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP)
|
||||||
|
.addColumn("c1", TSDB_DATA_TYPE_INT)
|
||||||
|
.addColumn("c2", TSDB_DATA_TYPE_BINARY, 20)
|
||||||
|
.addColumn("c3", TSDB_DATA_TYPE_BIGINT)
|
||||||
|
.addColumn("c4", TSDB_DATA_TYPE_DOUBLE)
|
||||||
|
.addColumn("c5", TSDB_DATA_TYPE_DOUBLE);
|
||||||
builder.done();
|
builder.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateTestST1(MockCatalogService* mcs) {
|
void generateTestST1(MockCatalogService* mcs) {
|
||||||
ITableBuilder& builder = mcs->createTableBuilder("test", "st1", TSDB_SUPER_TABLE, 3, 2)
|
ITableBuilder& builder = mcs->createTableBuilder("test", "st1", TSDB_SUPER_TABLE, 3, 2)
|
||||||
.setPrecision(TSDB_TIME_PRECISION_MILLI).addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP)
|
.setPrecision(TSDB_TIME_PRECISION_MILLI)
|
||||||
.addColumn("c1", TSDB_DATA_TYPE_INT).addColumn("c2", TSDB_DATA_TYPE_BINARY, 20)
|
.addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP)
|
||||||
.addTag("tag1", TSDB_DATA_TYPE_INT).addTag("tag2", TSDB_DATA_TYPE_BINARY, 20);
|
.addColumn("c1", TSDB_DATA_TYPE_INT)
|
||||||
|
.addColumn("c2", TSDB_DATA_TYPE_BINARY, 20)
|
||||||
|
.addTag("tag1", TSDB_DATA_TYPE_INT)
|
||||||
|
.addTag("tag2", TSDB_DATA_TYPE_BINARY, 20);
|
||||||
builder.done();
|
builder.done();
|
||||||
mcs->createSubTable("test", "st1", "st1s1", 1);
|
mcs->createSubTable("test", "st1", "st1s1", 1);
|
||||||
mcs->createSubTable("test", "st1", "st1s2", 2);
|
mcs->createSubTable("test", "st1", "st1s2", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
int32_t __catalogGetHandle(const char *clusterId, struct SCatalog** catalogHandle) {
|
int32_t __catalogGetHandle(const char* clusterId, struct SCatalog** catalogHandle) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t __catalogGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta) {
|
int32_t __catalogGetTableMeta(struct SCatalog* pCatalog, void* pRpc, const SEpSet* pMgmtEps, const SName* pTableName,
|
||||||
|
STableMeta** pTableMeta) {
|
||||||
return mockCatalogService->catalogGetTableMeta(pTableName, pTableMeta);
|
return mockCatalogService->catalogGetTableMeta(pTableName, pTableMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __catalogGetTableHashVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, SVgroupInfo* vgInfo) {
|
int32_t __catalogGetTableHashVgroup(struct SCatalog* pCatalog, void* pRpc, const SEpSet* pMgmtEps,
|
||||||
|
const SName* pTableName, SVgroupInfo* vgInfo) {
|
||||||
return mockCatalogService->catalogGetTableHashVgroup(pTableName, vgInfo);
|
return mockCatalogService->catalogGetTableHashVgroup(pTableName, vgInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, SArray** pVgList) {
|
int32_t __catalogGetTableDistVgInfo(SCatalog* pCtg, void* pRpc, const SEpSet* pMgmtEps, const SName* pTableName,
|
||||||
|
SArray** pVgList) {
|
||||||
return mockCatalogService->catalogGetTableDistVgInfo(pTableName, pVgList);
|
return mockCatalogService->catalogGetTableDistVgInfo(pTableName, pVgList);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId, int32_t *tableNum) {
|
int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId,
|
||||||
|
int32_t* tableNum) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __catalogGetDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName, SArray** vgroupList) {
|
int32_t __catalogGetDBVgInfo(SCatalog* pCtg, void* pRpc, const SEpSet* pMgmtEps, const char* dbFName,
|
||||||
|
SArray** vgroupList) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +214,4 @@ void generateMetaData() {
|
||||||
mockCatalogService->showTables();
|
mockCatalogService->showTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyMetaDataEnv() {
|
void destroyMetaDataEnv() { mockCatalogService.reset(); }
|
||||||
mockCatalogService.reset();
|
|
||||||
}
|
|
||||||
|
|
|
@ -13,19 +13,20 @@
|
||||||
* 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 "mockCatalogService.h"
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "mockCatalogService.h"
|
|
||||||
#include "tdatablock.h"
|
|
||||||
|
|
||||||
|
#include "tdatablock.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
|
|
||||||
std::unique_ptr<MockCatalogService> mockCatalogService;
|
std::unique_ptr<MockCatalogService> mockCatalogService;
|
||||||
|
|
||||||
class TableBuilder : public ITableBuilder {
|
class TableBuilder : public ITableBuilder {
|
||||||
public:
|
public:
|
||||||
virtual TableBuilder& addColumn(const std::string& name, int8_t type, int32_t bytes) {
|
virtual TableBuilder& addColumn(const std::string& name, int8_t type, int32_t bytes) {
|
||||||
assert(colId_ <= schema()->tableInfo.numOfTags + schema()->tableInfo.numOfColumns);
|
assert(colId_ <= schema()->tableInfo.numOfTags + schema()->tableInfo.numOfColumns);
|
||||||
SSchema* col = schema()->schema + (colId_ - 1);
|
SSchema* col = schema()->schema + (colId_ - 1);
|
||||||
|
@ -40,7 +41,7 @@ public:
|
||||||
virtual TableBuilder& setVgid(int16_t vgid) {
|
virtual TableBuilder& setVgid(int16_t vgid) {
|
||||||
schema()->vgId = vgid;
|
schema()->vgId = vgid;
|
||||||
|
|
||||||
SVgroupInfo vgroup = { vgid, 0, 0, {0}, 0};
|
SVgroupInfo vgroup = {vgid, 0, 0, {0}, 0};
|
||||||
addEpIntoEpSet(&vgroup.epSet, "dnode_1", 6030);
|
addEpIntoEpSet(&vgroup.epSet, "dnode_1", 6030);
|
||||||
addEpIntoEpSet(&vgroup.epSet, "dnode_2", 6030);
|
addEpIntoEpSet(&vgroup.epSet, "dnode_2", 6030);
|
||||||
addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030);
|
addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030);
|
||||||
|
@ -55,15 +56,14 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void done() {
|
virtual void done() { schema()->tableInfo.rowSize = rowsize_; }
|
||||||
schema()->tableInfo.rowSize = rowsize_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class MockCatalogServiceImpl;
|
friend class MockCatalogServiceImpl;
|
||||||
|
|
||||||
static std::unique_ptr<TableBuilder> createTableBuilder(int8_t tableType, int32_t numOfColumns, int32_t numOfTags) {
|
static std::unique_ptr<TableBuilder> createTableBuilder(int8_t tableType, int32_t numOfColumns, int32_t numOfTags) {
|
||||||
STableMeta* meta = (STableMeta*)taosMemoryCalloc(1, sizeof(STableMeta) + sizeof(SSchema) * (numOfColumns + numOfTags));
|
STableMeta* meta =
|
||||||
|
(STableMeta*)taosMemoryCalloc(1, sizeof(STableMeta) + sizeof(SSchema) * (numOfColumns + numOfTags));
|
||||||
if (nullptr == meta) {
|
if (nullptr == meta) {
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
|
@ -77,13 +77,9 @@ private:
|
||||||
meta_->schema = schemaMeta;
|
meta_->schema = schemaMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMeta* schema() {
|
STableMeta* schema() { return meta_->schema; }
|
||||||
return meta_->schema;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<MockTableMeta> table() {
|
std::shared_ptr<MockTableMeta> table() { return meta_; }
|
||||||
return meta_;
|
|
||||||
}
|
|
||||||
|
|
||||||
col_id_t colId_;
|
col_id_t colId_;
|
||||||
int32_t rowsize_;
|
int32_t rowsize_;
|
||||||
|
@ -91,15 +87,12 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockCatalogServiceImpl {
|
class MockCatalogServiceImpl {
|
||||||
public:
|
public:
|
||||||
static const int32_t numOfDataTypes = sizeof(tDataTypes) / sizeof(tDataTypes[0]);
|
static const int32_t numOfDataTypes = sizeof(tDataTypes) / sizeof(tDataTypes[0]);
|
||||||
|
|
||||||
MockCatalogServiceImpl() : id_(1) {
|
MockCatalogServiceImpl() : id_(1) {}
|
||||||
}
|
|
||||||
|
|
||||||
int32_t catalogGetHandle() const {
|
int32_t catalogGetHandle() const { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta) const {
|
int32_t catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta) const {
|
||||||
std::unique_ptr<STableMeta> table;
|
std::unique_ptr<STableMeta> table;
|
||||||
|
@ -129,7 +122,8 @@ public:
|
||||||
return copyTableVgroup(db, tNameGetTableName(pTableName), vgList);
|
return copyTableVgroup(db, tNameGetTableName(pTableName), vgList);
|
||||||
}
|
}
|
||||||
|
|
||||||
TableBuilder& createTableBuilder(const std::string& db, const std::string& tbname, int8_t tableType, int32_t numOfColumns, int32_t numOfTags) {
|
TableBuilder& createTableBuilder(const std::string& db, const std::string& tbname, int8_t tableType,
|
||||||
|
int32_t numOfColumns, int32_t numOfTags) {
|
||||||
builder_ = TableBuilder::createTableBuilder(tableType, numOfColumns, numOfTags);
|
builder_ = TableBuilder::createTableBuilder(tableType, numOfColumns, numOfTags);
|
||||||
meta_[db][tbname] = builder_->table();
|
meta_[db][tbname] = builder_->table();
|
||||||
meta_[db][tbname]->schema->uid = id_++;
|
meta_[db][tbname]->schema->uid = id_++;
|
||||||
|
@ -146,7 +140,7 @@ public:
|
||||||
meta_[db][tbname]->schema->uid = id_++;
|
meta_[db][tbname]->schema->uid = id_++;
|
||||||
meta_[db][tbname]->schema->tableType = TSDB_CHILD_TABLE;
|
meta_[db][tbname]->schema->tableType = TSDB_CHILD_TABLE;
|
||||||
|
|
||||||
SVgroupInfo vgroup = { vgid, 0, 0, {0}, 0};
|
SVgroupInfo vgroup = {vgid, 0, 0, {0}, 0};
|
||||||
addEpIntoEpSet(&vgroup.epSet, "dnode_1", 6030);
|
addEpIntoEpSet(&vgroup.epSet, "dnode_1", 6030);
|
||||||
addEpIntoEpSet(&vgroup.epSet, "dnode_2", 6030);
|
addEpIntoEpSet(&vgroup.epSet, "dnode_2", 6030);
|
||||||
addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030);
|
addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030);
|
||||||
|
@ -158,26 +152,28 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void showTables() const {
|
void showTables() const {
|
||||||
// number of forward fills
|
// number of forward fills
|
||||||
#define NOF(n) ((n) / 2)
|
#define NOF(n) ((n) / 2)
|
||||||
// number of backward fills
|
// number of backward fills
|
||||||
#define NOB(n) ((n) % 2 ? (n) / 2 + 1 : (n) / 2)
|
#define NOB(n) ((n) % 2 ? (n) / 2 + 1 : (n) / 2)
|
||||||
// center aligned
|
// center aligned
|
||||||
#define CA(n, s) std::setw(NOF((n) - (s).length())) << "" << (s) << std::setw(NOB((n) - (s).length())) << "" << "|"
|
#define CA(n, s) \
|
||||||
// string field length
|
std::setw(NOF((n) - (s).length())) << "" << (s) << std::setw(NOB((n) - (s).length())) << "" \
|
||||||
#define SFL 20
|
<< "|"
|
||||||
// string field header
|
// string field length
|
||||||
#define SH(h) CA(SFL, std::string(h))
|
#define SFL 20
|
||||||
// string field
|
// string field header
|
||||||
#define SF(n) CA(SFL, n)
|
#define SH(h) CA(SFL, std::string(h))
|
||||||
// integer field length
|
// string field
|
||||||
#define IFL 10
|
#define SF(n) CA(SFL, n)
|
||||||
// integer field header
|
// integer field length
|
||||||
#define IH(i) CA(IFL, std::string(i))
|
#define IFL 10
|
||||||
// integer field
|
// integer field header
|
||||||
#define IF(i) CA(IFL, std::to_string(i))
|
#define IH(i) CA(IFL, std::string(i))
|
||||||
// split line
|
// integer field
|
||||||
#define SL(sn, in) std::setfill('=') << std::setw((sn) * (SFL + 1) + (in) * (IFL + 1)) << "" << std::setfill(' ')
|
#define IF(i) CA(IFL, std::to_string(i))
|
||||||
|
// split line
|
||||||
|
#define SL(sn, in) std::setfill('=') << std::setw((sn) * (SFL + 1) + (in) * (IFL + 1)) << "" << std::setfill(' ')
|
||||||
|
|
||||||
for (const auto& db : meta_) {
|
for (const auto& db : meta_) {
|
||||||
std::cout << "Databse:" << db.first << std::endl;
|
std::cout << "Databse:" << db.first << std::endl;
|
||||||
|
@ -185,7 +181,8 @@ public:
|
||||||
std::cout << SL(3, 1) << std::endl;
|
std::cout << SL(3, 1) << std::endl;
|
||||||
for (const auto& table : db.second) {
|
for (const auto& table : db.second) {
|
||||||
const auto& schema = table.second->schema;
|
const auto& schema = table.second->schema;
|
||||||
std::cout << SF(table.first) << SF(ttToString(schema->tableType)) << SF(pToString(schema->tableInfo.precision)) << IF(schema->vgId) << IF(schema->tableInfo.rowSize) << std::endl;
|
std::cout << SF(table.first) << SF(ttToString(schema->tableType)) << SF(pToString(schema->tableInfo.precision))
|
||||||
|
<< IF(schema->vgId) << IF(schema->tableInfo.rowSize) << std::endl;
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +197,8 @@ public:
|
||||||
int16_t numOfFields = numOfColumns + schema->tableInfo.numOfTags;
|
int16_t numOfFields = numOfColumns + schema->tableInfo.numOfTags;
|
||||||
for (int16_t i = 0; i < numOfFields; ++i) {
|
for (int16_t i = 0; i < numOfFields; ++i) {
|
||||||
const SSchema* col = schema->schema + i;
|
const SSchema* col = schema->schema + i;
|
||||||
std::cout << SF(std::string(col->name)) << SH(ftToString(i, numOfColumns)) << SH(dtToString(col->type)) << IF(col->bytes) << std::endl;
|
std::cout << SF(std::string(col->name)) << SH(ftToString(i, numOfColumns)) << SH(dtToString(col->type))
|
||||||
|
<< IF(col->bytes) << std::endl;
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +217,7 @@ public:
|
||||||
return tit->second;
|
return tit->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<std::string, std::shared_ptr<MockTableMeta>> TableMetaCache;
|
typedef std::map<std::string, std::shared_ptr<MockTableMeta>> TableMetaCache;
|
||||||
typedef std::map<std::string, TableMetaCache> DbMetaCache;
|
typedef std::map<std::string, TableMetaCache> DbMetaCache;
|
||||||
|
|
||||||
|
@ -257,9 +255,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dtToString(int8_t type) const {
|
std::string dtToString(int8_t type) const { return tDataTypes[type].name; }
|
||||||
return tDataTypes[type].name;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ftToString(int16_t colid, int16_t numOfColumns) const {
|
std::string ftToString(int16_t colid, int16_t numOfColumns) const {
|
||||||
return (0 == colid ? "column" : (colid < numOfColumns ? "column" : "tag"));
|
return (0 == colid ? "column" : (colid < numOfColumns ? "column" : "tag"));
|
||||||
|
@ -270,7 +266,8 @@ private:
|
||||||
return table ? table->schema : nullptr;
|
return table ? table->schema : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t copyTableSchemaMeta(const std::string& db, const std::string& tbname, std::unique_ptr<STableMeta>* dst) const {
|
int32_t copyTableSchemaMeta(const std::string& db, const std::string& tbname,
|
||||||
|
std::unique_ptr<STableMeta>* dst) const {
|
||||||
STableMeta* src = getTableSchemaMeta(db, tbname);
|
STableMeta* src = getTableSchemaMeta(db, tbname);
|
||||||
if (nullptr == src) {
|
if (nullptr == src) {
|
||||||
return TSDB_CODE_TSC_INVALID_TABLE_NAME;
|
return TSDB_CODE_TSC_INVALID_TABLE_NAME;
|
||||||
|
@ -310,25 +307,24 @@ private:
|
||||||
DbMetaCache meta_;
|
DbMetaCache meta_;
|
||||||
};
|
};
|
||||||
|
|
||||||
MockCatalogService::MockCatalogService() : impl_(new MockCatalogServiceImpl()) {
|
MockCatalogService::MockCatalogService() : impl_(new MockCatalogServiceImpl()) {}
|
||||||
}
|
|
||||||
|
|
||||||
MockCatalogService::~MockCatalogService() {
|
MockCatalogService::~MockCatalogService() {}
|
||||||
}
|
|
||||||
|
|
||||||
ITableBuilder& MockCatalogService::createTableBuilder(const std::string& db, const std::string& tbname, int8_t tableType, int32_t numOfColumns, int32_t numOfTags) {
|
ITableBuilder& MockCatalogService::createTableBuilder(const std::string& db, const std::string& tbname,
|
||||||
|
int8_t tableType, int32_t numOfColumns, int32_t numOfTags) {
|
||||||
return impl_->createTableBuilder(db, tbname, tableType, numOfColumns, numOfTags);
|
return impl_->createTableBuilder(db, tbname, tableType, numOfColumns, numOfTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockCatalogService::createSubTable(const std::string& db, const std::string& stbname, const std::string& tbname, int16_t vgid) {
|
void MockCatalogService::createSubTable(const std::string& db, const std::string& stbname, const std::string& tbname,
|
||||||
|
int16_t vgid) {
|
||||||
impl_->createSubTable(db, stbname, tbname, vgid);
|
impl_->createSubTable(db, stbname, tbname, vgid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockCatalogService::showTables() const {
|
void MockCatalogService::showTables() const { impl_->showTables(); }
|
||||||
impl_->showTables();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<MockTableMeta> MockCatalogService::getTableMeta(const std::string& db, const std::string& tbname) const {
|
std::shared_ptr<MockTableMeta> MockCatalogService::getTableMeta(const std::string& db,
|
||||||
|
const std::string& tbname) const {
|
||||||
return impl_->getTableMeta(db, tbname);
|
return impl_->getTableMeta(db, tbname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,17 +20,15 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#define ALLOW_FORBID_FUNC
|
||||||
|
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
|
|
||||||
class ITableBuilder {
|
class ITableBuilder {
|
||||||
public:
|
public:
|
||||||
ITableBuilder& addTag(const std::string& name, int8_t type) {
|
ITableBuilder& addTag(const std::string& name, int8_t type) { return addColumn(name, type, tDataTypes[type].bytes); }
|
||||||
return addColumn(name, type, tDataTypes[type].bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
ITableBuilder& addTag(const std::string& name, int8_t type, int32_t bytes) {
|
ITableBuilder& addTag(const std::string& name, int8_t type, int32_t bytes) { return addColumn(name, type, bytes); }
|
||||||
return addColumn(name, type, bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
ITableBuilder& addColumn(const std::string& name, int8_t type) {
|
ITableBuilder& addColumn(const std::string& name, int8_t type) {
|
||||||
return addColumn(name, type, tDataTypes[type].bytes);
|
return addColumn(name, type, tDataTypes[type].bytes);
|
||||||
|
@ -43,9 +41,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MockTableMeta {
|
struct MockTableMeta {
|
||||||
~MockTableMeta() {
|
~MockTableMeta() { taosMemoryFree(schema); }
|
||||||
taosMemoryFree(schema);
|
|
||||||
}
|
|
||||||
|
|
||||||
STableMeta* schema;
|
STableMeta* schema;
|
||||||
std::vector<SVgroupInfo> vgs;
|
std::vector<SVgroupInfo> vgs;
|
||||||
|
@ -53,10 +49,11 @@ struct MockTableMeta {
|
||||||
|
|
||||||
class MockCatalogServiceImpl;
|
class MockCatalogServiceImpl;
|
||||||
class MockCatalogService {
|
class MockCatalogService {
|
||||||
public:
|
public:
|
||||||
MockCatalogService();
|
MockCatalogService();
|
||||||
~MockCatalogService();
|
~MockCatalogService();
|
||||||
ITableBuilder& createTableBuilder(const std::string& db, const std::string& tbname, int8_t tableType, int32_t numOfColumns, int32_t numOfTags = 0);
|
ITableBuilder& createTableBuilder(const std::string& db, const std::string& tbname, int8_t tableType,
|
||||||
|
int32_t numOfColumns, int32_t numOfTags = 0);
|
||||||
void createSubTable(const std::string& db, const std::string& stbname, const std::string& tbname, int16_t vgid);
|
void createSubTable(const std::string& db, const std::string& stbname, const std::string& tbname, int16_t vgid);
|
||||||
void showTables() const;
|
void showTables() const;
|
||||||
std::shared_ptr<MockTableMeta> getTableMeta(const std::string& db, const std::string& tbname) const;
|
std::shared_ptr<MockTableMeta> getTableMeta(const std::string& db, const std::string& tbname) const;
|
||||||
|
@ -65,7 +62,7 @@ public:
|
||||||
int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const;
|
int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const;
|
||||||
int32_t catalogGetTableDistVgInfo(const SName* pTableName, SArray** pVgList) const;
|
int32_t catalogGetTableDistVgInfo(const SName* pTableName, SArray** pVgList) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<MockCatalogServiceImpl> impl_;
|
std::unique_ptr<MockCatalogServiceImpl> impl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "parserTestUtil.h"
|
|
||||||
#include "parInt.h"
|
#include "parInt.h"
|
||||||
|
#include "parserTestUtil.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
|
||||||
class ParserTest : public Test {
|
class ParserTest : public Test {
|
||||||
protected:
|
protected:
|
||||||
void setDatabase(const string& acctId, const string& db) {
|
void setDatabase(const string& acctId, const string& db) {
|
||||||
acctId_ = acctId;
|
acctId_ = acctId;
|
||||||
db_ = db;
|
db_ = db;
|
||||||
|
@ -51,7 +51,7 @@ protected:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int max_err_len = 1024;
|
static const int max_err_len = 1024;
|
||||||
|
|
||||||
bool runImpl(int32_t parseCode, int32_t translateCode) {
|
bool runImpl(int32_t parseCode, int32_t translateCode) {
|
||||||
|
@ -207,7 +207,9 @@ TEST_F(ParserTest, selectConstant) {
|
||||||
bind("SELECT 123, 20.4, 'abc', \"wxy\", TIMESTAMP '2022-02-09 17:30:20', true, false, 10s FROM t1");
|
bind("SELECT 123, 20.4, 'abc', \"wxy\", TIMESTAMP '2022-02-09 17:30:20', true, false, 10s FROM t1");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("SELECT 1234567890123456789012345678901234567890, 20.1234567890123456789012345678901234567890, 'abc', \"wxy\", TIMESTAMP '2022-02-09 17:30:20', true, false, 15s FROM t1");
|
bind(
|
||||||
|
"SELECT 1234567890123456789012345678901234567890, 20.1234567890123456789012345678901234567890, 'abc', \"wxy\", "
|
||||||
|
"TIMESTAMP '2022-02-09 17:30:20', true, false, 15s FROM t1");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("SELECT 123 + 45 FROM t1 where 2 - 1");
|
bind("SELECT 123 + 45 FROM t1 where 2 - 1");
|
||||||
|
@ -449,7 +451,8 @@ TEST_F(ParserTest, createDatabase) {
|
||||||
bind("create database wxy_db");
|
bind("create database wxy_db");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("create database if not exists wxy_db "
|
bind(
|
||||||
|
"create database if not exists wxy_db "
|
||||||
"BLOCKS 100 "
|
"BLOCKS 100 "
|
||||||
"CACHE 100 "
|
"CACHE 100 "
|
||||||
"CACHELAST 2 "
|
"CACHELAST 2 "
|
||||||
|
@ -467,14 +470,13 @@ TEST_F(ParserTest, createDatabase) {
|
||||||
"VGROUPS 100 "
|
"VGROUPS 100 "
|
||||||
"SINGLE_STABLE 0 "
|
"SINGLE_STABLE 0 "
|
||||||
"STREAM_MODE 1 "
|
"STREAM_MODE 1 "
|
||||||
"RETENTIONS '15s:7d,1m:21d,15m:5y'"
|
"RETENTIONS '15s:7d,1m:21d,15m:5y'");
|
||||||
);
|
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("create database if not exists wxy_db "
|
bind(
|
||||||
|
"create database if not exists wxy_db "
|
||||||
"DAYS 100m "
|
"DAYS 100m "
|
||||||
"KEEP 200m,300h,400d "
|
"KEEP 200m,300h,400d ");
|
||||||
);
|
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,14 +486,14 @@ TEST_F(ParserTest, alterDatabase) {
|
||||||
bind("alter database wxy_db BLOCKS 200");
|
bind("alter database wxy_db BLOCKS 200");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("alter database wxy_db "
|
bind(
|
||||||
|
"alter database wxy_db "
|
||||||
"BLOCKS 200 "
|
"BLOCKS 200 "
|
||||||
"CACHELAST 1 "
|
"CACHELAST 1 "
|
||||||
"FSYNC 200 "
|
"FSYNC 200 "
|
||||||
"KEEP 200 "
|
"KEEP 200 "
|
||||||
"QUORUM 2 "
|
"QUORUM 2 "
|
||||||
"WAL 1 "
|
"WAL 1 ");
|
||||||
);
|
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,45 +517,55 @@ TEST_F(ParserTest, createTable) {
|
||||||
bind("create table t1(ts timestamp, c1 int)");
|
bind("create table t1(ts timestamp, c1 int)");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("create table if not exists test.t1("
|
bind(
|
||||||
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 SMALLINT, "
|
"create table if not exists test.t1("
|
||||||
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 NCHAR(30), c14 JSON, c15 VARCHAR(50)) "
|
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 "
|
||||||
"KEEP 100 TTL 100 COMMENT 'test create table' SMA(c1, c2, c3)"
|
"SMALLINT, "
|
||||||
);
|
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 NCHAR(30), "
|
||||||
|
"c14 JSON, c15 VARCHAR(50)) "
|
||||||
|
"KEEP 100 TTL 100 COMMENT 'test create table' SMA(c1, c2, c3)");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("create table if not exists test.t1("
|
bind(
|
||||||
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 SMALLINT, "
|
"create table if not exists test.t1("
|
||||||
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 NCHAR(30), c14 JSON, c15 VARCHAR(50)) "
|
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 "
|
||||||
"TAGS (tsa TIMESTAMP, a1 INT, a2 INT UNSIGNED, a3 BIGINT, a4 BIGINT UNSIGNED, a5 FLOAT, a6 DOUBLE, a7 BINARY(20), a8 SMALLINT, "
|
"SMALLINT, "
|
||||||
"a9 SMALLINT UNSIGNED COMMENT 'test column comment', a10 TINYINT, a11 TINYINT UNSIGNED, a12 BOOL, a13 NCHAR(30), a14 JSON, a15 VARCHAR(50)) "
|
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 NCHAR(30), "
|
||||||
"KEEP 100 TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (min) FILE_FACTOR 0.1 DELAY 2"
|
"c14 JSON, c15 VARCHAR(50)) "
|
||||||
);
|
"TAGS (tsa TIMESTAMP, a1 INT, a2 INT UNSIGNED, a3 BIGINT, a4 BIGINT UNSIGNED, a5 FLOAT, a6 DOUBLE, a7 "
|
||||||
|
"BINARY(20), a8 SMALLINT, "
|
||||||
|
"a9 SMALLINT UNSIGNED COMMENT 'test column comment', a10 TINYINT, a11 TINYINT UNSIGNED, a12 BOOL, a13 NCHAR(30), "
|
||||||
|
"a14 JSON, a15 VARCHAR(50)) "
|
||||||
|
"KEEP 100 TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (min) FILE_FACTOR 0.1 DELAY 2");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("create table if not exists t1 using st1 tags(1, 'wxy')");
|
bind("create table if not exists t1 using st1 tags(1, 'wxy')");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("create table "
|
bind(
|
||||||
|
"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') "
|
||||||
"if not exists test.t4 using test.st1 (tag1, tag2) tags(3, null) "
|
"if not exists test.t4 using test.st1 (tag1, tag2) tags(3, null) "
|
||||||
"if not exists test.t5 using test.st1 (tag1, tag2) tags(null, 'abc') "
|
"if not exists test.t5 using test.st1 (tag1, tag2) tags(null, 'abc') "
|
||||||
"if not exists test.t6 using test.st1 (tag1, tag2) tags(null, null)"
|
"if not exists test.t6 using test.st1 (tag1, tag2) tags(null, null)");
|
||||||
);
|
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("create stable t1(ts timestamp, c1 int) TAGS(id int)");
|
bind("create stable t1(ts timestamp, c1 int) TAGS(id int)");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("create stable if not exists test.t1("
|
bind(
|
||||||
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 SMALLINT, "
|
"create stable if not exists test.t1("
|
||||||
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 NCHAR(30), c14 JSON, c15 VARCHAR(50)) "
|
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 "
|
||||||
"TAGS (tsa TIMESTAMP, a1 INT, a2 INT UNSIGNED, a3 BIGINT, a4 BIGINT UNSIGNED, a5 FLOAT, a6 DOUBLE, a7 BINARY(20), a8 SMALLINT, "
|
"SMALLINT, "
|
||||||
"a9 SMALLINT UNSIGNED COMMENT 'test column comment', a10 TINYINT, a11 TINYINT UNSIGNED, a12 BOOL, a13 NCHAR(30), a14 JSON, a15 VARCHAR(50)) "
|
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 NCHAR(30), "
|
||||||
"KEEP 100 TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (min) FILE_FACTOR 0.1 DELAY 2"
|
"c14 JSON, c15 VARCHAR(50)) "
|
||||||
);
|
"TAGS (tsa TIMESTAMP, a1 INT, a2 INT UNSIGNED, a3 BIGINT, a4 BIGINT UNSIGNED, a5 FLOAT, a6 DOUBLE, a7 "
|
||||||
|
"BINARY(20), a8 SMALLINT, "
|
||||||
|
"a9 SMALLINT UNSIGNED COMMENT 'test column comment', a10 TINYINT, a11 TINYINT UNSIGNED, a12 BOOL, a13 NCHAR(30), "
|
||||||
|
"a14 JSON, a15 VARCHAR(50)) "
|
||||||
|
"KEEP 100 TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (min) FILE_FACTOR 0.1 DELAY 2");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,8 @@ using namespace std;
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
string toString(int32_t code) {
|
string toString(int32_t code) { return tstrerror(code); }
|
||||||
return tstrerror(code);
|
} // namespace
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// syntax:
|
// syntax:
|
||||||
// INSERT INTO
|
// INSERT INTO
|
||||||
|
@ -35,7 +33,7 @@ namespace {
|
||||||
// VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path
|
// VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path
|
||||||
// [...];
|
// [...];
|
||||||
class InsertTest : public Test {
|
class InsertTest : public Test {
|
||||||
protected:
|
protected:
|
||||||
void setDatabase(const string& acctId, const string& db) {
|
void setDatabase(const string& acctId, const string& db) {
|
||||||
acctId_ = acctId;
|
acctId_ = acctId;
|
||||||
db_ = db;
|
db_ = db;
|
||||||
|
@ -44,12 +42,11 @@ protected:
|
||||||
void bind(const char* sql) {
|
void bind(const char* sql) {
|
||||||
reset();
|
reset();
|
||||||
cxt_.acctId = atoi(acctId_.c_str());
|
cxt_.acctId = atoi(acctId_.c_str());
|
||||||
cxt_.db = (char*) db_.c_str();
|
cxt_.db = (char*)db_.c_str();
|
||||||
strcpy(sqlBuf_, sql);
|
strcpy(sqlBuf_, sql);
|
||||||
cxt_.sqlLen = strlen(sql);
|
cxt_.sqlLen = strlen(sql);
|
||||||
sqlBuf_[cxt_.sqlLen] = '\0';
|
sqlBuf_[cxt_.sqlLen] = '\0';
|
||||||
cxt_.pSql = sqlBuf_;
|
cxt_.pSql = sqlBuf_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t run() {
|
int32_t run() {
|
||||||
|
@ -63,7 +60,8 @@ protected:
|
||||||
void dumpReslut() {
|
void dumpReslut() {
|
||||||
SVnodeModifOpStmt* pStmt = getVnodeModifStmt(res_);
|
SVnodeModifOpStmt* pStmt = getVnodeModifStmt(res_);
|
||||||
size_t num = taosArrayGetSize(pStmt->pDataBlocks);
|
size_t num = taosArrayGetSize(pStmt->pDataBlocks);
|
||||||
cout << "payloadType:" << (int32_t)pStmt->payloadType << ", insertType:" << pStmt->insertType << ", numOfVgs:" << num << endl;
|
cout << "payloadType:" << (int32_t)pStmt->payloadType << ", insertType:" << pStmt->insertType
|
||||||
|
<< ", numOfVgs:" << num << endl;
|
||||||
for (size_t i = 0; i < num; ++i) {
|
for (size_t i = 0; i < num; ++i) {
|
||||||
SVgDataBlocks* vg = (SVgDataBlocks*)taosArrayGetP(pStmt->pDataBlocks, i);
|
SVgDataBlocks* vg = (SVgDataBlocks*)taosArrayGetP(pStmt->pDataBlocks, i);
|
||||||
cout << "vgId:" << vg->vg.vgId << ", numOfTables:" << vg->numOfTables << ", dataSize:" << vg->size << endl;
|
cout << "vgId:" << vg->vg.vgId << ", numOfTables:" << vg->numOfTables << ", dataSize:" << vg->size << endl;
|
||||||
|
@ -73,8 +71,9 @@ protected:
|
||||||
SSubmitBlk* blk = (SSubmitBlk*)(submit + 1);
|
SSubmitBlk* blk = (SSubmitBlk*)(submit + 1);
|
||||||
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||||
cout << "Block:" << i << endl;
|
cout << "Block:" << i << endl;
|
||||||
cout << "\tuid:" << be64toh(blk->uid) << ", tid:" << be64toh(blk->suid) << ", padding:" << ntohl(blk->padding) << ", sversion:" << ntohl(blk->sversion)
|
cout << "\tuid:" << be64toh(blk->uid) << ", tid:" << be64toh(blk->suid) << ", padding:" << ntohl(blk->padding)
|
||||||
<< ", dataLen:" << ntohl(blk->dataLen) << ", schemaLen:" << ntohl(blk->schemaLen) << ", numOfRows:" << ntohs(blk->numOfRows) << endl;
|
<< ", sversion:" << ntohl(blk->sversion) << ", dataLen:" << ntohl(blk->dataLen)
|
||||||
|
<< ", schemaLen:" << ntohl(blk->schemaLen) << ", numOfRows:" << ntohs(blk->numOfRows) << endl;
|
||||||
blk = (SSubmitBlk*)(blk->data + ntohl(blk->dataLen));
|
blk = (SSubmitBlk*)(blk->data + ntohl(blk->dataLen));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +101,7 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int max_err_len = 1024;
|
static const int max_err_len = 1024;
|
||||||
static const int max_sql_len = 1024 * 1024;
|
static const int max_sql_len = 1024 * 1024;
|
||||||
|
|
||||||
|
@ -114,9 +113,7 @@ private:
|
||||||
code_ = TSDB_CODE_SUCCESS;
|
code_ = TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SVnodeModifOpStmt* getVnodeModifStmt(SQuery* pQuery) {
|
SVnodeModifOpStmt* getVnodeModifStmt(SQuery* pQuery) { return (SVnodeModifOpStmt*)pQuery->pRoot; }
|
||||||
return (SVnodeModifOpStmt*)pQuery->pRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
string acctId_;
|
string acctId_;
|
||||||
string db_;
|
string db_;
|
||||||
|
@ -141,7 +138,9 @@ TEST_F(InsertTest, singleTableSingleRowTest) {
|
||||||
TEST_F(InsertTest, singleTableMultiRowTest) {
|
TEST_F(InsertTest, singleTableMultiRowTest) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("insert into t1 values (now, 1, 'beijing', 3, 4, 5)(now+1s, 2, 'shanghai', 6, 7, 8)(now+2s, 3, 'guangzhou', 9, 10, 11)");
|
bind(
|
||||||
|
"insert into t1 values (now, 1, 'beijing', 3, 4, 5)(now+1s, 2, 'shanghai', 6, 7, 8)(now+2s, 3, 'guangzhou', 9, "
|
||||||
|
"10, 11)");
|
||||||
ASSERT_EQ(run(), TSDB_CODE_SUCCESS);
|
ASSERT_EQ(run(), TSDB_CODE_SUCCESS);
|
||||||
dumpReslut();
|
dumpReslut();
|
||||||
checkReslut(1, 3);
|
checkReslut(1, 3);
|
||||||
|
@ -161,7 +160,8 @@ TEST_F(InsertTest, multiTableSingleRowTest) {
|
||||||
TEST_F(InsertTest, multiTableMultiRowTest) {
|
TEST_F(InsertTest, multiTableMultiRowTest) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("insert into st1s1 values (now, 1, \"beijing\")(now+1s, 2, \"shanghai\")(now+2s, 3, \"guangzhou\")"
|
bind(
|
||||||
|
"insert into st1s1 values (now, 1, \"beijing\")(now+1s, 2, \"shanghai\")(now+2s, 3, \"guangzhou\")"
|
||||||
" st1s2 values (now, 10, \"131028\")(now+1s, 20, \"132028\")");
|
" st1s2 values (now, 10, \"131028\")(now+1s, 20, \"132028\")");
|
||||||
ASSERT_EQ(run(), TSDB_CODE_SUCCESS);
|
ASSERT_EQ(run(), TSDB_CODE_SUCCESS);
|
||||||
dumpReslut();
|
dumpReslut();
|
||||||
|
@ -174,7 +174,9 @@ TEST_F(InsertTest, multiTableMultiRowTest) {
|
||||||
TEST_F(InsertTest, autoCreateTableTest) {
|
TEST_F(InsertTest, autoCreateTableTest) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("insert into st1s1 using st1 tags(1, 'wxy') values (now, 1, \"beijing\")(now+1s, 2, \"shanghai\")(now+2s, 3, \"guangzhou\")");
|
bind(
|
||||||
|
"insert into st1s1 using st1 tags(1, 'wxy') values (now, 1, \"beijing\")(now+1s, 2, \"shanghai\")(now+2s, 3, "
|
||||||
|
"\"guangzhou\")");
|
||||||
ASSERT_EQ(run(), TSDB_CODE_SUCCESS);
|
ASSERT_EQ(run(), TSDB_CODE_SUCCESS);
|
||||||
dumpReslut();
|
dumpReslut();
|
||||||
checkReslut(1, 3);
|
checkReslut(1, 3);
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* 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 <string>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
@ -23,16 +23,16 @@
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
#define TD_USE_WINSOCK
|
#define TD_USE_WINSOCK
|
||||||
#endif
|
#endif
|
||||||
#include "os.h"
|
|
||||||
#include "parserTestUtil.h"
|
|
||||||
#include "parToken.h"
|
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
#include "mockCatalog.h"
|
#include "mockCatalog.h"
|
||||||
|
#include "os.h"
|
||||||
|
#include "parToken.h"
|
||||||
|
#include "parserTestUtil.h"
|
||||||
|
|
||||||
bool g_isDump = false;
|
bool g_isDump = false;
|
||||||
|
|
||||||
class ParserEnv : public testing::Environment {
|
class ParserEnv : public testing::Environment {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
initMetaDataEnv();
|
initMetaDataEnv();
|
||||||
generateMetaData();
|
generateMetaData();
|
||||||
|
@ -50,11 +50,8 @@ public:
|
||||||
|
|
||||||
static void parseArg(int argc, char* argv[]) {
|
static void parseArg(int argc, char* argv[]) {
|
||||||
int opt = 0;
|
int opt = 0;
|
||||||
const char *optstring = "";
|
const char* optstring = "";
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {{"dump", no_argument, NULL, 'd'}, {0, 0, 0, 0}};
|
||||||
{"dump", no_argument, NULL, 'd'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) {
|
while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'd':
|
case 'd':
|
||||||
|
|
|
@ -24,7 +24,8 @@ typedef struct SLogicPlanContext {
|
||||||
typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, SSelectStmt*, SLogicNode**);
|
typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, SSelectStmt*, SLogicNode**);
|
||||||
typedef int32_t (*FCreateSetOpLogicNode)(SLogicPlanContext*, SSetOperator*, SLogicNode**);
|
typedef int32_t (*FCreateSetOpLogicNode)(SLogicPlanContext*, SSetOperator*, SLogicNode**);
|
||||||
|
|
||||||
static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode);
|
static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable,
|
||||||
|
SLogicNode** pLogicNode);
|
||||||
static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogicNode** pLogicNode);
|
static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogicNode** pLogicNode);
|
||||||
|
|
||||||
typedef struct SRewriteExprCxt {
|
typedef struct SRewriteExprCxt {
|
||||||
|
@ -87,13 +88,13 @@ static EDealRes doNameExpr(SNode* pNode, void* pContext) {
|
||||||
|
|
||||||
static int32_t rewriteExprForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ESqlClause clause) {
|
static int32_t rewriteExprForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ESqlClause clause) {
|
||||||
nodesWalkExprs(pExprs, doNameExpr, NULL);
|
nodesWalkExprs(pExprs, doNameExpr, NULL);
|
||||||
SRewriteExprCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs };
|
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs};
|
||||||
nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt);
|
nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt);
|
||||||
return cxt.errCode;
|
return cxt.errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewriteExprs(SNodeList* pExprs, SNodeList* pTarget) {
|
static int32_t rewriteExprs(SNodeList* pExprs, SNodeList* pTarget) {
|
||||||
SRewriteExprCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs };
|
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs};
|
||||||
nodesRewriteExprs(pTarget, doRewriteExpr, &cxt);
|
nodesRewriteExprs(pTarget, doRewriteExpr, &cxt);
|
||||||
return cxt.errCode;
|
return cxt.errCode;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +116,8 @@ static int32_t pushLogicNode(SLogicPlanContext* pCxt, SLogicNode** pOldRoot, SLo
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, FCreateLogicNode func, SLogicNode** pRoot) {
|
static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, FCreateLogicNode func,
|
||||||
|
SLogicNode** pRoot) {
|
||||||
SLogicNode* pNode = NULL;
|
SLogicNode* pNode = NULL;
|
||||||
int32_t code = func(pCxt, pSelect, &pNode);
|
int32_t code = func(pCxt, pSelect, &pNode);
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pNode) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pNode) {
|
||||||
|
@ -191,7 +193,8 @@ static int32_t addPrimaryKeyCol(uint64_t tableId, SNodeList** pCols) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable, SLogicNode** pLogicNode) {
|
static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable,
|
||||||
|
SLogicNode** pLogicNode) {
|
||||||
SScanLogicNode* pScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN);
|
SScanLogicNode* pScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN);
|
||||||
if (NULL == pScan) {
|
if (NULL == pScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -245,18 +248,18 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable, SLogicNode** pLogicNode) {
|
static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable,
|
||||||
|
SLogicNode** pLogicNode) {
|
||||||
int32_t code = createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode);
|
int32_t code = createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
FOREACH(pNode, (*pLogicNode)->pTargets) {
|
FOREACH(pNode, (*pLogicNode)->pTargets) { strcpy(((SColumnNode*)pNode)->tableAlias, pTable->table.tableAlias); }
|
||||||
strcpy(((SColumnNode*)pNode)->tableAlias, pTable->table.tableAlias);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SJoinTableNode* pJoinTable, SLogicNode** pLogicNode) {
|
static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SJoinTableNode* pJoinTable,
|
||||||
|
SLogicNode** pLogicNode) {
|
||||||
SJoinLogicNode* pJoin = (SJoinLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_JOIN);
|
SJoinLogicNode* pJoin = (SJoinLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_JOIN);
|
||||||
if (NULL == pJoin) {
|
if (NULL == pJoin) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -316,7 +319,8 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode) {
|
static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable,
|
||||||
|
SLogicNode** pLogicNode) {
|
||||||
switch (nodeType(pTable)) {
|
switch (nodeType(pTable)) {
|
||||||
case QUERY_NODE_REAL_TABLE:
|
case QUERY_NODE_REAL_TABLE:
|
||||||
return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode);
|
return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode);
|
||||||
|
@ -330,7 +334,8 @@ static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pS
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode) {
|
static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable,
|
||||||
|
SLogicNode** pLogicNode) {
|
||||||
SLogicNode* pNode = NULL;
|
SLogicNode* pNode = NULL;
|
||||||
int32_t code = doCreateLogicNodeByTable(pCxt, pSelect, pTable, &pNode);
|
int32_t code = doCreateLogicNodeByTable(pCxt, pSelect, pTable, &pNode);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -392,7 +397,7 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createColumnByRewriteExps(SLogicPlanContext* pCxt, SNodeList* pExprs, SNodeList** pList) {
|
static int32_t createColumnByRewriteExps(SLogicPlanContext* pCxt, SNodeList* pExprs, SNodeList** pList) {
|
||||||
SCreateColumnCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pList = (NULL == *pList ? nodesMakeList() : *pList) };
|
SCreateColumnCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pList = (NULL == *pList ? nodesMakeList() : *pList)};
|
||||||
if (NULL == cxt.pList) {
|
if (NULL == cxt.pList) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -409,12 +414,7 @@ static int32_t createColumnByRewriteExps(SLogicPlanContext* pCxt, SNodeList* pEx
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||||
SNodeList* pAggFuncs = NULL;
|
if (!pSelect->hasAggFuncs && NULL == pSelect->pGroupByList) {
|
||||||
int32_t code = nodesCollectFuncs(pSelect, fmIsAggFunc, &pAggFuncs);
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
if (NULL == pAggFuncs && NULL == pSelect->pGroupByList) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,6 +423,8 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
// set grouyp keys, agg funcs and having conditions
|
// set grouyp keys, agg funcs and having conditions
|
||||||
if (NULL != pSelect->pGroupByList) {
|
if (NULL != pSelect->pGroupByList) {
|
||||||
pAgg->pGroupKeys = nodesCloneList(pSelect->pGroupByList);
|
pAgg->pGroupKeys = nodesCloneList(pSelect->pGroupByList);
|
||||||
|
@ -431,17 +433,16 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pAggFuncs) {
|
|
||||||
pAgg->pAggFuncs = nodesCloneList(pAggFuncs);
|
|
||||||
if (NULL == pAgg->pAggFuncs) {
|
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rewrite the expression in subsequent clauses
|
// rewrite the expression in subsequent clauses
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = rewriteExprForSelect(pAgg->pGroupKeys, pSelect, SQL_CLAUSE_GROUP_BY);
|
code = rewriteExprForSelect(pAgg->pGroupKeys, pSelect, SQL_CLAUSE_GROUP_BY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code && pSelect->hasAggFuncs) {
|
||||||
|
code = nodesCollectFuncs(pSelect, fmIsAggFunc, &pAgg->pAggFuncs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// rewrite the expression in subsequent clauses
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = rewriteExprForSelect(pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY);
|
code = rewriteExprForSelect(pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY);
|
||||||
}
|
}
|
||||||
|
@ -470,7 +471,8 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SWindowLogicNode* pWindow, SLogicNode** pLogicNode) {
|
static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SWindowLogicNode* pWindow,
|
||||||
|
SLogicNode** pLogicNode) {
|
||||||
int32_t code = nodesCollectFuncs(pSelect, fmIsWindowClauseFunc, &pWindow->pFuncs);
|
int32_t code = nodesCollectFuncs(pSelect, fmIsWindowClauseFunc, &pWindow->pFuncs);
|
||||||
|
|
||||||
if (pCxt->pPlanCxt->streamQuery) {
|
if (pCxt->pPlanCxt->streamQuery) {
|
||||||
|
@ -486,6 +488,8 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
|
||||||
code = createColumnByRewriteExps(pCxt, pWindow->pFuncs, &pWindow->node.pTargets);
|
code = createColumnByRewriteExps(pCxt, pWindow->pFuncs, &pWindow->node.pTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pSelect->hasAggFuncs = false;
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pLogicNode = (SLogicNode*)pWindow;
|
*pLogicNode = (SLogicNode*)pWindow;
|
||||||
} else {
|
} else {
|
||||||
|
@ -495,7 +499,8 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindowNode* pState, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindowNode* pState, SSelectStmt* pSelect,
|
||||||
|
SLogicNode** pLogicNode) {
|
||||||
SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
||||||
if (NULL == pWindow) {
|
if (NULL == pWindow) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -513,7 +518,8 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo
|
||||||
return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode);
|
return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession,
|
||||||
|
SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||||
SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
||||||
if (NULL == pWindow) {
|
if (NULL == pWindow) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -531,7 +537,8 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW
|
||||||
return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode);
|
return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval,
|
||||||
|
SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||||
SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW);
|
||||||
if (NULL == pWindow) {
|
if (NULL == pWindow) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -542,7 +549,8 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
|
||||||
pWindow->intervalUnit = ((SValueNode*)pInterval->pInterval)->unit;
|
pWindow->intervalUnit = ((SValueNode*)pInterval->pInterval)->unit;
|
||||||
pWindow->offset = (NULL != pInterval->pOffset ? ((SValueNode*)pInterval->pOffset)->datum.i : 0);
|
pWindow->offset = (NULL != pInterval->pOffset ? ((SValueNode*)pInterval->pOffset)->datum.i : 0);
|
||||||
pWindow->sliding = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->datum.i : pWindow->interval);
|
pWindow->sliding = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->datum.i : pWindow->interval);
|
||||||
pWindow->slidingUnit = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->unit : pWindow->intervalUnit);
|
pWindow->slidingUnit =
|
||||||
|
(NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->unit : pWindow->intervalUnit);
|
||||||
|
|
||||||
pWindow->pTspk = nodesCloneNode(pInterval->pCol);
|
pWindow->pTspk = nodesCloneNode(pInterval->pCol);
|
||||||
if (NULL == pWindow->pTspk) {
|
if (NULL == pWindow->pTspk) {
|
||||||
|
@ -615,7 +623,8 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createColumnByProjections(SLogicPlanContext* pCxt, const char* pStmtName, SNodeList* pExprs, SNodeList** pCols) {
|
static int32_t createColumnByProjections(SLogicPlanContext* pCxt, const char* pStmtName, SNodeList* pExprs,
|
||||||
|
SNodeList** pCols) {
|
||||||
SNodeList* pList = nodesMakeList();
|
SNodeList* pList = nodesMakeList();
|
||||||
if (NULL == pList) {
|
if (NULL == pList) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -778,7 +787,8 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createSetOpChildLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator, FCreateSetOpLogicNode func, SLogicNode** pRoot) {
|
static int32_t createSetOpChildLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator,
|
||||||
|
FCreateSetOpLogicNode func, SLogicNode** pRoot) {
|
||||||
SLogicNode* pNode = NULL;
|
SLogicNode* pNode = NULL;
|
||||||
int32_t code = func(pCxt, pSetOperator, &pNode);
|
int32_t code = func(pCxt, pSetOperator, &pNode);
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pNode) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pNode) {
|
||||||
|
@ -823,7 +833,8 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator, SLogicNode** pLogicNode) {
|
static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator,
|
||||||
|
SLogicNode** pLogicNode) {
|
||||||
SProjectLogicNode* pProject = (SProjectLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT);
|
SProjectLogicNode* pProject = (SProjectLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT);
|
||||||
if (NULL == pProject) {
|
if (NULL == pProject) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -927,7 +938,8 @@ static int32_t createSetOpLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetO
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createSetOperatorLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator, SLogicNode** pLogicNode) {
|
static int32_t createSetOperatorLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator,
|
||||||
|
SLogicNode** pLogicNode) {
|
||||||
SLogicNode* pRoot = NULL;
|
SLogicNode* pRoot = NULL;
|
||||||
int32_t code = createSetOpLogicNode(pCxt, pSetOperator, &pRoot);
|
int32_t code = createSetOpLogicNode(pCxt, pSetOperator, &pRoot);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -944,7 +956,9 @@ static int32_t createSetOperatorLogicNode(SLogicPlanContext* pCxt, SSetOperator*
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getMsgType(ENodeType sqlType) {
|
static int32_t getMsgType(ENodeType sqlType) {
|
||||||
return (QUERY_NODE_CREATE_TABLE_STMT == sqlType || QUERY_NODE_CREATE_MULTI_TABLE_STMT == sqlType) ? TDMT_VND_CREATE_TABLE : TDMT_VND_SUBMIT;
|
return (QUERY_NODE_CREATE_TABLE_STMT == sqlType || QUERY_NODE_CREATE_MULTI_TABLE_STMT == sqlType)
|
||||||
|
? TDMT_VND_CREATE_TABLE
|
||||||
|
: TDMT_VND_SUBMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpStmt* pStmt, SLogicNode** pLogicNode) {
|
static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpStmt* pStmt, SLogicNode** pLogicNode) {
|
||||||
|
@ -975,7 +989,7 @@ static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogi
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t createLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode) {
|
int32_t createLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode) {
|
||||||
SLogicPlanContext cxt = { .pPlanCxt = pCxt };
|
SLogicPlanContext cxt = {.pPlanCxt = pCxt};
|
||||||
int32_t code = createQueryLogicNode(&cxt, pCxt->pAstRoot, pLogicNode);
|
int32_t code = createQueryLogicNode(&cxt, pCxt->pAstRoot, pLogicNode);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* 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 "planInt.h"
|
|
||||||
#include "functionMgt.h"
|
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
|
#include "functionMgt.h"
|
||||||
|
#include "planInt.h"
|
||||||
|
|
||||||
#define OPTIMIZE_FLAG_MASK(n) (1 << n)
|
#define OPTIMIZE_FLAG_MASK(n) (1 << n)
|
||||||
|
|
||||||
|
@ -101,8 +101,8 @@ static bool osdMayBeOptimized(SLogicNode* pNode) {
|
||||||
if (TSDB_SUPER_TABLE == ((SScanLogicNode*)pNode)->pMeta->tableType) {
|
if (TSDB_SUPER_TABLE == ((SScanLogicNode*)pNode)->pMeta->tableType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (NULL == pNode->pParent ||
|
if (NULL == pNode->pParent || (QUERY_NODE_LOGIC_PLAN_WINDOW != nodeType(pNode->pParent) &&
|
||||||
(QUERY_NODE_LOGIC_PLAN_WINDOW != nodeType(pNode->pParent) && QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent))) {
|
QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent)) {
|
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode->pParent)) {
|
||||||
|
@ -150,7 +150,7 @@ static int32_t osdMatch(SOptimizeContext* pCxt, SLogicNode* pLogicNode, SOsdInfo
|
||||||
return osdGetRelatedFuncs(pInfo->pScan, &pInfo->pSdrFuncs, &pInfo->pDsoFuncs);
|
return osdGetRelatedFuncs(pInfo->pScan, &pInfo->pSdrFuncs, &pInfo->pDsoFuncs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l , EFuncDataRequired r) {
|
static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l, EFuncDataRequired r) {
|
||||||
switch (l) {
|
switch (l) {
|
||||||
case FUNC_DATA_REQUIRED_DATA_LOAD:
|
case FUNC_DATA_REQUIRED_DATA_LOAD:
|
||||||
return l;
|
return l;
|
||||||
|
@ -399,13 +399,18 @@ static EDealRes cpdIsMultiTableCondImpl(SNode* pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static ECondAction cpdCondAction(EJoinType joinType, SNodeList* pLeftCols, SNodeList* pRightCols, SNode* pNode) {
|
static ECondAction cpdCondAction(EJoinType joinType, SNodeList* pLeftCols, SNodeList* pRightCols, SNode* pNode) {
|
||||||
SCpdIsMultiTableCondCxt cxt = { .pLeftCols = pLeftCols, .pRightCols = pRightCols, .havaLeftCol = false, .haveRightCol = false };
|
SCpdIsMultiTableCondCxt cxt = {
|
||||||
|
.pLeftCols = pLeftCols, .pRightCols = pRightCols, .havaLeftCol = false, .haveRightCol = false};
|
||||||
nodesWalkExpr(pNode, cpdIsMultiTableCondImpl, &cxt);
|
nodesWalkExpr(pNode, cpdIsMultiTableCondImpl, &cxt);
|
||||||
return (JOIN_TYPE_INNER != joinType ? COND_ACTION_STAY :
|
return (JOIN_TYPE_INNER != joinType
|
||||||
(cxt.havaLeftCol && cxt.haveRightCol ? COND_ACTION_PUSH_JOIN : (cxt.havaLeftCol ? COND_ACTION_PUSH_LEFT_CHILD : COND_ACTION_PUSH_RIGHT_CHILD)));
|
? COND_ACTION_STAY
|
||||||
|
: (cxt.havaLeftCol && cxt.haveRightCol
|
||||||
|
? COND_ACTION_PUSH_JOIN
|
||||||
|
: (cxt.havaLeftCol ? COND_ACTION_PUSH_LEFT_CHILD : COND_ACTION_PUSH_RIGHT_CHILD)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cpdPartitionLogicCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond, SNode** pRightChildCond) {
|
static int32_t cpdPartitionLogicCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond,
|
||||||
|
SNode** pRightChildCond) {
|
||||||
SLogicConditionNode* pLogicCond = (SLogicConditionNode*)pJoin->node.pConditions;
|
SLogicConditionNode* pLogicCond = (SLogicConditionNode*)pJoin->node.pConditions;
|
||||||
if (LOGIC_COND_TYPE_AND != pLogicCond->condType) {
|
if (LOGIC_COND_TYPE_AND != pLogicCond->condType) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -473,7 +478,8 @@ static int32_t cpdPartitionLogicCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNo
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cpdPartitionOpCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond, SNode** pRightChildCond) {
|
static int32_t cpdPartitionOpCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond,
|
||||||
|
SNode** pRightChildCond) {
|
||||||
SNodeList* pLeftCols = ((SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 0))->pTargets;
|
SNodeList* pLeftCols = ((SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 0))->pTargets;
|
||||||
SNodeList* pRightCols = ((SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1))->pTargets;
|
SNodeList* pRightCols = ((SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1))->pTargets;
|
||||||
ECondAction condAction = cpdCondAction(pJoin->joinType, pLeftCols, pRightCols, pJoin->node.pConditions);
|
ECondAction condAction = cpdCondAction(pJoin->joinType, pLeftCols, pRightCols, pJoin->node.pConditions);
|
||||||
|
@ -490,7 +496,8 @@ static int32_t cpdPartitionOpCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t cpdPartitionCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond, SNode** pRightChildCond) {
|
static int32_t cpdPartitionCond(SJoinLogicNode* pJoin, SNode** pOnCond, SNode** pLeftChildCond,
|
||||||
|
SNode** pRightChildCond) {
|
||||||
if (QUERY_NODE_LOGIC_CONDITION == nodeType(pJoin->node.pConditions)) {
|
if (QUERY_NODE_LOGIC_CONDITION == nodeType(pJoin->node.pConditions)) {
|
||||||
return cpdPartitionLogicCond(pJoin, pOnCond, pLeftChildCond, pRightChildCond);
|
return cpdPartitionLogicCond(pJoin, pOnCond, pLeftChildCond, pRightChildCond);
|
||||||
} else {
|
} else {
|
||||||
|
@ -762,16 +769,14 @@ static int32_t opkOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
return opkOptimizeImpl(pCxt, pSort);
|
return opkOptimizeImpl(pCxt, pSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const SOptimizeRule optimizeRuleSet[] = {
|
static const SOptimizeRule optimizeRuleSet[] = {{.pName = "OptimizeScanData", .optimizeFunc = osdOptimize},
|
||||||
{ .pName = "OptimizeScanData", .optimizeFunc = osdOptimize },
|
{.pName = "ConditionPushDown", .optimizeFunc = cpdOptimize},
|
||||||
{ .pName = "ConditionPushDown", .optimizeFunc = cpdOptimize },
|
{.pName = "OrderByPrimaryKey", .optimizeFunc = opkOptimize}};
|
||||||
{ .pName = "OrderByPrimaryKey", .optimizeFunc = opkOptimize }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int32_t optimizeRuleNum = (sizeof(optimizeRuleSet) / sizeof(SOptimizeRule));
|
static const int32_t optimizeRuleNum = (sizeof(optimizeRuleSet) / sizeof(SOptimizeRule));
|
||||||
|
|
||||||
static int32_t applyOptimizeRule(SPlanContext* pCxt, SLogicNode* pLogicNode) {
|
static int32_t applyOptimizeRule(SPlanContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
SOptimizeContext cxt = { .pPlanCxt = pCxt, .optimized = false };
|
SOptimizeContext cxt = {.pPlanCxt = pCxt, .optimized = false};
|
||||||
do {
|
do {
|
||||||
cxt.optimized = false;
|
cxt.optimized = false;
|
||||||
for (int32_t i = 0; i < optimizeRuleNum; ++i) {
|
for (int32_t i = 0; i < optimizeRuleNum; ++i) {
|
||||||
|
@ -784,6 +789,4 @@ static int32_t applyOptimizeRule(SPlanContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t optimizeLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode) {
|
int32_t optimizeLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode) { return applyOptimizeRule(pCxt, pLogicNode); }
|
||||||
return applyOptimizeRule(pCxt, pLogicNode);
|
|
||||||
}
|
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
|
|
||||||
#include "planInt.h"
|
#include "planInt.h"
|
||||||
|
|
||||||
|
#include "catalog.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "catalog.h"
|
|
||||||
|
|
||||||
typedef struct SSlotIdInfo {
|
typedef struct SSlotIdInfo {
|
||||||
int16_t slotId;
|
int16_t slotId;
|
||||||
|
@ -84,16 +84,16 @@ static int32_t createTarget(SNode* pNode, int16_t dataBlockId, int16_t slotId, S
|
||||||
static int32_t putSlotToHashImpl(int16_t dataBlockId, int16_t slotId, const char* pName, int32_t len, SHashObj* pHash) {
|
static int32_t putSlotToHashImpl(int16_t dataBlockId, int16_t slotId, const char* pName, int32_t len, SHashObj* pHash) {
|
||||||
SSlotIndex* pIndex = taosHashGet(pHash, pName, len);
|
SSlotIndex* pIndex = taosHashGet(pHash, pName, len);
|
||||||
if (NULL != pIndex) {
|
if (NULL != pIndex) {
|
||||||
SSlotIdInfo info = { .slotId = slotId, .set = false };
|
SSlotIdInfo info = {.slotId = slotId, .set = false};
|
||||||
taosArrayPush(pIndex->pSlotIdsInfo, &info);
|
taosArrayPush(pIndex->pSlotIdsInfo, &info);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSlotIndex index = { .dataBlockId = dataBlockId, .pSlotIdsInfo = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SSlotIdInfo)) };
|
SSlotIndex index = {.dataBlockId = dataBlockId, .pSlotIdsInfo = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SSlotIdInfo))};
|
||||||
if (NULL == index.pSlotIdsInfo) {
|
if (NULL == index.pSlotIdsInfo) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
SSlotIdInfo info = { .slotId = slotId, .set = false };
|
SSlotIdInfo info = {.slotId = slotId, .set = false};
|
||||||
taosArrayPush(index.pSlotIdsInfo, &info);
|
taosArrayPush(index.pSlotIdsInfo, &info);
|
||||||
return taosHashPut(pHash, pName, len, &index, sizeof(SSlotIndex));
|
return taosHashPut(pHash, pName, len, &index, sizeof(SSlotIndex));
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,8 @@ static int32_t putSlotToHash(int16_t dataBlockId, int16_t slotId, SNode* pNode,
|
||||||
return putSlotToHashImpl(dataBlockId, slotId, name, len, pHash);
|
return putSlotToHashImpl(dataBlockId, slotId, name, len, pHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createDataBlockDescHash(SPhysiPlanContext* pCxt, int32_t capacity, int16_t dataBlockId, SHashObj** pDescHash) {
|
static int32_t createDataBlockDescHash(SPhysiPlanContext* pCxt, int32_t capacity, int16_t dataBlockId,
|
||||||
|
SHashObj** pDescHash) {
|
||||||
SHashObj* pHash = taosHashInit(capacity, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
SHashObj* pHash = taosHashInit(capacity, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||||
if (NULL == pHash) {
|
if (NULL == pHash) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -118,7 +119,8 @@ static int32_t createDataBlockDescHash(SPhysiPlanContext* pCxt, int32_t capacity
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc, SHashObj* pHash) {
|
static int32_t buildDataBlockSlots(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc,
|
||||||
|
SHashObj* pHash) {
|
||||||
pDataBlockDesc->pSlots = nodesMakeList();
|
pDataBlockDesc->pSlots = nodesMakeList();
|
||||||
if (NULL == pDataBlockDesc->pSlots) {
|
if (NULL == pDataBlockDesc->pSlots) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -177,7 +179,8 @@ static int16_t getUnsetSlotId(const SArray* pSlotIdsInfo) {
|
||||||
return ((SSlotIdInfo*)taosArrayGet(pSlotIdsInfo, 0))->slotId;
|
return ((SSlotIdInfo*)taosArrayGet(pSlotIdsInfo, 0))->slotId;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc, const char* pStmtName, bool output) {
|
static int32_t addDataBlockSlotsImpl(SPhysiPlanContext* pCxt, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc,
|
||||||
|
const char* pStmtName, bool output) {
|
||||||
if (NULL == pList) {
|
if (NULL == pList) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +245,8 @@ static int32_t addDataBlockSlot(SPhysiPlanContext* pCxt, SNode** pNode, SDataBlo
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t addDataBlockSlotsForProject(SPhysiPlanContext* pCxt, const char* pStmtName, SNodeList* pList, SDataBlockDescNode* pDataBlockDesc) {
|
static int32_t addDataBlockSlotsForProject(SPhysiPlanContext* pCxt, const char* pStmtName, SNodeList* pList,
|
||||||
|
SDataBlockDescNode* pDataBlockDesc) {
|
||||||
return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, pStmtName, true);
|
return addDataBlockSlotsImpl(pCxt, pList, pDataBlockDesc, pStmtName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +281,8 @@ static EDealRes doSetSlotId(SNode* pNode, void* pContext) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setNodeSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, int16_t rightDataBlockId, SNode* pNode, SNode** pOutput) {
|
static int32_t setNodeSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, int16_t rightDataBlockId, SNode* pNode,
|
||||||
|
SNode** pOutput) {
|
||||||
SNode* pRes = nodesCloneNode(pNode);
|
SNode* pRes = nodesCloneNode(pNode);
|
||||||
if (NULL == pRes) {
|
if (NULL == pRes) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -286,8 +291,7 @@ static int32_t setNodeSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, i
|
||||||
SSetSlotIdCxt cxt = {
|
SSetSlotIdCxt cxt = {
|
||||||
.errCode = TSDB_CODE_SUCCESS,
|
.errCode = TSDB_CODE_SUCCESS,
|
||||||
.pLeftHash = taosArrayGetP(pCxt->pLocationHelper, leftDataBlockId),
|
.pLeftHash = taosArrayGetP(pCxt->pLocationHelper, leftDataBlockId),
|
||||||
.pRightHash = (rightDataBlockId < 0 ? NULL : taosArrayGetP(pCxt->pLocationHelper, rightDataBlockId))
|
.pRightHash = (rightDataBlockId < 0 ? NULL : taosArrayGetP(pCxt->pLocationHelper, rightDataBlockId))};
|
||||||
};
|
|
||||||
nodesWalkExpr(pRes, doSetSlotId, &cxt);
|
nodesWalkExpr(pRes, doSetSlotId, &cxt);
|
||||||
if (TSDB_CODE_SUCCESS != cxt.errCode) {
|
if (TSDB_CODE_SUCCESS != cxt.errCode) {
|
||||||
nodesDestroyNode(pRes);
|
nodesDestroyNode(pRes);
|
||||||
|
@ -298,7 +302,8 @@ static int32_t setNodeSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, i
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setListSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, int16_t rightDataBlockId, const SNodeList* pList, SNodeList** pOutput) {
|
static int32_t setListSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, int16_t rightDataBlockId,
|
||||||
|
const SNodeList* pList, SNodeList** pOutput) {
|
||||||
SNodeList* pRes = nodesCloneList(pList);
|
SNodeList* pRes = nodesCloneList(pList);
|
||||||
if (NULL == pRes) {
|
if (NULL == pRes) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -307,8 +312,7 @@ static int32_t setListSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, i
|
||||||
SSetSlotIdCxt cxt = {
|
SSetSlotIdCxt cxt = {
|
||||||
.errCode = TSDB_CODE_SUCCESS,
|
.errCode = TSDB_CODE_SUCCESS,
|
||||||
.pLeftHash = taosArrayGetP(pCxt->pLocationHelper, leftDataBlockId),
|
.pLeftHash = taosArrayGetP(pCxt->pLocationHelper, leftDataBlockId),
|
||||||
.pRightHash = (rightDataBlockId < 0 ? NULL : taosArrayGetP(pCxt->pLocationHelper, rightDataBlockId))
|
.pRightHash = (rightDataBlockId < 0 ? NULL : taosArrayGetP(pCxt->pLocationHelper, rightDataBlockId))};
|
||||||
};
|
|
||||||
nodesWalkExprs(pRes, doSetSlotId, &cxt);
|
nodesWalkExprs(pRes, doSetSlotId, &cxt);
|
||||||
if (TSDB_CODE_SUCCESS != cxt.errCode) {
|
if (TSDB_CODE_SUCCESS != cxt.errCode) {
|
||||||
nodesDestroyList(pRes);
|
nodesDestroyList(pRes);
|
||||||
|
@ -346,7 +350,8 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, uint8_t precision, SLo
|
||||||
|
|
||||||
static int32_t setConditionsSlotId(SPhysiPlanContext* pCxt, const SLogicNode* pLogicNode, SPhysiNode* pPhysiNode) {
|
static int32_t setConditionsSlotId(SPhysiPlanContext* pCxt, const SLogicNode* pLogicNode, SPhysiNode* pPhysiNode) {
|
||||||
if (NULL != pLogicNode->pConditions) {
|
if (NULL != pLogicNode->pConditions) {
|
||||||
return setNodeSlotId(pCxt, pPhysiNode->pOutputDataBlockDesc->dataBlockId, -1, pLogicNode->pConditions, &pPhysiNode->pConditions);
|
return setNodeSlotId(pCxt, pPhysiNode->pOutputDataBlockDesc->dataBlockId, -1, pLogicNode->pConditions,
|
||||||
|
&pPhysiNode->pConditions);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -364,15 +369,11 @@ static int32_t sortScanCols(SNodeList* pScanCols) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* pCol = NULL;
|
SNode* pCol = NULL;
|
||||||
FOREACH(pCol, pScanCols) {
|
FOREACH(pCol, pScanCols) { taosArrayPush(pArray, &pCol); }
|
||||||
taosArrayPush(pArray, &pCol);
|
|
||||||
}
|
|
||||||
taosArraySort(pArray, colIdCompare);
|
taosArraySort(pArray, colIdCompare);
|
||||||
|
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
FOREACH(pCol, pScanCols) {
|
FOREACH(pCol, pScanCols) { REPLACE_NODE(taosArrayGetP(pArray, index++)); }
|
||||||
REPLACE_NODE(taosArrayGetP(pArray, index++));
|
|
||||||
}
|
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -386,7 +387,8 @@ static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhys
|
||||||
return sortScanCols(pScanPhysiNode->pScanCols);
|
return sortScanCols(pScanPhysiNode->pScanCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createScanPhysiNodeFinalize(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode, SScanPhysiNode* pScanPhysiNode, SPhysiNode** pPhyNode) {
|
static int32_t createScanPhysiNodeFinalize(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode,
|
||||||
|
SScanPhysiNode* pScanPhysiNode, SPhysiNode** pPhyNode) {
|
||||||
int32_t code = createScanCols(pCxt, pScanPhysiNode, pScanLogicNode->pScanCols);
|
int32_t code = createScanCols(pCxt, pScanPhysiNode, pScanLogicNode->pScanCols);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
// Data block describe also needs to be set without scanning column, such as SELECT COUNT(*) FROM t
|
// Data block describe also needs to be set without scanning column, such as SELECT COUNT(*) FROM t
|
||||||
|
@ -416,15 +418,19 @@ static void vgroupInfoToNodeAddr(const SVgroupInfo* vg, SQueryNodeAddr* pNodeAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
|
||||||
STagScanPhysiNode* pTagScan = (STagScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN);
|
STagScanPhysiNode* pTagScan = (STagScanPhysiNode*)makePhysiNode(
|
||||||
|
pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN);
|
||||||
if (NULL == pTagScan) {
|
if (NULL == pTagScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pTagScan, pPhyNode);
|
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pTagScan, pPhyNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
|
||||||
STableScanPhysiNode* pTableScan = (STableScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN);
|
SPhysiNode** pPhyNode) {
|
||||||
|
STableScanPhysiNode* pTableScan =
|
||||||
|
(STableScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN);
|
||||||
if (NULL == pTableScan) {
|
if (NULL == pTableScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -451,8 +457,11 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
|
||||||
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode);
|
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
|
||||||
SSystemTableScanPhysiNode* pScan = (SSystemTableScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN);
|
SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
|
||||||
|
SSystemTableScanPhysiNode* pScan =
|
||||||
|
(SSystemTableScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision,
|
||||||
|
(SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN);
|
||||||
if (NULL == pScan) {
|
if (NULL == pScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -463,7 +472,7 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
|
||||||
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode);
|
||||||
taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode);
|
taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode);
|
||||||
} else {
|
} else {
|
||||||
SQueryNodeAddr addr = { .nodeId = MNODE_HANDLE, .epSet = pCxt->pPlanCxt->mgmtEpSet };
|
SQueryNodeAddr addr = {.nodeId = MNODE_HANDLE, .epSet = pCxt->pPlanCxt->mgmtEpSet};
|
||||||
taosArrayPush(pCxt->pExecNodeList, &addr);
|
taosArrayPush(pCxt->pExecNodeList, &addr);
|
||||||
}
|
}
|
||||||
pScan->mgmtEpSet = pCxt->pPlanCxt->mgmtEpSet;
|
pScan->mgmtEpSet = pCxt->pPlanCxt->mgmtEpSet;
|
||||||
|
@ -472,15 +481,19 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
|
||||||
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pScan, pPhyNode);
|
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pScan, pPhyNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createStreamScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createStreamScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
|
||||||
SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN);
|
SPhysiNode** pPhyNode) {
|
||||||
|
SStreamScanPhysiNode* pScan =
|
||||||
|
(SStreamScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision,
|
||||||
|
(SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN);
|
||||||
if (NULL == pScan) {
|
if (NULL == pScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pScan, pPhyNode);
|
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pScan, pPhyNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
|
||||||
|
SPhysiNode** pPhyNode) {
|
||||||
switch (pScanLogicNode->scanType) {
|
switch (pScanLogicNode->scanType) {
|
||||||
case SCAN_TYPE_TAG:
|
case SCAN_TYPE_TAG:
|
||||||
return createTagScanPhysiNode(pCxt, pScanLogicNode, pPhyNode);
|
return createTagScanPhysiNode(pCxt, pScanLogicNode, pPhyNode);
|
||||||
|
@ -496,8 +509,10 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode,
|
||||||
SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_JOIN);
|
SPhysiNode** pPhyNode) {
|
||||||
|
SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pJoinLogicNode,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_JOIN);
|
||||||
if (NULL == pJoin) {
|
if (NULL == pJoin) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -508,10 +523,12 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
||||||
|
|
||||||
pJoin->joinType = pJoinLogicNode->joinType;
|
pJoin->joinType = pJoinLogicNode->joinType;
|
||||||
if (NULL != pJoinLogicNode->pOnConditions) {
|
if (NULL != pJoinLogicNode->pOnConditions) {
|
||||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pOnConditions, &pJoin->pOnConditions);
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pOnConditions,
|
||||||
|
&pJoin->pOnConditions);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setListSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->node.pTargets, &pJoin->pTargets);
|
code = setListSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->node.pTargets,
|
||||||
|
&pJoin->pTargets);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addDataBlockSlots(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc);
|
code = addDataBlockSlots(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc);
|
||||||
|
@ -555,7 +572,8 @@ static EDealRes collectAndRewrite(SRewritePrecalcExprsCxt* pCxt, SNode** pNode)
|
||||||
if ('\0' != pRewrittenExpr->aliasName[0]) {
|
if ('\0' != pRewrittenExpr->aliasName[0]) {
|
||||||
strcpy(pCol->colName, pRewrittenExpr->aliasName);
|
strcpy(pCol->colName, pRewrittenExpr->aliasName);
|
||||||
} else {
|
} else {
|
||||||
snprintf(pRewrittenExpr->aliasName, sizeof(pRewrittenExpr->aliasName), "#expr_%d_%d", pCxt->planNodeId, pCxt->rewriteId);
|
snprintf(pRewrittenExpr->aliasName, sizeof(pRewrittenExpr->aliasName), "#expr_%d_%d", pCxt->planNodeId,
|
||||||
|
pCxt->rewriteId);
|
||||||
strcpy(pCol->colName, pRewrittenExpr->aliasName);
|
strcpy(pCol->colName, pRewrittenExpr->aliasName);
|
||||||
}
|
}
|
||||||
nodesDestroyNode(*pNode);
|
nodesDestroyNode(*pNode);
|
||||||
|
@ -581,7 +599,8 @@ static EDealRes doRewritePrecalcExprs(SNode** pNode, void* pContext) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewritePrecalcExprs(SPhysiPlanContext* pCxt, SNodeList* pList, SNodeList** pPrecalcExprs, SNodeList** pRewrittenList) {
|
static int32_t rewritePrecalcExprs(SPhysiPlanContext* pCxt, SNodeList* pList, SNodeList** pPrecalcExprs,
|
||||||
|
SNodeList** pRewrittenList) {
|
||||||
if (NULL == pList) {
|
if (NULL == pList) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -613,7 +632,7 @@ static int32_t rewritePrecalcExprs(SPhysiPlanContext* pCxt, SNodeList* pList, SN
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SRewritePrecalcExprsCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pPrecalcExprs = *pPrecalcExprs };
|
SRewritePrecalcExprsCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pPrecalcExprs = *pPrecalcExprs};
|
||||||
nodesRewriteExprs(*pRewrittenList, doRewritePrecalcExprs, &cxt);
|
nodesRewriteExprs(*pRewrittenList, doRewritePrecalcExprs, &cxt);
|
||||||
if (0 == LIST_LENGTH(cxt.pPrecalcExprs)) {
|
if (0 == LIST_LENGTH(cxt.pPrecalcExprs)) {
|
||||||
nodesDestroyList(cxt.pPrecalcExprs);
|
nodesDestroyList(cxt.pPrecalcExprs);
|
||||||
|
@ -622,7 +641,8 @@ static int32_t rewritePrecalcExprs(SPhysiPlanContext* pCxt, SNodeList* pList, SN
|
||||||
return cxt.errCode;
|
return cxt.errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t rewritePrecalcExpr(SPhysiPlanContext* pCxt, SNode* pNode, SNodeList** pPrecalcExprs, SNode** pRewritten) {
|
static int32_t rewritePrecalcExpr(SPhysiPlanContext* pCxt, SNode* pNode, SNodeList** pPrecalcExprs,
|
||||||
|
SNode** pRewritten) {
|
||||||
if (NULL == pNode) {
|
if (NULL == pNode) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -641,8 +661,10 @@ static int32_t rewritePrecalcExpr(SPhysiPlanContext* pCxt, SNode* pNode, SNodeLi
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SAggLogicNode* pAggLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SAggLogicNode* pAggLogicNode,
|
||||||
SAggPhysiNode* pAgg = (SAggPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pAggLogicNode, QUERY_NODE_PHYSICAL_PLAN_AGG);
|
SPhysiNode** pPhyNode) {
|
||||||
|
SAggPhysiNode* pAgg = (SAggPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pAggLogicNode,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_AGG);
|
||||||
if (NULL == pAgg) {
|
if (NULL == pAgg) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -695,8 +717,10 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SProjectLogicNode* pProjectLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SProjectPhysiNode* pProject = (SProjectPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pProjectLogicNode, QUERY_NODE_PHYSICAL_PLAN_PROJECT);
|
SProjectLogicNode* pProjectLogicNode, SPhysiNode** pPhyNode) {
|
||||||
|
SProjectPhysiNode* pProject = (SProjectPhysiNode*)makePhysiNode(
|
||||||
|
pCxt, getPrecision(pChildren), (SLogicNode*)pProjectLogicNode, QUERY_NODE_PHYSICAL_PLAN_PROJECT);
|
||||||
if (NULL == pProject) {
|
if (NULL == pProject) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -706,9 +730,11 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
|
||||||
pProject->slimit = pProjectLogicNode->slimit;
|
pProject->slimit = pProjectLogicNode->slimit;
|
||||||
pProject->soffset = pProjectLogicNode->soffset;
|
pProject->soffset = pProjectLogicNode->soffset;
|
||||||
|
|
||||||
int32_t code = setListSlotId(pCxt, ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc->dataBlockId, -1, pProjectLogicNode->pProjections, &pProject->pProjections);
|
int32_t code = setListSlotId(pCxt, ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc->dataBlockId,
|
||||||
|
-1, pProjectLogicNode->pProjections, &pProject->pProjections);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addDataBlockSlotsForProject(pCxt, pProjectLogicNode->stmtName, pProject->pProjections, pProject->node.pOutputDataBlockDesc);
|
code = addDataBlockSlotsForProject(pCxt, pProjectLogicNode->stmtName, pProject->pProjections,
|
||||||
|
pProject->node.pOutputDataBlockDesc);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = setConditionsSlotId(pCxt, (const SLogicNode*)pProjectLogicNode, (SPhysiNode*)pProject);
|
code = setConditionsSlotId(pCxt, (const SLogicNode*)pProjectLogicNode, (SPhysiNode*)pProject);
|
||||||
|
@ -723,8 +749,10 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode,
|
||||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)makePhysiNode(pCxt, pExchangeLogicNode->precision, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_EXCHANGE);
|
SPhysiNode** pPhyNode) {
|
||||||
|
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)makePhysiNode(
|
||||||
|
pCxt, pExchangeLogicNode->precision, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_EXCHANGE);
|
||||||
if (NULL == pExchange) {
|
if (NULL == pExchange) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -734,8 +762,10 @@ static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogic
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode,
|
||||||
SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, pExchangeLogicNode->precision, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN);
|
SPhysiNode** pPhyNode) {
|
||||||
|
SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(
|
||||||
|
pCxt, pExchangeLogicNode->precision, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN);
|
||||||
if (NULL == pScan) {
|
if (NULL == pScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -767,7 +797,8 @@ static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExc
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode,
|
||||||
|
SPhysiNode** pPhyNode) {
|
||||||
if (pCxt->pPlanCxt->streamQuery) {
|
if (pCxt->pPlanCxt->streamQuery) {
|
||||||
return createStreamScanPhysiNodeByExchange(pCxt, pExchangeLogicNode, pPhyNode);
|
return createStreamScanPhysiNodeByExchange(pCxt, pExchangeLogicNode, pPhyNode);
|
||||||
} else {
|
} else {
|
||||||
|
@ -775,7 +806,8 @@ static int32_t createExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWinodwPhysiNode* pWindow, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWinodwPhysiNode* pWindow,
|
||||||
|
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SNodeList* pPrecalcExprs = NULL;
|
SNodeList* pPrecalcExprs = NULL;
|
||||||
SNodeList* pFuncs = NULL;
|
SNodeList* pFuncs = NULL;
|
||||||
int32_t code = rewritePrecalcExprs(pCxt, pWindowLogicNode->pFuncs, &pPrecalcExprs, &pFuncs);
|
int32_t code = rewritePrecalcExprs(pCxt, pWindowLogicNode->pFuncs, &pPrecalcExprs, &pFuncs);
|
||||||
|
@ -812,8 +844,10 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_INTERVAL);
|
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
||||||
|
SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)makePhysiNode(
|
||||||
|
pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_INTERVAL);
|
||||||
if (NULL == pInterval) {
|
if (NULL == pInterval) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -833,8 +867,10 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
|
||||||
return createWindowPhysiNodeFinalize(pCxt, pChildren, &pInterval->window, pWindowLogicNode, pPhyNode);
|
return createWindowPhysiNodeFinalize(pCxt, pChildren, &pInterval->window, pWindowLogicNode, pPhyNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SSessionWinodwPhysiNode* pSession = (SSessionWinodwPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW);
|
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
||||||
|
SSessionWinodwPhysiNode* pSession = (SSessionWinodwPhysiNode*)makePhysiNode(
|
||||||
|
pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW);
|
||||||
if (NULL == pSession) {
|
if (NULL == pSession) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -844,8 +880,10 @@ static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
return createWindowPhysiNodeFinalize(pCxt, pChildren, &pSession->window, pWindowLogicNode, pPhyNode);
|
return createWindowPhysiNodeFinalize(pCxt, pChildren, &pSession->window, pWindowLogicNode, pPhyNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SStateWinodwPhysiNode* pState = (SStateWinodwPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW);
|
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
||||||
|
SStateWinodwPhysiNode* pState = (SStateWinodwPhysiNode*)makePhysiNode(
|
||||||
|
pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW);
|
||||||
if (NULL == pState) {
|
if (NULL == pState) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -878,7 +916,8 @@ static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pC
|
||||||
return createWindowPhysiNodeFinalize(pCxt, pChildren, &pState->window, pWindowLogicNode, pPhyNode);
|
return createWindowPhysiNodeFinalize(pCxt, pChildren, &pState->window, pWindowLogicNode, pPhyNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode,
|
||||||
|
SPhysiNode** pPhyNode) {
|
||||||
switch (pWindowLogicNode->winType) {
|
switch (pWindowLogicNode->winType) {
|
||||||
case WINDOW_TYPE_INTERVAL:
|
case WINDOW_TYPE_INTERVAL:
|
||||||
return createIntervalPhysiNode(pCxt, pChildren, pWindowLogicNode, pPhyNode);
|
return createIntervalPhysiNode(pCxt, pChildren, pWindowLogicNode, pPhyNode);
|
||||||
|
@ -892,8 +931,10 @@ static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildr
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SSortLogicNode* pSortLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SSortLogicNode* pSortLogicNode,
|
||||||
SSortPhysiNode* pSort = (SSortPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pSortLogicNode, QUERY_NODE_PHYSICAL_PLAN_SORT);
|
SPhysiNode** pPhyNode) {
|
||||||
|
SSortPhysiNode* pSort = (SSortPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pSortLogicNode,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_SORT);
|
||||||
if (NULL == pSort) {
|
if (NULL == pSort) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -931,8 +972,10 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pPartLogicNode, QUERY_NODE_PHYSICAL_PLAN_PARTITION);
|
SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) {
|
||||||
|
SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)makePhysiNode(
|
||||||
|
pCxt, getPrecision(pChildren), (SLogicNode*)pPartLogicNode, QUERY_NODE_PHYSICAL_PLAN_PARTITION);
|
||||||
if (NULL == pPart) {
|
if (NULL == pPart) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -970,7 +1013,8 @@ static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doCreatePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, SSubplan* pSubplan, SNodeList* pChildren, SPhysiNode** pPhyNode) {
|
static int32_t doCreatePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, SSubplan* pSubplan,
|
||||||
|
SNodeList* pChildren, SPhysiNode** pPhyNode) {
|
||||||
switch (nodeType(pLogicNode)) {
|
switch (nodeType(pLogicNode)) {
|
||||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||||
return createScanPhysiNode(pCxt, pSubplan, (SScanLogicNode*)pLogicNode, pPhyNode);
|
return createScanPhysiNode(pCxt, pSubplan, (SScanLogicNode*)pLogicNode, pPhyNode);
|
||||||
|
@ -995,7 +1039,8 @@ static int32_t doCreatePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, SSubplan* pSubplan, SPhysiNode** pPhyNode) {
|
static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, SSubplan* pSubplan,
|
||||||
|
SPhysiNode** pPhyNode) {
|
||||||
SNodeList* pChildren = nodesMakeList();
|
SNodeList* pChildren = nodesMakeList();
|
||||||
if (NULL == pChildren) {
|
if (NULL == pChildren) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -1019,9 +1064,7 @@ static int32_t createPhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode,
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
(*pPhyNode)->pChildren = pChildren;
|
(*pPhyNode)->pChildren = pChildren;
|
||||||
SNode* pChild;
|
SNode* pChild;
|
||||||
FOREACH(pChild, (*pPhyNode)->pChildren) {
|
FOREACH(pChild, (*pPhyNode)->pChildren) { ((SPhysiNode*)pChild)->pParent = (*pPhyNode); }
|
||||||
((SPhysiNode*)pChild)->pParent = (*pPhyNode);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
nodesDestroyList(pChildren);
|
nodesDestroyList(pChildren);
|
||||||
}
|
}
|
||||||
|
@ -1137,7 +1180,8 @@ static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t l
|
||||||
return nodesListStrictAppend(pGroup->pNodeList, pSubplan);
|
return nodesListStrictAppend(pGroup->pNodeList, pSubplan);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan* pParent, SQueryPlan* pQueryPlan) {
|
static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan* pParent,
|
||||||
|
SQueryPlan* pQueryPlan) {
|
||||||
SSubplan* pSubplan = NULL;
|
SSubplan* pSubplan = NULL;
|
||||||
int32_t code = createPhysiSubplan(pCxt, pLogicSubplan, &pSubplan);
|
int32_t code = createPhysiSubplan(pCxt, pLogicSubplan, &pSubplan);
|
||||||
|
|
||||||
|
@ -1221,13 +1265,11 @@ static void setExplainInfo(SPlanContext* pCxt, SQueryPlan* pPlan) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t createPhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPlan, SArray* pExecNodeList) {
|
int32_t createPhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPlan, SArray* pExecNodeList) {
|
||||||
SPhysiPlanContext cxt = {
|
SPhysiPlanContext cxt = {.pPlanCxt = pCxt,
|
||||||
.pPlanCxt = pCxt,
|
|
||||||
.errCode = TSDB_CODE_SUCCESS,
|
.errCode = TSDB_CODE_SUCCESS,
|
||||||
.nextDataBlockId = 0,
|
.nextDataBlockId = 0,
|
||||||
.pLocationHelper = taosArrayInit(32, POINTER_BYTES),
|
.pLocationHelper = taosArrayInit(32, POINTER_BYTES),
|
||||||
.pExecNodeList = pExecNodeList
|
.pExecNodeList = pExecNodeList};
|
||||||
};
|
|
||||||
if (NULL == cxt.pLocationHelper) {
|
if (NULL == cxt.pLocationHelper) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ int32_t scaleOutLogicPlan(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SQue
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SScaleOutContext cxt = { .pPlanCxt = pCxt, .subplanId = 1 };
|
SScaleOutContext cxt = {.pPlanCxt = pCxt, .subplanId = 1};
|
||||||
int32_t code = doScaleOut(&cxt, pLogicSubplan, 0, pPlan->pTopSubplans);
|
int32_t code = doScaleOut(&cxt, pLogicSubplan, 0, pPlan->pTopSubplans);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pLogicPlan = pPlan;
|
*pLogicPlan = pPlan;
|
||||||
|
|
|
@ -70,7 +70,8 @@ static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode*
|
||||||
return pSubplan;
|
return pSubplan;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t splCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SScanLogicNode* pScan, ESubplanType subplanType) {
|
static int32_t splCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SScanLogicNode* pScan,
|
||||||
|
ESubplanType subplanType) {
|
||||||
SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||||
if (NULL == pExchange) {
|
if (NULL == pExchange) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -117,8 +118,8 @@ static bool splMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan, int32_t flag,
|
||||||
}
|
}
|
||||||
|
|
||||||
static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
|
static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
|
||||||
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode) &&
|
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode) && NULL != ((SScanLogicNode*)pNode)->pVgroupList &&
|
||||||
NULL != ((SScanLogicNode*)pNode)->pVgroupList && ((SScanLogicNode*)pNode)->pVgroupList->numOfVgroups > 1) {
|
((SScanLogicNode*)pNode)->pVgroupList->numOfVgroups > 1) {
|
||||||
return pNode;
|
return pNode;
|
||||||
}
|
}
|
||||||
SNode* pChild;
|
SNode* pChild;
|
||||||
|
@ -145,7 +146,8 @@ static int32_t stsSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
||||||
if (!splMatch(pCxt, pSubplan, SPLIT_FLAG_STS, (FSplFindSplitNode)stsFindSplitNode, &info)) {
|
if (!splMatch(pCxt, pSubplan, SPLIT_FLAG_STS, (FSplFindSplitNode)stsFindSplitNode, &info)) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
int32_t code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, splCreateScanSubplan(pCxt, info.pScan, SPLIT_FLAG_STS));
|
int32_t code =
|
||||||
|
nodesListMakeStrictAppend(&info.pSubplan->pChildren, splCreateScanSubplan(pCxt, info.pScan, SPLIT_FLAG_STS));
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = splCreateExchangeNode(pCxt, info.pSubplan, info.pScan, SUBPLAN_TYPE_MERGE);
|
code = splCreateExchangeNode(pCxt, info.pSubplan, info.pScan, SUBPLAN_TYPE_MERGE);
|
||||||
}
|
}
|
||||||
|
@ -163,7 +165,8 @@ static SLogicNode* ctjMatchByNode(SLogicNode* pNode) {
|
||||||
SLogicNode* pLeft = (SLogicNode*)nodesListGetNode(pNode->pChildren, 0);
|
SLogicNode* pLeft = (SLogicNode*)nodesListGetNode(pNode->pChildren, 0);
|
||||||
SLogicNode* pRight = (SLogicNode*)nodesListGetNode(pNode->pChildren, 1);
|
SLogicNode* pRight = (SLogicNode*)nodesListGetNode(pNode->pChildren, 1);
|
||||||
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pLeft) && ctjIsSingleTable(((SScanLogicNode*)pLeft)->pMeta->tableType) &&
|
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pLeft) && ctjIsSingleTable(((SScanLogicNode*)pLeft)->pMeta->tableType) &&
|
||||||
QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pRight) && ctjIsSingleTable(((SScanLogicNode*)pRight)->pMeta->tableType)) {
|
QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pRight) &&
|
||||||
|
ctjIsSingleTable(((SScanLogicNode*)pRight)->pMeta->tableType)) {
|
||||||
return pRight;
|
return pRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +194,8 @@ static int32_t ctjSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
||||||
if (!splMatch(pCxt, pSubplan, SPLIT_FLAG_CTJ, (FSplFindSplitNode)ctjFindSplitNode, &info)) {
|
if (!splMatch(pCxt, pSubplan, SPLIT_FLAG_CTJ, (FSplFindSplitNode)ctjFindSplitNode, &info)) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
int32_t code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, splCreateScanSubplan(pCxt, info.pScan, SPLIT_FLAG_CTJ));
|
int32_t code =
|
||||||
|
nodesListMakeStrictAppend(&info.pSubplan->pChildren, splCreateScanSubplan(pCxt, info.pScan, SPLIT_FLAG_CTJ));
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = splCreateExchangeNode(pCxt, info.pSubplan, info.pScan, info.pSubplan->subplanType);
|
code = splCreateExchangeNode(pCxt, info.pSubplan, info.pScan, info.pSubplan->subplanType);
|
||||||
}
|
}
|
||||||
|
@ -360,17 +364,15 @@ static int32_t unSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const SSplitRule splitRuleSet[] = {
|
static const SSplitRule splitRuleSet[] = {{.pName = "SuperTableScan", .splitFunc = stsSplit},
|
||||||
{ .pName = "SuperTableScan", .splitFunc = stsSplit },
|
{.pName = "ChildTableJoin", .splitFunc = ctjSplit},
|
||||||
{ .pName = "ChildTableJoin", .splitFunc = ctjSplit },
|
{.pName = "UnionAll", .splitFunc = uaSplit},
|
||||||
{ .pName = "UnionAll", .splitFunc = uaSplit },
|
{.pName = "Union", .splitFunc = unSplit}};
|
||||||
{ .pName = "Union", .splitFunc = unSplit }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
|
static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
|
||||||
|
|
||||||
static int32_t applySplitRule(SLogicSubplan* pSubplan) {
|
static int32_t applySplitRule(SLogicSubplan* pSubplan) {
|
||||||
SSplitContext cxt = { .groupId = pSubplan->id.groupId + 1, .split = false };
|
SSplitContext cxt = {.groupId = pSubplan->id.groupId + 1, .split = false};
|
||||||
do {
|
do {
|
||||||
cxt.split = false;
|
cxt.split = false;
|
||||||
for (int32_t i = 0; i < splitRuleNum; ++i) {
|
for (int32_t i = 0; i < splitRuleNum; ++i) {
|
||||||
|
@ -386,14 +388,10 @@ static int32_t applySplitRule(SLogicSubplan* pSubplan) {
|
||||||
static void doSetLogicNodeParent(SLogicNode* pNode, SLogicNode* pParent) {
|
static void doSetLogicNodeParent(SLogicNode* pNode, SLogicNode* pParent) {
|
||||||
pNode->pParent = pParent;
|
pNode->pParent = pParent;
|
||||||
SNode* pChild;
|
SNode* pChild;
|
||||||
FOREACH(pChild, pNode->pChildren) {
|
FOREACH(pChild, pNode->pChildren) { doSetLogicNodeParent((SLogicNode*)pChild, pNode); }
|
||||||
doSetLogicNodeParent((SLogicNode*)pChild, pNode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setLogicNodeParent(SLogicNode* pNode) {
|
static void setLogicNodeParent(SLogicNode* pNode) { doSetLogicNodeParent(pNode, NULL); }
|
||||||
doSetLogicNodeParent(pNode, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t splitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan** pLogicSubplan) {
|
int32_t splitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan** pLogicSubplan) {
|
||||||
SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||||
|
@ -408,7 +406,8 @@ int32_t splitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_LOGIC_PLAN_VNODE_MODIF == nodeType(pLogicNode)) {
|
if (QUERY_NODE_LOGIC_PLAN_VNODE_MODIF == nodeType(pLogicNode)) {
|
||||||
pSubplan->subplanType = SUBPLAN_TYPE_MODIFY;
|
pSubplan->subplanType = SUBPLAN_TYPE_MODIFY;
|
||||||
TSWAP(((SVnodeModifLogicNode*)pLogicNode)->pDataBlocks, ((SVnodeModifLogicNode*)pSubplan->pNode)->pDataBlocks, SArray*);
|
TSWAP(((SVnodeModifLogicNode*)pLogicNode)->pDataBlocks, ((SVnodeModifLogicNode*)pSubplan->pNode)->pDataBlocks,
|
||||||
|
SArray*);
|
||||||
} else {
|
} else {
|
||||||
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ static EDealRes collectPlaceholderValuesImpl(SNode* pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectPlaceholderValues(SPlanContext* pCxt, SQueryPlan* pPlan) {
|
static int32_t collectPlaceholderValues(SPlanContext* pCxt, SQueryPlan* pPlan) {
|
||||||
SCollectPlaceholderValuesCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pValues = NULL };
|
SCollectPlaceholderValuesCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pValues = NULL};
|
||||||
nodesWalkPhysiPlan((SNode*)pPlan, collectPlaceholderValuesImpl, &cxt);
|
nodesWalkPhysiPlan((SNode*)pPlan, collectPlaceholderValuesImpl, &cxt);
|
||||||
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
||||||
pPlan->pPlaceholderValues = cxt.pValues;
|
pPlan->pPlaceholderValues = cxt.pValues;
|
||||||
|
@ -171,9 +171,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_BIND_v2* pParam) {
|
||||||
int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_BIND_v2* pParams) {
|
int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_BIND_v2* pParams) {
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pPlan->pPlaceholderValues) {
|
FOREACH(pNode, pPlan->pPlaceholderValues) { setValueByBindParam((SValueNode*)pNode, pParams + index); }
|
||||||
setValueByBindParam((SValueNode*)pNode, pParams + index);
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,9 +186,7 @@ int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) {
|
||||||
return nodesNodeToString((const SNode*)pSubplan, false, pStr, pLen);
|
return nodesNodeToString((const SNode*)pSubplan, false, pStr, pLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan) {
|
int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan) { return nodesStringToNode(pStr, (SNode**)pSubplan); }
|
||||||
return nodesStringToNode(pStr, (SNode**)pSubplan);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* qQueryPlanToString(const SQueryPlan* pPlan) {
|
char* qQueryPlanToString(const SQueryPlan* pPlan) {
|
||||||
char* pStr = NULL;
|
char* pStr = NULL;
|
||||||
|
@ -209,6 +205,4 @@ SQueryPlan* qStringToQueryPlan(const char* pStr) {
|
||||||
return pPlan;
|
return pPlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qDestroyQueryPlan(SQueryPlan* pPlan) {
|
void qDestroyQueryPlan(SQueryPlan* pPlan) { nodesDestroyNode(pPlan); }
|
||||||
nodesDestroyNode(pPlan);
|
|
||||||
}
|
|
||||||
|
|
|
@ -18,9 +18,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class PlanOptimizeTest : public PlannerTestBase {
|
class PlanOptimizeTest : public PlannerTestBase {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(PlanOptimizeTest, orderByPrimaryKey) {
|
TEST_F(PlanOptimizeTest, orderByPrimaryKey) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* 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 "planTestUtil.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class PlanSuperTableTest : public PlannerTestBase {};
|
||||||
|
|
||||||
|
TEST_F(PlanSuperTableTest, unionAll) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("select tbname from st1");
|
||||||
|
}
|
|
@ -18,9 +18,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class PlanSetOpTest : public PlannerTestBase {
|
class PlanSetOpTest : public PlannerTestBase {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(PlanSetOpTest, unionAll) {
|
TEST_F(PlanSetOpTest, unionAll) {
|
||||||
useDb("root", "test");
|
useDb("root", "test");
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class PlanStmtTest : public PlannerTestBase {
|
class PlanStmtTest : public PlannerTestBase {
|
||||||
public:
|
public:
|
||||||
void prepare(const string& sql) {
|
void prepare(const string& sql) {
|
||||||
run(sql);
|
run(sql);
|
||||||
// todo calloc pBindParams_
|
// todo calloc pBindParams_
|
||||||
|
@ -42,7 +42,7 @@ public:
|
||||||
// todo
|
// todo
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TAOS_BIND_v2* pBindParams_;
|
TAOS_BIND_v2* pBindParams_;
|
||||||
int32_t paramNo_;
|
int32_t paramNo_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,15 +21,13 @@
|
||||||
#include "planTestUtil.h"
|
#include "planTestUtil.h"
|
||||||
|
|
||||||
class PlannerEnv : public testing::Environment {
|
class PlannerEnv : public testing::Environment {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
initMetaDataEnv();
|
initMetaDataEnv();
|
||||||
generateMetaData();
|
generateMetaData();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TearDown() {
|
virtual void TearDown() { destroyMetaDataEnv(); }
|
||||||
destroyMetaDataEnv();
|
|
||||||
}
|
|
||||||
|
|
||||||
PlannerEnv() {}
|
PlannerEnv() {}
|
||||||
virtual ~PlannerEnv() {}
|
virtual ~PlannerEnv() {}
|
||||||
|
@ -37,11 +35,8 @@ public:
|
||||||
|
|
||||||
static void parseArg(int argc, char* argv[]) {
|
static void parseArg(int argc, char* argv[]) {
|
||||||
int opt = 0;
|
int opt = 0;
|
||||||
const char *optstring = "";
|
const char* optstring = "";
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {{"dump", no_argument, NULL, 'd'}, {0, 0, 0, 0}};
|
||||||
{"dump", no_argument, NULL, 'd'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) {
|
while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'd':
|
case 'd':
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* 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 <array>
|
|
||||||
#include "planTestUtil.h"
|
#include "planTestUtil.h"
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -29,14 +29,15 @@ using namespace testing;
|
||||||
do { \
|
do { \
|
||||||
int32_t code__ = func(__VA_ARGS__); \
|
int32_t code__ = func(__VA_ARGS__); \
|
||||||
if (TSDB_CODE_SUCCESS != code__) { \
|
if (TSDB_CODE_SUCCESS != code__) { \
|
||||||
throw runtime_error("sql:[" + stmtEnv_.sql_ + "] " #func " code:" + to_string(code__) + ", strerror:" + string(tstrerror(code__)) + ", msg:" + string(stmtEnv_.msgBuf_.data())); \
|
throw runtime_error("sql:[" + stmtEnv_.sql_ + "] " #func " code:" + to_string(code__) + \
|
||||||
|
", strerror:" + string(tstrerror(code__)) + ", msg:" + string(stmtEnv_.msgBuf_.data())); \
|
||||||
} \
|
} \
|
||||||
} while(0);
|
} while (0);
|
||||||
|
|
||||||
bool g_isDump = false;
|
bool g_isDump = false;
|
||||||
|
|
||||||
class PlannerTestBaseImpl {
|
class PlannerTestBaseImpl {
|
||||||
public:
|
public:
|
||||||
void useDb(const string& acctId, const string& db) {
|
void useDb(const string& acctId, const string& db) {
|
||||||
caseEnv_.acctId_ = acctId;
|
caseEnv_.acctId_ = acctId;
|
||||||
caseEnv_.db_ = db;
|
caseEnv_.db_ = db;
|
||||||
|
@ -74,7 +75,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct caseEnv {
|
struct caseEnv {
|
||||||
string acctId_;
|
string acctId_;
|
||||||
string db_;
|
string db_;
|
||||||
|
@ -170,9 +171,7 @@ private:
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
FOREACH(pNode, (*pPlan)->pSubplans) {
|
FOREACH(pNode, (*pPlan)->pSubplans) {
|
||||||
SNode* pSubplan;
|
SNode* pSubplan;
|
||||||
FOREACH(pSubplan, ((SNodeListNode*)pNode)->pNodeList) {
|
FOREACH(pSubplan, ((SNodeListNode*)pNode)->pNodeList) { res_.physiSubplans_.push_back(toString(pSubplan)); }
|
||||||
res_.physiSubplans_.push_back(toString(pSubplan));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,16 +209,10 @@ private:
|
||||||
stmtRes res_;
|
stmtRes res_;
|
||||||
};
|
};
|
||||||
|
|
||||||
PlannerTestBase::PlannerTestBase() : impl_(new PlannerTestBaseImpl()) {
|
PlannerTestBase::PlannerTestBase() : impl_(new PlannerTestBaseImpl()) {}
|
||||||
}
|
|
||||||
|
|
||||||
PlannerTestBase::~PlannerTestBase() {
|
PlannerTestBase::~PlannerTestBase() {}
|
||||||
}
|
|
||||||
|
|
||||||
void PlannerTestBase::useDb(const std::string& acctId, const std::string& db) {
|
void PlannerTestBase::useDb(const std::string& acctId, const std::string& db) { impl_->useDb(acctId, db); }
|
||||||
impl_->useDb(acctId, db);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlannerTestBase::run(const std::string& sql) {
|
void PlannerTestBase::run(const std::string& sql) { return impl_->run(sql); }
|
||||||
return impl_->run(sql);
|
|
||||||
}
|
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
class PlannerTestBaseImpl;
|
class PlannerTestBaseImpl;
|
||||||
|
|
||||||
class PlannerTestBase : public testing::Test {
|
class PlannerTestBase : public testing::Test {
|
||||||
public:
|
public:
|
||||||
PlannerTestBase();
|
PlannerTestBase();
|
||||||
virtual ~PlannerTestBase();
|
virtual ~PlannerTestBase();
|
||||||
|
|
||||||
void useDb(const std::string& acctId, const std::string& db);
|
void useDb(const std::string& acctId, const std::string& db);
|
||||||
void run(const std::string& sql);
|
void run(const std::string& sql);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<PlannerTestBaseImpl> impl_;
|
std::unique_ptr<PlannerTestBaseImpl> impl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ using namespace std;
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
|
||||||
class PlannerTest : public Test {
|
class PlannerTest : public Test {
|
||||||
protected:
|
protected:
|
||||||
void setDatabase(const string& acctId, const string& db) {
|
void setDatabase(const string& acctId, const string& db) {
|
||||||
acctId_ = acctId;
|
acctId_ = acctId;
|
||||||
db_ = db;
|
db_ = db;
|
||||||
|
@ -45,7 +45,8 @@ protected:
|
||||||
int32_t code = qParseQuerySql(&cxt_, &query_);
|
int32_t code = qParseQuerySql(&cxt_, &query_);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
cout << "sql:[" << cxt_.pSql << "] qParseQuerySql code:" << code << ", strerror:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl;
|
cout << "sql:[" << cxt_.pSql << "] qParseQuerySql code:" << code << ", strerror:" << tstrerror(code)
|
||||||
|
<< ", msg:" << errMagBuf_ << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +91,8 @@ protected:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = createPhysiPlan(&cxt, pLogicPlan, &plan_, NULL);
|
SArray* pExecNodeList = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SQueryNodeAddr));
|
||||||
|
code = createPhysiPlan(&cxt, pLogicPlan, &plan_, pExecNodeList);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
cout << "sql:[" << cxt_.pSql << "] createPhysiPlan code:" << code << ", strerror:" << tstrerror(code) << endl;
|
cout << "sql:[" << cxt_.pSql << "] createPhysiPlan code:" << code << ", strerror:" << tstrerror(code) << endl;
|
||||||
return false;
|
return false;
|
||||||
|
@ -110,7 +112,7 @@ protected:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int max_err_len = 1024;
|
static const int max_err_len = 1024;
|
||||||
|
|
||||||
void setPlanContext(SQuery* pQuery, SPlanContext* pCxt) {
|
void setPlanContext(SQuery* pQuery, SPlanContext* pCxt) {
|
||||||
|
@ -192,7 +194,9 @@ TEST_F(PlannerTest, selectJoin) {
|
||||||
bind("SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
|
bind("SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("SELECT t1.c1, t2.c1 FROM st1s1 t1 join st1s2 t2 on t1.ts = t2.ts where t1.c1 > t2.c1 and t1.c2 = 'abc' and t2.c2 = 'qwe'");
|
bind(
|
||||||
|
"SELECT t1.c1, t2.c1 FROM st1s1 t1 join st1s2 t2 on t1.ts = t2.ts where t1.c1 > t2.c1 and t1.c2 = 'abc' and "
|
||||||
|
"t2.c2 = 'qwe'");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,12 +214,17 @@ TEST_F(PlannerTest, selectGroupBy) {
|
||||||
|
|
||||||
bind("SELECT c1 + c3, sum(c4 * c5) FROM t1 where concat(c2, 'wwww') = 'abcwww' GROUP BY c1 + c3");
|
bind("SELECT c1 + c3, sum(c4 * c5) FROM t1 where concat(c2, 'wwww') = 'abcwww' GROUP BY c1 + c3");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
|
bind("SELECT sum(ceil(c1)) FROM t1 GROUP BY ceil(c1)");
|
||||||
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, selectSubquery) {
|
TEST_F(PlannerTest, selectSubquery) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT count(*) FROM (SELECT c1 + c3 a, c1 + count(*) b FROM t1 where c2 = 'abc' GROUP BY c1, c3) where a > 100 group by b");
|
bind(
|
||||||
|
"SELECT count(*) FROM (SELECT c1 + c3 a, c1 + count(*) b FROM t1 where c2 = 'abc' GROUP BY c1, c3) where a > 100 "
|
||||||
|
"group by b");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +371,9 @@ TEST_F(PlannerTest, createTopic) {
|
||||||
TEST_F(PlannerTest, createStream) {
|
TEST_F(PlannerTest, createStream) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("create stream if not exists s1 trigger window_close watermark 10s into st1 as select count(*) from t1 interval(10s)");
|
bind(
|
||||||
|
"create stream if not exists s1 trigger window_close watermark 10s into st1 as select count(*) from t1 "
|
||||||
|
"interval(10s)");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -979,7 +979,8 @@ void transCloseServer(void* arg) {
|
||||||
|
|
||||||
transSrvInst--;
|
transSrvInst--;
|
||||||
if (transSrvInst == 0) {
|
if (transSrvInst == 0) {
|
||||||
transModuleInit = PTHREAD_ONCE_INIT;
|
TdThreadOnce tmpInit = PTHREAD_ONCE_INIT;
|
||||||
|
memcpy(&transModuleInit, &tmpInit, sizeof(TdThreadOnce));
|
||||||
uvCloseExHandleMgt();
|
uvCloseExHandleMgt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,12 @@ static int32_t cfgCheckAndSetDir(SConfigItem *pItem, const char *inputDir) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (taosRealPath(fullDir, NULL, PATH_MAX) != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
uError("failed to get realpath of dir:%s since %s", inputDir, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pItem->str);
|
taosMemoryFreeClear(pItem->str);
|
||||||
pItem->str = strdup(fullDir);
|
pItem->str = strdup(fullDir);
|
||||||
if (pItem->str == NULL) {
|
if (pItem->str == NULL) {
|
||||||
|
@ -823,7 +829,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
if (bcmp(url, "jsonFile", 8) == 0) {
|
if (memcmp(url, "jsonFile", 8) == 0) {
|
||||||
char *filepath = p;
|
char *filepath = p;
|
||||||
if (!taosCheckExistFile(filepath)) {
|
if (!taosCheckExistFile(filepath)) {
|
||||||
uError("fial to load json file: %s", filepath);
|
uError("fial to load json file: %s", filepath);
|
||||||
|
@ -893,8 +899,8 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
}
|
}
|
||||||
tjsonDelete(pJson);
|
tjsonDelete(pJson);
|
||||||
|
|
||||||
// } else if (bcmp(url, "jsonUrl", 7) == 0) {
|
// } else if (memcmp(url, "jsonUrl", 7) == 0) {
|
||||||
// } else if (bcmp(url, "etcdUrl", 7) == 0) {
|
// } else if (memcmp(url, "etcdUrl", 7) == 0) {
|
||||||
} else {
|
} else {
|
||||||
uError("Unsupported url: %s", url);
|
uError("Unsupported url: %s", url);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -908,7 +914,7 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
if (envCmd == NULL) return 0;
|
if (envCmd == NULL) return 0;
|
||||||
while (envCmd[index]!=NULL) {
|
while (envCmd[index]!=NULL) {
|
||||||
if (bcmp(envCmd[index], "TAOS_APOLLO_URL", 14) == 0) {
|
if (memcmp(envCmd[index], "TAOS_APOLLO_URL", 14) == 0) {
|
||||||
char *p = strchr(envCmd[index], '=');
|
char *p = strchr(envCmd[index], '=');
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
p++;
|
p++;
|
||||||
|
@ -934,7 +940,7 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
|
if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
|
||||||
if (bcmp(line, "TAOS_APOLLO_URL", 14) == 0) {
|
if (memcmp(line, "TAOS_APOLLO_URL", 14) == 0) {
|
||||||
char *p = strchr(line, '=');
|
char *p = strchr(line, '=');
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
p++;
|
p++;
|
||||||
|
@ -975,7 +981,7 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
|
if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
|
||||||
if (bcmp(line, "TAOS_APOLLO_URL", 14) == 0) {
|
if (memcmp(line, "TAOS_APOLLO_URL", 14) == 0) {
|
||||||
char *p = strchr(line, '=');
|
char *p = strchr(line, '=');
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
p++;
|
p++;
|
||||||
|
|
|
@ -5,7 +5,7 @@ set -e
|
||||||
#python3 ./test.py -f 2-query/distinct.py
|
#python3 ./test.py -f 2-query/distinct.py
|
||||||
python3 ./test.py -f 2-query/varchar.py
|
python3 ./test.py -f 2-query/varchar.py
|
||||||
|
|
||||||
python3 ./test.py -f 2-query/timezone.py
|
#python3 ./test.py -f 2-query/timezone.py
|
||||||
python3 ./test.py -f 2-query/Now.py
|
python3 ./test.py -f 2-query/Now.py
|
||||||
python3 ./test.py -f 2-query/Today.py
|
python3 ./test.py -f 2-query/Today.py
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <dirent.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "taos.h"
|
#include "taos.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
|
@ -103,8 +101,8 @@ void initLogFile() {
|
||||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_TEXT | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
|
TdFilePtr pFile = taosOpenFile(file, TD_FILE_TEXT | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
|
||||||
if (NULL == pFile) {
|
if (NULL == pFile) {
|
||||||
fprintf(stderr, "Failed to open %s for save result\n", "./tmqlog.txt");
|
fprintf(stderr, "Failed to open %s for save result\n", "./tmqlog.txt");
|
||||||
exit -1;
|
exit(-1);
|
||||||
};
|
}
|
||||||
g_fp = pFile;
|
g_fp = pFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,35 @@ void shellPrintHelp() {
|
||||||
printf("\n\nReport bugs to %s.\n", SHELL_EMAIL);
|
printf("\n\nReport bugs to %s.\n", SHELL_EMAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LINUX
|
||||||
|
#include <argp.h>
|
||||||
|
#include <termio.h>
|
||||||
|
|
||||||
|
const char *argp_program_version = version;
|
||||||
|
const char *argp_program_bug_address = SHELL_EMAIL;
|
||||||
|
|
||||||
|
static struct argp_option shellOptions[] = {
|
||||||
|
{"host", 'h', "HOST", 0, SHELL_HOST},
|
||||||
|
{"port", 'P', "PORT", 0, SHELL_PORT},
|
||||||
|
{"user", 'u', "USER", 0, SHELL_USER},
|
||||||
|
{0, 'p', 0, 0, SHELL_PASSWORD},
|
||||||
|
{"auth", 'a', "AUTH", 0, SHELL_AUTH},
|
||||||
|
{"generate-auth", 'A', 0, 0, SHELL_GEN_AUTH},
|
||||||
|
{"config-dir", 'c', "DIR", 0, SHELL_CFG_DIR},
|
||||||
|
{"dump-config", 'C', 0, 0, SHELL_DMP_CFG},
|
||||||
|
{"commands", 's', "COMMANDS", 0, SHELL_CMD},
|
||||||
|
{"raw-time", 'r', 0, 0, SHELL_RAW_TIME},
|
||||||
|
{"file", 'f', "FILE", 0, SHELL_FILE},
|
||||||
|
{"database", 'd', "DATABASE", 0, SHELL_DB},
|
||||||
|
{"check", 'k', 0, 0, SHELL_CHECK},
|
||||||
|
{"startup", 't', 0, 0, SHELL_STARTUP},
|
||||||
|
{"display-width", 'w', "WIDTH", 0, SHELL_WIDTH},
|
||||||
|
{"netrole", 'n', "NETROLE", 0, SHELL_NET_ROLE},
|
||||||
|
{"pktlen", 'l', "PKTLEN", 0, SHELL_PKG_LEN},
|
||||||
|
{"pktnum", 'N', "PKTNUM", 0, SHELL_PKT_NUM},
|
||||||
|
{0},
|
||||||
|
};
|
||||||
|
|
||||||
static int32_t shellParseSingleOpt(int32_t key, char *arg) {
|
static int32_t shellParseSingleOpt(int32_t key, char *arg) {
|
||||||
SShellArgs *pArgs = &shell.args;
|
SShellArgs *pArgs = &shell.args;
|
||||||
|
|
||||||
|
@ -178,35 +207,6 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LINUX
|
|
||||||
#include <argp.h>
|
|
||||||
#include <termio.h>
|
|
||||||
|
|
||||||
const char *argp_program_version = version;
|
|
||||||
const char *argp_program_bug_address = SHELL_EMAIL;
|
|
||||||
|
|
||||||
static struct argp_option shellOptions[] = {
|
|
||||||
{"host", 'h', "HOST", 0, SHELL_HOST},
|
|
||||||
{"port", 'P', "PORT", 0, SHELL_PORT},
|
|
||||||
{"user", 'u', "USER", 0, SHELL_USER},
|
|
||||||
{0, 'p', 0, 0, SHELL_PASSWORD},
|
|
||||||
{"auth", 'a', "AUTH", 0, SHELL_AUTH},
|
|
||||||
{"generate-auth", 'A', 0, 0, SHELL_GEN_AUTH},
|
|
||||||
{"config-dir", 'c', "DIR", 0, SHELL_CFG_DIR},
|
|
||||||
{"dump-config", 'C', 0, 0, SHELL_DMP_CFG},
|
|
||||||
{"commands", 's', "COMMANDS", 0, SHELL_CMD},
|
|
||||||
{"raw-time", 'r', 0, 0, SHELL_RAW_TIME},
|
|
||||||
{"file", 'f', "FILE", 0, SHELL_FILE},
|
|
||||||
{"database", 'd', "DATABASE", 0, SHELL_DB},
|
|
||||||
{"check", 'k', 0, 0, SHELL_CHECK},
|
|
||||||
{"startup", 't', 0, 0, SHELL_STARTUP},
|
|
||||||
{"display-width", 'w', "WIDTH", 0, SHELL_WIDTH},
|
|
||||||
{"netrole", 'n', "NETROLE", 0, SHELL_NET_ROLE},
|
|
||||||
{"pktlen", 'l', "PKTLEN", 0, SHELL_PKG_LEN},
|
|
||||||
{"pktnum", 'N', "PKTNUM", 0, SHELL_PKT_NUM},
|
|
||||||
{0},
|
|
||||||
};
|
|
||||||
|
|
||||||
static error_t shellParseOpt(int32_t key, char *arg, struct argp_state *state) { return shellParseSingleOpt(key, arg); }
|
static error_t shellParseOpt(int32_t key, char *arg, struct argp_state *state) { return shellParseSingleOpt(key, arg); }
|
||||||
|
|
||||||
static struct argp shellArgp = {shellOptions, shellParseOpt, "", ""};
|
static struct argp shellArgp = {shellOptions, shellParseOpt, "", ""};
|
||||||
|
@ -335,7 +335,7 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
shell.info.osname = "Windows";
|
shell.info.osname = "Windows";
|
||||||
snprintf(shell.history.file, TSDB_FILENAME_LEN, "C:/TDengine/%s", SHELL_HISTORY_FILE);
|
snprintf(shell.history.file, TSDB_FILENAME_LEN, "C:/TDengine/%s", SHELL_HISTORY_FILE);
|
||||||
if (shellParseArgsWithoutArgp(argc, argv) != 0) return -1;
|
// if (shellParseArgsWithoutArgp(argc, argv) != 0) return -1;
|
||||||
#elif defined(_TD_DARWIN_64)
|
#elif defined(_TD_DARWIN_64)
|
||||||
shell.info.osname = "Darwin";
|
shell.info.osname = "Darwin";
|
||||||
snprintf(shell.history.file, TSDB_FILENAME_LEN, "%s/%s", getpwuid(getuid())->pw_dir, SHELL_HISTORY_FILE);
|
snprintf(shell.history.file, TSDB_FILENAME_LEN, "%s/%s", getpwuid(getuid())->pw_dir, SHELL_HISTORY_FILE);
|
||||||
|
|
|
@ -54,8 +54,8 @@ static void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos);
|
||||||
static void shellShowOnScreen(SShellCmd *cmd);
|
static void shellShowOnScreen(SShellCmd *cmd);
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
static void shellPrintContinuePrompt() { printf("%s", shell.args.promptContinue); }
|
// static void shellPrintContinuePrompt() { printf("%s", shell.args.promptContinue); }
|
||||||
static void shellPrintPrompt() { printf("%s", shell.args.promptHeader); }
|
// static void shellPrintPrompt() { printf("%s", shell.args.promptHeader); }
|
||||||
|
|
||||||
void shellUpdateBuffer(SShellCmd *cmd) {
|
void shellUpdateBuffer(SShellCmd *cmd) {
|
||||||
if (shellRegexMatch(cmd->buffer, "(\\s+$)|(^$)", REG_EXTENDED)) strcat(cmd->command, " ");
|
if (shellRegexMatch(cmd->buffer, "(\\s+$)|(^$)", REG_EXTENDED)) strcat(cmd->command, " ");
|
||||||
|
@ -112,7 +112,7 @@ int32_t shellReadCommand(char command[]) {
|
||||||
cmd.command = NULL;
|
cmd.command = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
shellPrintContinuePrompt();
|
// shellPrintContinuePrompt();
|
||||||
shellUpdateBuffer(&cmd);
|
shellUpdateBuffer(&cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -42,8 +42,6 @@ int main(int argc, char *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_init();
|
|
||||||
|
|
||||||
if (shell.args.is_dump_config) {
|
if (shell.args.is_dump_config) {
|
||||||
shellDumpConfig();
|
shellDumpConfig();
|
||||||
taos_cleanup();
|
taos_cleanup();
|
||||||
|
|
Loading…
Reference in New Issue