Merge branch '3.0' of https://github.com/taosdata/TDengine into feature/vnode_refact
This commit is contained in:
commit
f8b68e92d7
|
@ -46,16 +46,20 @@ IF (TD_WINDOWS)
|
|||
ENDIF ()
|
||||
|
||||
ELSE ()
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
|
||||
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
|
||||
IF (${SANITIZER} MATCHES "true")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
|
||||
MESSAGE(STATUS "Will compile with Address Sanitizer!")
|
||||
ELSE ()
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
|
||||
ENDIF ()
|
||||
|
||||
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
ADD_DEFINITIONS("-D_TD_ARM_")
|
||||
ELSE ()
|
||||
ADD_DEFINITIONS("-msse4.2 -mfma")
|
||||
ENDIF ()
|
||||
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
ADD_DEFINITIONS("-D_TD_ARM_")
|
||||
ELSE ()
|
||||
ADD_DEFINITIONS("-msse4.2 -mfma")
|
||||
ENDIF ()
|
||||
|
||||
ENDIF ()
|
||||
|
|
|
@ -65,22 +65,32 @@ static void prepare_data(TAOS* taos) {
|
|||
usleep(100000);
|
||||
taos_select_db(taos, "test");
|
||||
|
||||
res = taos_query(taos, "create table meters(ts timestamp, f float, n int, b binary(20)) tags(area int, localtion binary(20));");
|
||||
res = taos_query(taos, "create table meters(ts timestamp, f float, n int, b binary(20), c nchar(20)) tags(area int, city binary(20), dist nchar(20));");
|
||||
taos_free_result(res);
|
||||
|
||||
char command[1024] = {0};
|
||||
for (int64_t i = 0; i < g_num_of_tb; i ++) {
|
||||
sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s');",
|
||||
i, i, (i%2)?"beijing":"shanghai");
|
||||
// sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s', '%s');",
|
||||
// i, i, (i%2)?"beijing":"shanghai", (i%2)?"朝阳区":"黄浦区");
|
||||
sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s', '%s');",
|
||||
i, i, (i%2)?"beijing":"shanghai", (i%2)?"chaoyang":"huangpu");
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
okPrint("t%" PRId64 " created\n", i);
|
||||
} else {
|
||||
errorPrint("%s() LN%d: %s\n",
|
||||
__func__, __LINE__, taos_errstr(res));
|
||||
}
|
||||
taos_free_result(res);
|
||||
|
||||
int64_t j = 0;
|
||||
int64_t total = 0;
|
||||
int64_t affected;
|
||||
for (; j < g_num_of_rec -1; j ++) {
|
||||
sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", %f, %"PRId64", '%c%d')",
|
||||
i, 1650000000000+j, (float)j, j, 'a'+(int)j%10, rand());
|
||||
sprintf(command, "insert into t%"PRId64" "
|
||||
"values(%" PRId64 ", %f, %"PRId64", '%c%d', '%c%d')",
|
||||
i, 1650000000000+j, (float)j, j, 'a'+(int)j%25, rand(),
|
||||
'z' - (int)j%25, rand());
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
affected = taos_affected_rows(res);
|
||||
|
@ -91,7 +101,7 @@ static void prepare_data(TAOS* taos) {
|
|||
}
|
||||
taos_free_result(res);
|
||||
}
|
||||
sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", NULL, NULL, NULL)",
|
||||
sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", NULL, NULL, NULL, NULL)",
|
||||
i, 1650000000000+j+1);
|
||||
res = taos_query(taos, command);
|
||||
if ((res) && (0 == taos_errno(res))) {
|
||||
|
@ -107,12 +117,16 @@ static void prepare_data(TAOS* taos) {
|
|||
}
|
||||
}
|
||||
|
||||
static int print_result(TAOS_RES* res, int block) {
|
||||
static int print_result(char *tbname, TAOS_RES* res, int block) {
|
||||
int64_t num_rows = 0;
|
||||
TAOS_ROW row = NULL;
|
||||
int num_fields = taos_num_fields(res);
|
||||
TAOS_FIELD* fields = taos_fetch_fields(res);
|
||||
|
||||
for (int f = 0; f < num_fields; f++) {
|
||||
printf("fields[%d].name=%s, fields[%d].type=%d, fields[%d].bytes=%d\n",
|
||||
f, fields[f].name, f, fields[f].type, f, fields[f].bytes);
|
||||
}
|
||||
if (block) {
|
||||
warnPrint("%s() LN%d, call taos_fetch_block()\n", __func__, __LINE__);
|
||||
int rows = 0;
|
||||
|
@ -126,6 +140,16 @@ static int print_result(TAOS_RES* res, int block) {
|
|||
taos_print_row(temp, row, fields, num_fields);
|
||||
puts(temp);
|
||||
num_rows ++;
|
||||
|
||||
int* lengths = taos_fetch_lengths(res);
|
||||
if (lengths) {
|
||||
for (int c = 0; c < num_fields; c++) {
|
||||
printf("length of column %d is %d\n", c, lengths[c]);
|
||||
}
|
||||
} else {
|
||||
errorPrint("%s() LN%d: %s's lengths is NULL\n",
|
||||
__func__, __LINE__, tbname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,28 +158,21 @@ static int print_result(TAOS_RES* res, int block) {
|
|||
|
||||
static void verify_query(TAOS* taos) {
|
||||
// TODO: select count(tbname) from stable once stable query work
|
||||
//
|
||||
char tbname[193] = {0};
|
||||
char command[1024] = {0};
|
||||
|
||||
for (int64_t i = 0; i < g_num_of_tb; i++) {
|
||||
sprintf(command, "select * from t%"PRId64"", i);
|
||||
sprintf(tbname, "t%"PRId64"", i);
|
||||
sprintf(command, "select * from %s", tbname);
|
||||
TAOS_RES* res = taos_query(taos, command);
|
||||
|
||||
if (res) {
|
||||
if (0 == taos_errno(res)) {
|
||||
int field_count = taos_field_count(res);
|
||||
printf("field_count: %d\n", field_count);
|
||||
int* lengths = taos_fetch_lengths(res);
|
||||
if (lengths) {
|
||||
for (int c = 0; c < field_count; c++) {
|
||||
printf("length of column %d is %d\n", c, lengths[c]);
|
||||
}
|
||||
} else {
|
||||
errorPrint("%s() LN%d: t%"PRId64"'s lengths is NULL\n",
|
||||
__func__, __LINE__, i);
|
||||
}
|
||||
|
||||
int64_t rows = print_result(res, i % 2);
|
||||
printf("rows is: %"PRId64"\n", rows);
|
||||
int64_t rows = print_result(tbname, res, i % 2);
|
||||
printf("rows is: %"PRId64"\n", rows);
|
||||
|
||||
} else {
|
||||
errorPrint("%s() LN%d: %s\n",
|
||||
|
|
|
@ -86,30 +86,31 @@ enum {
|
|||
|
||||
typedef enum _mgmt_table {
|
||||
TSDB_MGMT_TABLE_START,
|
||||
TSDB_MGMT_TABLE_ACCT,
|
||||
TSDB_MGMT_TABLE_USER,
|
||||
TSDB_MGMT_TABLE_DB,
|
||||
TSDB_MGMT_TABLE_TABLE,
|
||||
TSDB_MGMT_TABLE_DNODE,
|
||||
TSDB_MGMT_TABLE_MNODE,
|
||||
TSDB_MGMT_TABLE_MODULE,
|
||||
TSDB_MGMT_TABLE_QNODE,
|
||||
TSDB_MGMT_TABLE_SNODE,
|
||||
TSDB_MGMT_TABLE_BNODE,
|
||||
TSDB_MGMT_TABLE_VGROUP,
|
||||
TSDB_MGMT_TABLE_STB,
|
||||
TSDB_MGMT_TABLE_MODULE,
|
||||
TSDB_MGMT_TABLE_QUERIES,
|
||||
TSDB_MGMT_TABLE_STREAMS,
|
||||
TSDB_MGMT_TABLE_VARIABLES,
|
||||
TSDB_MGMT_TABLE_CONNS,
|
||||
TSDB_MGMT_TABLE_TRANS,
|
||||
TSDB_MGMT_TABLE_GRANTS,
|
||||
TSDB_MGMT_TABLE_VNODES,
|
||||
TSDB_MGMT_TABLE_CLUSTER,
|
||||
TSDB_MGMT_TABLE_STREAMTABLES,
|
||||
TSDB_MGMT_TABLE_TP,
|
||||
TSDB_MGMT_TABLE_DB,
|
||||
TSDB_MGMT_TABLE_FUNC,
|
||||
TSDB_MGMT_TABLE_INDEX,
|
||||
TSDB_MGMT_TABLE_STB,
|
||||
TSDB_MGMT_TABLE_STREAMS,
|
||||
TSDB_MGMT_TABLE_TABLE,
|
||||
TSDB_MGMT_TABLE_USER,
|
||||
TSDB_MGMT_TABLE_GRANTS,
|
||||
TSDB_MGMT_TABLE_VGROUP,
|
||||
TSDB_MGMT_TABLE_TOPICS,
|
||||
TSDB_MGMT_TABLE_CONSUMERS,
|
||||
TSDB_MGMT_TABLE_SUBSCRIBES,
|
||||
TSDB_MGMT_TABLE_TRANS,
|
||||
TSDB_MGMT_TABLE_SMAS,
|
||||
TSDB_MGMT_TABLE_CONFIGS,
|
||||
TSDB_MGMT_TABLE_CONNS,
|
||||
TSDB_MGMT_TABLE_QUERIES,
|
||||
TSDB_MGMT_TABLE_VNODES,
|
||||
TSDB_MGMT_TABLE_MAX,
|
||||
} EShowType;
|
||||
|
||||
|
@ -363,7 +364,7 @@ typedef struct {
|
|||
int32_t maxTimeSeries;
|
||||
int32_t maxStreams;
|
||||
int32_t accessState; // Configured only by command
|
||||
int64_t maxStorage; // In unit of GB
|
||||
int64_t maxStorage;
|
||||
} SCreateAcctReq, SAlterAcctReq;
|
||||
|
||||
int32_t tSerializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pReq);
|
||||
|
@ -1884,7 +1885,6 @@ typedef struct {
|
|||
char topicName[TSDB_TOPIC_FNAME_LEN];
|
||||
char cgroup[TSDB_CGROUP_LEN];
|
||||
char* sql;
|
||||
char* logicalPlan;
|
||||
char* physicalPlan;
|
||||
char* qmsg;
|
||||
} SMqSetCVgReq;
|
||||
|
@ -1898,7 +1898,6 @@ static FORCE_INLINE int32_t tEncodeSMqSetCVgReq(void** buf, const SMqSetCVgReq*
|
|||
tlen += taosEncodeString(buf, pReq->topicName);
|
||||
tlen += taosEncodeString(buf, pReq->cgroup);
|
||||
tlen += taosEncodeString(buf, pReq->sql);
|
||||
tlen += taosEncodeString(buf, pReq->logicalPlan);
|
||||
tlen += taosEncodeString(buf, pReq->physicalPlan);
|
||||
tlen += taosEncodeString(buf, pReq->qmsg);
|
||||
return tlen;
|
||||
|
@ -1912,7 +1911,6 @@ static FORCE_INLINE void* tDecodeSMqSetCVgReq(void* buf, SMqSetCVgReq* pReq) {
|
|||
buf = taosDecodeStringTo(buf, pReq->topicName);
|
||||
buf = taosDecodeStringTo(buf, pReq->cgroup);
|
||||
buf = taosDecodeString(buf, &pReq->sql);
|
||||
buf = taosDecodeString(buf, &pReq->logicalPlan);
|
||||
buf = taosDecodeString(buf, &pReq->physicalPlan);
|
||||
buf = taosDecodeString(buf, &pReq->qmsg);
|
||||
return buf;
|
||||
|
|
|
@ -181,49 +181,50 @@
|
|||
#define TK_NULL 163
|
||||
#define TK_FIRST 164
|
||||
#define TK_LAST 165
|
||||
#define TK_NOW 166
|
||||
#define TK_TODAY 167
|
||||
#define TK_ROWTS 168
|
||||
#define TK_TBNAME 169
|
||||
#define TK_QSTARTTS 170
|
||||
#define TK_QENDTS 171
|
||||
#define TK_WSTARTTS 172
|
||||
#define TK_WENDTS 173
|
||||
#define TK_WDURATION 174
|
||||
#define TK_BETWEEN 175
|
||||
#define TK_IS 176
|
||||
#define TK_NK_LT 177
|
||||
#define TK_NK_GT 178
|
||||
#define TK_NK_LE 179
|
||||
#define TK_NK_GE 180
|
||||
#define TK_NK_NE 181
|
||||
#define TK_MATCH 182
|
||||
#define TK_NMATCH 183
|
||||
#define TK_JOIN 184
|
||||
#define TK_INNER 185
|
||||
#define TK_SELECT 186
|
||||
#define TK_DISTINCT 187
|
||||
#define TK_WHERE 188
|
||||
#define TK_PARTITION 189
|
||||
#define TK_BY 190
|
||||
#define TK_SESSION 191
|
||||
#define TK_STATE_WINDOW 192
|
||||
#define TK_SLIDING 193
|
||||
#define TK_FILL 194
|
||||
#define TK_VALUE 195
|
||||
#define TK_NONE 196
|
||||
#define TK_PREV 197
|
||||
#define TK_LINEAR 198
|
||||
#define TK_NEXT 199
|
||||
#define TK_GROUP 200
|
||||
#define TK_HAVING 201
|
||||
#define TK_ORDER 202
|
||||
#define TK_SLIMIT 203
|
||||
#define TK_SOFFSET 204
|
||||
#define TK_LIMIT 205
|
||||
#define TK_OFFSET 206
|
||||
#define TK_ASC 207
|
||||
#define TK_NULLS 208
|
||||
#define TK_CAST 166
|
||||
#define TK_NOW 167
|
||||
#define TK_TODAY 168
|
||||
#define TK_ROWTS 169
|
||||
#define TK_TBNAME 170
|
||||
#define TK_QSTARTTS 171
|
||||
#define TK_QENDTS 172
|
||||
#define TK_WSTARTTS 173
|
||||
#define TK_WENDTS 174
|
||||
#define TK_WDURATION 175
|
||||
#define TK_BETWEEN 176
|
||||
#define TK_IS 177
|
||||
#define TK_NK_LT 178
|
||||
#define TK_NK_GT 179
|
||||
#define TK_NK_LE 180
|
||||
#define TK_NK_GE 181
|
||||
#define TK_NK_NE 182
|
||||
#define TK_MATCH 183
|
||||
#define TK_NMATCH 184
|
||||
#define TK_JOIN 185
|
||||
#define TK_INNER 186
|
||||
#define TK_SELECT 187
|
||||
#define TK_DISTINCT 188
|
||||
#define TK_WHERE 189
|
||||
#define TK_PARTITION 190
|
||||
#define TK_BY 191
|
||||
#define TK_SESSION 192
|
||||
#define TK_STATE_WINDOW 193
|
||||
#define TK_SLIDING 194
|
||||
#define TK_FILL 195
|
||||
#define TK_VALUE 196
|
||||
#define TK_NONE 197
|
||||
#define TK_PREV 198
|
||||
#define TK_LINEAR 199
|
||||
#define TK_NEXT 200
|
||||
#define TK_GROUP 201
|
||||
#define TK_HAVING 202
|
||||
#define TK_ORDER 203
|
||||
#define TK_SLIMIT 204
|
||||
#define TK_SOFFSET 205
|
||||
#define TK_LIMIT 206
|
||||
#define TK_OFFSET 207
|
||||
#define TK_ASC 208
|
||||
#define TK_NULLS 209
|
||||
|
||||
#define TK_NK_SPACE 300
|
||||
#define TK_NK_COMMENT 301
|
||||
|
|
|
@ -181,6 +181,7 @@ typedef struct {
|
|||
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
|
||||
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
|
||||
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
|
||||
#define IS_INTEGER_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)))
|
||||
|
||||
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
|
||||
#define IS_MATHABLE_TYPE(_t) (IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
|
||||
|
|
|
@ -74,26 +74,12 @@ void mndStop(SMnode *pMnode);
|
|||
* @brief Get mnode monitor info.
|
||||
*
|
||||
* @param pMnode The mnode object.
|
||||
* @param pClusterInfo
|
||||
* @param pVgroupInfo
|
||||
* @param pGrantInfo
|
||||
* @param pCluster
|
||||
* @param pVgroup
|
||||
* @param pGrant
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo,
|
||||
SMonGrantInfo *pGrantInfo);
|
||||
|
||||
/**
|
||||
* @brief Get user authentication info.
|
||||
*
|
||||
* @param pMnode The mnode object.
|
||||
* @param user
|
||||
* @param spi
|
||||
* @param encrypt
|
||||
* @param secret
|
||||
* @param ckey
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t mndRetriveAuth(SMnode *pMnode, char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pCluster, SMonVgroupInfo *pVgroup, SMonGrantInfo *pGrant);
|
||||
|
||||
/**
|
||||
* @brief Process the read, write, sync request.
|
||||
|
@ -105,7 +91,6 @@ int32_t mndProcessMsg(SNodeMsg *pMsg);
|
|||
|
||||
/**
|
||||
* @brief Generate machine code
|
||||
*
|
||||
*/
|
||||
void mndGenerateMachineCode();
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ void fmFuncMgtDestroy();
|
|||
|
||||
int32_t fmGetFuncInfo(const char* pFuncName, int32_t* pFuncId, int32_t* pFuncType);
|
||||
|
||||
int32_t fmGetFuncResultType(SFunctionNode* pFunc);
|
||||
int32_t fmGetFuncResultType(SFunctionNode* pFunc, char* pErrBuf, int32_t len);
|
||||
|
||||
bool fmIsAggFunc(int32_t funcId);
|
||||
bool fmIsScalarFunc(int32_t funcId);
|
||||
|
|
|
@ -267,6 +267,11 @@ typedef struct SDescribeStmt {
|
|||
STableMeta* pMeta;
|
||||
} SDescribeStmt;
|
||||
|
||||
typedef struct SKillStmt {
|
||||
ENodeType type;
|
||||
int32_t targetId;
|
||||
} SKillStmt;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -52,7 +52,8 @@ extern "C" {
|
|||
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
|
||||
|
||||
typedef enum ENodeType {
|
||||
// Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN, VALUE, OPERATOR, FUNCTION and so on.
|
||||
// Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN,
|
||||
// VALUE, OPERATOR, FUNCTION and so on.
|
||||
QUERY_NODE_COLUMN = 1,
|
||||
QUERY_NODE_VALUE,
|
||||
QUERY_NODE_OPERATOR,
|
||||
|
@ -69,7 +70,7 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_INTERVAL_WINDOW,
|
||||
QUERY_NODE_NODE_LIST,
|
||||
QUERY_NODE_FILL,
|
||||
QUERY_NODE_RAW_EXPR, // Only be used in parser module.
|
||||
QUERY_NODE_RAW_EXPR, // Only be used in parser module.
|
||||
QUERY_NODE_TARGET,
|
||||
QUERY_NODE_DATABLOCK_DESC,
|
||||
QUERY_NODE_SLOT_DESC,
|
||||
|
@ -126,30 +127,30 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_REDISTRIBUTE_VGROUP_STMT,
|
||||
QUERY_NODE_SPLIT_VGROUP_STMT,
|
||||
QUERY_NODE_SYNCDB_STMT,
|
||||
QUERY_NODE_SHOW_DATABASES_STMT,
|
||||
QUERY_NODE_SHOW_TABLES_STMT,
|
||||
QUERY_NODE_SHOW_STABLES_STMT,
|
||||
QUERY_NODE_SHOW_USERS_STMT,
|
||||
QUERY_NODE_SHOW_DNODES_STMT,
|
||||
QUERY_NODE_SHOW_VGROUPS_STMT,
|
||||
QUERY_NODE_SHOW_MNODES_STMT,
|
||||
QUERY_NODE_SHOW_MODULES_STMT,
|
||||
QUERY_NODE_SHOW_QNODES_STMT,
|
||||
QUERY_NODE_SHOW_SNODES_STMT,
|
||||
QUERY_NODE_SHOW_BNODES_STMT,
|
||||
QUERY_NODE_SHOW_DATABASES_STMT,
|
||||
QUERY_NODE_SHOW_FUNCTIONS_STMT,
|
||||
QUERY_NODE_SHOW_INDEXES_STMT,
|
||||
QUERY_NODE_SHOW_STABLES_STMT,
|
||||
QUERY_NODE_SHOW_STREAMS_STMT,
|
||||
QUERY_NODE_SHOW_APPS_STMT,
|
||||
QUERY_NODE_SHOW_CONNECTIONS_STMT,
|
||||
QUERY_NODE_SHOW_TABLES_STMT,
|
||||
QUERY_NODE_SHOW_USERS_STMT,
|
||||
QUERY_NODE_SHOW_LICENCE_STMT,
|
||||
QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
|
||||
QUERY_NODE_SHOW_CREATE_TABLE_STMT,
|
||||
QUERY_NODE_SHOW_CREATE_STABLE_STMT,
|
||||
QUERY_NODE_SHOW_QUERIES_STMT,
|
||||
QUERY_NODE_SHOW_SCORES_STMT,
|
||||
QUERY_NODE_SHOW_VGROUPS_STMT,
|
||||
QUERY_NODE_SHOW_TOPICS_STMT,
|
||||
QUERY_NODE_SHOW_VARIABLE_STMT,
|
||||
QUERY_NODE_SHOW_BNODES_STMT,
|
||||
QUERY_NODE_SHOW_SNODES_STMT,
|
||||
QUERY_NODE_SHOW_CONSUMERS_STMT,
|
||||
QUERY_NODE_SHOW_SUBSCRIBES_STMT,
|
||||
QUERY_NODE_SHOW_TRANS_STMT,
|
||||
QUERY_NODE_SHOW_SMAS_STMT,
|
||||
QUERY_NODE_SHOW_CONFIGS_STMT,
|
||||
QUERY_NODE_SHOW_CONNECTIONS_STMT,
|
||||
QUERY_NODE_SHOW_QUERIES_STMT,
|
||||
QUERY_NODE_SHOW_VNODES_STMT,
|
||||
QUERY_NODE_KILL_CONNECTION_STMT,
|
||||
QUERY_NODE_KILL_QUERY_STMT,
|
||||
|
||||
|
|
|
@ -566,8 +566,6 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2603)
|
||||
#define TSDB_CODE_PAR_WRONG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2604)
|
||||
#define TSDB_CODE_PAR_INVALID_FUNTION TAOS_DEF_ERROR_CODE(0, 0x2605)
|
||||
#define TSDB_CODE_PAR_FUNTION_PARA_NUM TAOS_DEF_ERROR_CODE(0, 0x2606)
|
||||
#define TSDB_CODE_PAR_FUNTION_PARA_TYPE TAOS_DEF_ERROR_CODE(0, 0x2607)
|
||||
#define TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION TAOS_DEF_ERROR_CODE(0, 0x2608)
|
||||
#define TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT TAOS_DEF_ERROR_CODE(0, 0x2609)
|
||||
#define TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260A)
|
||||
|
@ -601,7 +599,12 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626)
|
||||
|
||||
//planner
|
||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||
|
||||
//function
|
||||
#define TSDB_CODE_FUNC_FUNTION_ERROR TAOS_DEF_ERROR_CODE(0, 0x2800)
|
||||
#define TSDB_CODE_FUNC_FUNTION_PARA_NUM TAOS_DEF_ERROR_CODE(0, 0x2801)
|
||||
#define TSDB_CODE_FUNC_FUNTION_PARA_TYPE TAOS_DEF_ERROR_CODE(0, 0x2802)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ extern const int32_t TYPE_BYTES[15];
|
|||
#define TSDB_INS_TABLE_MODULES "modules"
|
||||
#define TSDB_INS_TABLE_QNODES "qnodes"
|
||||
#define TSDB_INS_TABLE_BNODES "bnodes"
|
||||
#define TSDB_INS_TABLE_SNODES "snodes"
|
||||
#define TSDB_INS_TABLE_CLUSTER "cluster"
|
||||
#define TSDB_INS_TABLE_USER_DATABASES "user_databases"
|
||||
#define TSDB_INS_TABLE_USER_FUNCTIONS "user_functions"
|
||||
|
@ -115,10 +116,17 @@ extern const int32_t TYPE_BYTES[15];
|
|||
#define TSDB_INS_TABLE_USER_TABLES "user_tables"
|
||||
#define TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED "user_table_distributed"
|
||||
#define TSDB_INS_TABLE_USER_USERS "user_users"
|
||||
#define TSDB_INS_TABLE_VGROUPS "vgroups"
|
||||
#define TSDB_INS_TABLE_BNODES "bnodes"
|
||||
#define TSDB_INS_TABLE_SNODES "snodes"
|
||||
#define TSDB_INS_TABLE_LICENCES "grants"
|
||||
#define TSDB_INS_TABLE_VGROUPS "vgroups"
|
||||
#define TSDB_INS_TABLE_TOPICS "topics"
|
||||
#define TSDB_INS_TABLE_CONSUMERS "consumers"
|
||||
#define TSDB_INS_TABLE_SUBSCRIBES "subscribes"
|
||||
#define TSDB_INS_TABLE_TRANS "trans"
|
||||
#define TSDB_INS_TABLE_SMAS "smas"
|
||||
#define TSDB_INS_TABLE_CONFIGS "configs"
|
||||
#define TSDB_INS_TABLE_CONNS "connections"
|
||||
#define TSDB_INS_TABLE_QUERIES "queries"
|
||||
#define TSDB_INS_TABLE_VNODES "vnodes"
|
||||
|
||||
#define TSDB_INDEX_TYPE_SMA "SMA"
|
||||
#define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT"
|
||||
|
@ -498,6 +506,15 @@ enum {
|
|||
#define QNODE_HANDLE 1
|
||||
#define DEFAULT_HANDLE 0
|
||||
|
||||
#define TSDB_CONFIG_OPTION_LEN 16
|
||||
#define TSDB_CONIIG_VALUE_LEN 48
|
||||
#define TSDB_CONFIG_NUMBER 8
|
||||
|
||||
#define QUERY_ID_SIZE 20
|
||||
#define QUERY_OBJ_ID_SIZE 18
|
||||
#define SUBQUERY_INFO_SIZE 6
|
||||
#define QUERY_SAVE_SIZE 20
|
||||
|
||||
#define MAX_NUM_STR_SIZE 40
|
||||
|
||||
|
||||
|
|
|
@ -469,7 +469,10 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
|||
}
|
||||
if (TD_RES_TMQ(res)) {
|
||||
SReqResultInfo *pResultInfo = tmqGetNextResInfo(res);
|
||||
if (pResultInfo == NULL) return -1;
|
||||
if (pResultInfo == NULL) {
|
||||
(*numOfRows) = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pResultInfo->current = pResultInfo->numOfRows;
|
||||
(*numOfRows) = pResultInfo->numOfRows;
|
||||
|
|
|
@ -495,7 +495,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
|
|||
tsRpcTimer = cfgGetItem(pCfg, "rpcTimer")->i32;
|
||||
tsRpcMaxTime = cfgGetItem(pCfg, "rpcMaxTime")->i32;
|
||||
tsRpcForceTcp = cfgGetItem(pCfg, "rpcForceTcp")->i32;
|
||||
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->bval;
|
||||
tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32;
|
||||
tsCompressMsgSize = cfgGetItem(pCfg, "compressMsgSize")->i32;
|
||||
tsCompressColData = cfgGetItem(pCfg, "compressColData")->i32;
|
||||
tsMaxWildCardsLen = cfgGetItem(pCfg, "maxWildCardsLength")->i32;
|
||||
|
|
|
@ -2184,7 +2184,6 @@ int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq
|
|||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->showId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->type) < 0) return -1;
|
||||
// if (tEncodeI8(&encoder, pReq->free) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->tb) < 0) return -1;
|
||||
tEndEncode(&encoder);
|
||||
|
@ -2201,7 +2200,6 @@ int32_t tDeserializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableR
|
|||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->showId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->type) < 0) return -1;
|
||||
// if (tDecodeI8(&decoder, &pReq->free) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->tb) < 0) return -1;
|
||||
tEndDecode(&decoder);
|
||||
|
|
|
@ -174,7 +174,6 @@ void mmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
|||
dmSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_SHOW, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_STATUS, mmProcessReadMsg, DEFAULT_HANDLE);
|
||||
dmSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, mmProcessWriteMsg, DEFAULT_HANDLE);
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "os.h"
|
||||
|
||||
#include "dnode.h"
|
||||
#include "tmsg.h"
|
||||
#include "tdataformat.h"
|
||||
#include "tglobal.h"
|
||||
#include "tmsg.h"
|
||||
|
@ -48,92 +47,61 @@ class Testbase {
|
|||
int32_t connId;
|
||||
|
||||
public:
|
||||
void SendShowMetaReq(int8_t showType, const char* db);
|
||||
void SendShowRetrieveReq();
|
||||
|
||||
STableMetaRsp* GetShowMeta();
|
||||
SRetrieveTableRsp* GetRetrieveRsp();
|
||||
int32_t SendShowReq(int8_t showType, const char *tb, const char* db);
|
||||
int32_t GetShowRows();
|
||||
|
||||
#if 0
|
||||
int32_t GetMetaNum();
|
||||
const char* GetMetaTbName();
|
||||
int32_t GetMetaColId(int32_t index);
|
||||
int8_t GetMetaType(int32_t index);
|
||||
int32_t GetMetaBytes(int32_t index);
|
||||
const char* GetMetaName(int32_t index);
|
||||
int8_t GetMetaType(int32_t col);
|
||||
int32_t GetMetaBytes(int32_t col);
|
||||
const char* GetMetaName(int32_t col);
|
||||
|
||||
const char* GetShowName();
|
||||
int32_t GetShowRows();
|
||||
int8_t GetShowInt8();
|
||||
int16_t GetShowInt16();
|
||||
int32_t GetShowInt32();
|
||||
int64_t GetShowInt64();
|
||||
int64_t GetShowTimestamp();
|
||||
const char* GetShowBinary(int32_t len);
|
||||
int8_t GetShowInt8(int32_t row, int32_t col);
|
||||
int16_t GetShowInt16(int32_t row, int32_t col);
|
||||
int32_t GetShowInt32(int32_t row, int32_t col);
|
||||
int64_t GetShowInt64(int32_t row, int32_t col);
|
||||
int64_t GetShowTimestamp(int32_t row, int32_t col);
|
||||
const char* GetShowBinary(int32_t row, int32_t col);
|
||||
#endif
|
||||
|
||||
private:
|
||||
int64_t showId;
|
||||
STableMetaRsp metaRsp;
|
||||
SRetrieveTableRsp* pRetrieveRsp;
|
||||
char* pData;
|
||||
int32_t pos;
|
||||
SRetrieveMetaTableRsp* showRsp;
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
||||
#define CHECK_META(tbName, numOfColumns) \
|
||||
{ \
|
||||
EXPECT_EQ(test.GetMetaNum(), numOfColumns); \
|
||||
EXPECT_STREQ(test.GetMetaTbName(), tbName); \
|
||||
}
|
||||
|
||||
#define CHECK_SCHEMA(colId, type, bytes, colName) \
|
||||
{ \
|
||||
EXPECT_EQ(test.GetMetaType(colId), type); \
|
||||
EXPECT_EQ(test.GetMetaBytes(colId), bytes); \
|
||||
EXPECT_STREQ(test.GetMetaName(colId), colName); \
|
||||
}
|
||||
|
||||
#define CheckBinary(val, len) \
|
||||
{ EXPECT_STREQ(test.GetShowBinary(len), val); }
|
||||
|
||||
#define CheckBinaryByte(b, len) \
|
||||
#define CHECK_SCHEMA(col, type, bytes, colName) \
|
||||
{ \
|
||||
char* bytes = (char*)taosMemoryCalloc(1, len); \
|
||||
for (int32_t i = 0; i < len - 1; ++i) { \
|
||||
bytes[i] = b; \
|
||||
} \
|
||||
EXPECT_STREQ(test.GetShowBinary(len), bytes); \
|
||||
EXPECT_EQ(test.GetMetaType(col), type); \
|
||||
EXPECT_EQ(test.GetMetaBytes(col), bytes); \
|
||||
EXPECT_STREQ(test.GetMetaName(col), colName); \
|
||||
}
|
||||
|
||||
#define CheckBinary(row, col, val) \
|
||||
{ EXPECT_STREQ(test.GetShowBinary(row, col), val); }
|
||||
|
||||
#define CheckInt8(val) \
|
||||
{ EXPECT_EQ(test.GetShowInt8(), val); }
|
||||
{ EXPECT_EQ(test.GetShowInt8(row, col), val); }
|
||||
|
||||
#define CheckInt16(val) \
|
||||
{ EXPECT_EQ(test.GetShowInt16(), val); }
|
||||
{ EXPECT_EQ(test.GetShowInt16(row, col), val); }
|
||||
|
||||
#define CheckInt32(val) \
|
||||
{ EXPECT_EQ(test.GetShowInt32(), val); }
|
||||
{ EXPECT_EQ(test.GetShowInt32row, col(), val); }
|
||||
|
||||
#define CheckInt64(val) \
|
||||
{ EXPECT_EQ(test.GetShowInt64(), val); }
|
||||
{ EXPECT_EQ(test.GetShowInt64(row, col), val); }
|
||||
|
||||
#define CheckTimestamp() \
|
||||
{ EXPECT_GT(test.GetShowTimestamp(), 0); }
|
||||
{ EXPECT_GT(test.GetShowTimestamp(row, col), 0); }
|
||||
|
||||
#define IgnoreBinary(len) \
|
||||
{ test.GetShowBinary(len); }
|
||||
|
||||
#define IgnoreInt8() \
|
||||
{ test.GetShowInt8(); }
|
||||
|
||||
#define IgnoreInt16() \
|
||||
{ test.GetShowInt16(); }
|
||||
|
||||
#define IgnoreInt32() \
|
||||
{ test.GetShowInt32(); }
|
||||
|
||||
#define IgnoreInt64() \
|
||||
{ test.GetShowInt64(); }
|
||||
|
||||
#define IgnoreTimestamp() \
|
||||
{ test.GetShowTimestamp(); }
|
||||
#endif
|
||||
|
||||
#endif /* _TD_TEST_BASE_H_ */
|
||||
|
|
|
@ -49,16 +49,14 @@ void Testbase::Init(const char* path, int16_t port) {
|
|||
InitLog("/tmp/td");
|
||||
server.Start(path, fqdn, port, firstEp);
|
||||
client.Init("root", "taosdata", fqdn, port);
|
||||
|
||||
tFreeSTableMetaRsp(&metaRsp);
|
||||
showId = 0;
|
||||
pData = 0;
|
||||
pos = 0;
|
||||
pRetrieveRsp = NULL;
|
||||
showRsp = NULL;
|
||||
}
|
||||
|
||||
void Testbase::Cleanup() {
|
||||
tFreeSTableMetaRsp(&metaRsp);
|
||||
if (showRsp != NULL) {
|
||||
rpcFreeCont(showRsp);
|
||||
showRsp = NULL;
|
||||
}
|
||||
client.Cleanup();
|
||||
taosMsleep(10);
|
||||
server.Stop();
|
||||
|
@ -84,112 +82,40 @@ SRpcMsg* Testbase::SendReq(tmsg_t msgType, void* pCont, int32_t contLen) {
|
|||
return client.SendReq(&rpcMsg);
|
||||
}
|
||||
|
||||
void Testbase::SendShowMetaReq(int8_t showType, const char* db) {
|
||||
SShowReq showReq = {0};
|
||||
showReq.type = showType;
|
||||
strcpy(showReq.db, db);
|
||||
int32_t Testbase::SendShowReq(int8_t showType, const char *tb, const char* db) {
|
||||
if (showRsp != NULL) {
|
||||
rpcFreeCont(showRsp);
|
||||
showRsp = NULL;
|
||||
}
|
||||
|
||||
int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
tSerializeSShowReq(pReq, contLen, &showReq);
|
||||
tFreeSShowReq(&showReq);
|
||||
|
||||
SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT(pRsp->pCont != nullptr);
|
||||
|
||||
if (pRsp->contLen == 0) return;
|
||||
|
||||
SShowRsp showRsp = {0};
|
||||
tDeserializeSShowRsp(pRsp->pCont, pRsp->contLen, &showRsp);
|
||||
tFreeSTableMetaRsp(&metaRsp);
|
||||
metaRsp = showRsp.tableMeta;
|
||||
showId = showRsp.showId;
|
||||
}
|
||||
|
||||
int32_t Testbase::GetMetaColId(int32_t index) {
|
||||
SSchema* pSchema = &metaRsp.pSchemas[index];
|
||||
return pSchema->colId;
|
||||
}
|
||||
|
||||
int8_t Testbase::GetMetaType(int32_t index) {
|
||||
SSchema* pSchema = &metaRsp.pSchemas[index];
|
||||
return pSchema->type;
|
||||
}
|
||||
|
||||
int32_t Testbase::GetMetaBytes(int32_t index) {
|
||||
SSchema* pSchema = &metaRsp.pSchemas[index];
|
||||
return pSchema->bytes;
|
||||
}
|
||||
|
||||
const char* Testbase::GetMetaName(int32_t index) {
|
||||
SSchema* pSchema = &metaRsp.pSchemas[index];
|
||||
return pSchema->name;
|
||||
}
|
||||
|
||||
int32_t Testbase::GetMetaNum() { return metaRsp.numOfColumns; }
|
||||
|
||||
const char* Testbase::GetMetaTbName() { return metaRsp.tbName; }
|
||||
|
||||
void Testbase::SendShowRetrieveReq() {
|
||||
SRetrieveTableReq retrieveReq = {0};
|
||||
retrieveReq.showId = showId;
|
||||
// retrieveReq.free = 0;
|
||||
retrieveReq.type = showType;
|
||||
strcpy(retrieveReq.db, db);
|
||||
strcpy(retrieveReq.tb, tb);
|
||||
|
||||
int32_t contLen = tSerializeSRetrieveTableReq(NULL, 0, &retrieveReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
tSerializeSRetrieveTableReq(pReq, contLen, &retrieveReq);
|
||||
|
||||
// SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW_RETRIEVE, pReq, contLen);
|
||||
// pRetrieveRsp = (SRetrieveTableRsp*)pRsp->pCont;
|
||||
// pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
|
||||
// pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds);
|
||||
// pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen);
|
||||
SRpcMsg* pRsp = SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen);
|
||||
ASSERT(pRsp->pCont != nullptr);
|
||||
|
||||
pData = pRetrieveRsp->data;
|
||||
pos = 0;
|
||||
if (pRsp->contLen == 0) return -1;
|
||||
|
||||
showRsp = (SRetrieveMetaTableRsp*)pRsp->pCont;
|
||||
showRsp->handle = htobe64(showRsp->handle); // show Id
|
||||
showRsp->useconds = htobe64(showRsp->useconds);
|
||||
showRsp->numOfRows = htonl(showRsp->numOfRows);
|
||||
showRsp->compLen = htonl(showRsp->compLen);
|
||||
if (showRsp->numOfRows <= 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* Testbase::GetShowName() { return metaRsp.tbName; }
|
||||
|
||||
int8_t Testbase::GetShowInt8() {
|
||||
int8_t data = *((int8_t*)(pData + pos));
|
||||
pos += sizeof(int8_t);
|
||||
return data;
|
||||
int32_t Testbase::GetShowRows() {
|
||||
if (showRsp != NULL) {
|
||||
return showRsp->numOfRows;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int16_t Testbase::GetShowInt16() {
|
||||
int16_t data = *((int16_t*)(pData + pos));
|
||||
pos += sizeof(int16_t);
|
||||
return data;
|
||||
}
|
||||
|
||||
int32_t Testbase::GetShowInt32() {
|
||||
int32_t data = *((int32_t*)(pData + pos));
|
||||
pos += sizeof(int32_t);
|
||||
return data;
|
||||
}
|
||||
|
||||
int64_t Testbase::GetShowInt64() {
|
||||
int64_t data = *((int64_t*)(pData + pos));
|
||||
pos += sizeof(int64_t);
|
||||
return data;
|
||||
}
|
||||
|
||||
int64_t Testbase::GetShowTimestamp() {
|
||||
int64_t data = *((int64_t*)(pData + pos));
|
||||
pos += sizeof(int64_t);
|
||||
return data;
|
||||
}
|
||||
|
||||
const char* Testbase::GetShowBinary(int32_t len) {
|
||||
pos += sizeof(VarDataLenT);
|
||||
char* data = (char*)(pData + pos);
|
||||
pos += len;
|
||||
return data;
|
||||
}
|
||||
|
||||
int32_t Testbase::GetShowRows() { return pRetrieveRsp->numOfRows; }
|
||||
|
||||
STableMetaRsp* Testbase::GetShowMeta() { return &metaRsp; }
|
||||
|
||||
SRetrieveTableRsp* Testbase::GetRetrieveRsp() { return pRetrieveRsp; }
|
||||
|
|
|
@ -213,7 +213,7 @@ typedef struct {
|
|||
int32_t maxConsumers;
|
||||
int32_t maxConns;
|
||||
int32_t maxTopics;
|
||||
int64_t maxStorage; // In unit of GB
|
||||
int64_t maxStorage;
|
||||
int32_t accessState; // Configured only by command
|
||||
} SAcctCfg;
|
||||
|
||||
|
@ -379,20 +379,20 @@ typedef struct {
|
|||
} SFuncObj;
|
||||
|
||||
typedef struct {
|
||||
int64_t id;
|
||||
int8_t type;
|
||||
int8_t replica;
|
||||
int16_t numOfColumns;
|
||||
int32_t rowSize;
|
||||
int32_t numOfRows;
|
||||
int32_t payloadLen;
|
||||
void* pIter;
|
||||
SMnode* pMnode;
|
||||
int64_t id;
|
||||
int8_t type;
|
||||
int8_t replica;
|
||||
int16_t numOfColumns;
|
||||
int32_t rowSize;
|
||||
int32_t numOfRows;
|
||||
int32_t payloadLen;
|
||||
void* pIter;
|
||||
SMnode* pMnode;
|
||||
STableMetaRsp* pMeta;
|
||||
bool sysDbRsp;
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int16_t offset[TSDB_MAX_COLUMNS];
|
||||
int32_t bytes[TSDB_MAX_COLUMNS];
|
||||
bool sysDbRsp;
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int16_t offset[TSDB_MAX_COLUMNS];
|
||||
int32_t bytes[TSDB_MAX_COLUMNS];
|
||||
} SShowObj;
|
||||
|
||||
typedef struct {
|
||||
|
@ -625,14 +625,14 @@ static FORCE_INLINE void* tDecodeSubscribeObj(void* buf, SMqSubscribeObj* pSub)
|
|||
|
||||
static FORCE_INLINE void tDeleteSMqSubscribeObj(SMqSubscribeObj* pSub) {
|
||||
if (pSub->consumers) {
|
||||
//taosArrayDestroyEx(pSub->consumers, (void (*)(void*))tDeleteSMqSubConsumer);
|
||||
// taosArrayDestroy(pSub->consumers);
|
||||
// taosArrayDestroyEx(pSub->consumers, (void (*)(void*))tDeleteSMqSubConsumer);
|
||||
// taosArrayDestroy(pSub->consumers);
|
||||
pSub->consumers = NULL;
|
||||
}
|
||||
|
||||
if (pSub->unassignedVg) {
|
||||
//taosArrayDestroyEx(pSub->unassignedVg, (void (*)(void*))tDeleteSMqConsumerEp);
|
||||
// taosArrayDestroy(pSub->unassignedVg);
|
||||
// taosArrayDestroyEx(pSub->unassignedVg, (void (*)(void*))tDeleteSMqConsumerEp);
|
||||
// taosArrayDestroy(pSub->unassignedVg);
|
||||
pSub->unassignedVg = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -647,8 +647,9 @@ typedef struct {
|
|||
int32_t version;
|
||||
SRWLatch lock;
|
||||
int32_t sqlLen;
|
||||
int32_t astLen;
|
||||
char* sql;
|
||||
char* logicalPlan;
|
||||
char* ast;
|
||||
char* physicalPlan;
|
||||
SSchemaWrapper schema;
|
||||
} SMqTopicObj;
|
||||
|
|
|
@ -23,20 +23,20 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct SInfosTableSchema {
|
||||
char *name;
|
||||
int32_t type;
|
||||
int32_t bytes;
|
||||
const char *name;
|
||||
const int32_t type;
|
||||
const int32_t bytes;
|
||||
} SInfosTableSchema;
|
||||
|
||||
typedef struct SInfosTableMeta {
|
||||
char *name;
|
||||
const char *name;
|
||||
const SInfosTableSchema *schema;
|
||||
int32_t colNum;
|
||||
const int32_t colNum;
|
||||
} SInfosTableMeta;
|
||||
|
||||
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp);
|
||||
int32_t mndInitInfos(SMnode *pMnode);
|
||||
void mndCleanupInfos(SMnode *pMnode);
|
||||
void mndCleanupInfos(SMnode *pMnode);
|
||||
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ int32_t mndInitShow(SMnode *pMnode);
|
|||
void mndCleanupShow(SMnode *pMnode);
|
||||
void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp);
|
||||
void mndAddShowFreeIterHandle(SMnode *pMnode, EShowType msgType, ShowFreeIterFp fp);
|
||||
void mndVacuumResult(char *data, int32_t numOfCols, int32_t rows, int32_t capacity, SShowObj *pShow);
|
||||
char *mndShowStr(int32_t showType);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "mndAcct.h"
|
||||
#include "mndShow.h"
|
||||
|
||||
#define TSDB_ACCT_VER_NUMBER 1
|
||||
#define TSDB_ACCT_VER_NUMBER 1
|
||||
#define TSDB_ACCT_RESERVE_SIZE 128
|
||||
|
||||
static int32_t mndCreateDefaultAcct(SMnode *pMnode);
|
||||
|
@ -80,32 +80,32 @@ static SSdbRaw *mndAcctActionEncode(SAcctObj *pAcct) {
|
|||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_ACCT, TSDB_ACCT_VER_NUMBER, sizeof(SAcctObj) + TSDB_ACCT_RESERVE_SIZE);
|
||||
if (pRaw == NULL) goto ACCT_ENCODE_OVER;
|
||||
if (pRaw == NULL) goto _OVER;
|
||||
|
||||
int32_t dataPos = 0;
|
||||
SDB_SET_BINARY(pRaw, dataPos, pAcct->acct, TSDB_USER_LEN, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pAcct->createdTime, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pAcct->updateTime, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->acctId, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->status, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxUsers, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxDbs, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxStbs, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTbs, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTimeSeries, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxStreams, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxFuncs, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxConsumers, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxConns, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTopics, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pAcct->cfg.maxStorage, ACCT_ENCODE_OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.accessState, ACCT_ENCODE_OVER)
|
||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_ACCT_RESERVE_SIZE, ACCT_ENCODE_OVER)
|
||||
SDB_SET_DATALEN(pRaw, dataPos, ACCT_ENCODE_OVER)
|
||||
SDB_SET_BINARY(pRaw, dataPos, pAcct->acct, TSDB_USER_LEN, _OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pAcct->createdTime, _OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pAcct->updateTime, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->acctId, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->status, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxUsers, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxDbs, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxStbs, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTbs, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTimeSeries, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxStreams, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxFuncs, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxConsumers, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxConns, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.maxTopics, _OVER)
|
||||
SDB_SET_INT64(pRaw, dataPos, pAcct->cfg.maxStorage, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pAcct->cfg.accessState, _OVER)
|
||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_ACCT_RESERVE_SIZE, _OVER)
|
||||
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||
|
||||
terrno = 0;
|
||||
|
||||
ACCT_ENCODE_OVER:
|
||||
_OVER:
|
||||
if (terrno != 0) {
|
||||
mError("acct:%s, failed to encode to raw:%p since %s", pAcct->acct, pRaw, terrstr());
|
||||
sdbFreeRaw(pRaw);
|
||||
|
@ -120,42 +120,42 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw) {
|
|||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
int8_t sver = 0;
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto ACCT_DECODE_OVER;
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
|
||||
|
||||
if (sver != TSDB_ACCT_VER_NUMBER) {
|
||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||
goto ACCT_DECODE_OVER;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
SSdbRow *pRow = sdbAllocRow(sizeof(SAcctObj));
|
||||
if (pRow == NULL) goto ACCT_DECODE_OVER;
|
||||
if (pRow == NULL) goto _OVER;
|
||||
|
||||
SAcctObj *pAcct = sdbGetRowObj(pRow);
|
||||
if (pAcct == NULL) goto ACCT_DECODE_OVER;
|
||||
if (pAcct == NULL) goto _OVER;
|
||||
|
||||
int32_t dataPos = 0;
|
||||
SDB_GET_BINARY(pRaw, dataPos, pAcct->acct, TSDB_USER_LEN, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pAcct->createdTime, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pAcct->updateTime, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->acctId, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->status, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxUsers, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxDbs, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxStbs, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTbs, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTimeSeries, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxStreams, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxFuncs, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxConsumers, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxConns, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTopics, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pAcct->cfg.maxStorage, ACCT_DECODE_OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.accessState, ACCT_DECODE_OVER)
|
||||
SDB_GET_RESERVE(pRaw, dataPos, TSDB_ACCT_RESERVE_SIZE, ACCT_DECODE_OVER)
|
||||
SDB_GET_BINARY(pRaw, dataPos, pAcct->acct, TSDB_USER_LEN, _OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pAcct->createdTime, _OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pAcct->updateTime, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->acctId, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->status, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxUsers, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxDbs, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxStbs, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTbs, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTimeSeries, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxStreams, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxFuncs, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxConsumers, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxConns, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.maxTopics, _OVER)
|
||||
SDB_GET_INT64(pRaw, dataPos, &pAcct->cfg.maxStorage, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pAcct->cfg.accessState, _OVER)
|
||||
SDB_GET_RESERVE(pRaw, dataPos, TSDB_ACCT_RESERVE_SIZE, _OVER)
|
||||
|
||||
terrno = 0;
|
||||
|
||||
ACCT_DECODE_OVER:
|
||||
_OVER:
|
||||
if (terrno != 0) {
|
||||
mError("acct:%s, failed to decode from raw:%p since %s", pAcct->acct, pRaw, terrstr());
|
||||
taosMemoryFreeClear(pRow);
|
||||
|
|
|
@ -26,22 +26,22 @@ int32_t mndInitAuth(SMnode *pMnode) {
|
|||
|
||||
void mndCleanupAuth(SMnode *pMnode) {}
|
||||
|
||||
int32_t mndRetriveAuth(SMnode *pMnode, char *user, char *spi, char *encrypt, char *secret, char *ckey) {
|
||||
SUserObj *pUser = mndAcquireUser(pMnode, user);
|
||||
static int32_t mndRetriveAuth(SMnode *pMnode, SAuthRsp *pRsp) {
|
||||
SUserObj *pUser = mndAcquireUser(pMnode, pRsp->user);
|
||||
if (pUser == NULL) {
|
||||
*secret = 0;
|
||||
mError("user:%s, failed to auth user since %s", user, terrstr());
|
||||
*pRsp->secret = 0;
|
||||
mError("user:%s, failed to auth user since %s", pRsp->user, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
*spi = 1;
|
||||
*encrypt = 0;
|
||||
*ckey = 0;
|
||||
pRsp->spi = 1;
|
||||
pRsp->encrypt = 0;
|
||||
*pRsp->ckey = 0;
|
||||
|
||||
memcpy(secret, pUser->pass, TSDB_PASSWORD_LEN);
|
||||
memcpy(pRsp->secret, pUser->pass, TSDB_PASSWORD_LEN);
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
|
||||
mDebug("user:%s, auth info is returned", user);
|
||||
mDebug("user:%s, auth info is returned", pRsp->user);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -55,14 +55,19 @@ static int32_t mndProcessAuthReq(SNodeMsg *pReq) {
|
|||
SAuthReq authRsp = {0};
|
||||
memcpy(authRsp.user, authReq.user, TSDB_USER_LEN);
|
||||
|
||||
int32_t code =
|
||||
mndRetriveAuth(pReq->pNode, authRsp.user, &authRsp.spi, &authRsp.encrypt, authRsp.secret, authRsp.ckey);
|
||||
int32_t code = mndRetriveAuth(pReq->pNode, &authRsp);
|
||||
mTrace("user:%s, auth req received, spi:%d encrypt:%d ruser:%s", pReq->user, authRsp.spi, authRsp.encrypt,
|
||||
authRsp.user);
|
||||
|
||||
int32_t contLen = tSerializeSAuthReq(NULL, 0, &authRsp);
|
||||
void *pRsp = rpcMallocCont(contLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tSerializeSAuthReq(pRsp, contLen, &authRsp);
|
||||
|
||||
pReq->pRsp = pRsp;
|
||||
pReq->rspLen = contLen;
|
||||
return code;
|
||||
|
@ -95,11 +100,11 @@ int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SDbObj *pDb,
|
|||
}
|
||||
}
|
||||
|
||||
if (pAlter->alterType == TSDB_ALTER_USER_CLEAR_WRITE_DB || pAlter->alterType == TSDB_ALTER_USER_CLEAR_READ_DB) {
|
||||
if (pOperUser->superUser) {
|
||||
return 0;
|
||||
}
|
||||
if (pAlter->alterType == TSDB_ALTER_USER_CLEAR_WRITE_DB || pAlter->alterType == TSDB_ALTER_USER_CLEAR_READ_DB) {
|
||||
if (pOperUser->superUser) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (pAlter->alterType == TSDB_ALTER_USER_ADD_READ_DB || pAlter->alterType == TSDB_ALTER_USER_REMOVE_READ_DB ||
|
||||
pAlter->alterType == TSDB_ALTER_USER_ADD_WRITE_DB || pAlter->alterType == TSDB_ALTER_USER_REMOVE_WRITE_DB) {
|
||||
|
@ -176,4 +181,4 @@ int32_t mndCheckReadAuth(SUserObj *pOperUser, SDbObj *pDb) {
|
|||
|
||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
|
||||
#define TSDB_DNODE_VER_NUMBER 1
|
||||
#define TSDB_DNODE_RESERVE_SIZE 64
|
||||
#define TSDB_CONFIG_OPTION_LEN 16
|
||||
#define TSDB_CONIIG_VALUE_LEN 48
|
||||
#define TSDB_CONFIG_NUMBER 8
|
||||
|
||||
static const char *offlineReason[] = {
|
||||
"",
|
||||
|
@ -55,7 +52,6 @@ static int32_t mndProcessConfigDnodeReq(SNodeMsg *pReq);
|
|||
static int32_t mndProcessConfigDnodeRsp(SNodeMsg *pRsp);
|
||||
static int32_t mndProcessStatusReq(SNodeMsg *pReq);
|
||||
|
||||
static int32_t mndGetConfigMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta);
|
||||
static int32_t mndRetrieveConfigs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows);
|
||||
static void mndCancelGetNextConfig(SMnode *pMnode, void *pIter);
|
||||
static int32_t mndRetrieveDnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows);
|
||||
|
@ -77,8 +73,8 @@ int32_t mndInitDnode(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndProcessConfigDnodeRsp);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_STATUS, mndProcessStatusReq);
|
||||
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_VARIABLES, mndRetrieveConfigs);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_VARIABLES, mndCancelGetNextConfig);
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig);
|
||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_DNODE, mndRetrieveDnodes);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_DNODE, mndCancelGetNextDnode);
|
||||
|
||||
|
@ -638,37 +634,6 @@ static int32_t mndProcessConfigDnodeRsp(SNodeMsg *pRsp) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mndGetConfigMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) {
|
||||
int32_t cols = 0;
|
||||
SSchema *pSchema = pMeta->pSchemas;
|
||||
|
||||
pShow->bytes[cols] = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_CONIIG_VALUE_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "value");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = cols;
|
||||
pShow->numOfColumns = cols;
|
||||
|
||||
pShow->offset[0] = 0;
|
||||
for (int32_t i = 1; i < cols; ++i) {
|
||||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||
}
|
||||
|
||||
pShow->numOfRows = TSDB_CONFIG_NUMBER;
|
||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||
strcpy(pMeta->tbName, mndShowStr(pShow->type));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveConfigs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t totalRows = 0;
|
||||
|
|
|
@ -18,9 +18,8 @@
|
|||
|
||||
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
||||
|
||||
//!!!! Note: only APPEND columns in below tables, NO insert !!!!
|
||||
static const SInfosTableSchema dnodesSchema[] = {
|
||||
{.name = "id", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
|
@ -30,6 +29,7 @@ static const SInfosTableSchema dnodesSchema[] = {
|
|||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema mnodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
|
@ -37,31 +37,37 @@ static const SInfosTableSchema mnodesSchema[] = {
|
|||
{.name = "role_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema modulesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = 134, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "module", .bytes = 10, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema qnodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema snodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema bnodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema clusterSchema[] = {
|
||||
{.name = "id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "name", .bytes = TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userDBSchema[] = {
|
||||
{.name = "name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
|
@ -84,9 +90,9 @@ static const SInfosTableSchema userDBSchema[] = {
|
|||
{.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "stream_mode", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
// {.name = "update", .bytes = 1, .type =
|
||||
// TSDB_DATA_TYPE_TINYINT}, // disable update
|
||||
// {.name = "update", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, // disable update
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userFuncSchema[] = {
|
||||
{.name = "name", .bytes = 32, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
|
@ -94,6 +100,7 @@ static const SInfosTableSchema userFuncSchema[] = {
|
|||
{.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userIdxSchema[] = {
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
|
@ -103,6 +110,7 @@ static const SInfosTableSchema userIdxSchema[] = {
|
|||
{.name = "index_type", .bytes = 10, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "index_extensions", .bytes = 256, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userStbsSchema[] = {
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
|
@ -112,6 +120,7 @@ static const SInfosTableSchema userStbsSchema[] = {
|
|||
{.name = "last_update", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "table_comment", .bytes = 1024 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userStreamsSchema[] = {
|
||||
{.name = "stream_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "user_name", .bytes = 23, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
|
@ -119,6 +128,7 @@ static const SInfosTableSchema userStreamsSchema[] = {
|
|||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = 1024, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userTblsSchema[] = {
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
|
@ -130,6 +140,7 @@ static const SInfosTableSchema userTblsSchema[] = {
|
|||
{.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "table_comment", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userTblDistSchema[] = {
|
||||
{.name = "db_name", .bytes = 32, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
|
@ -145,12 +156,14 @@ static const SInfosTableSchema userTblDistSchema[] = {
|
|||
{.name = "rows_in_mem", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "seek_header_time", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userUsersSchema[] = {
|
||||
{.name = "name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "privilege", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "account", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema grantsSchema[] = {
|
||||
{.name = "version", .bytes = 8 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "expire time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
|
@ -167,6 +180,7 @@ static const SInfosTableSchema grantsSchema[] = {
|
|||
{.name = "speed(PPS)", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema vgroupsSchema[] = {
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
|
@ -210,14 +224,62 @@ static const SInfosTableSchema subscribeSchema[] = {
|
|||
{.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema smaSchema[] = {
|
||||
{.name = "sma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema transSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "stage", .bytes = TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "type", .bytes = TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "last_exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "last_error", .bytes = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema configSchema[] = {
|
||||
{.name = "name", .bytes = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "value", .bytes = TSDB_CONIIG_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema connSchema[] = {
|
||||
{.name = "connId", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "program", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "ip:port", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema querySchema[] = {
|
||||
{.name = "queryId", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "connId", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "ip:port", .bytes = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "qid", .bytes = 22 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "created_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "time", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "sql_obj_id", .bytes = QUERY_OBJ_ID_SIZE + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "ep", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "stable_query", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
|
||||
{.name = "sub_queries", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "sub_query_info", .bytes = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableMeta infosMeta[] = {
|
||||
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema)},
|
||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema)},
|
||||
{TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema)},
|
||||
{TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema)},
|
||||
{TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)},
|
||||
{TSDB_INS_TABLE_BNODES, bnodesSchema, tListLen(bnodesSchema)},
|
||||
{TSDB_INS_TABLE_CLUSTER, clusterSchema, tListLen(clusterSchema)},
|
||||
{TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)},
|
||||
{TSDB_INS_TABLE_USER_DATABASES, userDBSchema, tListLen(userDBSchema)},
|
||||
{TSDB_INS_TABLE_USER_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema)},
|
||||
{TSDB_INS_TABLE_USER_INDEXES, userIdxSchema, tListLen(userIdxSchema)},
|
||||
|
@ -226,12 +288,19 @@ static const SInfosTableMeta infosMeta[] = {
|
|||
{TSDB_INS_TABLE_USER_TABLES, userTblsSchema, tListLen(userTblsSchema)},
|
||||
{TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, userTblDistSchema, tListLen(userTblDistSchema)},
|
||||
{TSDB_INS_TABLE_USER_USERS, userUsersSchema, tListLen(userUsersSchema)},
|
||||
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)},
|
||||
{TSDB_INS_TABLE_LICENCES, grantsSchema, tListLen(grantsSchema)},
|
||||
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)},
|
||||
{TSDB_INS_TABLE_TOPICS, topicSchema, tListLen(topicSchema)},
|
||||
{TSDB_INS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema)},
|
||||
{TSDB_INS_TABLE_SUBSCRIBES, subscribeSchema, tListLen(subscribeSchema)},
|
||||
{TSDB_INS_TABLE_TRANS, transSchema, tListLen(transSchema)},
|
||||
{TSDB_INS_TABLE_SMAS, smaSchema, tListLen(smaSchema)},
|
||||
{TSDB_INS_TABLE_CONFIGS, configSchema, tListLen(configSchema)},
|
||||
{TSDB_INS_TABLE_CONNS, connSchema, tListLen(connSchema)},
|
||||
{TSDB_INS_TABLE_QUERIES, querySchema, tListLen(querySchema)},
|
||||
};
|
||||
|
||||
// connection/application/
|
||||
int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
||||
static int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
||||
SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
|
||||
if (NULL == schema) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -239,40 +308,39 @@ int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, S
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < colNum; ++i) {
|
||||
strcpy(schema[i].name, pSrc[i].name);
|
||||
|
||||
tstrncpy(schema[i].name, pSrc[i].name, sizeof(schema[i].name));
|
||||
schema[i].type = pSrc[i].type;
|
||||
schema[i].colId = i + 1;
|
||||
schema[i].bytes = pSrc[i].bytes;
|
||||
}
|
||||
|
||||
*pDst = schema;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndInsInitMeta(SHashObj *hash) {
|
||||
static int32_t mndInsInitMeta(SHashObj *hash) {
|
||||
STableMetaRsp meta = {0};
|
||||
|
||||
strcpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB);
|
||||
tstrncpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB, sizeof(meta.dbFName));
|
||||
meta.tableType = TSDB_SYSTEM_TABLE;
|
||||
meta.sversion = 1;
|
||||
meta.tversion = 1;
|
||||
|
||||
for (int32_t i = 0; i < tListLen(infosMeta); ++i) {
|
||||
strcpy(meta.tbName, infosMeta[i].name);
|
||||
tstrncpy(meta.tbName, infosMeta[i].name, sizeof(meta.tbName));
|
||||
meta.numOfColumns = infosMeta[i].colNum;
|
||||
|
||||
if (mndInitInfosTableSchema(infosMeta[i].schema, infosMeta[i].colNum, &meta.pSchemas)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) {
|
||||
if (taosHashPut(hash, meta.tbName, strlen(meta.tbName) + 1, &meta, sizeof(meta))) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) {
|
||||
|
@ -281,24 +349,23 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
|
|||
return -1;
|
||||
}
|
||||
|
||||
STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, tbName, strlen(tbName));
|
||||
if (NULL == meta) {
|
||||
STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName) + 1);
|
||||
if (NULL == pMeta) {
|
||||
mError("invalid information schema table name:%s", tbName);
|
||||
terrno = TSDB_CODE_MND_INVALID_INFOS_TBL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*pRsp = *meta;
|
||||
*pRsp = *pMeta;
|
||||
|
||||
pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema));
|
||||
pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema));
|
||||
if (pRsp->pSchemas == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
pRsp->pSchemas = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(pRsp->pSchemas, meta->pSchemas, meta->numOfColumns * sizeof(SSchema));
|
||||
|
||||
memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -317,16 +384,12 @@ void mndCleanupInfos(SMnode *pMnode) {
|
|||
return;
|
||||
}
|
||||
|
||||
void *pIter = taosHashIterate(pMnode->infosMeta, NULL);
|
||||
while (pIter) {
|
||||
STableMetaRsp *meta = (STableMetaRsp *)pIter;
|
||||
|
||||
taosMemoryFreeClear(meta->pSchemas);
|
||||
|
||||
pIter = taosHashIterate(pMnode->infosMeta, pIter);
|
||||
STableMetaRsp *pMeta = taosHashIterate(pMnode->infosMeta, NULL);
|
||||
while (pMeta) {
|
||||
taosMemoryFreeClear(pMeta->pSchemas);
|
||||
pMeta = taosHashIterate(pMnode->infosMeta, pMeta);
|
||||
}
|
||||
|
||||
taosHashCleanup(pMnode->infosMeta);
|
||||
pMnode->infosMeta = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ static int32_t mndOffsetActionDelete(SSdb *pSdb, SMqOffsetObj *pOffset) {
|
|||
|
||||
static int32_t mndOffsetActionUpdate(SSdb *pSdb, SMqOffsetObj *pOldOffset, SMqOffsetObj *pNewOffset) {
|
||||
mTrace("offset:%s, perform update action", pOldOffset->key);
|
||||
pOldOffset->offset = pNewOffset->offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,6 @@
|
|||
#include "tglobal.h"
|
||||
#include "version.h"
|
||||
|
||||
#define QUERY_ID_SIZE 20
|
||||
#define QUERY_OBJ_ID_SIZE 18
|
||||
#define SUBQUERY_INFO_SIZE 6
|
||||
#define QUERY_SAVE_SIZE 20
|
||||
|
||||
typedef struct {
|
||||
int32_t id;
|
||||
int8_t connType;
|
||||
|
@ -56,9 +51,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq);
|
|||
static int32_t mndProcessConnectReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessKillQueryReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessKillConnReq(SNodeMsg *pReq);
|
||||
static int32_t mndGetConnsMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta);
|
||||
static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
||||
static int32_t mndGetQueryMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta);
|
||||
static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
||||
static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter);
|
||||
|
||||
|
@ -558,81 +551,6 @@ static int32_t mndProcessKillConnReq(SNodeMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t mndGetConnsMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
SUserObj *pUser = mndAcquireUser(pMnode, pReq->user);
|
||||
if (pUser == NULL) return 0;
|
||||
if (!pUser->superUser) {
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||
return -1;
|
||||
}
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
|
||||
int32_t cols = 0;
|
||||
SSchema *pSchema = pMeta->pSchemas;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "connId");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_USER_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "user");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
// app name
|
||||
pShow->bytes[cols] = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "program");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
// app pid
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "pid");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "ip:port");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "login_time");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "last_access");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = cols;
|
||||
pShow->numOfColumns = cols;
|
||||
|
||||
pShow->offset[0] = 0;
|
||||
for (int32_t i = 1; i < cols; ++i) {
|
||||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||
}
|
||||
|
||||
pShow->numOfRows = taosCacheGetNumOfObj(pMgmt->cache);
|
||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||
strcpy(pMeta->tbName, mndShowStr(pShow->type));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t numOfRows = 0;
|
||||
|
@ -692,121 +610,6 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int
|
|||
return numOfRows;
|
||||
}
|
||||
|
||||
static int32_t mndGetQueryMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
||||
SUserObj *pUser = mndAcquireUser(pMnode, pReq->user);
|
||||
if (pUser == NULL) return 0;
|
||||
if (!pUser->superUser) {
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||
return -1;
|
||||
}
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
|
||||
int32_t cols = 0;
|
||||
SSchema *pSchema = pMeta->pSchemas;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "queryId");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "connId");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_USER_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "user");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "ip:port");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 22 + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "qid");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "created_time");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BIGINT;
|
||||
strcpy(pSchema[cols].name, "time");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = QUERY_OBJ_ID_SIZE + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "sql_obj_id");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "pid");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_EP_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "ep");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 1;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BOOL;
|
||||
strcpy(pSchema[cols].name, "stable_query");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "sub_queries");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "sub_query_info");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "sql");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = cols;
|
||||
pShow->numOfColumns = cols;
|
||||
|
||||
pShow->offset[0] = 0;
|
||||
for (int32_t i = 1; i < cols; ++i) {
|
||||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||
}
|
||||
|
||||
pShow->numOfRows = 1000000;
|
||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||
strcpy(pMeta->tbName, mndShowStr(pShow->type));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
int32_t numOfRows = 0;
|
||||
|
|
|
@ -115,6 +115,7 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
|
|||
static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SShowMgmt *pMgmt = &pMnode->showMgmt;
|
||||
SShowObj *pShow = NULL;
|
||||
int32_t rowsToRead = SHOW_STEP_SIZE;
|
||||
int32_t size = 0;
|
||||
int32_t rowsRead = 0;
|
||||
|
@ -125,8 +126,6 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
SShowObj* pShow = NULL;
|
||||
|
||||
if (retrieveReq.showId == 0) {
|
||||
SShowReq req = {0};
|
||||
req.type = retrieveReq.type;
|
||||
|
@ -139,11 +138,11 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pShow->pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb));
|
||||
pShow->pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb) + 1);
|
||||
pShow->numOfColumns = pShow->pMeta->numOfColumns;
|
||||
int32_t offset = 0;
|
||||
|
||||
for(int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) {
|
||||
for (int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) {
|
||||
pShow->offset[i] = offset;
|
||||
|
||||
int32_t bytes = pShow->pMeta->pSchemas[i].bytes;
|
||||
|
@ -162,26 +161,25 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
|
||||
ShowRetrieveFp retrieveFp = pMgmt->retrieveFps[pShow->type];
|
||||
if (retrieveFp == NULL) {
|
||||
mndReleaseShowObj((SShowObj*) pShow, false);
|
||||
mndReleaseShowObj(pShow, false);
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
mDebug("show:0x%" PRIx64 ", start retrieve data, type:%s", pShow->id, mndShowStr(pShow->type));
|
||||
mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type);
|
||||
|
||||
int32_t numOfCols = pShow->pMeta->numOfColumns;
|
||||
|
||||
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||
int32_t numOfCols = pShow->pMeta->numOfColumns;
|
||||
SSDataBlock *pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||
pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
||||
pBlock->info.numOfCols = numOfCols;
|
||||
|
||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData idata = {0};
|
||||
SSchema* p = &pShow->pMeta->pSchemas[i];
|
||||
SSchema *p = &pShow->pMeta->pSchemas[i];
|
||||
|
||||
idata.info.bytes = p->bytes;
|
||||
idata.info.type = p->type;
|
||||
idata.info.type = p->type;
|
||||
idata.info.colId = p->colId;
|
||||
|
||||
taosArrayPush(pBlock->pDataBlock, &idata);
|
||||
|
@ -191,15 +189,15 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
}
|
||||
|
||||
blockDataEnsureCapacity(pBlock, rowsToRead);
|
||||
if (mndCheckRetrieveFinished((SShowObj*) pShow)) {
|
||||
if (mndCheckRetrieveFinished(pShow)) {
|
||||
mDebug("show:0x%" PRIx64 ", read finished, numOfRows:%d", pShow->id, pShow->numOfRows);
|
||||
rowsRead = 0;
|
||||
} else {
|
||||
rowsRead = (*retrieveFp)(pReq, (SShowObj *)pShow, pBlock, rowsToRead);
|
||||
rowsRead = (*retrieveFp)(pReq, pShow, pBlock, rowsToRead);
|
||||
if (rowsRead < 0) {
|
||||
terrno = rowsRead;
|
||||
mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
|
||||
mndReleaseShowObj((SShowObj *)pShow, true);
|
||||
mndReleaseShowObj(pShow, true);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -207,13 +205,12 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d numOfRows:%d", pShow->id, rowsRead, pShow->numOfRows);
|
||||
}
|
||||
|
||||
// numOfCols + sizeof(SSysTableSchema) * numOfCols + data payload
|
||||
size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns + blockDataGetSize(pBlock)
|
||||
+ blockDataGetSerialMetaSize(pBlock);
|
||||
size = sizeof(SRetrieveMetaTableRsp) + sizeof(int32_t) + sizeof(SSysTableSchema) * pShow->pMeta->numOfColumns +
|
||||
blockDataGetSize(pBlock) + blockDataGetSerialMetaSize(pBlock);
|
||||
|
||||
SRetrieveMetaTableRsp *pRsp = rpcMallocCont(size);
|
||||
if (pRsp == NULL) {
|
||||
mndReleaseShowObj((SShowObj*) pShow, false);
|
||||
mndReleaseShowObj(pShow, false);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("show:0x%" PRIx64 ", failed to retrieve data since %s", pShow->id, terrstr());
|
||||
blockDataDestroy(pBlock);
|
||||
|
@ -222,9 +219,8 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
|
||||
pRsp->handle = htobe64(pShow->id);
|
||||
|
||||
// if free flag is set, client wants to clean the resources
|
||||
if (rowsRead > 0) {
|
||||
char * pStart = pRsp->data;
|
||||
char *pStart = pRsp->data;
|
||||
SSchema *ps = pShow->pMeta->pSchemas;
|
||||
|
||||
*(int32_t *)pStart = htonl(pShow->pMeta->numOfColumns);
|
||||
|
@ -245,77 +241,22 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
|
||||
pRsp->numOfRows = htonl(rowsRead);
|
||||
pRsp->precision = TSDB_TIME_PRECISION_MILLI; // millisecond time precision
|
||||
pReq->pRsp = pRsp;
|
||||
pReq->rspLen = size;
|
||||
pReq->pRsp = pRsp;
|
||||
pReq->rspLen = size;
|
||||
|
||||
if (rowsRead == 0 || rowsRead < rowsToRead) {
|
||||
pRsp->completed = 1;
|
||||
mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id);
|
||||
mndReleaseShowObj((SShowObj*) pShow, true);
|
||||
mndReleaseShowObj(pShow, true);
|
||||
} else {
|
||||
mDebug("show:0x%" PRIx64 ", retrieve not completed yet", pShow->id);
|
||||
mndReleaseShowObj((SShowObj*) pShow, false);
|
||||
mndReleaseShowObj(pShow, false);
|
||||
}
|
||||
|
||||
blockDataDestroy(pBlock);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char *mndShowStr(int32_t showType) {
|
||||
switch (showType) {
|
||||
case TSDB_MGMT_TABLE_ACCT:
|
||||
return "show accounts";
|
||||
case TSDB_MGMT_TABLE_USER:
|
||||
return "show users";
|
||||
case TSDB_MGMT_TABLE_DB:
|
||||
return "show databases";
|
||||
case TSDB_MGMT_TABLE_TABLE:
|
||||
return "show tables";
|
||||
case TSDB_MGMT_TABLE_DNODE:
|
||||
return "show dnodes";
|
||||
case TSDB_MGMT_TABLE_MNODE:
|
||||
return "show mnodes";
|
||||
case TSDB_MGMT_TABLE_QNODE:
|
||||
return "show qnodes";
|
||||
case TSDB_MGMT_TABLE_SNODE:
|
||||
return "show snodes";
|
||||
case TSDB_MGMT_TABLE_BNODE:
|
||||
return "show bnodes";
|
||||
case TSDB_MGMT_TABLE_VGROUP:
|
||||
return "show vgroups";
|
||||
case TSDB_MGMT_TABLE_STB:
|
||||
return "show stables";
|
||||
case TSDB_MGMT_TABLE_MODULE:
|
||||
return "show modules";
|
||||
case TSDB_MGMT_TABLE_QUERIES:
|
||||
return "show queries";
|
||||
case TSDB_MGMT_TABLE_STREAMS:
|
||||
return "show streams";
|
||||
case TSDB_MGMT_TABLE_VARIABLES:
|
||||
return "show configs";
|
||||
case TSDB_MGMT_TABLE_CONNS:
|
||||
return "show connections";
|
||||
case TSDB_MGMT_TABLE_TRANS:
|
||||
return "show trans";
|
||||
case TSDB_MGMT_TABLE_GRANTS:
|
||||
return "show grants";
|
||||
case TSDB_MGMT_TABLE_VNODES:
|
||||
return "show vnodes";
|
||||
case TSDB_MGMT_TABLE_CLUSTER:
|
||||
return "show cluster";
|
||||
case TSDB_MGMT_TABLE_STREAMTABLES:
|
||||
return "show streamtables";
|
||||
case TSDB_MGMT_TABLE_TP:
|
||||
return "show topics";
|
||||
case TSDB_MGMT_TABLE_FUNC:
|
||||
return "show functions";
|
||||
case TSDB_MGMT_TABLE_INDEX:
|
||||
return "show indexes";
|
||||
default:
|
||||
return "undefined";
|
||||
}
|
||||
}
|
||||
|
||||
static bool mndCheckRetrieveFinished(SShowObj *pShow) {
|
||||
if (pShow->pIter == NULL && pShow->numOfRows != 0) {
|
||||
return true;
|
||||
|
@ -323,14 +264,6 @@ static bool mndCheckRetrieveFinished(SShowObj *pShow) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void mndVacuumResult(char *data, int32_t numOfCols, int32_t rows, int32_t capacity, SShowObj *pShow) {
|
||||
if (rows < capacity) {
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
memmove(data + pShow->offset[i] * rows, data + pShow->offset[i] * capacity, pShow->bytes[i] * rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mndAddShowRetrieveHandle(SMnode *pMnode, EShowType showType, ShowRetrieveFp fp) {
|
||||
SShowMgmt *pMgmt = &pMnode->showMgmt;
|
||||
pMgmt->retrieveFps[showType] = fp;
|
||||
|
|
|
@ -724,46 +724,6 @@ static int32_t mndProcessVDropSmaRsp(SNodeMsg *pRsp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndGetSmaMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
int32_t cols = 0;
|
||||
SSchema *pSchema = pMeta->pSchemas;
|
||||
|
||||
pShow->bytes[cols] = TSDB_INDEX_NAME_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "stb");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = cols;
|
||||
pShow->numOfColumns = cols;
|
||||
|
||||
pShow->offset[0] = 0;
|
||||
for (int32_t i = 1; i < cols; ++i) {
|
||||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||
}
|
||||
|
||||
pShow->numOfRows = sdbGetSize(pSdb, SDB_SMA);
|
||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||
strcpy(pMeta->tbName, mndShowStr(pShow->type));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveSma(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlock, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
|
|
@ -58,8 +58,8 @@ int32_t mndInitStream(SMnode *pMnode) {
|
|||
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);*/
|
||||
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
|
||||
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TP, mndRetrieveStream);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TP, mndCancelGetNextStream);
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveStream);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextStream);
|
||||
|
||||
return sdbSetTable(pMnode->pSdb, table);
|
||||
}
|
||||
|
@ -421,50 +421,6 @@ static int32_t mndGetNumOfStreams(SMnode *pMnode, char *dbName, int32_t *pNumOfS
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndGetStreamMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
if (mndGetNumOfStreams(pMnode, pShow->db, &pShow->numOfRows) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t cols = 0;
|
||||
SSchema *pSchema = pMeta->pSchemas;
|
||||
|
||||
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "sql");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = cols;
|
||||
pShow->numOfColumns = cols;
|
||||
|
||||
pShow->offset[0] = 0;
|
||||
for (int32_t i = 1; i < cols; ++i) {
|
||||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||
}
|
||||
|
||||
pShow->numOfRows = sdbGetSize(pSdb, SDB_STREAM);
|
||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||
strcpy(pMeta->tbName, mndShowStr(pShow->type));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveStream(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
|
|
@ -469,6 +469,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
|
|||
ASSERT(pConsumerEp != NULL);
|
||||
ASSERT(pConsumerEp->consumerId == pSubConsumer->consumerId);
|
||||
taosArrayPush(pSub->unassignedVg, pConsumerEp);
|
||||
mDebug("mq rebalance: vg %d push to unassignedVg", pConsumerEp->vgId);
|
||||
}
|
||||
|
||||
SMqConsumerObj *pRebConsumer = mndAcquireConsumer(pMnode, pSubConsumer->consumerId);
|
||||
|
@ -512,6 +513,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
|
|||
|
||||
while (taosArrayGetSize(pSubConsumer->vgInfo) < vgThisConsumerAfterRb) {
|
||||
SMqConsumerEp *pConsumerEp = taosArrayPop(pSub->unassignedVg);
|
||||
mDebug("mq rebalance: vg %d pop from unassignedVg", pConsumerEp->vgId);
|
||||
ASSERT(pConsumerEp != NULL);
|
||||
|
||||
pConsumerEp->oldConsumerId = pConsumerEp->consumerId;
|
||||
|
@ -570,7 +572,6 @@ static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqT
|
|||
.vgId = vgId,
|
||||
.consumerId = pConsumerEp->consumerId,
|
||||
.sql = pTopic->sql,
|
||||
.logicalPlan = pTopic->logicalPlan,
|
||||
.physicalPlan = pTopic->physicalPlan,
|
||||
.qmsg = pConsumerEp->qmsg,
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "parser.h"
|
||||
#include "tname.h"
|
||||
|
||||
#define MND_TOPIC_VER_NUMBER 1
|
||||
#define MND_TOPIC_VER_NUMBER 1
|
||||
#define MND_TOPIC_RESERVE_SIZE 64
|
||||
|
||||
static int32_t mndTopicActionInsert(SSdb *pSdb, SMqTopicObj *pTopic);
|
||||
|
@ -35,7 +35,6 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pTopic, SMqTopicObj
|
|||
static int32_t mndProcessCreateTopicReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessDropTopicReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessDropTopicInRsp(SNodeMsg *pRsp);
|
||||
static int32_t mndGetTopicMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta);
|
||||
static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
||||
static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter);
|
||||
|
||||
|
@ -52,8 +51,8 @@ int32_t mndInitTopic(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_TOPIC, mndProcessDropTopicReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_TOPIC_RSP, mndProcessDropTopicInRsp);
|
||||
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TP, mndRetrieveTopic);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TP, mndCancelGetNextTopic);
|
||||
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic);
|
||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextTopic);
|
||||
|
||||
return sdbSetTable(pMnode->pSdb, table);
|
||||
}
|
||||
|
@ -63,11 +62,10 @@ void mndCleanupTopic(SMnode *pMnode) {}
|
|||
SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
int32_t logicalPlanLen = strlen(pTopic->logicalPlan) + 1;
|
||||
int32_t physicalPlanLen = strlen(pTopic->physicalPlan) + 1;
|
||||
int32_t swLen = taosEncodeSSchemaWrapper(NULL, &pTopic->schema);
|
||||
int32_t schemaLen = taosEncodeSSchemaWrapper(NULL, &pTopic->schema);
|
||||
int32_t size =
|
||||
sizeof(SMqTopicObj) + logicalPlanLen + physicalPlanLen + pTopic->sqlLen + swLen + MND_TOPIC_RESERVE_SIZE;
|
||||
sizeof(SMqTopicObj) + physicalPlanLen + pTopic->sqlLen + pTopic->astLen + schemaLen + MND_TOPIC_RESERVE_SIZE;
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_TOPIC, MND_TOPIC_VER_NUMBER, size);
|
||||
if (pRaw == NULL) goto TOPIC_ENCODE_OVER;
|
||||
|
||||
|
@ -81,19 +79,19 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
|
|||
SDB_SET_INT32(pRaw, dataPos, pTopic->version, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT32(pRaw, dataPos, logicalPlanLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_BINARY(pRaw, dataPos, pTopic->logicalPlan, logicalPlanLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT32(pRaw, dataPos, pTopic->astLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_BINARY(pRaw, dataPos, pTopic->ast, pTopic->astLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT32(pRaw, dataPos, physicalPlanLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_BINARY(pRaw, dataPos, pTopic->physicalPlan, physicalPlanLen, TOPIC_ENCODE_OVER);
|
||||
|
||||
void *swBuf = taosMemoryMalloc(swLen);
|
||||
void *swBuf = taosMemoryMalloc(schemaLen);
|
||||
if (swBuf == NULL) {
|
||||
goto TOPIC_ENCODE_OVER;
|
||||
}
|
||||
void *aswBuf = swBuf;
|
||||
taosEncodeSSchemaWrapper(&aswBuf, &pTopic->schema);
|
||||
SDB_SET_INT32(pRaw, dataPos, swLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_BINARY(pRaw, dataPos, swBuf, swLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_INT32(pRaw, dataPos, schemaLen, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_BINARY(pRaw, dataPos, swBuf, schemaLen, TOPIC_ENCODE_OVER);
|
||||
|
||||
SDB_SET_RESERVE(pRaw, dataPos, MND_TOPIC_RESERVE_SIZE, TOPIC_ENCODE_OVER);
|
||||
SDB_SET_DATALEN(pRaw, dataPos, TOPIC_ENCODE_OVER);
|
||||
|
@ -137,23 +135,25 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT64(pRaw, dataPos, &pTopic->uid, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT64(pRaw, dataPos, &pTopic->dbUid, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT32(pRaw, dataPos, &pTopic->version, TOPIC_DECODE_OVER);
|
||||
|
||||
SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER);
|
||||
|
||||
pTopic->sql = taosMemoryCalloc(pTopic->sqlLen + 1, sizeof(char));
|
||||
SDB_GET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_DECODE_OVER);
|
||||
|
||||
SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER);
|
||||
pTopic->logicalPlan = taosMemoryCalloc(len + 1, sizeof(char));
|
||||
if (pTopic->logicalPlan == NULL) {
|
||||
pTopic->sql = taosMemoryCalloc(pTopic->sqlLen, sizeof(char));
|
||||
if (pTopic->sql == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto TOPIC_DECODE_OVER;
|
||||
}
|
||||
SDB_GET_BINARY(pRaw, dataPos, pTopic->logicalPlan, len, TOPIC_DECODE_OVER);
|
||||
SDB_GET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_DECODE_OVER);
|
||||
|
||||
SDB_GET_INT32(pRaw, dataPos, &pTopic->astLen, TOPIC_DECODE_OVER);
|
||||
pTopic->ast = taosMemoryCalloc(pTopic->astLen, sizeof(char));
|
||||
if (pTopic->ast == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto TOPIC_DECODE_OVER;
|
||||
}
|
||||
SDB_GET_BINARY(pRaw, dataPos, pTopic->ast, pTopic->astLen, TOPIC_DECODE_OVER);
|
||||
SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER);
|
||||
pTopic->physicalPlan = taosMemoryCalloc(len + 1, sizeof(char));
|
||||
pTopic->physicalPlan = taosMemoryCalloc(len, sizeof(char));
|
||||
if (pTopic->physicalPlan == NULL) {
|
||||
taosMemoryFree(pTopic->logicalPlan);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto TOPIC_DECODE_OVER;
|
||||
}
|
||||
|
@ -257,6 +257,7 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) {
|
||||
if (NULL == pCreate->ast) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -279,6 +280,7 @@ static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) {
|
|||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb) {
|
||||
mDebug("topic:%s to create", pCreate->name);
|
||||
|
@ -290,32 +292,39 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
|
|||
topicObj.uid = mndGenerateUid(pCreate->name, strlen(pCreate->name));
|
||||
topicObj.dbUid = pDb->uid;
|
||||
topicObj.version = 1;
|
||||
topicObj.sql = pCreate->sql;
|
||||
topicObj.physicalPlan = "";
|
||||
topicObj.logicalPlan = "";
|
||||
topicObj.sqlLen = strlen(pCreate->sql);
|
||||
|
||||
char *pPlanStr = NULL;
|
||||
if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &pPlanStr)) {
|
||||
mError("topic:%s, failed to get plan since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
if (NULL != pPlanStr) {
|
||||
topicObj.physicalPlan = pPlanStr;
|
||||
}
|
||||
topicObj.sql = strdup(pCreate->sql);
|
||||
topicObj.sqlLen = strlen(pCreate->sql) + 1;
|
||||
topicObj.ast = strdup(pCreate->ast);
|
||||
topicObj.astLen = strlen(pCreate->ast) + 1;
|
||||
|
||||
SNode *pAst = NULL;
|
||||
if (nodesStringToNode(pCreate->ast, &pAst) < 0) {
|
||||
if (nodesStringToNode(pCreate->ast, &pAst) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
SQueryPlan *pPlan = NULL;
|
||||
|
||||
SPlanContext cxt = {.pAstRoot = pAst, .topicQuery = true};
|
||||
if (qCreateQueryPlan(&cxt, &pPlan, NULL) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qExtractResultSchema(pAst, &topicObj.schema.nCols, &topicObj.schema.pSchema) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nodesNodeToString(pPlan, false, &topicObj.physicalPlan, NULL) != 0) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) {
|
||||
mError("topic:%s, failed to create since %s", pCreate->name, terrstr());
|
||||
taosMemoryFreeClear(pPlanStr);
|
||||
taosMemoryFreeClear(topicObj.physicalPlan);
|
||||
return -1;
|
||||
}
|
||||
mDebug("trans:%d, used to create topic:%s", pTrans->id, pCreate->name);
|
||||
|
@ -323,7 +332,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
|
|||
SSdbRaw *pRedoRaw = mndTopicActionEncode(&topicObj);
|
||||
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) {
|
||||
mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr());
|
||||
taosMemoryFreeClear(pPlanStr);
|
||||
taosMemoryFreeClear(topicObj.physicalPlan);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
@ -331,12 +340,12 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
|
|||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
taosMemoryFreeClear(pPlanStr);
|
||||
taosMemoryFreeClear(topicObj.physicalPlan);
|
||||
mndTransDrop(pTrans);
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(pPlanStr);
|
||||
taosMemoryFreeClear(topicObj.physicalPlan);
|
||||
mndTransDrop(pTrans);
|
||||
return 0;
|
||||
}
|
||||
|
@ -500,50 +509,6 @@ static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTo
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndGetTopicMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
if (mndGetNumOfTopics(pMnode, pShow->db, &pShow->numOfRows) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t cols = 0;
|
||||
SSchema *pSchema = pMeta->pSchemas;
|
||||
|
||||
pShow->bytes[cols] = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "name");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "sql");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = cols;
|
||||
pShow->numOfColumns = cols;
|
||||
|
||||
pShow->offset[0] = 0;
|
||||
for (int32_t i = 1; i < cols; ++i) {
|
||||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||
}
|
||||
|
||||
pShow->numOfRows = sdbGetSize(pSdb, SDB_TOPIC);
|
||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||
strcpy(pMeta->tbName, mndShowStr(pShow->type));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
|
|
@ -58,7 +58,6 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans);
|
|||
static int32_t mndProcessTransReq(SNodeMsg *pReq);
|
||||
static int32_t mndProcessKillTransReq(SNodeMsg *pReq);
|
||||
|
||||
static int32_t mndGetTransMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta);
|
||||
static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows);
|
||||
static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter);
|
||||
|
||||
|
@ -1260,69 +1259,6 @@ void mndTransPullup(SMnode *pMnode) {
|
|||
sdbWriteFile(pMnode->pSdb);
|
||||
}
|
||||
|
||||
static int32_t mndGetTransMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
||||
int32_t cols = 0;
|
||||
SSchema *pSchema = pMeta->pSchemas;
|
||||
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
strcpy(pSchema[cols].name, "id");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "create_time");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "stage");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "db");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "type");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = 8;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
strcpy(pSchema[cols].name, "last_exec_time");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pShow->bytes[cols] = (TSDB_TRANS_ERROR_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||
strcpy(pSchema[cols].name, "last_error");
|
||||
pSchema[cols].bytes = pShow->bytes[cols];
|
||||
cols++;
|
||||
|
||||
pMeta->numOfColumns = cols;
|
||||
pShow->numOfColumns = cols;
|
||||
|
||||
pShow->offset[0] = 0;
|
||||
for (int32_t i = 1; i < cols; ++i) {
|
||||
pShow->offset[i] = pShow->offset[i - 1] + pShow->bytes[i - 1];
|
||||
}
|
||||
|
||||
pShow->numOfRows = sdbGetSize(pSdb, SDB_TRANS);
|
||||
pShow->rowSize = pShow->offset[cols - 1] + pShow->bytes[cols - 1];
|
||||
strcpy(pMeta->tbName, mndShowStr(pShow->type));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
enable_testing()
|
||||
|
||||
#add_subdirectory(user)
|
||||
#add_subdirectory(acct)
|
||||
add_subdirectory(acct)
|
||||
#add_subdirectory(trans)
|
||||
#add_subdirectory(qnode)
|
||||
#add_subdirectory(snode)
|
||||
#add_subdirectory(bnode)
|
||||
add_subdirectory(bnode)
|
||||
#add_subdirectory(show)
|
||||
#add_subdirectory(profile)
|
||||
add_subdirectory(dnode)
|
||||
#add_subdirectory(dnode)
|
||||
#add_subdirectory(mnode)
|
||||
add_subdirectory(db)
|
||||
add_subdirectory(stb)
|
||||
#add_subdirectory(db)
|
||||
#add_subdirectory(stb)
|
||||
#add_subdirectory(sma)
|
||||
#add_subdirectory(func)
|
||||
#add_subdirectory(topic)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. ACCT_SRC)
|
||||
add_executable(mnode_test_acct ${ACCT_SRC})
|
||||
aux_source_directory(. MNODE_ACCT_TEST_SRC)
|
||||
add_executable(acctTest ${MNODE_ACCT_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_acct
|
||||
acctTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_acct
|
||||
COMMAND mnode_test_acct
|
||||
NAME acctTest
|
||||
COMMAND acctTest
|
||||
)
|
||||
|
|
|
@ -54,17 +54,3 @@ TEST_F(MndTestAcct, 03_Drop_Acct) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
|
||||
}
|
||||
|
||||
TEST_F(MndTestAcct, 04_Show_Acct) {
|
||||
SShowReq showReq = {0};
|
||||
showReq.type = TSDB_MGMT_TABLE_ACCT;
|
||||
|
||||
int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
tSerializeSShowReq(pReq, contLen, &showReq);
|
||||
tFreeSShowReq(&showReq);
|
||||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE);
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
aux_source_directory(. STEST_SRC)
|
||||
add_executable(mnode_test_bnode ${STEST_SRC})
|
||||
aux_source_directory(. MNODE_BNODE_TEST_SRC)
|
||||
add_executable(mbnodeTest ${MNODE_BNODE_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_bnode
|
||||
mbnodeTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
add_test(
|
||||
NAME mnode_test_bnode
|
||||
COMMAND mnode_test_bnode
|
||||
NAME mbnodeTest
|
||||
COMMAND mbnodeTest
|
||||
)
|
||||
|
|
|
@ -39,14 +39,7 @@ Testbase MndTestBnode::test;
|
|||
TestServer MndTestBnode::server2;
|
||||
|
||||
TEST_F(MndTestBnode, 01_Show_Bnode) {
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, "");
|
||||
CHECK_META("show bnodes", 3);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
|
||||
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
|
||||
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
|
||||
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_BNODE, "bnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
|
||||
|
@ -76,14 +69,8 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, "");
|
||||
CHECK_META("show bnodes", 3);
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_BNODE, "bnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckBinary("localhost:9018", TSDB_EP_LEN);
|
||||
CheckTimestamp();
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -115,8 +102,7 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
taosMsleep(1300);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
}
|
||||
|
||||
|
@ -132,16 +118,8 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_BNODE, "bnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 2);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckInt16(2);
|
||||
CheckBinary("localhost:9018", TSDB_EP_LEN);
|
||||
CheckBinary("localhost:9019", TSDB_EP_LEN);
|
||||
CheckTimestamp();
|
||||
CheckTimestamp();
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -156,13 +134,8 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, 0);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, "");
|
||||
test.SendShowRetrieveReq();
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_BNODE, "bnodes", "");
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
CheckInt16(1);
|
||||
CheckBinary("localhost:9018", TSDB_EP_LEN);
|
||||
CheckTimestamp();
|
||||
}
|
||||
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
aux_source_directory(. DB_SRC)
|
||||
add_executable(mnode_test_db ${DB_SRC})
|
||||
aux_source_directory(. MNODE_DB_TEST_SRC)
|
||||
add_executable(dbTest ${MNODE_DB_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_db
|
||||
dbTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
aux_source_directory(. DTEST_SRC)
|
||||
add_executable(mnode_test_dnode ${DTEST_SRC})
|
||||
aux_source_directory(. MNODE_DNODE_TEST_SRC)
|
||||
add_executable(mdnodeTest ${MNODE_DNODE_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_dnode
|
||||
mdnodeTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
aux_source_directory(. STB_SRC)
|
||||
add_executable(mnode_test_stb ${STB_SRC})
|
||||
aux_source_directory(. MNODE_STB_TEST_SRC)
|
||||
add_executable(stbTest ${MNODE_STB_TEST_SRC})
|
||||
target_link_libraries(
|
||||
mnode_test_stb
|
||||
stbTest
|
||||
PUBLIC sut
|
||||
)
|
||||
|
||||
|
|
|
@ -88,6 +88,8 @@ void* MndTestTopic::BuildDropTopicReq(const char* topicName, int32_t* pContLen)
|
|||
}
|
||||
|
||||
TEST_F(MndTestTopic, 01_Create_Topic) {
|
||||
// TODO add valid ast for unit test
|
||||
#if 0
|
||||
const char* dbname = "1.d1";
|
||||
const char* topicName = "1.d1.t1";
|
||||
|
||||
|
@ -99,7 +101,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
|
|||
ASSERT_EQ(pRsp->code, 0);
|
||||
}
|
||||
|
||||
{ test.SendShowMetaReq(TSDB_MGMT_TABLE_TP, ""); }
|
||||
{ test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, ""); }
|
||||
|
||||
{
|
||||
int32_t contLen = 0;
|
||||
|
@ -126,7 +128,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
|
|||
}
|
||||
|
||||
{
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TP, dbname);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname);
|
||||
CHECK_META("show topics", 3);
|
||||
|
||||
CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name");
|
||||
|
@ -143,7 +145,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
|
|||
// restart
|
||||
test.Restart();
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TP, dbname);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 1);
|
||||
|
||||
|
@ -167,8 +169,9 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
|
|||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TOPIC_NOT_EXIST);
|
||||
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TP, dbname);
|
||||
test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname);
|
||||
test.SendShowRetrieveReq();
|
||||
EXPECT_EQ(test.GetShowRows(), 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -126,8 +126,8 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t versi
|
|||
int tqCommit(STQ* pTq) { return tqStorePersist(pTq->tqMeta); }
|
||||
|
||||
int32_t tqGetTopicHandleSize(const STqTopic* pTopic) {
|
||||
return strlen(pTopic->topicName) + strlen(pTopic->sql) + strlen(pTopic->logicalPlan) + strlen(pTopic->physicalPlan) +
|
||||
strlen(pTopic->qmsg) + sizeof(int64_t) * 3;
|
||||
return strlen(pTopic->topicName) + strlen(pTopic->sql) + strlen(pTopic->physicalPlan) + strlen(pTopic->qmsg) +
|
||||
sizeof(int64_t) * 3;
|
||||
}
|
||||
|
||||
int32_t tqGetConsumerHandleSize(const STqConsumer* pConsumer) {
|
||||
|
@ -144,7 +144,6 @@ static FORCE_INLINE int32_t tEncodeSTqTopic(void** buf, const STqTopic* pTopic)
|
|||
int32_t tlen = 0;
|
||||
tlen += taosEncodeString(buf, pTopic->topicName);
|
||||
/*tlen += taosEncodeString(buf, pTopic->sql);*/
|
||||
/*tlen += taosEncodeString(buf, pTopic->logicalPlan);*/
|
||||
/*tlen += taosEncodeString(buf, pTopic->physicalPlan);*/
|
||||
tlen += taosEncodeString(buf, pTopic->qmsg);
|
||||
/*tlen += taosEncodeFixedI64(buf, pTopic->persistedOffset);*/
|
||||
|
@ -156,7 +155,6 @@ static FORCE_INLINE int32_t tEncodeSTqTopic(void** buf, const STqTopic* pTopic)
|
|||
static FORCE_INLINE const void* tDecodeSTqTopic(const void* buf, STqTopic* pTopic) {
|
||||
buf = taosDecodeStringTo(buf, pTopic->topicName);
|
||||
/*buf = taosDecodeString(buf, &pTopic->sql);*/
|
||||
/*buf = taosDecodeString(buf, &pTopic->logicalPlan);*/
|
||||
/*buf = taosDecodeString(buf, &pTopic->physicalPlan);*/
|
||||
buf = taosDecodeString(buf, &pTopic->qmsg);
|
||||
/*buf = taosDecodeFixedI64(buf, &pTopic->persistedOffset);*/
|
||||
|
@ -722,7 +720,6 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
|
|||
}
|
||||
strcpy(pTopic->topicName, req.topicName);
|
||||
pTopic->sql = req.sql;
|
||||
pTopic->logicalPlan = req.logicalPlan;
|
||||
pTopic->physicalPlan = req.physicalPlan;
|
||||
pTopic->qmsg = req.qmsg;
|
||||
/*pTopic->committedOffset = -1;*/
|
||||
|
|
|
@ -375,6 +375,8 @@ static int tsdbMemTableInsertTbData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *p
|
|||
if (pMemTable->keyMin > keyMin) pMemTable->keyMin = keyMin;
|
||||
if (pMemTable->keyMax < keyMax) pMemTable->keyMax = keyMax;
|
||||
|
||||
(*pAffectedRows) += pBlock->numOfRows;
|
||||
|
||||
// STSRow* lastRow = NULL;
|
||||
// int64_t osize = SL_SIZE(pTableData->pData);
|
||||
// tsdbSetupSkipListHookFns(pTableData->pData, pRepo, pTable, &points, &lastRow);
|
||||
|
|
|
@ -107,8 +107,7 @@ int32_t tsdbSaveSmaToDB(SDBFile *pDBF, void *pKey, int32_t keyLen, void *pVal, i
|
|||
}
|
||||
|
||||
void *tsdbGetSmaDataByKey(SDBFile *pDBF, const void *pKey, int32_t keyLen, int32_t *valLen) {
|
||||
void *result;
|
||||
void *pVal;
|
||||
void *pVal = NULL;
|
||||
int ret;
|
||||
|
||||
ret = tdbDbGet(pDBF->pDB, pKey, keyLen, &pVal, valLen);
|
||||
|
@ -120,18 +119,10 @@ void *tsdbGetSmaDataByKey(SDBFile *pDBF, const void *pKey, int32_t keyLen, int32
|
|||
|
||||
ASSERT(*valLen >= 0);
|
||||
|
||||
result = taosMemoryMalloc(*valLen);
|
||||
|
||||
if (result == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// TODO: lock?
|
||||
// TODO: Would the key/value be destoryed during return the data?
|
||||
// TODO: How about the key is updated while value length is changed? The original value buffer would be freed
|
||||
// automatically?
|
||||
memcpy(result, pVal, *valLen);
|
||||
|
||||
return result;
|
||||
return pVal;
|
||||
}
|
|
@ -31,5 +31,5 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
return tsdbMemTableInsert(pTsdb, pTsdb->mem, pMsg, NULL);
|
||||
return tsdbMemTableInsert(pTsdb, pTsdb->mem, pMsg, pRsp);
|
||||
}
|
|
@ -767,24 +767,22 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
|
|||
// TODO remove it
|
||||
int32_t tableType = 0;
|
||||
const char* name = tNameGetTableName(pName);
|
||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_DATABASES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_DB;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_USERS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_USER;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_DNODES, tListLen(pName->tname)) == 0) {
|
||||
if (strncasecmp(name, TSDB_INS_TABLE_DNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_DNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_GRANTS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_MNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_MNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_MODULES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_MODULE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_QNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_QNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_SNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_BNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_BNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_SNODE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_CLUSTER;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_DATABASES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_DB;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_FUNCTIONS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_FUNC;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_INDEXES, tListLen(pName->tname)) == 0) {
|
||||
|
@ -795,13 +793,33 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
|
|||
tableType = TSDB_MGMT_TABLE_STREAMS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_TABLE;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_VGROUP;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, tListLen(pName->tname)) == 0) {
|
||||
// tableType = TSDB_MGMT_TABLE_DIST;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_CLUSTER;
|
||||
} else {
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_USER_USERS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_USER;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_LICENCES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_GRANTS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_VGROUP;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_TOPICS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONSUMERS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_CONSUMERS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIBES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_SUBSCRIBES;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TRANS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_TRANS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SMAS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_SMAS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_CONFIGS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONNS, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_CONNS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_QUERIES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_QUERIES;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, tListLen(pName->tname)) == 0) {
|
||||
tableType = TSDB_MGMT_TABLE_VNODES;
|
||||
}else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,14 +40,14 @@ extern "C" {
|
|||
|
||||
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
||||
|
||||
typedef int32_t (*FCheckAndGetResultType)(SFunctionNode* pFunc);
|
||||
typedef int32_t (*FTranslateFunc)(SFunctionNode* pFunc, char* pErrBuf, int32_t len);
|
||||
typedef EFuncDataRequired (*FFuncDataRequired)(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||
|
||||
typedef struct SBuiltinFuncDefinition {
|
||||
char name[FUNCTION_NAME_MAX_LENGTH];
|
||||
EFunctionType type;
|
||||
uint64_t classification;
|
||||
FCheckAndGetResultType checkFunc;
|
||||
FTranslateFunc translateFunc;
|
||||
FFuncDataRequired dataRequiredFunc;
|
||||
FExecGetEnv getEnvFunc;
|
||||
FExecInit initFunc;
|
||||
|
|
|
@ -19,14 +19,363 @@
|
|||
#include "taoserror.h"
|
||||
#include "tdatablock.h"
|
||||
|
||||
int32_t checkAndGetResultType(SFunctionNode* pFunc);
|
||||
static int32_t buildFuncErrMsg(char* pErrBuf, int32_t len, int32_t errCode, const char* pFormat, ...) {
|
||||
va_list vArgList;
|
||||
va_start(vArgList, pFormat);
|
||||
vsnprintf(pErrBuf, len, pFormat, vArgList);
|
||||
va_end(vArgList);
|
||||
return errCode;
|
||||
}
|
||||
|
||||
static int32_t invaildFuncParaNumErrMsg(char* pErrBuf, int32_t len, const char* pFuncName) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_NUM, "Invalid number of arguments : %s", pFuncName);
|
||||
}
|
||||
|
||||
static int32_t invaildFuncParaTypeErrMsg(char* pErrBuf, int32_t len, const char* pFuncName) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_PARA_TYPE, "Inconsistent datatypes : %s", pFuncName);
|
||||
}
|
||||
|
||||
// There is only one parameter of numeric type, and the return type is parameter type
|
||||
static int32_t translateInOutNum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (!IS_NUMERIC_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// There is only one parameter of numeric type, and the return type is double type
|
||||
static int32_t translateInNumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (!IS_NUMERIC_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// There are two parameters of numeric type, and the return type is double type
|
||||
static int32_t translateIn2NumOutDou(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (2 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||
if (!IS_NUMERIC_TYPE(para1Type) || !IS_NUMERIC_TYPE(para2Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// There is only one parameter of string type, and the return type is parameter type
|
||||
static int32_t translateInOutStr(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
SExprNode* pPara1 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||
if (!IS_VAR_DATA_TYPE(pPara1->resType.type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = pPara1->resType.bytes, .type = pPara1->resType.type };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateSum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (!IS_NUMERIC_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t resType = 0;
|
||||
if (IS_SIGNED_NUMERIC_TYPE(paraType) || paraType == TSDB_DATA_TYPE_BOOL) {
|
||||
resType = TSDB_DATA_TYPE_BIGINT;
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(paraType)) {
|
||||
resType = TSDB_DATA_TYPE_UBIGINT;
|
||||
} else if (IS_FLOAT_TYPE(paraType)) {
|
||||
resType = TSDB_DATA_TYPE_DOUBLE;
|
||||
}
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[resType].bytes, .type = resType };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateWduration(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// pseudo column do not need to check parameters
|
||||
pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// pseudo column do not need to check parameters
|
||||
pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_TIMESTAMP};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (2 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||
if (!IS_NUMERIC_TYPE(para1Type) || (!IS_SIGNED_NUMERIC_TYPE(para2Type) && !IS_UNSIGNED_NUMERIC_TYPE(para2Type))) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static bool validAperventileAlgo(const SValueNode* pVal) {
|
||||
if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) {
|
||||
return false;
|
||||
}
|
||||
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) {
|
||||
int32_t paraNum = LIST_LENGTH(pFunc->pParameterList);
|
||||
if (2 != paraNum && 3 != paraNum) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||
if (!IS_NUMERIC_TYPE(para1Type) || !IS_INTEGER_TYPE(para2Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
if (3 == paraNum) {
|
||||
SNode* pPara3 = nodesListGetNode(pFunc->pParameterList, 2);
|
||||
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'");
|
||||
}
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTop(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// todo
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateBottom(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// todo
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateSpread(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// todo
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateLastRow(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// todo
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// first(*)/first(col_list) has been rewritten as first(col)
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
if (QUERY_NODE_COLUMN != nodeType(pPara)) {
|
||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "The parameters of first/last can only be columns");
|
||||
}
|
||||
|
||||
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
if (!IS_VAR_DATA_TYPE(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_SMALLINT].bytes, .type = TSDB_DATA_TYPE_SMALLINT };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, int32_t minParaNum, int32_t maxParaNum, int32_t primaryParaNo) {
|
||||
int32_t paraNum = LIST_LENGTH(pFunc->pParameterList);
|
||||
if (paraNum < minParaNum || paraNum > maxParaNum) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t resultType = TSDB_DATA_TYPE_NCHAR;
|
||||
int32_t resultBytes = 0;
|
||||
int32_t sepBytes = 0;
|
||||
for (int32_t i = 0; i < LIST_LENGTH(pFunc->pParameterList); ++i) {
|
||||
SNode* pPara = nodesListGetNode(pFunc->pParameterList, i);
|
||||
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
||||
int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes;
|
||||
if (!IS_VAR_DATA_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
if (i < primaryParaNo) {
|
||||
sepBytes = paraBytes;
|
||||
continue;
|
||||
}
|
||||
if (TSDB_DATA_TYPE_BINARY == paraType) {
|
||||
resultType = TSDB_DATA_TYPE_BINARY;
|
||||
}
|
||||
resultBytes += paraBytes;
|
||||
}
|
||||
if (sepBytes > 0) {
|
||||
resultBytes += sepBytes * (paraNum - 2);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = resultBytes, .type = resultType };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateConcat(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
return translateConcatImpl(pFunc, pErrBuf, len, 2, 8, 0);
|
||||
}
|
||||
|
||||
static int32_t translateConcatWs(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
return translateConcatImpl(pFunc, pErrBuf, len, 3, 9, 1);
|
||||
}
|
||||
|
||||
static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
int32_t paraNum = LIST_LENGTH(pFunc->pParameterList);
|
||||
if (2 != paraNum && 3 != paraNum) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
SExprNode* pPara1 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
|
||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||
if (!IS_VAR_DATA_TYPE(pPara1->resType.type) || !IS_INTEGER_TYPE(para2Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
if (3 == paraNum) {
|
||||
uint8_t para3Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||
if (!IS_INTEGER_TYPE(para3Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = pPara1->resType.bytes, .type = pPara1->resType.type };
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// The number of parameters has been limited by the syntax definition
|
||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
// The function return type has been set during syntax parsing
|
||||
uint8_t para2Type = pFunc->node.resType.type;
|
||||
if ((TSDB_DATA_TYPE_JSON == para1Type || TSDB_DATA_TYPE_BLOB == para1Type || TSDB_DATA_TYPE_MEDIUMBLOB == para1Type) ||
|
||||
(TSDB_DATA_TYPE_JSON == para2Type || TSDB_DATA_TYPE_BLOB == para2Type || TSDB_DATA_TYPE_MEDIUMBLOB == para2Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (!IS_VAR_DATA_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = 64, .type = TSDB_DATA_TYPE_BINARY};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
if (!IS_VAR_DATA_TYPE(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (2 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||
if ((!IS_VAR_DATA_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) || !IS_INTEGER_TYPE(para2Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
int32_t paraNum = LIST_LENGTH(pFunc->pParameterList);
|
||||
if (2 != paraNum && 3 != paraNum) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||
if ((!IS_VAR_DATA_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) ||
|
||||
(!IS_VAR_DATA_TYPE(para2Type) && TSDB_DATA_TYPE_TIMESTAMP != para2Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
if (3 == paraNum) {
|
||||
if (!IS_INTEGER_TYPE(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||
{
|
||||
.name = "count",
|
||||
.type = FUNCTION_TYPE_COUNT,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateCount,
|
||||
.dataRequiredFunc = countDataRequired,
|
||||
.getEnvFunc = getCountFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
|
@ -37,7 +386,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "sum",
|
||||
.type = FUNCTION_TYPE_SUM,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateSum,
|
||||
.getEnvFunc = getSumFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = sumFunction,
|
||||
|
@ -47,7 +396,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "min",
|
||||
.type = FUNCTION_TYPE_MIN,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = minFunctionSetup,
|
||||
.processFunc = minFunction,
|
||||
|
@ -57,7 +406,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "max",
|
||||
.type = FUNCTION_TYPE_MAX,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
|
@ -67,7 +416,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "stddev",
|
||||
.type = FUNCTION_TYPE_STDDEV,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = getStddevFuncEnv,
|
||||
.initFunc = stddevFunctionSetup,
|
||||
.processFunc = stddevFunction,
|
||||
|
@ -77,7 +426,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "percentile",
|
||||
.type = FUNCTION_TYPE_PERCENTILE,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translatePercentile,
|
||||
.getEnvFunc = getPercentileFuncEnv,
|
||||
.initFunc = percentileFunctionSetup,
|
||||
.processFunc = percentileFunction,
|
||||
|
@ -87,7 +436,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "apercentile",
|
||||
.type = FUNCTION_TYPE_APERCENTILE,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateApercentile,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
|
@ -97,7 +446,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "top",
|
||||
.type = FUNCTION_TYPE_TOP,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateTop,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
|
@ -107,7 +456,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "bottom",
|
||||
.type = FUNCTION_TYPE_BOTTOM,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateBottom,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
|
@ -117,7 +466,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "spread",
|
||||
.type = FUNCTION_TYPE_SPREAD,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateSpread,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
|
@ -127,7 +476,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "last_row",
|
||||
.type = FUNCTION_TYPE_LAST_ROW,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateLastRow,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
|
@ -137,7 +486,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "first",
|
||||
.type = FUNCTION_TYPE_FIRST,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateFirstLast,
|
||||
.getEnvFunc = getFirstLastFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = firstFunction,
|
||||
|
@ -147,7 +496,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "last",
|
||||
.type = FUNCTION_TYPE_LAST,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateFirstLast,
|
||||
.getEnvFunc = getFirstLastFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = lastFunction,
|
||||
|
@ -157,7 +506,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "diff",
|
||||
.type = FUNCTION_TYPE_DIFF,
|
||||
.classification = FUNC_MGT_NONSTANDARD_SQL_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = getDiffFuncEnv,
|
||||
.initFunc = diffFunctionSetup,
|
||||
.processFunc = diffFunction,
|
||||
|
@ -167,7 +516,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "abs",
|
||||
.type = FUNCTION_TYPE_ABS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = absFunction,
|
||||
|
@ -177,7 +526,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "log",
|
||||
.type = FUNCTION_TYPE_LOG,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateIn2NumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = logFunction,
|
||||
|
@ -187,7 +536,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "pow",
|
||||
.type = FUNCTION_TYPE_POW,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateIn2NumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = powFunction,
|
||||
|
@ -197,7 +546,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "sqrt",
|
||||
.type = FUNCTION_TYPE_SQRT,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = sqrtFunction,
|
||||
|
@ -207,7 +556,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "ceil",
|
||||
.type = FUNCTION_TYPE_CEIL,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = ceilFunction,
|
||||
|
@ -217,7 +566,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "floor",
|
||||
.type = FUNCTION_TYPE_FLOOR,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = floorFunction,
|
||||
|
@ -227,7 +576,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "round",
|
||||
.type = FUNCTION_TYPE_ROUND,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = roundFunction,
|
||||
|
@ -237,7 +586,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "sin",
|
||||
.type = FUNCTION_TYPE_SIN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = sinFunction,
|
||||
|
@ -247,7 +596,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "cos",
|
||||
.type = FUNCTION_TYPE_COS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = cosFunction,
|
||||
|
@ -257,7 +606,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "tan",
|
||||
.type = FUNCTION_TYPE_TAN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = tanFunction,
|
||||
|
@ -267,7 +616,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "asin",
|
||||
.type = FUNCTION_TYPE_ASIN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = asinFunction,
|
||||
|
@ -277,7 +626,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "acos",
|
||||
.type = FUNCTION_TYPE_ACOS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = acosFunction,
|
||||
|
@ -287,7 +636,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "atan",
|
||||
.type = FUNCTION_TYPE_ATAN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = atanFunction,
|
||||
|
@ -297,7 +646,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "length",
|
||||
.type = FUNCTION_TYPE_LENGTH,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateLength,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = lengthFunction,
|
||||
|
@ -307,7 +656,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "char_length",
|
||||
.type = FUNCTION_TYPE_CHAR_LENGTH,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateLength,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = charLengthFunction,
|
||||
|
@ -317,7 +666,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "concat",
|
||||
.type = FUNCTION_TYPE_CONCAT,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateConcat,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = concatFunction,
|
||||
|
@ -327,7 +676,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "concat_ws",
|
||||
.type = FUNCTION_TYPE_CONCAT_WS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateConcatWs,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = concatWsFunction,
|
||||
|
@ -337,7 +686,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "lower",
|
||||
.type = FUNCTION_TYPE_LOWER,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = lowerFunction,
|
||||
|
@ -347,7 +696,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "upper",
|
||||
.type = FUNCTION_TYPE_UPPER,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = upperFunction,
|
||||
|
@ -357,7 +706,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "ltrim",
|
||||
.type = FUNCTION_TYPE_LTRIM,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = ltrimFunction,
|
||||
|
@ -367,7 +716,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "rtrim",
|
||||
.type = FUNCTION_TYPE_RTRIM,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = rtrimFunction,
|
||||
|
@ -377,7 +726,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "substr",
|
||||
.type = FUNCTION_TYPE_SUBSTR,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateSubstr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = substrFunction,
|
||||
|
@ -387,7 +736,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "cast",
|
||||
.type = FUNCTION_TYPE_CAST,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateCast,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = castFunction,
|
||||
|
@ -397,7 +746,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "to_iso8601",
|
||||
.type = FUNCTION_TYPE_TO_ISO8601,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateToIso8601,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = toISO8601Function,
|
||||
|
@ -407,7 +756,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "to_unixtimestamp",
|
||||
.type = FUNCTION_TYPE_TO_UNIXTIMESTAMP,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateToUnixtimestamp,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = toUnixtimestampFunction,
|
||||
|
@ -417,7 +766,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "timetruncate",
|
||||
.type = FUNCTION_TYPE_TIMETRUNCATE,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateTimeTruncate,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = timeTruncateFunction,
|
||||
|
@ -427,7 +776,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "timediff",
|
||||
.type = FUNCTION_TYPE_TIMEDIFF,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateTimeDiff,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = timeDiffFunction,
|
||||
|
@ -437,7 +786,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "_rowts",
|
||||
.type = FUNCTION_TYPE_ROWTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
|
@ -447,7 +796,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "tbname",
|
||||
.type = FUNCTION_TYPE_TBNAME,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = NULL,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
|
@ -457,7 +806,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "_qstartts",
|
||||
.type = FUNCTION_TYPE_QSTARTTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = qStartTsFunction,
|
||||
|
@ -467,7 +816,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "_qendts",
|
||||
.type = FUNCTION_TYPE_QENDTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = qEndTsFunction,
|
||||
|
@ -477,7 +826,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "_wstartts",
|
||||
.type = FUNCTION_TYPE_WSTARTTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winStartTsFunction,
|
||||
|
@ -487,7 +836,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "_wendts",
|
||||
.type = FUNCTION_TYPE_QENDTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winEndTsFunction,
|
||||
|
@ -497,7 +846,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "_wduration",
|
||||
.type = FUNCTION_TYPE_WDURATION,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateWduration,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winDurFunction,
|
||||
|
@ -507,7 +856,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "now",
|
||||
.type = FUNCTION_TYPE_NOW,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||
.checkFunc = checkAndGetResultType,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winDurFunction,
|
||||
|
@ -516,167 +865,3 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
};
|
||||
|
||||
const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFuncDefinition));
|
||||
|
||||
int32_t checkAndGetResultType(SFunctionNode* pFunc) {
|
||||
switch(pFunc->funcType) {
|
||||
case FUNCTION_TYPE_WDURATION:
|
||||
case FUNCTION_TYPE_COUNT: {
|
||||
pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT};
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_SUM: {
|
||||
SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
int32_t paraType = pParam->node.resType.type;
|
||||
|
||||
int32_t resType = 0;
|
||||
if (IS_SIGNED_NUMERIC_TYPE(paraType) || paraType == TSDB_DATA_TYPE_BOOL) {
|
||||
resType = TSDB_DATA_TYPE_BIGINT;
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(paraType)) {
|
||||
resType = TSDB_DATA_TYPE_UBIGINT;
|
||||
} else if (IS_FLOAT_TYPE(paraType)) {
|
||||
resType = TSDB_DATA_TYPE_DOUBLE;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[resType].bytes, .type = resType };
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_DIFF:
|
||||
case FUNCTION_TYPE_FIRST:
|
||||
case FUNCTION_TYPE_LAST:
|
||||
case FUNCTION_TYPE_MIN:
|
||||
case FUNCTION_TYPE_MAX: {
|
||||
SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
int32_t paraType = pParam->node.resType.type;
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType };
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_ROWTS:
|
||||
case FUNCTION_TYPE_QSTARTTS:
|
||||
case FUNCTION_TYPE_QENDTS:
|
||||
case FUNCTION_TYPE_WSTARTTS:
|
||||
case FUNCTION_TYPE_WENDTS:{
|
||||
pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_TIMESTAMP};
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_ABS:
|
||||
case FUNCTION_TYPE_CEIL:
|
||||
case FUNCTION_TYPE_FLOOR:
|
||||
case FUNCTION_TYPE_ROUND: {
|
||||
SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
int32_t paraType = pParam->node.resType.type;
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[paraType].bytes, .type = paraType };
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_PERCENTILE:
|
||||
case FUNCTION_TYPE_STDDEV:
|
||||
case FUNCTION_TYPE_SIN:
|
||||
case FUNCTION_TYPE_COS:
|
||||
case FUNCTION_TYPE_TAN:
|
||||
case FUNCTION_TYPE_ASIN:
|
||||
case FUNCTION_TYPE_ACOS:
|
||||
case FUNCTION_TYPE_ATAN:
|
||||
case FUNCTION_TYPE_SQRT:
|
||||
case FUNCTION_TYPE_LOG:
|
||||
case FUNCTION_TYPE_POW: {
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE };
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_LENGTH:
|
||||
case FUNCTION_TYPE_CHAR_LENGTH: {
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_SMALLINT].bytes, .type = TSDB_DATA_TYPE_SMALLINT };
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_CONCAT:
|
||||
case FUNCTION_TYPE_CONCAT_WS: {
|
||||
int32_t paraType, paraBytes = 0;
|
||||
bool typeSet = false;
|
||||
for (int32_t i = 0; i < pFunc->pParameterList->length; ++i) {
|
||||
SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, i);
|
||||
if (pParam->node.type == QUERY_NODE_COLUMN) {
|
||||
if (typeSet == false) {
|
||||
paraType = pParam->node.resType.type;
|
||||
typeSet = true;
|
||||
} else {
|
||||
//columns have to be the same type
|
||||
if (paraType != pParam->node.resType.type) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
paraBytes += pParam->node.resType.bytes;
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < pFunc->pParameterList->length; ++i) {
|
||||
SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, i);
|
||||
if (pParam->node.type == QUERY_NODE_VALUE) {
|
||||
if (paraType == TSDB_DATA_TYPE_NCHAR) {
|
||||
paraBytes += pParam->node.resType.bytes * TSDB_NCHAR_SIZE;
|
||||
} else {
|
||||
paraBytes += pParam->node.resType.bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
pFunc->node.resType = (SDataType) { .bytes = paraBytes, .type = paraType };
|
||||
break;
|
||||
}
|
||||
case FUNCTION_TYPE_LOWER:
|
||||
case FUNCTION_TYPE_UPPER:
|
||||
case FUNCTION_TYPE_LTRIM:
|
||||
case FUNCTION_TYPE_RTRIM:
|
||||
case FUNCTION_TYPE_SUBSTR: {
|
||||
SColumnNode* pParam = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
int32_t paraType = pParam->node.resType.type;
|
||||
int32_t paraBytes = pParam->node.resType.bytes;
|
||||
pFunc->node.resType = (SDataType) { .bytes = paraBytes, .type = paraType };
|
||||
break;
|
||||
}
|
||||
case FUNCTION_TYPE_CAST: {
|
||||
//type
|
||||
SValueNode* pParam = nodesListGetNode(pFunc->pParameterList, 1);
|
||||
int32_t paraType = pParam->datum.i;
|
||||
//bytes
|
||||
pParam = nodesListGetNode(pFunc->pParameterList, 2);
|
||||
int32_t paraBytes = pParam->datum.i;
|
||||
pFunc->node.resType = (SDataType) { .bytes = paraBytes, .type = paraType};
|
||||
break;
|
||||
}
|
||||
case FUNCTION_TYPE_TO_ISO8601: {
|
||||
pFunc->node.resType = (SDataType) { .bytes = 64, .type = TSDB_DATA_TYPE_BINARY};
|
||||
break;
|
||||
}
|
||||
case FUNCTION_TYPE_TO_UNIXTIMESTAMP: {
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
break;
|
||||
}
|
||||
case FUNCTION_TYPE_TIMETRUNCATE: {
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP};
|
||||
break;
|
||||
}
|
||||
case FUNCTION_TYPE_TIMEDIFF: {
|
||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_TBNAME: {
|
||||
// todo
|
||||
break;
|
||||
}
|
||||
|
||||
case FUNCTION_TYPE_NOW:
|
||||
// todo
|
||||
break;
|
||||
default:
|
||||
ASSERT(0); // to found the fault ASAP.
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -69,11 +69,11 @@ int32_t fmGetFuncInfo(const char* pFuncName, int32_t* pFuncId, int32_t* pFuncTyp
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t fmGetFuncResultType(SFunctionNode* pFunc) {
|
||||
int32_t fmGetFuncResultType(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
return funcMgtBuiltins[pFunc->funcId].checkFunc(pFunc);
|
||||
return funcMgtBuiltins[pFunc->funcId].translateFunc(pFunc, pErrBuf, len);
|
||||
}
|
||||
|
||||
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) {
|
||||
|
|
|
@ -132,30 +132,52 @@ const char* nodesNodeName(ENodeType type) {
|
|||
return "DropTopicStmt";
|
||||
case QUERY_NODE_ALTER_LOCAL_STMT:
|
||||
return "AlterLocalStmt";
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
return "ShowDatabaseStmt";
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
return "ShowTablesStmt";
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
return "ShowStablesStmt";
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
return "ShowUsersStmt";
|
||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||
return "ShowDnodesStmt";
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
return "ShowVgroupsStmt";
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
return "ShowMnodesStmt";
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
return "ShowModulesStmt";
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
return "ShowQnodesStmt";
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
return "ShowSnodesStmt";
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
return "ShowBnodesStmt";
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
return "ShowDatabaseStmt";
|
||||
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
||||
return "ShowFunctionsStmt";
|
||||
case QUERY_NODE_SHOW_INDEXES_STMT:
|
||||
return "ShowIndexesStmt";
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
return "ShowStablesStmt";
|
||||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
return "ShowStreamsStmt";
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
return "ShowTablesStmt";
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
return "ShowUsersStmt";
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
return "ShowGrantsStmt";
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
return "ShowVgroupsStmt";
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
return "ShowTopicsStmt";
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
return "ShowConsumersStmt";
|
||||
case QUERY_NODE_SHOW_SUBSCRIBES_STMT:
|
||||
return "ShowSubscribesStmt";
|
||||
case QUERY_NODE_SHOW_TRANS_STMT:
|
||||
return "ShowTransStmt";
|
||||
case QUERY_NODE_SHOW_SMAS_STMT:
|
||||
return "ShowSmasStmt";
|
||||
case QUERY_NODE_SHOW_CONFIGS_STMT:
|
||||
return "ShowConfigsStmt";
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
return "ShowQueriesStmt";
|
||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||
return "ShowVnodeStmt";
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
return "LogicScan";
|
||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||
|
|
|
@ -146,30 +146,29 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
|||
return makeNode(type, sizeof(SDescribeStmt));
|
||||
case QUERY_NODE_RESET_QUERY_CACHE_STMT:
|
||||
return makeNode(type, sizeof(SNode));
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_INDEXES_STMT:
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
case QUERY_NODE_SHOW_APPS_STMT:
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
case QUERY_NODE_SHOW_CONSUMERS_STMT:
|
||||
case QUERY_NODE_SHOW_SUBSCRIBES_STMT:
|
||||
case QUERY_NODE_SHOW_TRANS_STMT:
|
||||
case QUERY_NODE_SHOW_SMAS_STMT:
|
||||
case QUERY_NODE_SHOW_CONFIGS_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
case QUERY_NODE_SHOW_VNODES_STMT:
|
||||
return makeNode(type, sizeof(SShowStmt));
|
||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||
return makeNode(type, sizeof(SScanLogicNode));
|
||||
|
|
|
@ -81,7 +81,6 @@ SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode);
|
|||
|
||||
SNodeList* createNodeList(SAstCreateContext* pCxt, SNode* pNode);
|
||||
SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode);
|
||||
SNodeList* addValueNodeFromTypeToList(SAstCreateContext* pCxt, SDataType dataType, SNodeList* pList);
|
||||
|
||||
SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pColumnName);
|
||||
SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral);
|
||||
|
@ -93,6 +92,7 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
|
|||
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList);
|
||||
SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt);
|
||||
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList);
|
||||
SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2);
|
||||
SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTableName, SToken* pTableAlias);
|
||||
|
|
|
@ -535,13 +535,7 @@ expression(A) ::= pseudo_column(B).
|
|||
expression(A) ::= column_reference(B). { A = B; }
|
||||
expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||
expression(A) ::= function_name(B) NK_LP NK_STAR(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, createNodeList(pCxt, createColumnNode(pCxt, NULL, &C)))); }
|
||||
//for CAST function CAST(expr AS type_name)
|
||||
expression(A) ::= function_name(B) NK_LP expression(C) AS type_name(D) NK_RP(E). {
|
||||
SNodeList *p = createNodeList(pCxt, releaseRawExprNode(pCxt, C));
|
||||
p = addValueNodeFromTypeToList(pCxt, D, p);
|
||||
A = createRawExprNodeExt(pCxt, &B, &E, createFunctionNode(pCxt, &B, p));
|
||||
}
|
||||
//expression(A) ::= cast_expression(B). { A = B; }
|
||||
expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||
//expression(A) ::= case_expression(B). { A = B; }
|
||||
expression(A) ::= subquery(B). { A = B; }
|
||||
expression(A) ::= NK_LP(B) expression(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, releaseRawExprNode(pCxt, C)); }
|
||||
|
|
|
@ -208,7 +208,9 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
|
|||
SRawExprNode* pRawExpr = (SRawExprNode*)pNode;
|
||||
SNode* pExpr = pRawExpr->pNode;
|
||||
if (nodesIsExprNode(pExpr)) {
|
||||
strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, pRawExpr->n);
|
||||
int32_t len = TMIN(sizeof(((SExprNode*)pExpr)->aliasName) - 1, pRawExpr->n);
|
||||
strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, len);
|
||||
((SExprNode*)pExpr)->aliasName[len] = '\0';
|
||||
}
|
||||
taosMemoryFreeClear(pNode);
|
||||
return pExpr;
|
||||
|
@ -253,33 +255,6 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC
|
|||
return (SNode*)col;
|
||||
}
|
||||
|
||||
SNodeList* addValueNodeFromTypeToList(SAstCreateContext* pCxt, SDataType dataType, SNodeList* pList) {
|
||||
char buf[64] = {0};
|
||||
//add value node for type
|
||||
snprintf(buf, sizeof(buf), "%u", dataType.type);
|
||||
SToken token = {.type = TSDB_DATA_TYPE_SMALLINT, .n = strlen(buf), .z = buf};
|
||||
SNode* pNode = createValueNode(pCxt, token.type, &token);
|
||||
addNodeToList(pCxt, pList, pNode);
|
||||
|
||||
//add value node for bytes
|
||||
memset(buf, 0, sizeof(buf));
|
||||
int32_t bytes;
|
||||
if (IS_VAR_DATA_TYPE(dataType.type)) {
|
||||
bytes = (dataType.type == TSDB_DATA_TYPE_NCHAR) ? dataType.bytes * TSDB_NCHAR_SIZE : dataType.bytes;
|
||||
bytes += VARSTR_HEADER_SIZE;
|
||||
} else {
|
||||
bytes = dataType.bytes;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%d", bytes);
|
||||
token.type = TSDB_DATA_TYPE_BIGINT;
|
||||
token.n = strlen(buf);
|
||||
token.z = buf;
|
||||
pNode = createValueNode(pCxt, token.type, &token);
|
||||
addNodeToList(pCxt, pList, pNode);
|
||||
|
||||
return pList;
|
||||
}
|
||||
|
||||
SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral) {
|
||||
SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
CHECK_OUT_OF_MEM(val);
|
||||
|
@ -385,6 +360,15 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod
|
|||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt) {
|
||||
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
CHECK_OUT_OF_MEM(func);
|
||||
strcpy(func->functionName, "cast");
|
||||
func->node.resType = dt;
|
||||
nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
return (SNode*)func;
|
||||
}
|
||||
|
||||
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList) {
|
||||
SNodeListNode* list = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
CHECK_OUT_OF_MEM(list);
|
||||
|
@ -927,18 +911,6 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) {
|
||||
SNode* pStmt = nodesMakeNode(QUERY_NODE_SHOW_CREATE_DATABASE_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
return pStmt;
|
||||
}
|
||||
|
||||
SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable) {
|
||||
SNode* pStmt = nodesMakeNode(type);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
return pStmt;
|
||||
}
|
||||
|
||||
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword) {
|
||||
char password[TSDB_USET_PASSWORD_LEN] = {0};
|
||||
if (!checkUserName(pCxt, pUserName) || !checkPassword(pCxt, pPassword, password)) {
|
||||
|
|
|
@ -415,7 +415,6 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
|||
pVal->datum.d = strtold(pVal->literal, &endPtr);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
case TSDB_DATA_TYPE_VARBINARY: {
|
||||
pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
|
||||
|
@ -433,6 +432,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_JSON:
|
||||
case TSDB_DATA_TYPE_DECIMAL:
|
||||
case TSDB_DATA_TYPE_BLOB:
|
||||
|
@ -485,9 +485,9 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
|
|||
if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pFunc->functionName, &pFunc->funcId, &pFunc->funcType)) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_FUNTION, pFunc->functionName);
|
||||
}
|
||||
int32_t code = fmGetFuncResultType(pFunc);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return generateDealNodeErrMsg(pCxt, code, pFunc->functionName);
|
||||
pCxt->errCode = fmGetFuncResultType(pFunc, pCxt->msgBuf.buf, pCxt->msgBuf.len);
|
||||
if (TSDB_CODE_SUCCESS != pCxt->errCode) {
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
if (fmIsAggFunc(pFunc->funcId) && beforeHaving(pCxt->currClause)) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION);
|
||||
|
@ -1366,6 +1366,25 @@ static int32_t checkCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt*
|
|||
return checkDatabaseOptions(pCxt, pStmt->pOptions);
|
||||
}
|
||||
|
||||
typedef int32_t (*FSerializeFunc)(void *pBuf, int32_t bufLen, void *pReq);
|
||||
|
||||
static int32_t buildCmdMsg(STranslateContext* pCxt, int16_t msgType, FSerializeFunc func, void* pReq) {
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = msgType;
|
||||
pCxt->pCmdMsg->msgLen = func(NULL, 0, pReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
func(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, pReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt) {
|
||||
SCreateDbReq createReq = {0};
|
||||
|
||||
|
@ -1375,18 +1394,7 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSCreateDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_CREATE_DB, (FSerializeFunc)tSerializeSCreateDbReq, &createReq);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -1394,25 +1402,12 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
|
|||
|
||||
static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* pStmt) {
|
||||
SDropDbReq dropReq = {0};
|
||||
SName name = {0};
|
||||
SName name = {0};
|
||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||
tNameGetFullDbName(&name, dropReq.db);
|
||||
dropReq.ignoreNotExists = pStmt->ignoreNotExists;
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_DROP_DB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSDropDbReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSDropDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_DROP_DB, (FSerializeFunc)tSerializeSDropDbReq, &dropReq);
|
||||
}
|
||||
|
||||
static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, SAlterDbReq* pReq) {
|
||||
|
@ -1440,20 +1435,7 @@ static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStm
|
|||
SAlterDbReq alterReq = {0};
|
||||
buildAlterDbReq(pCxt, pStmt, &alterReq);
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_DB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSAlterDbReq(NULL, 0, &alterReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSAlterDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_ALTER_DB, (FSerializeFunc)tSerializeSAlterDbReq, &alterReq);
|
||||
}
|
||||
|
||||
static int32_t calcTypeBytes(SDataType dt) {
|
||||
|
@ -1615,23 +1597,9 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
|
|||
strcpy(tableName.tname, pStmt->tableName);
|
||||
tNameExtractFullName(&tableName, createReq.name);
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
tFreeSMCreateStbReq(&createReq);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_STB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMCreateStbReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
tFreeSMCreateStbReq(&createReq);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMCreateStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_CREATE_STB, (FSerializeFunc)tSerializeSMCreateStbReq, &createReq);
|
||||
tFreeSMCreateStbReq(&createReq);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* pTableName, bool ignoreNotExists) {
|
||||
|
@ -1639,20 +1607,7 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p
|
|||
tNameExtractFullName(pTableName, dropReq.name);
|
||||
dropReq.igNotExists = ignoreNotExists;
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_DROP_STB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMDropStbReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMDropStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_DROP_STB, (FSerializeFunc)tSerializeSMDropStbReq, &dropReq);
|
||||
}
|
||||
|
||||
static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt) {
|
||||
|
@ -1736,20 +1691,7 @@ static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pSt
|
|||
}
|
||||
}
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_STB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMAlterStbReq(NULL, 0, &alterReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMAlterStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_ALTER_STB, (FSerializeFunc)tSerializeSMAlterStbReq, &alterReq);
|
||||
}
|
||||
|
||||
static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* pStmt) {
|
||||
|
@ -1758,24 +1700,10 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p
|
|||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||
tNameExtractFullName(&name, usedbReq.db);
|
||||
int32_t code = getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_USE_DB, (FSerializeFunc)tSerializeSUseDbReq, &usedbReq);
|
||||
}
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_USE_DB;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSUseDbReq(NULL, 0, &usedbReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSUseDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &usedbReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pStmt) {
|
||||
|
@ -1785,20 +1713,7 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt
|
|||
createReq.superUser = 0;
|
||||
strcpy(createReq.pass, pStmt->password);
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_USER;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSCreateUserReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSCreateUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_CREATE_USER, (FSerializeFunc)tSerializeSCreateUserReq, &createReq);
|
||||
}
|
||||
|
||||
static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt) {
|
||||
|
@ -1811,40 +1726,14 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt
|
|||
strcpy(alterReq.dbname, pCxt->pParseCxt->db);
|
||||
}
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_USER;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSAlterUserReq(NULL, 0, &alterReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSAlterUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &alterReq);
|
||||
}
|
||||
|
||||
static int32_t translateDropUser(STranslateContext* pCxt, SDropUserStmt* pStmt) {
|
||||
SDropUserReq dropReq = {0};
|
||||
strcpy(dropReq.user, pStmt->useName);
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_DROP_USER;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSDropUserReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSDropUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_DROP_USER, (FSerializeFunc)tSerializeSDropUserReq, &dropReq);
|
||||
}
|
||||
|
||||
static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* pStmt) {
|
||||
|
@ -1852,20 +1741,7 @@ static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* p
|
|||
strcpy(createReq.fqdn, pStmt->fqdn);
|
||||
createReq.port = pStmt->port;
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DNODE;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSCreateDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_CREATE_DNODE, (FSerializeFunc)tSerializeSCreateDnodeReq, &createReq);
|
||||
}
|
||||
|
||||
static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt) {
|
||||
|
@ -1874,20 +1750,7 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt
|
|||
strcpy(dropReq.fqdn, pStmt->fqdn);
|
||||
dropReq.port = pStmt->port;
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_DROP_DNODE;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSDropDnodeReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSDropDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_DROP_DNODE, (FSerializeFunc)tSerializeSDropDnodeReq, &dropReq);
|
||||
}
|
||||
|
||||
static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pStmt) {
|
||||
|
@ -1896,61 +1759,30 @@ static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pSt
|
|||
strcpy(cfgReq.config, pStmt->config);
|
||||
strcpy(cfgReq.value, pStmt->value);
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CONFIG_DNODE;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMCfgDnodeReq(NULL, 0, &cfgReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMCfgDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &cfgReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_CONFIG_DNODE, (FSerializeFunc)tSerializeSMCfgDnodeReq, &cfgReq);
|
||||
}
|
||||
|
||||
static int32_t nodeTypeToShowType(ENodeType nt) {
|
||||
switch (nt) {
|
||||
case QUERY_NODE_SHOW_APPS_STMT:
|
||||
return 0; // todo
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
return TSDB_MGMT_TABLE_CONNS;
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
return TSDB_MGMT_TABLE_GRANTS;
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
return TSDB_MGMT_TABLE_QUERIES;
|
||||
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||
return 0; // todo
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
return 0; // todo
|
||||
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
||||
return TSDB_MGMT_TABLE_VARIABLES;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// switch (nt) {
|
||||
// case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
// return TSDB_MGMT_TABLE_CONNS;
|
||||
// case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
// return TSDB_MGMT_TABLE_GRANTS;
|
||||
// case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
// return TSDB_MGMT_TABLE_QUERIES;
|
||||
// case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
// return 0; // todo
|
||||
// case QUERY_NODE_SHOW_VARIABLE_STMT:
|
||||
// return TSDB_MGMT_TABLE_VARIABLES;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) {
|
||||
SShowReq showReq = {.type = nodeTypeToShowType(nodeType(pStmt))};
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_SHOW;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSShowReq(NULL, 0, &showReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSShowReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &showReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_SHOW, (FSerializeFunc)tSerializeSShowReq, &showReq);
|
||||
}
|
||||
|
||||
static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, char* pTableName, int32_t* pVgId) {
|
||||
|
@ -2070,61 +1902,25 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
|
|||
}
|
||||
|
||||
SMCreateSmaReq createSmaReq = {0};
|
||||
|
||||
int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_CREATE_SMA, (FSerializeFunc)tSerializeSMCreateSmaReq, &createSmaReq);
|
||||
}
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_SMA;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMCreateSmaReq(NULL, 0, &createSmaReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMCreateSmaReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createSmaReq);
|
||||
tFreeSMCreateSmaReq(&createSmaReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SMCreateFullTextReq* pReq) {
|
||||
// impl later
|
||||
return 0;
|
||||
}
|
||||
static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
|
||||
if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) ||
|
||||
(NULL != pStmt->pOptions->pOffset &&
|
||||
DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) ||
|
||||
(NULL != pStmt->pOptions->pSliding &&
|
||||
DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) {
|
||||
return pCxt->errCode;
|
||||
}
|
||||
SMCreateFullTextReq createFTReq = {0};
|
||||
|
||||
int32_t code = buildCreateFullTextReq(pCxt, pStmt, &createFTReq);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildCmdMsg(pCxt, TDMT_MND_CREATE_INDEX, (FSerializeFunc)tSerializeSMCreateFullTextReq, &createFTReq);
|
||||
}
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_INDEX;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMCreateFullTextReq(NULL, 0, &createFTReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMCreateFullTextReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createFTReq);
|
||||
tFreeSMCreateFullTextReq(&createFTReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
|
||||
|
@ -2132,7 +1928,6 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p
|
|||
return translateCreateSmaIndex(pCxt, pStmt);
|
||||
} else if (INDEX_TYPE_FULLTEXT == pStmt->indexType) {
|
||||
return translateCreateFullTextIndex(pCxt, pStmt);
|
||||
// todo fulltext index
|
||||
}
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -2176,21 +1971,7 @@ static int16_t getCreateComponentNodeMsgType(ENodeType type) {
|
|||
|
||||
static int32_t translateCreateComponentNode(STranslateContext* pCxt, SCreateComponentNodeStmt* pStmt) {
|
||||
SMCreateQnodeReq createReq = {.dnodeId = pStmt->dnodeId};
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = getCreateComponentNodeMsgType(nodeType(pStmt));
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSCreateDropMQSBNodeReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSCreateDropMQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, getCreateComponentNodeMsgType(nodeType(pStmt)), (FSerializeFunc)tSerializeSCreateDropMQSBNodeReq, &createReq);
|
||||
}
|
||||
|
||||
static int16_t getDropComponentNodeMsgType(ENodeType type) {
|
||||
|
@ -2211,21 +1992,7 @@ static int16_t getDropComponentNodeMsgType(ENodeType type) {
|
|||
|
||||
static int32_t translateDropComponentNode(STranslateContext* pCxt, SDropComponentNodeStmt* pStmt) {
|
||||
SDDropQnodeReq dropReq = {.dnodeId = pStmt->dnodeId};
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = getDropComponentNodeMsgType(nodeType(pStmt));
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSCreateDropMQSBNodeReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSCreateDropMQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, getDropComponentNodeMsgType(nodeType(pStmt)), (FSerializeFunc)tSerializeSCreateDropMQSBNodeReq, &dropReq);
|
||||
}
|
||||
|
||||
static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt) {
|
||||
|
@ -2255,21 +2022,9 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
|
|||
tNameExtractFullName(&name, createReq.name);
|
||||
createReq.igExists = pStmt->ignoreExists;
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_TOPIC;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSCMCreateTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq);
|
||||
int32_t code = buildCmdMsg(pCxt, TDMT_MND_CREATE_TOPIC, (FSerializeFunc)tSerializeSCMCreateTopicReq, &createReq);
|
||||
tFreeSCMCreateTopicReq(&createReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt) {
|
||||
|
@ -2281,20 +2036,7 @@ static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt
|
|||
tNameExtractFullName(&name, dropReq.name);
|
||||
dropReq.igNotExists = pStmt->ignoreNotExists;
|
||||
|
||||
pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo));
|
||||
if (NULL == pCxt->pCmdMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_DROP_TOPIC;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMDropTopicReq(NULL, 0, &dropReq);
|
||||
pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tSerializeSMDropTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_DROP_TOPIC, (FSerializeFunc)tSerializeSMDropTopicReq, &dropReq);
|
||||
}
|
||||
|
||||
static int32_t translateAlterLocal(STranslateContext* pCxt, SAlterLocalStmt* pStmt) {
|
||||
|
@ -2313,6 +2055,19 @@ static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt)
|
|||
return getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta);
|
||||
}
|
||||
|
||||
static int32_t translateKillConnection(STranslateContext* pCxt, SKillStmt* pStmt) {
|
||||
SKillConnReq killReq = {0};
|
||||
killReq.connId = pStmt->targetId;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_KILL_CONN, (FSerializeFunc)tSerializeSKillQueryReq, &killReq);
|
||||
}
|
||||
|
||||
static int32_t translateKillQuery(STranslateContext* pCxt, SKillStmt* pStmt) {
|
||||
SKillQueryReq killReq = {0};
|
||||
killReq.queryId = pStmt->targetId;
|
||||
return buildCmdMsg(pCxt, TDMT_MND_KILL_QUERY, (FSerializeFunc)tSerializeSKillQueryReq, &killReq);
|
||||
}
|
||||
|
||||
|
||||
static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (nodeType(pNode)) {
|
||||
|
@ -2361,19 +2116,11 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
|||
case QUERY_NODE_ALTER_DNODE_STMT:
|
||||
code = translateAlterDnode(pCxt, (SAlterDnodeStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_SHOW_APPS_STMT:
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
||||
code = translateShow(pCxt, (SShowStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||
// todo
|
||||
break;
|
||||
case QUERY_NODE_CREATE_INDEX_STMT:
|
||||
code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode);
|
||||
break;
|
||||
|
@ -2407,6 +2154,12 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
|
|||
case QUERY_NODE_DESCRIBE_STMT:
|
||||
code = translateDescribe(pCxt, (SDescribeStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_KILL_CONNECTION_STMT:
|
||||
code = translateKillConnection(pCxt, (SKillStmt*)pNode);
|
||||
break;
|
||||
case QUERY_NODE_KILL_QUERY_STMT:
|
||||
code = translateKillQuery(pCxt, (SKillStmt*)pNode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -2520,6 +2273,33 @@ static void destroyTranslateContext(STranslateContext* pCxt) {
|
|||
taosHashCleanup(pCxt->pTables);
|
||||
}
|
||||
|
||||
static const char* getSysDbName(ENodeType type) {
|
||||
switch (type) {
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
case QUERY_NODE_SHOW_TABLES_STMT:
|
||||
case QUERY_NODE_SHOW_STABLES_STMT:
|
||||
case QUERY_NODE_SHOW_USERS_STMT:
|
||||
case QUERY_NODE_SHOW_DNODES_STMT:
|
||||
case QUERY_NODE_SHOW_VGROUPS_STMT:
|
||||
case QUERY_NODE_SHOW_MNODES_STMT:
|
||||
case QUERY_NODE_SHOW_MODULES_STMT:
|
||||
case QUERY_NODE_SHOW_QNODES_STMT:
|
||||
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_INDEXES_STMT:
|
||||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
return TSDB_INFORMATION_SCHEMA_DB;
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
return TSDB_PERFORMANCE_SCHEMA_DB;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char* getSysTableName(ENodeType type) {
|
||||
switch (type) {
|
||||
case QUERY_NODE_SHOW_DATABASES_STMT:
|
||||
|
@ -2552,6 +2332,9 @@ static const char* getSysTableName(ENodeType type) {
|
|||
return TSDB_INS_TABLE_SNODES;
|
||||
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||
return TSDB_INS_TABLE_LICENCES;
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
// todo
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -2570,7 +2353,7 @@ static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt)
|
|||
nodesDestroyNode(pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pTable->table.dbName, TSDB_INFORMATION_SCHEMA_DB);
|
||||
strcpy(pTable->table.dbName, getSysDbName(showType));
|
||||
strcpy(pTable->table.tableName, getSysTableName(showType));
|
||||
strcpy(pTable->table.tableAlias, pTable->table.tableName);
|
||||
pSelect->pFromTable = (SNode*)pTable;
|
||||
|
@ -3074,6 +2857,8 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||
code = rewriteShow(pCxt, pQuery);
|
||||
break;
|
||||
case QUERY_NODE_CREATE_TABLE_STMT:
|
||||
|
|
|
@ -31,10 +31,6 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
|||
return "Invalid value type : %s";
|
||||
case TSDB_CODE_PAR_INVALID_FUNTION:
|
||||
return "Invalid function name : %s";
|
||||
case TSDB_CODE_PAR_FUNTION_PARA_NUM:
|
||||
return "Invalid number of arguments : %s";
|
||||
case TSDB_CODE_PAR_FUNTION_PARA_TYPE:
|
||||
return "Inconsistent datatypes : %s";
|
||||
case TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION:
|
||||
return "There mustn't be aggregation";
|
||||
case TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -498,19 +498,16 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
||||
SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
pJoin->joinType = pJoinLogicNode->joinType;
|
||||
if (NULL != pJoinLogicNode->pOnConditions) {
|
||||
SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
||||
SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc;
|
||||
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pOnConditions, &pJoin->pOnConditions);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pJoin->pTargets = nodesCloneList(pJoinLogicNode->node.pTargets);
|
||||
if (NULL == pJoin->pTargets) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
code = setListSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->node.pTargets, &pJoin->pTargets);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = addDataBlockSlots(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc);
|
||||
|
|
|
@ -180,11 +180,11 @@ TEST_F(PlannerTest, selectStableBasic) {
|
|||
TEST_F(PlannerTest, selectJoin) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
// bind("SELECT t1.c1, t2.c2 FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
|
||||
// ASSERT_TRUE(run());
|
||||
bind("SELECT t1.c1, t2.c2 FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
|
||||
ASSERT_TRUE(run());
|
||||
|
||||
// bind("SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
|
||||
// ASSERT_TRUE(run());
|
||||
bind("SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
|
||||
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'");
|
||||
ASSERT_TRUE(run());
|
||||
|
|
|
@ -54,10 +54,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 9223372036854770000)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -75,10 +75,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2.000000000)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -91,10 +91,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
###################################################################
|
||||
# Copyright (c) 2016 by TAOS Technologies, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is proprietary and confidential to TAOS Technologies.
|
||||
# No part of this file may be reproduced, stored, transmitted,
|
||||
# disclosed or used in any form or by any means other than as
|
||||
# expressly provided by the written permission from Jianhui Tao
|
||||
#
|
||||
###################################################################
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
self.ts = 1607281690000
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
|
||||
# TS-806
|
||||
tdLog.info("test case for TS-806")
|
||||
|
||||
# Case 1
|
||||
tdSql.execute("create table t1(ts timestamp, c1 int)")
|
||||
tdSql.execute("insert into t1(c1, ts) values(1, %d)" % self.ts)
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
# Case 2
|
||||
tdSql.execute(
|
||||
"insert into t1(c1, ts) values(2, %d)(3, %d)" %
|
||||
(self.ts + 1000, self.ts + 2000))
|
||||
tdSql.query("select * from t1")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
# Case 3
|
||||
tdSql.execute("create table t2(ts timestamp, c1 timestamp)")
|
||||
tdSql.execute(
|
||||
" insert into t2(c1, ts) values(%d, %d)" %
|
||||
(self.ts, self.ts + 5000))
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.execute(
|
||||
" insert into t2(c1, ts) values(%d, %d)(%d, %d)" %
|
||||
(self.ts, self.ts + 6000, self.ts + 3000, self.ts + 8000))
|
||||
tdSql.query("select * from t2")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
# Case 4
|
||||
tdSql.execute(
|
||||
"create table stb(ts timestamp, c1 int, c2 binary(20)) tags(tstag timestamp, t1 int)")
|
||||
tdSql.execute(
|
||||
"insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', %d, 1)" %
|
||||
self.ts)
|
||||
tdSql.query("select * from stb")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
# Case 5
|
||||
tdSql.execute(
|
||||
"insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', now, 1) tb2(c1, ts) using stb tags(now + 2m, 1000) values(1, now - 1h)")
|
||||
tdSql.query("select * from stb")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.execute(" insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', now + 10s, 1) tb2(c1, ts) using stb(tstag) tags(now + 2m) values(1, now - 3h)(2, now - 2h)")
|
||||
tdSql.query("select * from stb")
|
||||
tdSql.checkRows(6)
|
||||
|
||||
# Case 6
|
||||
tdSql.execute(
|
||||
"create table stb2 (ts timestamp, c1 timestamp, c2 timestamp) tags(t1 timestamp, t2 timestamp)")
|
||||
tdSql.execute(" insert into tb4(c1, c2, ts) using stb2(t2, t1) tags(now, now + 1h) values(now + 1s, now + 2s, now + 3s)(now -1s, now - 2s, now - 3s) tb5(c2, ts, c1) using stb2(t2) tags(now + 1h) values(now, now, now)")
|
||||
tdSql.query("select * from stb2")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success("%s successfully executed" % __file__)
|
||||
|
||||
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -91,10 +91,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -93,10 +93,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -93,10 +93,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -93,10 +93,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
# convert end
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -91,10 +91,6 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 1, 2)
|
||||
tdLog.info('drop database db')
|
||||
tdSql.execute('drop database db')
|
||||
tdLog.info('show databases')
|
||||
tdSql.query('show databases')
|
||||
tdLog.info('tdSql.checkRow(0)')
|
||||
tdSql.checkRows(0)
|
||||
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -4,10 +4,32 @@ ulimit -c unlimited
|
|||
# insert
|
||||
python3 ./test.py $1 -f insert/basic.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/bool.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/tinyint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/smallint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/int.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/bigint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/float.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/double.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/nchar.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/timestamp.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/unsignedTinyint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/unsignedSmallint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/unsignedInt.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/unsignedBigint.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
python3 ./test.py $1 -f insert/multi.py
|
||||
python3 ./test.py $1 -s && sleep 1
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
./test.sh -f tsim/query/interval.sim
|
||||
./test.sh -f tsim/query/interval-offset.sim
|
||||
./test.sh -f tsim/query/scalarFunction.sim
|
||||
./test.sh -f tsim/query/charScalarFunction.sim
|
||||
#./test.sh -f tsim/query/charScalarFunction.sim
|
||||
./test.sh -f tsim/query/explain.sim
|
||||
./test.sh -f tsim/query/session.sim
|
||||
|
||||
|
|
|
@ -125,8 +125,8 @@ ulimit -c unlimited
|
|||
if [ -n "$FILE_NAME" ]; then
|
||||
echo "------------------------------------------------------------------------"
|
||||
if [ $VALGRIND -eq 1 ]; then
|
||||
echo valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME
|
||||
valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME
|
||||
echo valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME -v
|
||||
valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME -v
|
||||
else
|
||||
if [[ $MULTIPROCESS -eq 1 ]];then
|
||||
echo "ExcuteCmd(multiprocess):" $PROGRAM -m -c $CFG_DIR -f $FILE_NAME
|
||||
|
|
|
@ -280,7 +280,6 @@ endi
|
|||
if $data12 != NULL then
|
||||
return -1
|
||||
endi
|
||||
return
|
||||
|
||||
print ====> select c2, c3 , concat(c2,c3) from ntb6
|
||||
sql select c2, c3 , concat(c2,c3) from ntb6
|
||||
|
|
|
@ -156,6 +156,7 @@ extern int32_t simDebugFlag;
|
|||
extern char simScriptDir[];
|
||||
extern bool abortExecution;
|
||||
extern bool useMultiProcess;
|
||||
extern bool useValgrind;
|
||||
|
||||
SScript *simParseScript(char *fileName);
|
||||
SScript *simProcessCallOver(SScript *script);
|
||||
|
|
|
@ -340,6 +340,10 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
|
|||
simReplaceStr(buf, "deploy.sh", "deploy.sh -m");
|
||||
}
|
||||
|
||||
if (useValgrind) {
|
||||
simReplaceStr(buf, "exec.sh", "exec.sh -v");
|
||||
}
|
||||
|
||||
simLogSql(buf, true);
|
||||
int32_t code = system(buf);
|
||||
int32_t repeatTimes = 0;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
bool simExecSuccess = false;
|
||||
bool abortExecution = false;
|
||||
bool useMultiProcess = false;
|
||||
bool useValgrind = false;
|
||||
|
||||
void simHandleSignal(int32_t signo, void *sigInfo, void *context) {
|
||||
simSystemCleanUp();
|
||||
|
@ -35,6 +36,8 @@ int32_t main(int32_t argc, char *argv[]) {
|
|||
strcpy(scriptFile, argv[++i]);
|
||||
} else if (strcmp(argv[i], "-m") == 0) {
|
||||
useMultiProcess = true;
|
||||
} else if (strcmp(argv[i], "-v") == 0) {
|
||||
useValgrind = true;
|
||||
} else {
|
||||
printf("usage: %s [options] \n", argv[0]);
|
||||
printf(" [-c config]: config directory, default is: %s\n", configDir);
|
||||
|
|
Loading…
Reference in New Issue