Merge branch '3.0' of https://github.com/taosdata/TDengine into feature/vnode_refact1
This commit is contained in:
commit
ab0e435d81
|
@ -228,7 +228,7 @@ endif()
|
|||
|
||||
# iconv
|
||||
if(${BUILD_WITH_ICONV})
|
||||
add_subdirectory(iconv EXCLUDE_FROM_ALL)
|
||||
add_library(iconv STATIC iconv/win_iconv.c)
|
||||
endif(${BUILD_WITH_ICONV})
|
||||
|
||||
# wingetopt
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "taos.h"
|
||||
|
@ -24,7 +26,7 @@ static void msg_process(TAOS_RES* msg) {
|
|||
char buf[1024];
|
||||
memset(buf, 0, 1024);
|
||||
printf("topic: %s\n", tmq_get_topic_name(msg));
|
||||
printf("vg:%d\n", tmq_get_vgroup_id(msg));
|
||||
printf("vg: %d\n", tmq_get_vgroup_id(msg));
|
||||
while (1) {
|
||||
TAOS_ROW row = taos_fetch_row(msg);
|
||||
if (row == NULL) break;
|
||||
|
@ -140,8 +142,8 @@ int32_t create_topic() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tmq_commit_cb_print(tmq_t* tmq, tmq_resp_err_t resp, tmq_topic_vgroup_list_t* offsets) {
|
||||
printf("commit %d\n", resp);
|
||||
void tmq_commit_cb_print(tmq_t* tmq, tmq_resp_err_t resp, tmq_topic_vgroup_list_t* offsets, void* param) {
|
||||
printf("commit %d tmq %p offsets %p param %p\n", resp, tmq, offsets, param);
|
||||
}
|
||||
|
||||
tmq_t* build_consumer() {
|
||||
|
@ -161,7 +163,7 @@ tmq_t* build_consumer() {
|
|||
tmq_conf_set(conf, "td.connect.user", "root");
|
||||
tmq_conf_set(conf, "td.connect.pass", "taosdata");
|
||||
/*tmq_conf_set(conf, "td.connect.db", "abc1");*/
|
||||
tmq_conf_set_offset_commit_cb(conf, tmq_commit_cb_print);
|
||||
tmq_conf_set_offset_commit_cb(conf, tmq_commit_cb_print, NULL);
|
||||
tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
|
||||
assert(tmq);
|
||||
return tmq;
|
||||
|
@ -215,12 +217,24 @@ void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
|||
return;
|
||||
}
|
||||
|
||||
tmq_list_t* subList = NULL;
|
||||
tmq_subscription(tmq, &subList);
|
||||
char** subTopics = tmq_list_to_c_array(subList);
|
||||
int32_t sz = tmq_list_get_size(subList);
|
||||
printf("subscribed topics: ");
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
printf("%s, ", subTopics[i]);
|
||||
}
|
||||
printf("\n");
|
||||
tmq_list_destroy(subList);
|
||||
|
||||
while (running) {
|
||||
TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000);
|
||||
if (tmqmessage) {
|
||||
msg_process(tmqmessage);
|
||||
taos_free_result(tmqmessage);
|
||||
|
||||
tmq_commit(tmq, NULL, 1);
|
||||
/*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ int32_t init_env() {
|
|||
return -1;
|
||||
}
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 2");
|
||||
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
|
@ -78,11 +78,14 @@ int32_t create_stream() {
|
|||
taos_free_result(pRes);
|
||||
|
||||
/*const char* sql = "select min(k), max(k), sum(k) from tu1";*/
|
||||
const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";
|
||||
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
|
||||
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
|
||||
pRes = tmq_create_stream(pConn, "stream1", "out1", sql);
|
||||
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
|
||||
pRes = taos_query(
|
||||
pConn,
|
||||
"create stream stream1 trigger window_close as select min(k), max(k), sum(k) as sum_of_k from tu1 interval(10m)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create stream out1, reason:%s\n", taos_errstr(pRes));
|
||||
printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
|
|
@ -86,9 +86,9 @@ typedef struct taosField {
|
|||
} TAOS_FIELD;
|
||||
|
||||
#ifdef WINDOWS
|
||||
#define DLL_EXPORT __declspec(dllexport)
|
||||
#define DLL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define DLL_EXPORT
|
||||
#define DLL_EXPORT
|
||||
#endif
|
||||
|
||||
typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *, int code);
|
||||
|
@ -123,42 +123,42 @@ DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...);
|
|||
DLL_EXPORT setConfRet taos_set_config(const char *config);
|
||||
DLL_EXPORT int taos_init(void);
|
||||
DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port);
|
||||
DLL_EXPORT TAOS *taos_connect_l(const char *ip, int ipLen, const char *user, int userLen, const char *pass, int passLen,
|
||||
DLL_EXPORT TAOS *taos_connect_l(const char *ip, int ipLen, const char *user, int userLen, const char *pass, int passLen,
|
||||
const char *db, int dbLen, uint16_t port);
|
||||
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
|
||||
DLL_EXPORT void taos_close(TAOS *taos);
|
||||
DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
|
||||
DLL_EXPORT void taos_close(TAOS *taos);
|
||||
|
||||
const char *taos_data_type(int type);
|
||||
const char *taos_data_type(int type);
|
||||
|
||||
DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos);
|
||||
DLL_EXPORT int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length);
|
||||
DLL_EXPORT int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_MULTI_BIND *tags);
|
||||
DLL_EXPORT int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name);
|
||||
DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name);
|
||||
DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos);
|
||||
DLL_EXPORT int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length);
|
||||
DLL_EXPORT int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_MULTI_BIND *tags);
|
||||
DLL_EXPORT int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name);
|
||||
DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT *stmt, const char *name);
|
||||
|
||||
DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert);
|
||||
DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums);
|
||||
DLL_EXPORT int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes);
|
||||
DLL_EXPORT int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
|
||||
DLL_EXPORT int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
|
||||
DLL_EXPORT int taos_stmt_bind_single_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int colIdx);
|
||||
DLL_EXPORT int taos_stmt_add_batch(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_execute(TAOS_STMT *stmt);
|
||||
DLL_EXPORT TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_close(TAOS_STMT *stmt);
|
||||
DLL_EXPORT char *taos_stmt_errstr(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_affected_rows_once(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert);
|
||||
DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums);
|
||||
DLL_EXPORT int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes);
|
||||
DLL_EXPORT int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
|
||||
DLL_EXPORT int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind);
|
||||
DLL_EXPORT int taos_stmt_bind_single_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int colIdx);
|
||||
DLL_EXPORT int taos_stmt_add_batch(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_execute(TAOS_STMT *stmt);
|
||||
DLL_EXPORT TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_close(TAOS_STMT *stmt);
|
||||
DLL_EXPORT char *taos_stmt_errstr(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt);
|
||||
DLL_EXPORT int taos_stmt_affected_rows_once(TAOS_STMT *stmt);
|
||||
|
||||
DLL_EXPORT TAOS_RES *taos_query(TAOS *taos, const char *sql);
|
||||
DLL_EXPORT TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen);
|
||||
DLL_EXPORT TAOS_RES *taos_query(TAOS *taos, const char *sql);
|
||||
DLL_EXPORT TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen);
|
||||
|
||||
DLL_EXPORT TAOS_ROW taos_fetch_row(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_result_precision(TAOS_RES *res); // get the time precision of result
|
||||
DLL_EXPORT void taos_free_result(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_field_count(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_num_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_affected_rows(TAOS_RES *res);
|
||||
DLL_EXPORT TAOS_ROW taos_fetch_row(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_result_precision(TAOS_RES *res); // get the time precision of result
|
||||
DLL_EXPORT void taos_free_result(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_field_count(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_num_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_affected_rows(TAOS_RES *res);
|
||||
|
||||
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
||||
|
@ -213,7 +213,7 @@ typedef struct tmq_topic_vgroup_list_t tmq_topic_vgroup_list_t;
|
|||
typedef struct tmq_conf_t tmq_conf_t;
|
||||
typedef struct tmq_list_t tmq_list_t;
|
||||
|
||||
typedef void(tmq_commit_cb(tmq_t *, tmq_resp_err_t, tmq_topic_vgroup_list_t *));
|
||||
typedef void(tmq_commit_cb(tmq_t *, tmq_resp_err_t, tmq_topic_vgroup_list_t *, void *param));
|
||||
|
||||
DLL_EXPORT tmq_list_t *tmq_list_new();
|
||||
DLL_EXPORT int32_t tmq_list_append(tmq_list_t *, const char *);
|
||||
|
@ -253,12 +253,12 @@ typedef enum tmq_conf_res_t tmq_conf_res_t;
|
|||
DLL_EXPORT tmq_conf_t *tmq_conf_new();
|
||||
DLL_EXPORT tmq_conf_res_t tmq_conf_set(tmq_conf_t *conf, const char *key, const char *value);
|
||||
DLL_EXPORT void tmq_conf_destroy(tmq_conf_t *conf);
|
||||
DLL_EXPORT void tmq_conf_set_offset_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb);
|
||||
DLL_EXPORT void tmq_conf_set_offset_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb, void *param);
|
||||
|
||||
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
|
||||
|
||||
DLL_EXPORT char *tmq_get_topic_name(TAOS_RES *res);
|
||||
DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res);
|
||||
DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res);
|
||||
DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res);
|
||||
// TODO
|
||||
#if 0
|
||||
DLL_EXPORT char *tmq_get_table_name(TAOS_RES *res);
|
||||
|
@ -271,10 +271,8 @@ DLL_EXPORT int64_t tmq_get_response_offset(tmq_message_t *message);
|
|||
/* --------------------TMPORARY INTERFACE FOR TESTING--------------------- */
|
||||
#if 0
|
||||
DLL_EXPORT TAOS_RES *tmq_create_topic(TAOS *taos, const char *name, const char *sql, int sqlLen);
|
||||
#endif
|
||||
|
||||
DLL_EXPORT TAOS_RES *tmq_create_stream(TAOS *taos, const char *streamName, const char *tbName, const char *sql);
|
||||
|
||||
#endif
|
||||
/* ------------------------------ TMQ END -------------------------------- */
|
||||
#if 1 // Shuduo: temporary enable for app build
|
||||
typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB *tsub, TAOS_RES *res, void *param, int code);
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#ifndef TDENGINE_SYSTABLE_H
|
||||
#define TDENGINE_SYSTABLE_H
|
||||
|
||||
#define TSDB_INFORMATION_SCHEMA_DB "information_schema"
|
||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_INS_TABLE_DNODES "dnodes"
|
||||
#define TSDB_INS_TABLE_MNODES "mnodes"
|
||||
#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"
|
||||
#define TSDB_INS_TABLE_USER_INDEXES "user_indexes"
|
||||
#define TSDB_INS_TABLE_USER_STABLES "user_stables"
|
||||
#define TSDB_INS_TABLE_USER_STREAMS "user_streams"
|
||||
#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_LICENCES "grants"
|
||||
#define TSDB_INS_TABLE_VGROUPS "vgroups"
|
||||
#define TSDB_INS_TABLE_VNODES "vnodes"
|
||||
#define TSDB_INS_TABLE_CONFIGS "configs"
|
||||
|
||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_PERFS_TABLE_SMAS "smas"
|
||||
#define TSDB_PERFS_TABLE_SUBSCRIBES "subscribes"
|
||||
#define TSDB_PERFS_TABLE_CONNECTIONS "connections"
|
||||
#define TSDB_PERFS_TABLE_QUERIES "queries"
|
||||
#define TSDB_PERFS_TABLE_TOPICS "topics"
|
||||
#define TSDB_PERFS_TABLE_CONSUMERS "consumers"
|
||||
#define TSDB_PERFS_TABLE_SUBSCRIPTIONS "subscriptions"
|
||||
#define TSDB_PERFS_TABLE_OFFSETS "offsets"
|
||||
#define TSDB_PERFS_TABLE_TRANS "trans"
|
||||
#define TSDB_PERFS_TABLE_STREAMS "streams"
|
||||
|
||||
typedef struct SSysDbTableSchema {
|
||||
const char *name;
|
||||
const int32_t type;
|
||||
const int32_t bytes;
|
||||
} SSysDbTableSchema;
|
||||
|
||||
typedef struct SSysTableMeta {
|
||||
const char *name;
|
||||
const SSysDbTableSchema *schema;
|
||||
const int32_t colNum;
|
||||
} SSysTableMeta;
|
||||
|
||||
void getInfosDbMeta(const SSysTableMeta** pInfosTableMeta, size_t* size);
|
||||
void getPerfDbMeta(const SSysTableMeta** pPerfsTableMeta, size_t* size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TDENGINE_SYSTABLE_H
|
|
@ -65,14 +65,12 @@ typedef struct SDataBlockInfo {
|
|||
STimeWindow window;
|
||||
int32_t rows;
|
||||
int32_t rowSize;
|
||||
union {
|
||||
int64_t uid; // from which table of uid, comes from this data block
|
||||
int64_t blockId;
|
||||
};
|
||||
uint64_t groupId; // no need to serialize
|
||||
int16_t numOfCols;
|
||||
int16_t hasVarCol;
|
||||
int16_t capacity;
|
||||
int64_t uid; // the uid of table, from which current data block comes
|
||||
int64_t blockId; // block id, generated by physical planner
|
||||
uint64_t groupId; // no need to serialize
|
||||
int16_t numOfCols;
|
||||
int16_t hasVarCol;
|
||||
int16_t capacity;
|
||||
} SDataBlockInfo;
|
||||
|
||||
typedef struct SSDataBlock {
|
||||
|
|
|
@ -531,27 +531,24 @@ int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pR
|
|||
typedef struct {
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int32_t numOfVgroups;
|
||||
int32_t cacheBlockSize; // MB
|
||||
int32_t totalBlocks;
|
||||
int32_t numOfStables; // single_stable
|
||||
int32_t buffer; // MB
|
||||
int32_t pageSize;
|
||||
int32_t pages;
|
||||
int32_t daysPerFile;
|
||||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t minRows;
|
||||
int32_t maxRows;
|
||||
int32_t commitTime;
|
||||
int32_t fsyncPeriod;
|
||||
int32_t ttl;
|
||||
int8_t walLevel;
|
||||
int8_t precision; // time resolution
|
||||
int8_t compression;
|
||||
int8_t replications;
|
||||
int8_t strict;
|
||||
int8_t update;
|
||||
int8_t cacheLastRow;
|
||||
int8_t ignoreExist;
|
||||
int8_t streamMode;
|
||||
int8_t singleSTable;
|
||||
int32_t numOfRetensions;
|
||||
SArray* pRetensions; // SRetention
|
||||
} SCreateDbReq;
|
||||
|
@ -562,7 +559,10 @@ void tFreeSCreateDbReq(SCreateDbReq* pReq);
|
|||
|
||||
typedef struct {
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int32_t totalBlocks;
|
||||
int32_t buffer;
|
||||
int32_t pageSize;
|
||||
int32_t pages;
|
||||
int32_t daysPerFile;
|
||||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
|
@ -626,26 +626,23 @@ int32_t tDeserializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq);
|
|||
|
||||
typedef struct {
|
||||
int32_t numOfVgroups;
|
||||
int32_t cacheBlockSize;
|
||||
int32_t totalBlocks;
|
||||
int32_t numOfStables;
|
||||
int32_t buffer;
|
||||
int32_t pageSize;
|
||||
int32_t pages;
|
||||
int32_t daysPerFile;
|
||||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t minRows;
|
||||
int32_t maxRows;
|
||||
int32_t commitTime;
|
||||
int32_t fsyncPeriod;
|
||||
int32_t ttl;
|
||||
int8_t walLevel;
|
||||
int8_t precision;
|
||||
int8_t compression;
|
||||
int8_t replications;
|
||||
int8_t strict;
|
||||
int8_t update;
|
||||
int8_t cacheLastRow;
|
||||
int8_t streamMode;
|
||||
int8_t singleSTable;
|
||||
int32_t numOfRetensions;
|
||||
SArray* pRetensions;
|
||||
} SDbCfgRsp;
|
||||
|
@ -845,15 +842,16 @@ typedef struct {
|
|||
char db[TSDB_DB_FNAME_LEN];
|
||||
int64_t dbUid;
|
||||
int32_t vgVersion;
|
||||
int32_t cacheBlockSize;
|
||||
int32_t totalBlocks;
|
||||
int32_t numOfStables;
|
||||
int32_t buffer;
|
||||
int32_t pageSize;
|
||||
int32_t pages;
|
||||
int32_t daysPerFile;
|
||||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t minRows;
|
||||
int32_t maxRows;
|
||||
int32_t commitTime;
|
||||
int32_t fsyncPeriod;
|
||||
uint32_t hashBegin;
|
||||
uint32_t hashEnd;
|
||||
|
@ -862,11 +860,9 @@ typedef struct {
|
|||
int8_t precision;
|
||||
int8_t compression;
|
||||
int8_t strict;
|
||||
int8_t update;
|
||||
int8_t cacheLastRow;
|
||||
int8_t replica;
|
||||
int8_t selfIndex;
|
||||
int8_t streamMode;
|
||||
SReplica replicas[TSDB_MAX_REPLICA];
|
||||
int32_t numOfRetensions;
|
||||
SArray* pRetensions; // SRetention
|
||||
|
@ -896,10 +892,14 @@ int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq
|
|||
|
||||
typedef struct {
|
||||
int32_t vgVersion;
|
||||
int32_t totalBlocks;
|
||||
int32_t buffer;
|
||||
int32_t pageSize;
|
||||
int32_t pages;
|
||||
int32_t daysPerFile;
|
||||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t fsyncPeriod;
|
||||
int8_t walLevel;
|
||||
int8_t strict;
|
||||
int8_t cacheLastRow;
|
||||
|
@ -954,7 +954,6 @@ typedef struct {
|
|||
int32_t numOfColumns;
|
||||
int8_t precision;
|
||||
int8_t tableType;
|
||||
int8_t update;
|
||||
int32_t sversion;
|
||||
int32_t tversion;
|
||||
uint64_t suid;
|
||||
|
@ -1039,6 +1038,7 @@ typedef struct {
|
|||
int8_t compressed;
|
||||
int32_t compLen;
|
||||
int32_t numOfRows;
|
||||
int32_t numOfCols;
|
||||
char data[];
|
||||
} SRetrieveTableRsp;
|
||||
|
||||
|
|
|
@ -595,6 +595,34 @@ static FORCE_INLINE int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols,
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param pBuilder
|
||||
* @param nCols
|
||||
* @param nBoundCols use -1 if not available
|
||||
* @param flen
|
||||
* @return FORCE_INLINE
|
||||
*/
|
||||
static FORCE_INLINE int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t flen) {
|
||||
pBuilder->flen = flen;
|
||||
pBuilder->nCols = nCols;
|
||||
if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) {
|
||||
TASSERT(0);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
// the primary TS key is stored separatedly
|
||||
pBuilder->nBitmaps = (int16_t)TD_BITMAP_BYTES(pBuilder->nCols - 1);
|
||||
#else
|
||||
pBuilder->nBitmaps = 0;
|
||||
pBuilder->nBoundBitmaps = 0;
|
||||
#endif
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief To judge row type: STpRow/SKvRow
|
||||
*
|
||||
|
@ -1376,7 +1404,7 @@ static void tdSRowPrint(STSRow *row, STSchema *pSchema, const char* tag) {
|
|||
printf("%s >>>", tag);
|
||||
for (int i = 0; i < pSchema->numOfCols; ++i) {
|
||||
STColumn *stCol = pSchema->columns + i;
|
||||
SCellVal sVal = {.valType = 255, .val = NULL};
|
||||
SCellVal sVal = { 255, NULL};
|
||||
if (!tdSTSRowIterNext(&iter, stCol->colId, stCol->type, &sVal)) {
|
||||
break;
|
||||
}
|
||||
|
@ -1385,7 +1413,6 @@ static void tdSRowPrint(STSRow *row, STSchema *pSchema, const char* tag) {
|
|||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
#ifdef TROW_ORIGIN_HZ
|
||||
typedef struct {
|
||||
uint32_t nRows;
|
||||
|
|
|
@ -45,6 +45,7 @@ typedef struct SInputData {
|
|||
|
||||
typedef struct SOutputData {
|
||||
int32_t numOfRows;
|
||||
int32_t numOfCols;
|
||||
int8_t compressed;
|
||||
char* pData;
|
||||
bool queryEnd;
|
||||
|
|
|
@ -33,6 +33,7 @@ typedef struct SReadHandle {
|
|||
void* meta;
|
||||
void* config;
|
||||
void* vnode;
|
||||
void* mnd;
|
||||
} SReadHandle;
|
||||
|
||||
#define STREAM_DATA_TYPE_SUBMIT_BLOCK 0x1
|
||||
|
|
|
@ -165,7 +165,7 @@ typedef struct SInputColumnInfoData {
|
|||
SColumnInfoData *pPTS; // primary timestamp column
|
||||
SColumnInfoData **pData;
|
||||
SColumnDataAgg **pColumnDataAgg;
|
||||
uint64_t uid; // table uid
|
||||
uint64_t uid; // table uid, used to set the tag value when building the final query result for selectivity functions.
|
||||
} SInputColumnInfoData;
|
||||
|
||||
// sql function runtime context
|
||||
|
|
|
@ -40,6 +40,7 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_STDDEV,
|
||||
FUNCTION_TYPE_SUM,
|
||||
FUNCTION_TYPE_TWA,
|
||||
FUNCTION_TYPE_HISTOGRAM,
|
||||
|
||||
// nonstandard SQL function
|
||||
FUNCTION_TYPE_BOTTOM = 500,
|
||||
|
|
|
@ -22,19 +22,20 @@ extern "C" {
|
|||
|
||||
#include "tdef.h"
|
||||
|
||||
#define nodeType(nodeptr) (((const SNode*)(nodeptr))->type)
|
||||
#define nodeType(nodeptr) (((const SNode*)(nodeptr))->type)
|
||||
#define setNodeType(nodeptr, type) (((SNode*)(nodeptr))->type = (type))
|
||||
|
||||
#define LIST_LENGTH(l) (NULL != (l) ? (l)->length : 0)
|
||||
|
||||
#define FOREACH(node, list) \
|
||||
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext)
|
||||
#define FOREACH(node, list) \
|
||||
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \
|
||||
(NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext)
|
||||
|
||||
#define REPLACE_NODE(newNode) cell->pNode = (SNode*)(newNode)
|
||||
|
||||
#define INSERT_LIST(target, src) nodesListInsertList((target), cell, src)
|
||||
|
||||
#define WHERE_EACH(node, list) \
|
||||
#define WHERE_EACH(node, list) \
|
||||
SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \
|
||||
while (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false))
|
||||
|
||||
|
@ -43,16 +44,26 @@ extern "C" {
|
|||
// only be use in WHERE_EACH
|
||||
#define ERASE_NODE(list) cell = nodesListErase((list), cell)
|
||||
|
||||
#define FORBOTH(node1, list1, node2, list2) \
|
||||
for (SListCell* cell1 = (NULL != (list1) ? (list1)->pHead : NULL), *cell2 = (NULL != (list2) ? (list2)->pHead : NULL); \
|
||||
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), (NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), (node1 != NULL && node2 != NULL); \
|
||||
cell1 = cell1->pNext, cell2 = cell2->pNext)
|
||||
#define FORBOTH(node1, list1, node2, list2) \
|
||||
for (SListCell* cell1 = (NULL != (list1) ? (list1)->pHead : NULL), \
|
||||
*cell2 = (NULL != (list2) ? (list2)->pHead : NULL); \
|
||||
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), \
|
||||
(NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), \
|
||||
(node1 != NULL && node2 != NULL); \
|
||||
cell1 = cell1->pNext, cell2 = cell2->pNext)
|
||||
|
||||
#define REPLACE_LIST1_NODE(newNode) cell1->pNode = (SNode*)(newNode)
|
||||
#define REPLACE_LIST2_NODE(newNode) cell2->pNode = (SNode*)(newNode)
|
||||
|
||||
#define FOREACH_FOR_REWRITE(node, list) \
|
||||
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
|
||||
#define FOREACH_FOR_REWRITE(node, list) \
|
||||
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \
|
||||
(NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
|
||||
|
||||
#define DESTORY_LIST(list) \
|
||||
do { \
|
||||
nodesDestroyList(list); \
|
||||
list = NULL; \
|
||||
} while (0)
|
||||
|
||||
typedef enum ENodeType {
|
||||
// Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN,
|
||||
|
@ -202,7 +213,7 @@ typedef enum ENodeType {
|
|||
|
||||
/**
|
||||
* The first field of a node of any type is guaranteed to be the ENodeType.
|
||||
* Hence the type of any node can be gotten by casting it to SNode.
|
||||
* Hence the type of any node can be gotten by casting it to SNode.
|
||||
*/
|
||||
typedef struct SNode {
|
||||
ENodeType type;
|
||||
|
@ -211,41 +222,36 @@ typedef struct SNode {
|
|||
typedef struct SListCell {
|
||||
struct SListCell* pPrev;
|
||||
struct SListCell* pNext;
|
||||
SNode* pNode;
|
||||
SNode* pNode;
|
||||
} SListCell;
|
||||
|
||||
typedef struct SNodeList {
|
||||
int32_t length;
|
||||
int32_t length;
|
||||
SListCell* pHead;
|
||||
SListCell* pTail;
|
||||
} SNodeList;
|
||||
|
||||
#define SNodeptr void*
|
||||
#define SNodeptr void*
|
||||
|
||||
SNodeptr nodesMakeNode(ENodeType type);
|
||||
void nodesDestroyNode(SNodeptr pNode);
|
||||
void nodesDestroyNode(SNodeptr pNode);
|
||||
|
||||
SNodeList* nodesMakeList();
|
||||
int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode);
|
||||
int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
|
||||
int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode);
|
||||
int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode);
|
||||
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||
int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||
int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode);
|
||||
int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode);
|
||||
int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
|
||||
int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode);
|
||||
int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode);
|
||||
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||
int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||
int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode);
|
||||
SListCell* nodesListErase(SNodeList* pList, SListCell* pCell);
|
||||
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||
SNodeptr nodesListGetNode(SNodeList* pList, int32_t index);
|
||||
void nodesDestroyList(SNodeList* pList);
|
||||
void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc);
|
||||
SNodeptr nodesListGetNode(SNodeList* pList, int32_t index);
|
||||
void nodesDestroyList(SNodeList* pList);
|
||||
// Only clear the linked list structure, without releasing the elements inside
|
||||
void nodesClearList(SNodeList* pList);
|
||||
|
||||
typedef enum EDealRes {
|
||||
DEAL_RES_CONTINUE = 1,
|
||||
DEAL_RES_IGNORE_CHILD,
|
||||
DEAL_RES_ERROR,
|
||||
DEAL_RES_END
|
||||
} EDealRes;
|
||||
typedef enum EDealRes { DEAL_RES_CONTINUE = 1, DEAL_RES_IGNORE_CHILD, DEAL_RES_ERROR, DEAL_RES_END } EDealRes;
|
||||
|
||||
typedef EDealRes (*FNodeWalker)(SNode* pNode, void* pContext);
|
||||
void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext);
|
||||
|
@ -261,18 +267,18 @@ void nodesRewriteExprsPostOrder(SNodeList* pList, FNodeRewriter rewriter, void*
|
|||
|
||||
bool nodesEqualNode(const SNodeptr a, const SNodeptr b);
|
||||
|
||||
SNodeptr nodesCloneNode(const SNodeptr pNode);
|
||||
SNodeptr nodesCloneNode(const SNodeptr pNode);
|
||||
SNodeList* nodesCloneList(const SNodeList* pList);
|
||||
|
||||
const char* nodesNodeName(ENodeType type);
|
||||
int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen);
|
||||
int32_t nodesStringToNode(const char* pStr, SNode** pNode);
|
||||
int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen);
|
||||
int32_t nodesStringToNode(const char* pStr, SNode** pNode);
|
||||
|
||||
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen);
|
||||
int32_t nodesStringToList(const char* pStr, SNodeList** pList);
|
||||
|
||||
int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len);
|
||||
char *nodesGetNameFromColumnNode(SNode *pNode);
|
||||
int32_t nodesNodeToSQL(SNode* pNode, char* buf, int32_t bufSize, int32_t* len);
|
||||
char* nodesGetNameFromColumnNode(SNode* pNode);
|
||||
int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -88,6 +88,7 @@ typedef struct SValueNode {
|
|||
double d;
|
||||
char* p;
|
||||
} datum;
|
||||
int64_t typeData;
|
||||
char unit;
|
||||
} SValueNode;
|
||||
|
||||
|
@ -294,13 +295,14 @@ void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker wa
|
|||
void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewriter rewriter, void* pContext);
|
||||
|
||||
typedef enum ECollectColType { COLLECT_COL_TYPE_COL = 1, COLLECT_COL_TYPE_TAG, COLLECT_COL_TYPE_ALL } ECollectColType;
|
||||
|
||||
int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char* pTableAlias, ECollectColType type,
|
||||
SNodeList** pCols);
|
||||
|
||||
typedef bool (*FFuncClassifier)(int32_t funcId);
|
||||
int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNodeList** pFuncs);
|
||||
|
||||
int32_t nodesCollectSpecialNodes(SSelectStmt* pSelect, ESqlClause clause, ENodeType type, SNodeList** pNodes);
|
||||
|
||||
bool nodesIsExprNode(const SNode* pNode);
|
||||
|
||||
bool nodesIsUnaryOp(const SOperatorNode* pOp);
|
||||
|
@ -312,6 +314,7 @@ bool nodesIsTimeorderQuery(const SNode* pQuery);
|
|||
bool nodesIsTimelineQuery(const SNode* pQuery);
|
||||
|
||||
void* nodesGetValueFromNode(SValueNode* pNode);
|
||||
int32_t nodesSetValueNodeValue(SValueNode* pNode, void *value);
|
||||
char* nodesGetStrValueFromNode(SValueNode* pNode);
|
||||
char* getFillModeString(EFillMode mode);
|
||||
void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
|
||||
|
|
|
@ -35,19 +35,6 @@ enum {
|
|||
STREAM_CREATED_BY__SMA,
|
||||
};
|
||||
|
||||
#if 0
|
||||
// pipe -> fetch/pipe queue
|
||||
// merge -> merge queue
|
||||
// write -> write queue
|
||||
enum {
|
||||
TASK_DISPATCH_MSG__SND_PIPE = 1,
|
||||
TASK_DISPATCH_MSG__SND_MERGE,
|
||||
TASK_DISPATCH_MSG__VND_PIPE,
|
||||
TASK_DISPATCH_MSG__VND_MERGE,
|
||||
TASK_DISPATCH_MSG__VND_WRITE,
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int32_t nodeId; // 0 for snode
|
||||
SEpSet epSet;
|
||||
|
@ -100,10 +87,6 @@ typedef struct {
|
|||
int8_t reserved;
|
||||
} STaskSinkFetch;
|
||||
|
||||
typedef struct {
|
||||
int8_t reserved;
|
||||
} STaskSinkShow;
|
||||
|
||||
enum {
|
||||
TASK_SOURCE__SCAN = 1,
|
||||
TASK_SOURCE__PIPE,
|
||||
|
@ -128,7 +111,6 @@ enum {
|
|||
TASK_SINK__TABLE,
|
||||
TASK_SINK__SMA,
|
||||
TASK_SINK__FETCH,
|
||||
TASK_SINK__SHOW,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
@ -155,7 +137,6 @@ typedef struct {
|
|||
STaskSinkTb tbSink;
|
||||
STaskSinkSma smaSink;
|
||||
STaskSinkFetch fetchSink;
|
||||
STaskSinkShow showSink;
|
||||
};
|
||||
|
||||
// dispatch
|
||||
|
|
|
@ -244,9 +244,10 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x03AC)
|
||||
#define TSDB_CODE_MND_COLUMN_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AD)
|
||||
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE)
|
||||
#define TSDB_CODE_MND_SINGLE_STB_MODE_DB TAOS_DEF_ERROR_CODE(0, 0x03B0)
|
||||
|
||||
// mnode-infoSchema
|
||||
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x03B0)
|
||||
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x03BA)
|
||||
|
||||
// mnode-func
|
||||
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
|
||||
|
|
|
@ -97,43 +97,6 @@ extern const int32_t TYPE_BYTES[15];
|
|||
#define TSDB_TIME_PRECISION_MICRO_DIGITS 16
|
||||
#define TSDB_TIME_PRECISION_NANO_DIGITS 19
|
||||
|
||||
#define TSDB_INFORMATION_SCHEMA_DB "information_schema"
|
||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_INS_TABLE_DNODES "dnodes"
|
||||
#define TSDB_INS_TABLE_MNODES "mnodes"
|
||||
#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"
|
||||
#define TSDB_INS_TABLE_USER_INDEXES "user_indexes"
|
||||
#define TSDB_INS_TABLE_USER_STABLES "user_stables"
|
||||
#define TSDB_INS_TABLE_USER_STREAMS "user_streams"
|
||||
#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_LICENCES "grants"
|
||||
#define TSDB_INS_TABLE_VGROUPS "vgroups"
|
||||
#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_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_PERFS_TABLE_CONNECTIONS "connections"
|
||||
#define TSDB_PERFS_TABLE_QUERIES "queries"
|
||||
#define TSDB_PERFS_TABLE_TOPICS "topics"
|
||||
#define TSDB_PERFS_TABLE_CONSUMERS "consumers"
|
||||
#define TSDB_PERFS_TABLE_SUBSCRIPTIONS "subscriptions"
|
||||
#define TSDB_PERFS_TABLE_OFFSETS "offsets"
|
||||
#define TSDB_PERFS_TABLE_STREAMS "streams"
|
||||
|
||||
#define TSDB_INDEX_TYPE_SMA "SMA"
|
||||
#define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT"
|
||||
|
||||
|
@ -205,16 +168,6 @@ typedef enum ELogicConditionType {
|
|||
LOGIC_COND_TYPE_NOT,
|
||||
} ELogicConditionType;
|
||||
|
||||
#define FUNCTION_CEIL 4500
|
||||
#define FUNCTION_FLOOR 4501
|
||||
#define FUNCTION_ABS 4502
|
||||
#define FUNCTION_ROUND 4503
|
||||
|
||||
#define FUNCTION_LENGTH 4800
|
||||
#define FUNCTION_CONCAT 4801
|
||||
#define FUNCTION_LTRIM 4802
|
||||
#define FUNCTION_RTRIM 4803
|
||||
|
||||
#define TSDB_NAME_DELIMITER_LEN 1
|
||||
|
||||
#define TSDB_UNI_LEN 24
|
||||
|
@ -327,15 +280,21 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_MIN_VNODES_PER_DB 1
|
||||
#define TSDB_MAX_VNODES_PER_DB 4096
|
||||
#define TSDB_DEFAULT_VN_PER_DB 2
|
||||
#define TSDB_MIN_CACHE_BLOCK_SIZE 1
|
||||
#define TSDB_MAX_CACHE_BLOCK_SIZE 128 // 128MB for each vnode
|
||||
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16
|
||||
#define TSDB_MIN_TOTAL_BLOCKS 3
|
||||
#define TSDB_MAX_TOTAL_BLOCKS 10000
|
||||
#define TSDB_DEFAULT_TOTAL_BLOCKS 6
|
||||
#define TSDB_MIN_BUFFER_PER_VNODE 3 // unit MB
|
||||
#define TSDB_MAX_BUFFER_PER_VNODE 16384 // unit MB
|
||||
#define TSDB_DEFAULT_BUFFER_PER_VNODE 96
|
||||
#define TSDB_MIN_PAGES_PER_VNODE 64
|
||||
#define TSDB_MAX_PAGES_PER_VNODE 16384
|
||||
#define TSDB_DEFAULT_PAGES_PER_VNODE 256
|
||||
#define TSDB_MIN_PAGESIZE_PER_VNODE 1 // unit KB
|
||||
#define TSDB_MAX_PAGESIZE_PER_VNODE 16384
|
||||
#define TSDB_DEFAULT_PAGESIZE_PER_VNODE 4
|
||||
#define TSDB_MIN_DAYS_PER_FILE 60 // unit minute
|
||||
#define TSDB_MAX_DAYS_PER_FILE (3650 * 1440)
|
||||
#define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440)
|
||||
#define TSDB_MIN_DURATION_PER_FILE 60 // unit minute
|
||||
#define TSDB_MAX_DURATION_PER_FILE (3650 * 1440)
|
||||
#define TSDB_DEFAULT_DURATION_PER_FILE (10 * 1440)
|
||||
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
|
||||
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
|
||||
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
|
||||
|
@ -345,9 +304,6 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_MIN_MAXROWS_FBLOCK 200
|
||||
#define TSDB_MAX_MAXROWS_FBLOCK 10000
|
||||
#define TSDB_DEFAULT_MAXROWS_FBLOCK 4096
|
||||
#define TSDB_MIN_COMMIT_TIME 30
|
||||
#define TSDB_MAX_COMMIT_TIME 40960
|
||||
#define TSDB_DEFAULT_COMMIT_TIME 3600
|
||||
#define TSDB_MIN_FSYNC_PERIOD 0
|
||||
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
|
||||
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
|
||||
|
@ -366,9 +322,6 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_DB_STRICT_OFF 0
|
||||
#define TSDB_DB_STRICT_ON 1
|
||||
#define TSDB_DEFAULT_DB_STRICT 0
|
||||
#define TSDB_MIN_DB_UPDATE 0
|
||||
#define TSDB_MAX_DB_UPDATE 2
|
||||
#define TSDB_DEFAULT_DB_UPDATE 0
|
||||
#define TSDB_MIN_DB_CACHE_LAST_ROW 0
|
||||
#define TSDB_MAX_DB_CACHE_LAST_ROW 3
|
||||
#define TSDB_DEFAULT_CACHE_LAST_ROW 0
|
||||
|
@ -378,13 +331,6 @@ typedef enum ELogicConditionType {
|
|||
#define TSDB_DB_SINGLE_STABLE_ON 0
|
||||
#define TSDB_DB_SINGLE_STABLE_OFF 1
|
||||
#define TSDB_DEFAULT_DB_SINGLE_STABLE 0
|
||||
#define TSDB_MIN_BUFFER_PER_VNODE 3 // unit MB
|
||||
#define TSDB_DEFAULT_BUFFER_PER_VNODE 96
|
||||
#define TSDB_MIN_PAGES_PER_VNODE 64
|
||||
#define TSDB_DEFAULT_PAGES_PER_VNODE 256
|
||||
#define TSDB_MIN_PAGESIZE_PER_VNODE 1 // unit KB
|
||||
#define TSDB_MAX_PAGESIZE_PER_VNODE 16384
|
||||
#define TSDB_DEFAULT_PAGESIZE_PER_VNODE 4
|
||||
|
||||
#define TSDB_MIN_ROLLUP_FILE_FACTOR 0
|
||||
#define TSDB_MAX_ROLLUP_FILE_FACTOR 1
|
||||
|
@ -424,21 +370,9 @@ typedef enum ELogicConditionType {
|
|||
* 1. ordinary sub query for select * from super_table
|
||||
* 2. all sqlobj generated by createSubqueryObj with this flag
|
||||
*/
|
||||
#define TSDB_QUERY_TYPE_SUBQUERY 0x02u
|
||||
#define TSDB_QUERY_TYPE_STABLE_SUBQUERY 0x04u // two-stage subquery for super table
|
||||
|
||||
#define TSDB_QUERY_TYPE_TABLE_QUERY 0x08u // query ordinary table; below only apply to client side
|
||||
#define TSDB_QUERY_TYPE_STABLE_QUERY 0x10u // query on super table
|
||||
#define TSDB_QUERY_TYPE_JOIN_QUERY 0x20u // join query
|
||||
#define TSDB_QUERY_TYPE_PROJECTION_QUERY 0x40u // select *,columns... query
|
||||
#define TSDB_QUERY_TYPE_JOIN_SEC_STAGE 0x80u // join sub query at the second stage
|
||||
|
||||
#define TSDB_QUERY_TYPE_TAG_FILTER_QUERY 0x400u
|
||||
#define TSDB_QUERY_TYPE_INSERT 0x100u // insert type
|
||||
#define TSDB_QUERY_TYPE_MULTITABLE_QUERY 0x200u
|
||||
#define TSDB_QUERY_TYPE_FILE_INSERT 0x400u // insert data from file
|
||||
#define TSDB_QUERY_TYPE_STMT_INSERT 0x800u // stmt insert type
|
||||
#define TSDB_QUERY_TYPE_NEST_SUBQUERY 0x1000u // nested sub query
|
||||
|
||||
#define TSDB_QUERY_HAS_TYPE(x, _type) (((x) & (_type)) != 0)
|
||||
#define TSDB_QUERY_SET_TYPE(x, _type) ((x) |= (_type))
|
||||
|
|
|
@ -46,11 +46,12 @@ typedef struct SStmtTableCache {
|
|||
void* boundTags;
|
||||
} SStmtTableCache;
|
||||
|
||||
typedef struct SQueryFields {
|
||||
typedef struct SStmtQueryResInfo {
|
||||
TAOS_FIELD* fields;
|
||||
TAOS_FIELD* userFields;
|
||||
uint32_t numOfCols;
|
||||
} SQueryFields;
|
||||
int32_t precision;
|
||||
} SStmtQueryResInfo;
|
||||
|
||||
typedef struct SStmtBindInfo {
|
||||
bool needParse;
|
||||
|
@ -72,17 +73,17 @@ typedef struct SStmtExecInfo {
|
|||
} SStmtExecInfo;
|
||||
|
||||
typedef struct SStmtSQLInfo {
|
||||
STMT_TYPE type;
|
||||
STMT_STATUS status;
|
||||
bool autoCreate;
|
||||
uint64_t runTimes;
|
||||
SHashObj* pTableCache; //SHash<SStmtTableCache>
|
||||
SQuery* pQuery;
|
||||
char* sqlStr;
|
||||
int32_t sqlLen;
|
||||
SArray* nodeList;
|
||||
SQueryPlan* pQueryPlan;
|
||||
SQueryFields fields;
|
||||
STMT_TYPE type;
|
||||
STMT_STATUS status;
|
||||
bool autoCreate;
|
||||
uint64_t runTimes;
|
||||
SHashObj* pTableCache; //SHash<SStmtTableCache>
|
||||
SQuery* pQuery;
|
||||
char* sqlStr;
|
||||
int32_t sqlLen;
|
||||
SArray* nodeList;
|
||||
SQueryPlan* pQueryPlan;
|
||||
SStmtQueryResInfo queryRes;
|
||||
} SStmtSQLInfo;
|
||||
|
||||
typedef struct STscStmt {
|
||||
|
|
|
@ -74,17 +74,44 @@ int32_t stmtGetTbName(TAOS_STMT *stmt, char **tbName) {
|
|||
}
|
||||
|
||||
int32_t stmtBackupQueryFields(STscStmt* pStmt) {
|
||||
SQueryFields *pFields = &pStmt->sql.fields;
|
||||
int32_t size = pFields->numOfCols * sizeof(TAOS_FIELD);
|
||||
SStmtQueryResInfo *pRes = &pStmt->sql.queryRes;
|
||||
pRes->numOfCols = pStmt->exec.pRequest->body.resInfo.numOfCols;
|
||||
pRes->precision = pStmt->exec.pRequest->body.resInfo.precision;
|
||||
|
||||
pFields->numOfCols = pStmt->exec.pRequest->body.resInfo.numOfCols;
|
||||
pFields->fields = taosMemoryMalloc(size);
|
||||
pFields->userFields = taosMemoryMalloc(size);
|
||||
if (NULL == pFields->fields || NULL == pFields->userFields) {
|
||||
int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
|
||||
pRes->fields = taosMemoryMalloc(size);
|
||||
pRes->userFields = taosMemoryMalloc(size);
|
||||
if (NULL == pRes->fields || NULL == pRes->userFields) {
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(pFields->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
|
||||
memcpy(pFields->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
|
||||
memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
|
||||
memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
||||
SStmtQueryResInfo *pRes = &pStmt->sql.queryRes;
|
||||
int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
|
||||
|
||||
pStmt->exec.pRequest->body.resInfo.numOfCols = pRes->numOfCols;
|
||||
pStmt->exec.pRequest->body.resInfo.precision = pRes->precision;
|
||||
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||
pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size);
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size);
|
||||
}
|
||||
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||
pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size);
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -235,6 +262,8 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) {
|
|||
}
|
||||
|
||||
int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
|
||||
taosMemoryFree(pStmt->sql.queryRes.fields);
|
||||
taosMemoryFree(pStmt->sql.queryRes.userFields);
|
||||
taosMemoryFree(pStmt->sql.sqlStr);
|
||||
qDestroyQuery(pStmt->sql.pQuery);
|
||||
qDestroyQueryPlan(pStmt->sql.pQueryPlan);
|
||||
|
@ -497,6 +526,8 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
|
|||
pStmt->sql.pQueryPlan = pStmt->exec.pRequest->body.pDag;
|
||||
pStmt->exec.pRequest->body.pDag = NULL;
|
||||
STMT_ERR_RET(stmtBackupQueryFields(pStmt));
|
||||
} else {
|
||||
STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
|
||||
}
|
||||
|
||||
STMT_RET(qStmtBindParam(pStmt->sql.pQueryPlan, bind, colIdx, pStmt->exec.pRequest->requestId));
|
||||
|
@ -509,7 +540,11 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
|
|||
}
|
||||
|
||||
if (colIdx < 0) {
|
||||
qBindStmtColsValue(*pDataBlock, bind, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen);
|
||||
int32_t code = qBindStmtColsValue(*pDataBlock, bind, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen);
|
||||
if (code) {
|
||||
tscError("qBindStmtColsValue failed, error:%s", tstrerror(code));
|
||||
STMT_ERR_RET(code);
|
||||
}
|
||||
} else {
|
||||
if (colIdx != (pStmt->bInfo.sBindLastIdx + 1) && colIdx != 0) {
|
||||
tscError("bind column index not in sequence");
|
||||
|
|
|
@ -68,6 +68,7 @@ struct tmq_conf_t {
|
|||
char* pass;
|
||||
char* db;
|
||||
tmq_commit_cb* commitCb;
|
||||
void* commitCbUserParam;
|
||||
};
|
||||
|
||||
struct tmq_t {
|
||||
|
@ -78,7 +79,8 @@ struct tmq_t {
|
|||
int32_t autoCommitInterval;
|
||||
int32_t resetOffsetCfg;
|
||||
int64_t consumerId;
|
||||
tmq_commit_cb* commit_cb;
|
||||
tmq_commit_cb* commitCb;
|
||||
void* commitCbUserParam;
|
||||
|
||||
// status
|
||||
int8_t status;
|
||||
|
@ -372,10 +374,18 @@ int32_t tmqSubscribeCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
|||
int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||
SMqCommitCbParam* pParam = (SMqCommitCbParam*)param;
|
||||
pParam->rspErr = code == 0 ? TMQ_RESP_ERR__SUCCESS : TMQ_RESP_ERR__FAIL;
|
||||
if (pParam->tmq->commit_cb) {
|
||||
pParam->tmq->commit_cb(pParam->tmq, pParam->rspErr, NULL);
|
||||
if (pParam->tmq->commitCb) {
|
||||
pParam->tmq->commitCb(pParam->tmq, pParam->rspErr, NULL, pParam->tmq->commitCbUserParam);
|
||||
}
|
||||
if (!pParam->async)
|
||||
tsem_post(&pParam->rspSem);
|
||||
else {
|
||||
tsem_destroy(&pParam->rspSem);
|
||||
/*if (pParam->pArray) {*/
|
||||
/*taosArrayDestroy(pParam->pArray);*/
|
||||
/*}*/
|
||||
taosMemoryFree(pParam);
|
||||
}
|
||||
if (!pParam->async) tsem_post(&pParam->rspSem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -384,7 +394,7 @@ tmq_resp_err_t tmq_subscription(tmq_t* tmq, tmq_list_t** topics) {
|
|||
*topics = tmq_list_new();
|
||||
}
|
||||
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
||||
SMqClientTopic* topic = taosArrayGetP(tmq->clientTopics, i);
|
||||
SMqClientTopic* topic = taosArrayGet(tmq->clientTopics, i);
|
||||
tmq_list_append(*topics, topic->topicName);
|
||||
}
|
||||
return TMQ_RESP_ERR__SUCCESS;
|
||||
|
@ -477,7 +487,8 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
strcpy(pTmq->groupId, conf->groupId);
|
||||
pTmq->autoCommit = conf->autoCommit;
|
||||
pTmq->autoCommitInterval = conf->autoCommitInterval;
|
||||
pTmq->commit_cb = conf->commitCb;
|
||||
pTmq->commitCb = conf->commitCb;
|
||||
pTmq->commitCbUserParam = conf->commitCbUserParam;
|
||||
pTmq->resetOffsetCfg = conf->resetOffset;
|
||||
|
||||
// assign consumerId
|
||||
|
@ -557,7 +568,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
|||
tscError("failed to malloc request");
|
||||
}
|
||||
|
||||
SMqCommitCbParam* pParam = taosMemoryMalloc(sizeof(SMqCommitCbParam));
|
||||
SMqCommitCbParam* pParam = taosMemoryCalloc(1, sizeof(SMqCommitCbParam));
|
||||
if (pParam == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -572,6 +583,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
|||
};
|
||||
|
||||
SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest);
|
||||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->fp = tmqCommitCb;
|
||||
SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp);
|
||||
|
@ -582,13 +594,12 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
|||
if (!async) {
|
||||
tsem_wait(&pParam->rspSem);
|
||||
resp = pParam->rspErr;
|
||||
}
|
||||
tsem_destroy(&pParam->rspSem);
|
||||
taosMemoryFree(pParam);
|
||||
|
||||
tsem_destroy(&pParam->rspSem);
|
||||
taosMemoryFree(pParam);
|
||||
|
||||
if (pArray) {
|
||||
taosArrayDestroy(pArray);
|
||||
if (pArray) {
|
||||
taosArrayDestroy(pArray);
|
||||
}
|
||||
}
|
||||
|
||||
return resp;
|
||||
|
@ -667,7 +678,7 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
|||
if (code != 0) goto FAIL;
|
||||
|
||||
while (TSDB_CODE_MND_CONSUMER_NOT_READY == tmqAskEp(tmq, false)) {
|
||||
tscDebug("not ready, retry");
|
||||
tscDebug("consumer not ready, retry");
|
||||
taosMsleep(500);
|
||||
}
|
||||
|
||||
|
@ -688,11 +699,13 @@ FAIL:
|
|||
return code;
|
||||
}
|
||||
|
||||
void tmq_conf_set_offset_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb) {
|
||||
void tmq_conf_set_offset_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb, void* param) {
|
||||
//
|
||||
conf->commitCb = cb;
|
||||
conf->commitCbUserParam = param;
|
||||
}
|
||||
|
||||
#if 0
|
||||
TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbName, const char* sql) {
|
||||
STscObj* pTscObj = (STscObj*)taos;
|
||||
SRequestObj* pRequest = NULL;
|
||||
|
@ -777,6 +790,7 @@ _return:
|
|||
|
||||
return pRequest;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
int32_t tmqGetSkipLogNum(tmq_message_t* tmq_message) {
|
||||
|
@ -1304,10 +1318,10 @@ const char* tmq_err2str(tmq_resp_err_t err) {
|
|||
return "fail";
|
||||
}
|
||||
|
||||
char* tmq_get_topic_name(TAOS_RES* res) {
|
||||
const char* tmq_get_topic_name(TAOS_RES* res) {
|
||||
if (TD_RES_TMQ(res)) {
|
||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||
return pRspObj->topic;
|
||||
return strchr(pRspObj->topic, '.') + 1;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -659,10 +659,15 @@ TEST(testCase, agg_query_tables) {
|
|||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||
TAOS_RES* pRes = taos_query(pConn, "use db");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "select now() from m1");
|
||||
pRes = taos_query(pConn, "select tbname from st1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
|
|
|
@ -0,0 +1,340 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "systable.h"
|
||||
#include "tdef.h"
|
||||
#include "types.h"
|
||||
#include "taos.h"
|
||||
|
||||
#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)
|
||||
|
||||
static const SSysDbTableSchema dnodesSchema[] = {
|
||||
{.name = "id", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "max_vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema mnodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "role", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "role_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema modulesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "endpoint", .bytes = 134 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "module", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema 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 SSysDbTableSchema 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 SSysDbTableSchema 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 SSysDbTableSchema 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 SSysDbTableSchema userDBSchema[] = {
|
||||
{.name = "name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "vgroups", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "replica", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "strict", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "duration", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "keep", .bytes = 24 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "buffer", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "pagesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "pages", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "wal", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "fsync", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "cachelast", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "single_stable", .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
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userFuncSchema[] = {
|
||||
{.name = "name", .bytes = TSDB_FUNC_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "comment", .bytes = PATH_MAX - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "aggregate", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "output_type", .bytes = TSDB_TYPE_STR_MAX_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "code_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "bufsize", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema 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},
|
||||
{.name = "index_database", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "index_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "column_name", .bytes = SYSTABLE_SCH_COL_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "index_type", .bytes = 10, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "index_extensions", .bytes = 256, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema 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},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.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 SSysDbTableSchema 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},
|
||||
{.name = "dest_table", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = 1024, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema 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},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "uid", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "table_comment", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "type", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema userTblDistSchema[] = {
|
||||
{.name = "db_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "distributed_histogram", .bytes = 500 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "min_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "max_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "avg_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "stddev_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "rows", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "storage_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "compression_ratio", .bytes = 8, .type = TSDB_DATA_TYPE_DOUBLE},
|
||||
{.name = "rows_in_mem", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "seek_header_time", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema 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},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema grantsSchema[] = {
|
||||
{.name = "version", .bytes = 8 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "expire time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "storage(GB)", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "databases", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "users", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "accounts", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "connections", .bytes = 11 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "streams", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "cpu cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "speed(PPS)", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema 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},
|
||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v1_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v1_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "v2_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v2_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v3_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema 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 SSysDbTableSchema transSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "create_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 SSysDbTableSchema 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 SSysTableMeta 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_USER_DATABASES, userDBSchema, tListLen(userDBSchema)},
|
||||
{TSDB_INS_TABLE_USER_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema)},
|
||||
{TSDB_INS_TABLE_USER_INDEXES, userIdxSchema, tListLen(userIdxSchema)},
|
||||
{TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)},
|
||||
{TSDB_INS_TABLE_USER_STREAMS, userStreamsSchema, tListLen(userStreamsSchema)},
|
||||
{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_LICENCES, grantsSchema, tListLen(grantsSchema)},
|
||||
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)},
|
||||
{TSDB_INS_TABLE_CONFIGS, configSchema, tListLen(configSchema)},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema connectionsSchema[] = {
|
||||
{.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "program", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema topicSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
// TODO config
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema consumerSchema[] = {
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "app_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "topics", .bytes = TSDB_SHOW_LIST_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "up_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "subscribe_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "rebalance_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema subscriptionSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema offsetSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "committed_offset", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "current_offset", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "skip_log_cnt", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema querySchema[] = {
|
||||
{.name = "query_id", .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 = "end_point", .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 = "create_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 SSysDbTableSchema streamSchema[] = {
|
||||
{.name = "stream_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "source_db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "target_db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "target_table", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "watermark", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "trigger", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
static const SSysTableMeta perfsMeta[] = {
|
||||
{TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)},
|
||||
{TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema)},
|
||||
{TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema)},
|
||||
{TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema)},
|
||||
{TSDB_PERFS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema)},
|
||||
{TSDB_PERFS_TABLE_OFFSETS, offsetSchema, tListLen(offsetSchema)},
|
||||
{TSDB_PERFS_TABLE_TRANS, transSchema, tListLen(transSchema)},
|
||||
{TSDB_PERFS_TABLE_SMAS, smaSchema, tListLen(smaSchema)},
|
||||
{TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)},
|
||||
};
|
||||
|
||||
void getInfosDbMeta(const SSysTableMeta** pInfosTableMeta, size_t* size) {
|
||||
*pInfosTableMeta = infosMeta;
|
||||
*size = tListLen(infosMeta);
|
||||
}
|
||||
|
||||
void getPerfDbMeta(const SSysTableMeta** pPerfsTableMeta, size_t* size) {
|
||||
*pPerfsTableMeta = perfsMeta;
|
||||
*size = tListLen(perfsMeta);
|
||||
}
|
|
@ -1661,27 +1661,24 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
|
|||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->numOfVgroups) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->cacheBlockSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->totalBlocks) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->numOfStables) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->buffer) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->pageSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->pages) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->maxRows) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->commitTime) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->ttl) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->precision) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->compression) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->replications) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->update) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->streamMode) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->singleSTable) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1;
|
||||
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
||||
SRetention *pRetension = taosArrayGet(pReq->pRetensions, i);
|
||||
|
@ -1704,27 +1701,24 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
|
|||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->numOfVgroups) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->cacheBlockSize) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->totalBlocks) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->numOfStables) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->buffer) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->pageSize) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->pages) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->maxRows) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->commitTime) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->ttl) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->precision) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->update) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->streamMode) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->singleSTable) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->numOfRetensions) < 0) return -1;
|
||||
pReq->pRetensions = taosArrayInit(pReq->numOfRetensions, sizeof(SRetention));
|
||||
if (pReq->pRetensions == NULL) {
|
||||
|
@ -1761,7 +1755,10 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->totalBlocks) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->buffer) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->pageSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->pages) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1;
|
||||
|
@ -1783,7 +1780,10 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
|
|||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->totalBlocks) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->buffer) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->pageSize) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->pages) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1;
|
||||
|
@ -2138,24 +2138,23 @@ int32_t tSerializeSDbCfgRsp(void *buf, int32_t bufLen, const SDbCfgRsp *pRsp) {
|
|||
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->numOfVgroups) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->cacheBlockSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->totalBlocks) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->numOfStables) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->buffer) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->pageSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->pages) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->daysPerFile) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->daysToKeep0) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->daysToKeep1) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->daysToKeep2) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->minRows) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->maxRows) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->commitTime) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->fsyncPeriod) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->walLevel) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->precision) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->compression) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->replications) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->strict) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->update) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->cacheLastRow) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pRsp->streamMode) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->numOfRetensions) < 0) return -1;
|
||||
for (int32_t i = 0; i < pRsp->numOfRetensions; ++i) {
|
||||
SRetention *pRetension = taosArrayGet(pRsp->pRetensions, i);
|
||||
|
@ -2177,24 +2176,23 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
|
|||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->numOfVgroups) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->cacheBlockSize) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->totalBlocks) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->numOfStables) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->buffer) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->pageSize) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->pages) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->daysPerFile) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->daysToKeep0) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->daysToKeep1) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->daysToKeep2) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->minRows) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->maxRows) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->commitTime) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->fsyncPeriod) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->walLevel) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->precision) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->compression) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->replications) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->strict) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->update) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->cacheLastRow) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pRsp->streamMode) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->numOfRetensions) < 0) return -1;
|
||||
pRsp->pRetensions = taosArrayInit(pRsp->numOfRetensions, sizeof(SRetention));
|
||||
if (pRsp->pRetensions == NULL) {
|
||||
|
@ -2353,7 +2351,6 @@ static int32_t tEncodeSTableMetaRsp(SCoder *pEncoder, STableMetaRsp *pRsp) {
|
|||
if (tEncodeI32(pEncoder, pRsp->numOfColumns) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pRsp->precision) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pRsp->tableType) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pRsp->update) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pRsp->sversion) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pRsp->tversion) < 0) return -1;
|
||||
if (tEncodeU64(pEncoder, pRsp->suid) < 0) return -1;
|
||||
|
@ -2376,7 +2373,6 @@ static int32_t tDecodeSTableMetaRsp(SCoder *pDecoder, STableMetaRsp *pRsp) {
|
|||
if (tDecodeI32(pDecoder, &pRsp->numOfColumns) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pRsp->precision) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pRsp->tableType) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pRsp->update) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pRsp->sversion) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pRsp->tversion) < 0) return -1;
|
||||
if (tDecodeU64(pDecoder, &pRsp->suid) < 0) return -1;
|
||||
|
@ -2796,15 +2792,16 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
|||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->vgVersion) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->cacheBlockSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->totalBlocks) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->numOfStables) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->buffer) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->pageSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->pages) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->maxRows) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->commitTime) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1;
|
||||
if (tEncodeU32(&encoder, pReq->hashBegin) < 0) return -1;
|
||||
if (tEncodeU32(&encoder, pReq->hashEnd) < 0) return -1;
|
||||
|
@ -2813,11 +2810,9 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
|||
if (tEncodeI8(&encoder, pReq->precision) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->compression) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->update) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->replica) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->selfIndex) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->streamMode) < 0) return -1;
|
||||
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
||||
SReplica *pReplica = &pReq->replicas[i];
|
||||
if (tEncodeSReplica(&encoder, pReplica) < 0) return -1;
|
||||
|
@ -2847,15 +2842,16 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
|||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->vgVersion) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->cacheBlockSize) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->totalBlocks) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->numOfStables) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->buffer) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->pageSize) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->pages) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->maxRows) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->commitTime) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1;
|
||||
if (tDecodeU32(&decoder, &pReq->hashBegin) < 0) return -1;
|
||||
if (tDecodeU32(&decoder, &pReq->hashEnd) < 0) return -1;
|
||||
|
@ -2864,11 +2860,9 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
|||
if (tDecodeI8(&decoder, &pReq->precision) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->compression) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->update) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->replica) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->selfIndex) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->streamMode) < 0) return -1;
|
||||
for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) {
|
||||
SReplica *pReplica = &pReq->replicas[i];
|
||||
if (tDecodeSReplica(&decoder, pReplica) < 0) return -1;
|
||||
|
@ -2968,10 +2962,14 @@ int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq
|
|||
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->vgVersion) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->totalBlocks) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->buffer) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->pageSize) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->pages) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->fsyncPeriod) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1;
|
||||
|
@ -2995,10 +2993,14 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR
|
|||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->vgVersion) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->totalBlocks) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->buffer) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->pageSize) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->pages) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->fsyncPeriod) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1;
|
||||
|
|
|
@ -107,13 +107,11 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
|||
|
||||
pCfg->vgId = pCreate->vgId;
|
||||
strcpy(pCfg->dbname, pCreate->db);
|
||||
// pCfg->szBuf = pCreate->cacheBlockSize * 1024 * 1024;
|
||||
pCfg->streamMode = pCreate->streamMode;
|
||||
pCfg->isWeak = true;
|
||||
pCfg->tsdbCfg.days = 10;
|
||||
pCfg->tsdbCfg.keep2 = 3650; // pCreate->daysToKeep0;
|
||||
pCfg->tsdbCfg.keep0 = 3650; // pCreate->daysToKeep2;
|
||||
pCfg->tsdbCfg.keep1 = 3650; // pCreate->daysToKeep0;
|
||||
pCfg->tsdbCfg.keep2 = 3650;
|
||||
pCfg->tsdbCfg.keep0 = 3650;
|
||||
pCfg->tsdbCfg.keep1 = 3650;
|
||||
pCfg->tsdbCfg.retentions = pCreate->pRetensions;
|
||||
pCfg->walCfg.vgId = pCreate->vgId;
|
||||
pCfg->hashBegin = pCreate->hashBegin;
|
||||
|
|
|
@ -33,22 +33,18 @@ TEST_F(DndTestVnode, 01_Create_Vnode) {
|
|||
strcpy(createReq.db, "1.d1");
|
||||
createReq.dbUid = 9527;
|
||||
createReq.vgVersion = 1;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.daysPerFile = 10;
|
||||
createReq.daysToKeep0 = 3650;
|
||||
createReq.daysToKeep1 = 3650;
|
||||
createReq.daysToKeep2 = 3650;
|
||||
createReq.minRows = 100;
|
||||
createReq.minRows = 4096;
|
||||
createReq.commitTime = 3600;
|
||||
createReq.fsyncPeriod = 3000;
|
||||
createReq.walLevel = 1;
|
||||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replica = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.selfIndex = 0;
|
||||
for (int r = 0; r < createReq.replica; ++r) {
|
||||
|
@ -75,27 +71,15 @@ TEST_F(DndTestVnode, 01_Create_Vnode) {
|
|||
TEST_F(DndTestVnode, 02_Alter_Vnode) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
SAlterVnodeReq alterReq = {0};
|
||||
alterReq.vgId = 2;
|
||||
alterReq.dnodeId = 1;
|
||||
strcpy(alterReq.db, "1.d1");
|
||||
alterReq.dbUid = 9527;
|
||||
alterReq.vgVersion = 2;
|
||||
alterReq.cacheBlockSize = 16;
|
||||
alterReq.totalBlocks = 10;
|
||||
alterReq.daysPerFile = 10;
|
||||
alterReq.daysToKeep0 = 3650;
|
||||
alterReq.daysToKeep1 = 3650;
|
||||
alterReq.daysToKeep2 = 3650;
|
||||
alterReq.minRows = 100;
|
||||
alterReq.minRows = 4096;
|
||||
alterReq.commitTime = 3600;
|
||||
alterReq.fsyncPeriod = 3000;
|
||||
alterReq.walLevel = 1;
|
||||
alterReq.precision = 0;
|
||||
alterReq.compression = 2;
|
||||
alterReq.replica = 1;
|
||||
alterReq.strict = 1;
|
||||
alterReq.update = 0;
|
||||
alterReq.cacheLastRow = 0;
|
||||
alterReq.selfIndex = 0;
|
||||
for (int r = 0; r < alterReq.replica; ++r) {
|
||||
|
|
|
@ -257,26 +257,23 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
int32_t numOfVgroups;
|
||||
int32_t cacheBlockSize;
|
||||
int32_t totalBlocks;
|
||||
int32_t numOfStables;
|
||||
int32_t buffer;
|
||||
int32_t pageSize;
|
||||
int32_t pages;
|
||||
int32_t daysPerFile;
|
||||
int32_t daysToKeep0;
|
||||
int32_t daysToKeep1;
|
||||
int32_t daysToKeep2;
|
||||
int32_t minRows;
|
||||
int32_t maxRows;
|
||||
int32_t commitTime;
|
||||
int32_t fsyncPeriod;
|
||||
int32_t ttl;
|
||||
int8_t walLevel;
|
||||
int8_t precision;
|
||||
int8_t compression;
|
||||
int8_t replications;
|
||||
int8_t strict;
|
||||
int8_t update;
|
||||
int8_t cacheLastRow;
|
||||
int8_t streamMode;
|
||||
int8_t singleSTable;
|
||||
int8_t hashMethod; // default is 1
|
||||
int32_t numOfRetensions;
|
||||
SArray* pRetensions;
|
||||
|
@ -316,7 +313,6 @@ typedef struct {
|
|||
int64_t pointsWritten;
|
||||
int8_t compact;
|
||||
int8_t replica;
|
||||
int8_t streamMode;
|
||||
SVnodeGid vnodeGid[TSDB_MAX_REPLICA];
|
||||
} SVgObj;
|
||||
|
||||
|
@ -392,15 +388,12 @@ typedef struct {
|
|||
int8_t type;
|
||||
int8_t replica;
|
||||
int16_t numOfColumns;
|
||||
int32_t rowSize;
|
||||
int32_t numOfRows;
|
||||
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];
|
||||
} SShowObj;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -22,18 +22,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SInfosTableSchema {
|
||||
const char *name;
|
||||
const int32_t type;
|
||||
const int32_t bytes;
|
||||
} SInfosTableSchema;
|
||||
|
||||
typedef struct SInfosTableMeta {
|
||||
const char *name;
|
||||
const SInfosTableSchema *schema;
|
||||
const int32_t colNum;
|
||||
} SInfosTableMeta;
|
||||
|
||||
int32_t mndInitInfos(SMnode *pMnode);
|
||||
void mndCleanupInfos(SMnode *pMnode);
|
||||
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp);
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef int32_t (*MndInitFp)(SMnode *pMnode);
|
|||
typedef void (*MndCleanupFp)(SMnode *pMnode);
|
||||
typedef int32_t (*ShowRetrieveFp)(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||
typedef void (*ShowFreeIterFp)(SMnode *pMnode, void *pIter);
|
||||
typedef struct SQWorkerMgmt SQHandle;
|
||||
typedef struct SQWorker SQHandle;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
|
|
|
@ -22,18 +22,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SPerfsTableSchema {
|
||||
char *name;
|
||||
int32_t type;
|
||||
int32_t bytes;
|
||||
} SPerfsTableSchema;
|
||||
|
||||
typedef struct SPerfsTableMeta {
|
||||
char *name;
|
||||
const SPerfsTableSchema *schema;
|
||||
int32_t colNum;
|
||||
} SPerfsTableMeta;
|
||||
|
||||
int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp);
|
||||
int32_t mndInitPerfs(SMnode *pMnode);
|
||||
void mndCleanupPerfs(SMnode *pMnode);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define _TD_MND_SHOW_H_
|
||||
|
||||
#include "mndInt.h"
|
||||
#include "systable.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -29,6 +29,7 @@ void mndReleaseStb(SMnode *pMnode, SStbObj *pStb);
|
|||
SSdbRaw *mndStbActionEncode(SStbObj *pStb);
|
||||
int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *pStbs, int32_t numOfStbs, void **ppRsp,
|
||||
int32_t *pRspLen);
|
||||
int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -453,7 +453,7 @@ static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false);
|
||||
|
||||
char buf[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, pObj->pDnode->ep, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, pObj->pDnode->ep, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, buf, false);
|
||||
|
|
|
@ -194,7 +194,7 @@ static int32_t mndRetrieveClusters(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock
|
|||
colDataAppend(pColInfo, numOfRows, (const char*) &pCluster->id, false);
|
||||
|
||||
char buf[tListLen(pCluster->name) + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, pCluster->name, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, pCluster->name, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, buf, false);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
#include "mndVgroup.h"
|
||||
#include "systable.h"
|
||||
|
||||
#define DB_VER_NUMBER 1
|
||||
#define DB_RESERVE_SIZE 64
|
||||
|
@ -84,26 +85,23 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
|||
SDB_SET_INT32(pRaw, dataPos, pDb->cfgVersion, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->vgVersion, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfVgroups, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.cacheBlockSize, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.totalBlocks, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfStables, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.buffer, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.pageSize, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.pages, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysPerFile, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep0, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep1, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.daysToKeep2, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.minRows, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.maxRows, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.commitTime, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.fsyncPeriod, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.ttl, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.walLevel, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.precision, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.compression, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.replications, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.strict, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.update, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.cacheLastRow, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.streamMode, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.singleSTable, _OVER)
|
||||
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.hashMethod, _OVER)
|
||||
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfRetensions, _OVER)
|
||||
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
||||
|
@ -158,26 +156,23 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfgVersion, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->vgVersion, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfVgroups, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.cacheBlockSize, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.totalBlocks, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfStables, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.buffer, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.pageSize, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.pages, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysPerFile, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep0, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep1, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.daysToKeep2, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.minRows, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.maxRows, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.commitTime, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.fsyncPeriod, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.ttl, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.walLevel, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.precision, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.compression, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.replications, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.strict, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.update, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.cacheLastRow, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.streamMode, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.singleSTable, _OVER)
|
||||
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.hashMethod, _OVER)
|
||||
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.numOfRetensions, _OVER)
|
||||
if (pDb->cfg.numOfRetensions > 0) {
|
||||
|
@ -268,10 +263,10 @@ static int32_t mndCheckDbName(const char *dbName, SUserObj *pUser) {
|
|||
|
||||
static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
||||
if (pCfg->numOfVgroups < TSDB_MIN_VNODES_PER_DB || pCfg->numOfVgroups > TSDB_MAX_VNODES_PER_DB) return -1;
|
||||
/*
|
||||
if (pCfg->cacheBlockSize < TSDB_MIN_CACHE_BLOCK_SIZE || pCfg->cacheBlockSize > TSDB_MAX_CACHE_BLOCK_SIZE) return -1;
|
||||
if (pCfg->totalBlocks < TSDB_MIN_TOTAL_BLOCKS || pCfg->totalBlocks > TSDB_MAX_TOTAL_BLOCKS) return -1;
|
||||
*/
|
||||
if (pCfg->numOfStables < TSDB_DB_STREAM_MODE_OFF || pCfg->numOfStables > TSDB_DB_STREAM_MODE_ON) return -1;
|
||||
if (pCfg->buffer < TSDB_MIN_BUFFER_PER_VNODE || pCfg->buffer > TSDB_MAX_BUFFER_PER_VNODE) return -1;
|
||||
if (pCfg->pageSize < TSDB_MIN_PAGESIZE_PER_VNODE || pCfg->pageSize > TSDB_MAX_PAGESIZE_PER_VNODE) return -1;
|
||||
if (pCfg->pages < TSDB_MIN_PAGES_PER_VNODE || pCfg->pages > TSDB_MAX_PAGES_PER_VNODE) return -1;
|
||||
if (pCfg->daysPerFile < TSDB_MIN_DAYS_PER_FILE || pCfg->daysPerFile > TSDB_MAX_DAYS_PER_FILE) return -1;
|
||||
if (pCfg->daysToKeep0 < TSDB_MIN_KEEP || pCfg->daysToKeep0 > TSDB_MAX_KEEP) return -1;
|
||||
if (pCfg->daysToKeep1 < TSDB_MIN_KEEP || pCfg->daysToKeep1 > TSDB_MAX_KEEP) return -1;
|
||||
|
@ -282,9 +277,7 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
|||
if (pCfg->minRows < TSDB_MIN_MINROWS_FBLOCK || pCfg->minRows > TSDB_MAX_MINROWS_FBLOCK) return -1;
|
||||
if (pCfg->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) return -1;
|
||||
if (pCfg->minRows > pCfg->maxRows) return -1;
|
||||
if (pCfg->commitTime < TSDB_MIN_COMMIT_TIME || pCfg->commitTime > TSDB_MAX_COMMIT_TIME) return -1;
|
||||
if (pCfg->fsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pCfg->fsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1;
|
||||
// if (pCfg->ttl < TSDB_MIN_TABLE_TTL) return -1;
|
||||
if (pCfg->walLevel < TSDB_MIN_WAL_LEVEL || pCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1;
|
||||
if (pCfg->precision < TSDB_MIN_PRECISION && pCfg->precision > TSDB_MAX_PRECISION) return -1;
|
||||
if (pCfg->compression < TSDB_MIN_COMP_LEVEL || pCfg->compression > TSDB_MAX_COMP_LEVEL) return -1;
|
||||
|
@ -292,36 +285,30 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
|
|||
if (pCfg->replications > mndGetDnodeSize(pMnode)) return -1;
|
||||
if (pCfg->strict < TSDB_DB_STRICT_OFF || pCfg->strict > TSDB_DB_STRICT_ON) return -1;
|
||||
if (pCfg->strict > pCfg->replications) return -1;
|
||||
if (pCfg->update < TSDB_MIN_DB_UPDATE || pCfg->update > TSDB_MAX_DB_UPDATE) return -1;
|
||||
if (pCfg->cacheLastRow < TSDB_MIN_DB_CACHE_LAST_ROW || pCfg->cacheLastRow > TSDB_MAX_DB_CACHE_LAST_ROW) return -1;
|
||||
if (pCfg->streamMode < TSDB_DB_STREAM_MODE_OFF || pCfg->streamMode > TSDB_DB_STREAM_MODE_ON) return -1;
|
||||
if (pCfg->singleSTable < TSDB_DB_SINGLE_STABLE_ON || pCfg->streamMode > TSDB_DB_SINGLE_STABLE_OFF) return -1;
|
||||
if (pCfg->hashMethod != 1) return -1;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
||||
if (pCfg->numOfVgroups < 0) pCfg->numOfVgroups = TSDB_DEFAULT_VN_PER_DB;
|
||||
if (pCfg->cacheBlockSize < 0) pCfg->cacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE;
|
||||
if (pCfg->totalBlocks < 0) pCfg->totalBlocks = TSDB_DEFAULT_TOTAL_BLOCKS;
|
||||
if (pCfg->daysPerFile < 0) pCfg->daysPerFile = TSDB_DEFAULT_DAYS_PER_FILE;
|
||||
if (pCfg->numOfStables < 0) pCfg->numOfStables = TSDB_DEFAULT_DB_SINGLE_STABLE;
|
||||
if (pCfg->buffer < 0) pCfg->buffer = TSDB_DEFAULT_BUFFER_PER_VNODE;
|
||||
if (pCfg->pageSize < 0) pCfg->pageSize = TSDB_DEFAULT_PAGES_PER_VNODE;
|
||||
if (pCfg->pages < 0) pCfg->pages = TSDB_MAX_PAGESIZE_PER_VNODE;
|
||||
if (pCfg->daysPerFile < 0) pCfg->daysPerFile = TSDB_DEFAULT_DURATION_PER_FILE;
|
||||
if (pCfg->daysToKeep0 < 0) pCfg->daysToKeep0 = TSDB_DEFAULT_KEEP;
|
||||
if (pCfg->daysToKeep1 < 0) pCfg->daysToKeep1 = pCfg->daysToKeep0;
|
||||
if (pCfg->daysToKeep2 < 0) pCfg->daysToKeep2 = pCfg->daysToKeep1;
|
||||
if (pCfg->minRows < 0) pCfg->minRows = TSDB_DEFAULT_MINROWS_FBLOCK;
|
||||
if (pCfg->maxRows < 0) pCfg->maxRows = TSDB_DEFAULT_MAXROWS_FBLOCK;
|
||||
if (pCfg->commitTime < 0) pCfg->commitTime = TSDB_DEFAULT_COMMIT_TIME;
|
||||
if (pCfg->fsyncPeriod < 0) pCfg->fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
|
||||
if (pCfg->ttl < 0) pCfg->ttl = TSDB_DEFAULT_TABLE_TTL;
|
||||
if (pCfg->walLevel < 0) pCfg->walLevel = TSDB_DEFAULT_WAL_LEVEL;
|
||||
if (pCfg->precision < 0) pCfg->precision = TSDB_DEFAULT_PRECISION;
|
||||
if (pCfg->compression < 0) pCfg->compression = TSDB_DEFAULT_COMP_LEVEL;
|
||||
if (pCfg->replications < 0) pCfg->replications = TSDB_DEFAULT_DB_REPLICA;
|
||||
if (pCfg->strict < 0) pCfg->strict = TSDB_DEFAULT_DB_STRICT;
|
||||
if (pCfg->update < 0) pCfg->update = TSDB_DEFAULT_DB_UPDATE;
|
||||
if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW;
|
||||
if (pCfg->streamMode < 0) pCfg->streamMode = TSDB_DEFAULT_DB_STREAM_MODE;
|
||||
if (pCfg->singleSTable < 0) pCfg->singleSTable = TSDB_DEFAULT_DB_SINGLE_STABLE;
|
||||
if (pCfg->numOfRetensions < 0) pCfg->numOfRetensions = 0;
|
||||
}
|
||||
|
||||
|
@ -447,26 +434,23 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
|
|||
memcpy(dbObj.createUser, pUser->user, TSDB_USER_LEN);
|
||||
dbObj.cfg = (SDbCfg){
|
||||
.numOfVgroups = pCreate->numOfVgroups,
|
||||
.cacheBlockSize = pCreate->cacheBlockSize,
|
||||
.totalBlocks = pCreate->totalBlocks,
|
||||
.numOfStables = pCreate->numOfStables,
|
||||
.buffer = pCreate->buffer,
|
||||
.pageSize = pCreate->pageSize,
|
||||
.pages = pCreate->pages,
|
||||
.daysPerFile = pCreate->daysPerFile,
|
||||
.daysToKeep0 = pCreate->daysToKeep0,
|
||||
.daysToKeep1 = pCreate->daysToKeep1,
|
||||
.daysToKeep2 = pCreate->daysToKeep2,
|
||||
.minRows = pCreate->minRows,
|
||||
.maxRows = pCreate->maxRows,
|
||||
.commitTime = pCreate->commitTime,
|
||||
.fsyncPeriod = pCreate->fsyncPeriod,
|
||||
.ttl = pCreate->ttl,
|
||||
.walLevel = pCreate->walLevel,
|
||||
.precision = pCreate->precision,
|
||||
.compression = pCreate->compression,
|
||||
.replications = pCreate->replications,
|
||||
.strict = pCreate->strict,
|
||||
.update = pCreate->update,
|
||||
.cacheLastRow = pCreate->cacheLastRow,
|
||||
.streamMode = pCreate->streamMode,
|
||||
.singleSTable = pCreate->singleSTable,
|
||||
.hashMethod = 1,
|
||||
};
|
||||
|
||||
|
@ -570,8 +554,23 @@ _OVER:
|
|||
static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
|
||||
terrno = TSDB_CODE_MND_DB_OPTION_UNCHANGED;
|
||||
|
||||
if (pAlter->totalBlocks >= 0 && pAlter->totalBlocks != pDb->cfg.totalBlocks) {
|
||||
pDb->cfg.totalBlocks = pAlter->totalBlocks;
|
||||
if (pAlter->buffer >= 0 && pAlter->buffer != pDb->cfg.buffer) {
|
||||
pDb->cfg.buffer = pAlter->buffer;
|
||||
terrno = 0;
|
||||
}
|
||||
|
||||
if (pAlter->pages >= 0 && pAlter->pages != pDb->cfg.pages) {
|
||||
pDb->cfg.pages = pAlter->pages;
|
||||
terrno = 0;
|
||||
}
|
||||
|
||||
if (pAlter->pageSize >= 0 && pAlter->pageSize != pDb->cfg.pageSize) {
|
||||
pDb->cfg.pageSize = pAlter->pageSize;
|
||||
terrno = 0;
|
||||
}
|
||||
|
||||
if (pAlter->daysPerFile >= 0 && pAlter->daysPerFile != pDb->cfg.daysPerFile) {
|
||||
pDb->cfg.daysPerFile = pAlter->daysPerFile;
|
||||
terrno = 0;
|
||||
}
|
||||
|
||||
|
@ -639,10 +638,14 @@ static int32_t mndSetAlterDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
|
|||
void *mndBuildAlterVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen) {
|
||||
SAlterVnodeReq alterReq = {0};
|
||||
alterReq.vgVersion = pVgroup->version;
|
||||
alterReq.totalBlocks = pDb->cfg.totalBlocks;
|
||||
alterReq.buffer = pDb->cfg.buffer;
|
||||
alterReq.pages = pDb->cfg.pages;
|
||||
alterReq.pageSize = pDb->cfg.pageSize;
|
||||
alterReq.daysPerFile = pDb->cfg.daysPerFile;
|
||||
alterReq.daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||
alterReq.daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||
alterReq.daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||
alterReq.fsyncPeriod = pDb->cfg.fsyncPeriod;
|
||||
alterReq.walLevel = pDb->cfg.walLevel;
|
||||
alterReq.strict = pDb->cfg.strict;
|
||||
alterReq.cacheLastRow = pDb->cfg.cacheLastRow;
|
||||
|
@ -835,26 +838,23 @@ static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq) {
|
|||
}
|
||||
|
||||
cfgRsp.numOfVgroups = pDb->cfg.numOfVgroups;
|
||||
cfgRsp.cacheBlockSize = pDb->cfg.cacheBlockSize;
|
||||
cfgRsp.totalBlocks = pDb->cfg.totalBlocks;
|
||||
cfgRsp.numOfStables = pDb->cfg.numOfStables;
|
||||
cfgRsp.buffer = pDb->cfg.buffer;
|
||||
cfgRsp.pageSize = pDb->cfg.pageSize;
|
||||
cfgRsp.pages = pDb->cfg.pages;
|
||||
cfgRsp.daysPerFile = pDb->cfg.daysPerFile;
|
||||
cfgRsp.daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||
cfgRsp.daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||
cfgRsp.daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||
cfgRsp.minRows = pDb->cfg.minRows;
|
||||
cfgRsp.maxRows = pDb->cfg.maxRows;
|
||||
cfgRsp.commitTime = pDb->cfg.commitTime;
|
||||
cfgRsp.fsyncPeriod = pDb->cfg.fsyncPeriod;
|
||||
cfgRsp.ttl = pDb->cfg.ttl;
|
||||
cfgRsp.walLevel = pDb->cfg.walLevel;
|
||||
cfgRsp.precision = pDb->cfg.precision;
|
||||
cfgRsp.compression = pDb->cfg.compression;
|
||||
cfgRsp.replications = pDb->cfg.replications;
|
||||
cfgRsp.strict = pDb->cfg.strict;
|
||||
cfgRsp.update = pDb->cfg.update;
|
||||
cfgRsp.cacheLastRow = pDb->cfg.cacheLastRow;
|
||||
cfgRsp.streamMode = pDb->cfg.streamMode;
|
||||
cfgRsp.singleSTable = pDb->cfg.singleSTable;
|
||||
cfgRsp.numOfRetensions = pDb->cfg.numOfRetensions;
|
||||
cfgRsp.pRetensions = pDb->cfg.pRetensions;
|
||||
|
||||
|
@ -1193,7 +1193,7 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) {
|
|||
}
|
||||
|
||||
char *p = strchr(usedbReq.db, '.');
|
||||
if (p && 0 == strcmp(p + 1, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||
if (p && ((0 == strcmp(p + 1, TSDB_INFORMATION_SCHEMA_DB) || (0 == strcmp(p + 1, TSDB_PERFORMANCE_SCHEMA_DB))))) {
|
||||
memcpy(usedbRsp.db, usedbReq.db, TSDB_DB_FNAME_LEN);
|
||||
int32_t vgVersion = mndGetGlobalVgroupVersion(pMnode);
|
||||
if (usedbReq.vgVersion < vgVersion) {
|
||||
|
@ -1387,12 +1387,13 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
bool sysDb) {
|
||||
int32_t cols = 0;
|
||||
|
||||
char *buf = taosMemoryMalloc(pShow->bytes[cols]);
|
||||
int32_t bytes = pShow->pMeta->pSchemas[cols].bytes;
|
||||
char *buf = taosMemoryMalloc(bytes);
|
||||
const char *name = mndGetDbStr(pDb->name);
|
||||
if (name != NULL) {
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, name, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, name, bytes);
|
||||
} else {
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, "NULL", pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, "NULL", bytes);
|
||||
}
|
||||
|
||||
char *status = "ready";
|
||||
|
@ -1430,7 +1431,6 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.replications, false);
|
||||
|
||||
const char *src = pDb->cfg.strict ? "strict" : "nostrict";
|
||||
char b[9 + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_SIZE_TO_VARSTR(b, src, strlen(src));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)b, false);
|
||||
|
@ -1453,10 +1453,13 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
colDataAppend(pColInfo, rows, (const char *)tmp, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheBlockSize, false);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.buffer, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.totalBlocks, false);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.pageSize, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.pages, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.minRows, false);
|
||||
|
@ -1497,14 +1500,10 @@ static void dumpDbInfoData(SSDataBlock *pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)t, false);
|
||||
|
||||
// single stable model
|
||||
int8_t m = 0;
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.ttl, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.singleSTable, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.streamMode, false);
|
||||
colDataAppend(pColInfo, rows, (const char *)&m, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
colDataAppend(pColInfo, rows, (const char *)b, false);
|
||||
|
@ -1522,7 +1521,6 @@ static void setInformationSchemaDbCfg(SDbObj *pDbObj) {
|
|||
pDbObj->cfg.numOfVgroups = 0;
|
||||
pDbObj->cfg.strict = 1;
|
||||
pDbObj->cfg.replications = 1;
|
||||
pDbObj->cfg.update = 1;
|
||||
pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI;
|
||||
}
|
||||
|
||||
|
@ -1534,7 +1532,6 @@ static void setPerfSchemaDbCfg(SDbObj *pDbObj) {
|
|||
pDbObj->cfg.numOfVgroups = 0;
|
||||
pDbObj->cfg.strict = 1;
|
||||
pDbObj->cfg.replications = 1;
|
||||
pDbObj->cfg.update = 1;
|
||||
pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI;
|
||||
}
|
||||
|
||||
|
|
|
@ -418,6 +418,9 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
|
|||
if (tEncodeI32(pEncoder, pObj->version) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pObj->status) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pObj->createdBy) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pObj->trigger) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pObj->triggerParam) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pObj->waterMark) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pObj->fixedSinkVgId) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pObj->smaId) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1;
|
||||
|
@ -464,6 +467,9 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
|
|||
if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pObj->createdBy) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pObj->trigger) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pObj->triggerParam) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pObj->waterMark) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pObj->fixedSinkVgId) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pObj->smaId) < 0) return -1;
|
||||
if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1;
|
||||
|
|
|
@ -705,7 +705,7 @@ static int32_t mndRetrieveDnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
colDataAppend(pColInfo, numOfRows, (const char *)&pDnode->id, false);
|
||||
|
||||
char buf[tListLen(pDnode->ep) + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, pDnode->ep, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf, pDnode->ep, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, buf, false);
|
||||
|
|
|
@ -517,14 +517,14 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
cols = 0;
|
||||
|
||||
char b1[tListLen(pFunc->name) + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b1, pFunc->name, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b1, pFunc->name, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)b1, false);
|
||||
|
||||
if (pFunc->pComment) {
|
||||
char *b2 = taosMemoryCalloc(1, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, pFunc->pComment, pShow->bytes[cols]);
|
||||
char *b2 = taosMemoryCalloc(1, pShow->pMeta->pSchemas[cols].bytes);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, pFunc->pComment, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)b2, false);
|
||||
|
@ -540,7 +540,7 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
|
||||
char b3[TSDB_TYPE_STR_MAX_LEN] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b3, mnodeGenTypeStr(buf, TSDB_TYPE_STR_MAX_LEN, pFunc->outputType, pFunc->outputLen),
|
||||
pShow->bytes[cols]);
|
||||
pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)b3, false);
|
||||
|
|
|
@ -14,256 +14,10 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndInfoSchema.h"
|
||||
#include "systable.h"
|
||||
#include "mndInt.h"
|
||||
|
||||
#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)
|
||||
|
||||
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},
|
||||
{.name = "vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "max_vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.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},
|
||||
{.name = "role", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.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 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "module", .bytes = 10 + VARSTR_HEADER_SIZE, .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},
|
||||
{.name = "vgroups", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT},
|
||||
{.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "replica", .bytes = 2, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "strict", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "days", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "keep", .bytes = 24 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "cache", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "wal", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "fsync", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "cachelast", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
|
||||
{.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.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
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userFuncSchema[] = {
|
||||
{.name = "name", .bytes = TSDB_FUNC_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "comment", .bytes = PATH_MAX - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "aggregate", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "output_type", .bytes = TSDB_TYPE_STR_MAX_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "code_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "bufsize", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
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},
|
||||
{.name = "index_database", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "index_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "column_name", .bytes = SYSTABLE_SCH_COL_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.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},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.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 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},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "uid", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "ttl", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "table_comment", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "type", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema userTblDistSchema[] = {
|
||||
{.name = "db_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "table_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "distributed_histogram", .bytes = 500 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "min_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "max_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "avg_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "stddev_of_rows", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "rows", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "storage_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "compression_ratio", .bytes = 8, .type = TSDB_DATA_TYPE_DOUBLE},
|
||||
{.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},
|
||||
};
|
||||
|
||||
static const SInfosTableSchema grantsSchema[] = {
|
||||
{.name = "version", .bytes = 8 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "expire time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "storage(GB)", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "databases", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "users", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "accounts", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "connections", .bytes = 11 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "streams", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "cpu cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "speed(PPS)", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
};
|
||||
|
||||
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},
|
||||
{.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v1_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v1_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "v2_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v2_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "v3_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
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_USER_DATABASES, userDBSchema, tListLen(userDBSchema)},
|
||||
{TSDB_INS_TABLE_USER_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema)},
|
||||
{TSDB_INS_TABLE_USER_INDEXES, userIdxSchema, tListLen(userIdxSchema)},
|
||||
{TSDB_INS_TABLE_USER_STABLES, userStbsSchema, tListLen(userStbsSchema)},
|
||||
{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_LICENCES, grantsSchema, tListLen(grantsSchema)},
|
||||
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema)},
|
||||
{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)},
|
||||
};
|
||||
|
||||
static int32_t mndInitInfosTableSchema(const SInfosTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
||||
static int32_t mndInitInfosTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
||||
SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
|
||||
if (NULL == schema) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -289,11 +43,15 @@ static int32_t mndInsInitMeta(SHashObj *hash) {
|
|||
meta.sversion = 1;
|
||||
meta.tversion = 1;
|
||||
|
||||
for (int32_t i = 0; i < tListLen(infosMeta); ++i) {
|
||||
tstrncpy(meta.tbName, infosMeta[i].name, sizeof(meta.tbName));
|
||||
meta.numOfColumns = infosMeta[i].colNum;
|
||||
size_t size = 0;
|
||||
const SSysTableMeta* pInfosTableMeta = NULL;
|
||||
getInfosDbMeta(&pInfosTableMeta, &size);
|
||||
|
||||
if (mndInitInfosTableSchema(infosMeta[i].schema, infosMeta[i].colNum, &meta.pSchemas)) {
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
tstrncpy(meta.tbName, pInfosTableMeta[i].name, sizeof(meta.tbName));
|
||||
meta.numOfColumns = pInfosTableMeta[i].colNum;
|
||||
|
||||
if (mndInitInfosTableSchema(pInfosTableMeta[i].schema, pInfosTableMeta[i].colNum, &meta.pSchemas)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -619,14 +619,14 @@ static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false);
|
||||
|
||||
char b1[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b1, pObj->pDnode->ep, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b1, pObj->pDnode->ep, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, b1, false);
|
||||
|
||||
const char *roles = syncStr(pObj->role);
|
||||
char *b2 = taosMemoryCalloc(1, strlen(roles) + VARSTR_HEADER_SIZE);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, roles, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, roles, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)b2, false);
|
||||
|
|
|
@ -14,92 +14,11 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndPerfSchema.h"
|
||||
#include "mndInt.h"
|
||||
|
||||
//!!!! Note: only APPEND columns in below tables, NO insert !!!!
|
||||
static const SPerfsTableSchema connectionsSchema[] = {
|
||||
{.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "program", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
static const SPerfsTableSchema queriesSchema[] = {
|
||||
{.name = "query_id", .bytes = 4, .type = TSDB_DATA_TYPE_UBIGINT},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "fqdn", .bytes = TSDB_FQDN_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.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_BINARY},
|
||||
};
|
||||
|
||||
static const SPerfsTableSchema topicSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
// TODO config
|
||||
};
|
||||
|
||||
static const SPerfsTableSchema consumerSchema[] = {
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "app_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "topics", .bytes = TSDB_SHOW_LIST_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "up_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "subscribe_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "rebalance_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
};
|
||||
|
||||
static const SPerfsTableSchema subscriptionSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
};
|
||||
|
||||
static const SPerfsTableSchema offsetSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
{.name = "committed_offset", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "current_offset", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "skip_log_cnt", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
};
|
||||
|
||||
static const SPerfsTableSchema streamSchema[] = {
|
||||
{.name = "stream_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "status", .bytes = 20 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY},
|
||||
{.name = "source_db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "target_db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "target_table", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
|
||||
{.name = "watermark", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT},
|
||||
{.name = "trigger", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
|
||||
};
|
||||
|
||||
static const SPerfsTableMeta perfsMeta[] = {
|
||||
{TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)},
|
||||
{TSDB_PERFS_TABLE_QUERIES, queriesSchema, tListLen(queriesSchema)},
|
||||
{TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema)},
|
||||
{TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema)},
|
||||
{TSDB_PERFS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema)},
|
||||
{TSDB_PERFS_TABLE_OFFSETS, offsetSchema, tListLen(offsetSchema)},
|
||||
{TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema)},
|
||||
};
|
||||
#include "systable.h"
|
||||
|
||||
// connection/application/
|
||||
int32_t mndInitPerfsTableSchema(const SPerfsTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
||||
int32_t mndInitPerfsTableSchema(const SSysDbTableSchema *pSrc, int32_t colNum, SSchema **pDst) {
|
||||
SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema));
|
||||
if (NULL == schema) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -126,11 +45,15 @@ int32_t mndPerfsInitMeta(SHashObj *hash) {
|
|||
meta.sversion = 1;
|
||||
meta.tversion = 1;
|
||||
|
||||
for (int32_t i = 0; i < tListLen(perfsMeta); ++i) {
|
||||
strcpy(meta.tbName, perfsMeta[i].name);
|
||||
meta.numOfColumns = perfsMeta[i].colNum;
|
||||
size_t size = 0;
|
||||
const SSysTableMeta* pSysDbTableMeta = NULL;
|
||||
getPerfDbMeta(&pSysDbTableMeta, &size);
|
||||
|
||||
if (mndInitPerfsTableSchema(perfsMeta[i].schema, perfsMeta[i].colNum, &meta.pSchemas)) {
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
strcpy(meta.tbName, pSysDbTableMeta[i].name);
|
||||
meta.numOfColumns = pSysDbTableMeta[i].colNum;
|
||||
|
||||
if (mndInitPerfsTableSchema(pSysDbTableMeta[i].schema, pSysDbTableMeta[i].colNum, &meta.pSchemas)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -166,7 +89,6 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char
|
|||
}
|
||||
|
||||
memcpy(pRsp->pSchemas, meta->pSchemas, meta->numOfColumns * sizeof(SSchema));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -570,38 +570,39 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int
|
|||
if (pConn == NULL) break;
|
||||
|
||||
cols = 0;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
#if 0
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
*(uint32_t *)pWrite = pConn->id;
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->user, pShow->bytes[cols]);
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->user, pShow->pMeta->pSchemas[cols].bytes);
|
||||
cols++;
|
||||
|
||||
// app name
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->app, pShow->bytes[cols]);
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->app, pShow->pMeta->pSchemas[cols].bytes);
|
||||
cols++;
|
||||
|
||||
// app pid
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
*(int32_t *)pWrite = pConn->pid;
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
taosIpPort2String(pConn->ip, pConn->port, ipStr);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, pShow->pMeta->pSchemas[cols].bytes);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
*(int64_t *)pWrite = pConn->loginTimeMs;
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
if (pConn->lastAccessTimeMs < pConn->loginTimeMs) pConn->lastAccessTimeMs = pConn->loginTimeMs;
|
||||
*(int64_t *)pWrite = pConn->lastAccessTimeMs;
|
||||
cols++;
|
||||
#endif
|
||||
|
||||
numOfRows++;
|
||||
}
|
||||
|
@ -643,67 +644,67 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i
|
|||
SQueryDesc *pDesc = pConn->pQueries + i;
|
||||
cols = 0;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
*(int64_t *)pWrite = htobe64(pDesc->queryId);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
*(int64_t *)pWrite = htobe64(pConn->id);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->user, pShow->bytes[cols]);
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->user, pShow->pMeta->pSchemas[cols].bytes);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
snprintf(str, tListLen(str), "%s:%u", taosIpStr(pConn->ip), pConn->port);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, str, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, str, pShow->pMeta->pSchemas[cols].bytes);
|
||||
cols++;
|
||||
|
||||
char handleBuf[24] = {0};
|
||||
snprintf(handleBuf, tListLen(handleBuf), "%" PRIu64, htobe64(pDesc->qId));
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, handleBuf, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, handleBuf, pShow->pMeta->pSchemas[cols].bytes);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
*(int64_t *)pWrite = htobe64(pDesc->stime);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
*(int64_t *)pWrite = htobe64(pDesc->useconds);
|
||||
cols++;
|
||||
|
||||
snprintf(str, tListLen(str), "0x%" PRIx64, htobe64(pDesc->sqlObjId));
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, str, pShow->bytes[cols]);
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, str, pShow->pMeta->pSchemas[cols].bytes);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
*(int32_t *)pWrite = htonl(pDesc->pid);
|
||||
cols++;
|
||||
|
||||
char epBuf[TSDB_EP_LEN + 1] = {0};
|
||||
snprintf(epBuf, tListLen(epBuf), "%s:%u", pDesc->fqdn, pConn->port);
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, epBuf, pShow->bytes[cols]);
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, epBuf, pShow->pMeta->pSchemas[cols].bytes);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
*(bool *)pWrite = pDesc->stableQuery;
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
*(int32_t *)pWrite = htonl(pDesc->numOfSub);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDesc->subSqlInfo, pShow->bytes[cols]);
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDesc->subSqlInfo, pShow->pMeta->pSchemas[cols].bytes);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDesc->sql, pShow->bytes[cols]);
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDesc->sql, pShow->pMeta->pSchemas[cols].bytes);
|
||||
cols++;
|
||||
|
||||
numOfRows++;
|
||||
|
|
|
@ -517,7 +517,7 @@ static int32_t mndRetrieveQnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false);
|
||||
|
||||
char ep[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(ep, pObj->pDnode->ep, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(ep, pObj->pDnode->ep, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)ep, false);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
int32_t mndProcessQueryMsg(SNodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pNode;
|
||||
SReadHandle handle = {0};
|
||||
SReadHandle handle = {.mnd = pMnode};
|
||||
|
||||
mTrace("msg:%p, in query queue is processing", pReq);
|
||||
switch (pReq->rpcMsg.msgType) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndShow.h"
|
||||
#include "systable.h"
|
||||
|
||||
#define SHOW_STEP_SIZE 100
|
||||
|
||||
|
@ -82,19 +83,19 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
|||
type = TSDB_MGMT_TABLE_GRANTS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VGROUPS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_VGROUP;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONSUMERS, len) == 0) {
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_CONSUMERS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIBES, len) == 0) {
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_SUBSCRIBES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_SUBSCRIBES;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TRANS, len) == 0) {
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_TRANS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SMAS, len) == 0) {
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_SMAS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_SMAS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONFIGS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_CONFIGS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_CONNS, len) == 0) {
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_CONNECTIONS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_CONNS;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_QUERIES, len) == 0) {
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_QUERIES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_QUERIES;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_VNODES;
|
||||
|
@ -208,16 +209,6 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
|
|||
|
||||
pShow->pMeta = pMeta;
|
||||
pShow->numOfColumns = pShow->pMeta->numOfColumns;
|
||||
int32_t offset = 0;
|
||||
|
||||
for (int32_t i = 0; i < pShow->pMeta->numOfColumns; ++i) {
|
||||
pShow->offset[i] = offset;
|
||||
|
||||
int32_t bytes = pShow->pMeta->pSchemas[i].bytes;
|
||||
pShow->rowSize += bytes;
|
||||
pShow->bytes[i] = bytes;
|
||||
offset += bytes;
|
||||
}
|
||||
} else {
|
||||
pShow = mndAcquireShowObj(pMnode, retrieveReq.showId);
|
||||
if (pShow == NULL) {
|
||||
|
|
|
@ -463,7 +463,7 @@ static int32_t mndRetrieveSnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
colDataAppend(pColInfo, numOfRows, (const char *)&pObj->id, false);
|
||||
|
||||
char ep[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(ep, pObj->pDnode->ep, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(ep, pObj->pDnode->ep, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)ep, false);
|
||||
|
|
|
@ -783,6 +783,13 @@ static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
int32_t numOfStbs = -1;
|
||||
mndGetNumOfStbs(pMnode, pDb->name, &numOfStbs);
|
||||
if (pDb->cfg.numOfStables == 1 && numOfStbs != 0 ) {
|
||||
terrno = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = mndCreateStb(pMnode, pReq, &createReq, pDb);
|
||||
if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
|
||||
|
@ -1436,7 +1443,6 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa
|
|||
pRsp->numOfColumns = pStb->numOfColumns;
|
||||
pRsp->precision = pDb->cfg.precision;
|
||||
pRsp->tableType = TSDB_SUPER_TABLE;
|
||||
pRsp->update = pDb->cfg.update;
|
||||
pRsp->sversion = pStb->version;
|
||||
pRsp->suid = pStb->uid;
|
||||
pRsp->tuid = pStb->uid;
|
||||
|
@ -1589,7 +1595,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableMetaVersion *pStbVersions, int
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs) {
|
||||
int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, dbName);
|
||||
if (pDb == NULL) {
|
||||
|
|
|
@ -308,6 +308,8 @@ static int32_t mndCreateStream(SMnode *pMnode, SNodeMsg *pReq, SCMCreateStreamRe
|
|||
streamObj.smaId = 0;
|
||||
/*streamObj.physicalPlan = "";*/
|
||||
streamObj.logicalPlan = "not implemented";
|
||||
streamObj.trigger = pCreate->triggerType;
|
||||
streamObj.waterMark = pCreate->watermark;
|
||||
|
||||
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_TYPE_CREATE_STREAM, &pReq->rpcMsg);
|
||||
if (pTrans == NULL) {
|
||||
|
@ -431,7 +433,7 @@ static int32_t mndRetrieveStream(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
SStreamObj *pStream = NULL;
|
||||
|
||||
while (numOfRows < rows) {
|
||||
pShow->pIter = sdbFetch(pSdb, SDB_TOPIC, pShow->pIter, (void **)&pStream);
|
||||
pShow->pIter = sdbFetch(pSdb, SDB_STREAM, pShow->pIter, (void **)&pStream);
|
||||
if (pShow->pIter == NULL) break;
|
||||
|
||||
SColumnInfoData *pColInfo;
|
||||
|
@ -471,8 +473,13 @@ static int32_t mndRetrieveStream(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pStream->trigger, false);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pStream);
|
||||
}
|
||||
return 0;
|
||||
|
||||
pShow->numOfRows += numOfRows;
|
||||
return numOfRows;
|
||||
}
|
||||
|
||||
static void mndCancelGetNextStream(SMnode *pMnode, void *pIter) {
|
||||
|
|
|
@ -144,6 +144,10 @@ static int32_t mndPersistSubChangeVgReq(SMnode *pMnode, STrans *pTrans, const SM
|
|||
|
||||
int32_t vgId = pRebVg->pVgEp->vgId;
|
||||
SVgObj *pVgObj = mndAcquireVgroup(pMnode, vgId);
|
||||
if (pVgObj == NULL) {
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetVgroupEpset(pMnode, pVgObj);
|
||||
|
@ -509,7 +513,9 @@ static int32_t mndProcessRebalanceReq(SNodeMsg *pMsg) {
|
|||
/*ASSERT(taosArrayGetSize(rebOutput.rebVgs) != 0);*/
|
||||
|
||||
// TODO replace assert with error check
|
||||
ASSERT(mndPersistRebResult(pMnode, pMsg, &rebOutput) == 0);
|
||||
if (mndPersistRebResult(pMnode, pMsg, &rebOutput) < 0) {
|
||||
mError("persist rebalance output error, possibly vnode splitted or dropped");
|
||||
}
|
||||
|
||||
if (rebInput.pTopic) {
|
||||
SMqTopicObj *pTopic = (SMqTopicObj *)rebInput.pTopic;
|
||||
|
|
|
@ -1351,17 +1351,17 @@ static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false);
|
||||
|
||||
char stage[TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(stage, mndTransStr(pTrans->stage), pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(stage, mndTransStr(pTrans->stage), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)stage, false);
|
||||
|
||||
char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)dbname, false);
|
||||
|
||||
char transType[TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndTransType(pTrans->transType), pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndTransType(pTrans->transType), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)transType, false);
|
||||
|
||||
|
@ -1369,7 +1369,7 @@ static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
|
||||
|
||||
char lastError[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, pTrans->lastError, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, pTrans->lastError, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)lastError, false);
|
||||
|
||||
|
|
|
@ -657,7 +657,7 @@ static int32_t mndRetrieveUsers(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
|
||||
char name[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(name, pUser->user, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(name, pUser->user, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)name, false);
|
||||
|
||||
|
|
|
@ -190,25 +190,24 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
|||
memcpy(createReq.db, pDb->name, TSDB_DB_FNAME_LEN);
|
||||
createReq.dbUid = pDb->uid;
|
||||
createReq.vgVersion = pVgroup->version;
|
||||
createReq.cacheBlockSize = pDb->cfg.cacheBlockSize;
|
||||
createReq.totalBlocks = pDb->cfg.totalBlocks;
|
||||
createReq.numOfStables = pDb->cfg.numOfStables;
|
||||
createReq.buffer = pDb->cfg.buffer;
|
||||
createReq.pageSize = pDb->cfg.pageSize;
|
||||
createReq.pages = pDb->cfg.pages;
|
||||
createReq.daysPerFile = pDb->cfg.daysPerFile;
|
||||
createReq.daysToKeep0 = pDb->cfg.daysToKeep0;
|
||||
createReq.daysToKeep1 = pDb->cfg.daysToKeep1;
|
||||
createReq.daysToKeep2 = pDb->cfg.daysToKeep2;
|
||||
createReq.minRows = pDb->cfg.minRows;
|
||||
createReq.maxRows = pDb->cfg.maxRows;
|
||||
createReq.commitTime = pDb->cfg.commitTime;
|
||||
createReq.fsyncPeriod = pDb->cfg.fsyncPeriod;
|
||||
createReq.walLevel = pDb->cfg.walLevel;
|
||||
createReq.precision = pDb->cfg.precision;
|
||||
createReq.compression = pDb->cfg.compression;
|
||||
createReq.strict = pDb->cfg.strict;
|
||||
createReq.update = pDb->cfg.update;
|
||||
createReq.cacheLastRow = pDb->cfg.cacheLastRow;
|
||||
createReq.replica = pVgroup->replica;
|
||||
createReq.selfIndex = -1;
|
||||
createReq.streamMode = pVgroup->streamMode;
|
||||
createReq.hashBegin = pVgroup->hashBegin;
|
||||
createReq.hashEnd = pVgroup->hashEnd;
|
||||
createReq.hashMethod = pDb->cfg.hashMethod;
|
||||
|
@ -398,7 +397,6 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
|
|||
pVgroup->createdTime = taosGetTimestampMs();
|
||||
pVgroup->updateTime = pVgroups->createdTime;
|
||||
pVgroup->version = 1;
|
||||
pVgroup->streamMode = pDb->cfg.streamMode;
|
||||
pVgroup->hashBegin = hashMin + hashInterval * v;
|
||||
if (v == pDb->cfg.numOfVgroups - 1) {
|
||||
pVgroup->hashEnd = hashMax;
|
||||
|
@ -542,7 +540,7 @@ static int32_t mndRetrieveVgroups(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock*
|
|||
|
||||
char buf1[20] = {0};
|
||||
const char *role = syncStr(pVgroup->vnodeGid[i].role);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->bytes[cols]);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)buf1, false);
|
||||
|
|
|
@ -35,27 +35,24 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
SCreateDbReq createReq = {0};
|
||||
strcpy(createReq.db, "1.d1");
|
||||
createReq.numOfVgroups = 2;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.buffer = -1;
|
||||
createReq.pageSize = -1;
|
||||
createReq.pages = -1;
|
||||
createReq.daysPerFile = 1000;
|
||||
createReq.daysToKeep0 = 3650;
|
||||
createReq.daysToKeep1 = 3650;
|
||||
createReq.daysToKeep2 = 3650;
|
||||
createReq.minRows = 100;
|
||||
createReq.maxRows = 4096;
|
||||
createReq.commitTime = 3600;
|
||||
createReq.fsyncPeriod = 3000;
|
||||
createReq.ttl = 1;
|
||||
createReq.walLevel = 1;
|
||||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
createReq.streamMode = 0;
|
||||
createReq.singleSTable = 0;
|
||||
createReq.numOfStables = 0;
|
||||
createReq.numOfRetensions = 0;
|
||||
|
||||
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
|
@ -76,7 +73,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
|
|||
{
|
||||
SAlterDbReq alterdbReq = {0};
|
||||
strcpy(alterdbReq.db, "1.d1");
|
||||
alterdbReq.totalBlocks = 12;
|
||||
alterdbReq.buffer = 12;
|
||||
alterdbReq.daysToKeep0 = 300;
|
||||
alterdbReq.daysToKeep1 = 400;
|
||||
alterdbReq.daysToKeep2 = 500;
|
||||
|
@ -129,27 +126,24 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
|
|||
SCreateDbReq createReq = {0};
|
||||
strcpy(createReq.db, "1.d2");
|
||||
createReq.numOfVgroups = 2;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.buffer = -1;
|
||||
createReq.pageSize = -1;
|
||||
createReq.pages = -1;
|
||||
createReq.daysPerFile = 1000;
|
||||
createReq.daysToKeep0 = 3650;
|
||||
createReq.daysToKeep1 = 3650;
|
||||
createReq.daysToKeep2 = 3650;
|
||||
createReq.minRows = 100;
|
||||
createReq.maxRows = 4096;
|
||||
createReq.commitTime = 3600;
|
||||
createReq.fsyncPeriod = 3000;
|
||||
createReq.ttl = 1;
|
||||
createReq.walLevel = 1;
|
||||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ignoreExist = 1;
|
||||
createReq.streamMode = 0;
|
||||
createReq.singleSTable = 0;
|
||||
createReq.numOfStables = 0;
|
||||
createReq.numOfRetensions = 0;
|
||||
|
||||
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
|
|
|
@ -184,14 +184,14 @@ TEST_F(MndTestSdb, 01_Write) {
|
|||
taosRemoveDir(opt.path);
|
||||
|
||||
SSdbTable strTable = {
|
||||
.sdbType = SDB_USER,
|
||||
.keyType = SDB_KEY_BINARY,
|
||||
.deployFp = (SdbDeployFp)strDefault,
|
||||
.encodeFp = (SdbEncodeFp)strEncode,
|
||||
.decodeFp = (SdbDecodeFp)strDecode,
|
||||
.insertFp = (SdbInsertFp)strInsert,
|
||||
.updateFp = (SdbUpdateFp)strUpdate,
|
||||
.deleteFp = (SdbDeleteFp)strDelete,
|
||||
SDB_USER,
|
||||
SDB_KEY_BINARY,
|
||||
(SdbDeployFp)strDefault,
|
||||
(SdbEncodeFp)strEncode,
|
||||
(SdbDecodeFp)strDecode,
|
||||
(SdbInsertFp)strInsert,
|
||||
(SdbUpdateFp)strUpdate,
|
||||
(SdbDeleteFp)strDelete,
|
||||
};
|
||||
|
||||
pSdb = sdbInit(&opt);
|
||||
|
@ -304,14 +304,14 @@ TEST_F(MndTestSdb, 01_Read) {
|
|||
taosRemoveDir(opt.path);
|
||||
|
||||
SSdbTable strTable = {
|
||||
.sdbType = SDB_USER,
|
||||
.keyType = SDB_KEY_BINARY,
|
||||
.deployFp = (SdbDeployFp)strDefault,
|
||||
.encodeFp = (SdbEncodeFp)strEncode,
|
||||
.decodeFp = (SdbDecodeFp)strDecode,
|
||||
.insertFp = (SdbInsertFp)strInsert,
|
||||
.updateFp = (SdbUpdateFp)strDelete,
|
||||
.deleteFp = (SdbDeleteFp)strUpdate,
|
||||
SDB_USER,
|
||||
SDB_KEY_BINARY,
|
||||
(SdbDeployFp)strDefault,
|
||||
(SdbEncodeFp)strEncode,
|
||||
(SdbDecodeFp)strDecode,
|
||||
(SdbInsertFp)strInsert,
|
||||
(SdbUpdateFp)strUpdate,
|
||||
(SdbDeleteFp)strDelete,
|
||||
};
|
||||
|
||||
pSdb = sdbInit(&opt);
|
||||
|
|
|
@ -40,24 +40,22 @@ void* MndTestSma::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
|
|||
SCreateDbReq createReq = {0};
|
||||
strcpy(createReq.db, dbname);
|
||||
createReq.numOfVgroups = 2;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.buffer = -1;
|
||||
createReq.pageSize = -1;
|
||||
createReq.pages = -1;
|
||||
createReq.daysPerFile = 10 * 1440;
|
||||
createReq.daysToKeep0 = 3650 * 1440;
|
||||
createReq.daysToKeep1 = 3650 * 1440;
|
||||
createReq.daysToKeep2 = 3650 * 1440;
|
||||
createReq.minRows = 100;
|
||||
createReq.maxRows = 4096;
|
||||
createReq.commitTime = 3600;
|
||||
createReq.fsyncPeriod = 3000;
|
||||
createReq.walLevel = 1;
|
||||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ttl = 1;
|
||||
createReq.ignoreExist = 1;
|
||||
|
||||
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
|
|
|
@ -41,24 +41,22 @@ void* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
|
|||
SCreateDbReq createReq = {0};
|
||||
strcpy(createReq.db, dbname);
|
||||
createReq.numOfVgroups = 2;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.buffer = -1;
|
||||
createReq.pageSize = -1;
|
||||
createReq.pages = -1;
|
||||
createReq.daysPerFile = 1000;
|
||||
createReq.daysToKeep0 = 3650;
|
||||
createReq.daysToKeep1 = 3650;
|
||||
createReq.daysToKeep2 = 3650;
|
||||
createReq.minRows = 100;
|
||||
createReq.maxRows = 4096;
|
||||
createReq.commitTime = 3600;
|
||||
createReq.fsyncPeriod = 3000;
|
||||
createReq.walLevel = 1;
|
||||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ttl = 1;
|
||||
createReq.ignoreExist = 1;
|
||||
|
||||
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
|
@ -343,7 +341,6 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
|
|||
EXPECT_EQ(metaRsp.numOfTags, 3);
|
||||
EXPECT_EQ(metaRsp.precision, TSDB_TIME_PRECISION_MILLI);
|
||||
EXPECT_EQ(metaRsp.tableType, TSDB_SUPER_TABLE);
|
||||
EXPECT_EQ(metaRsp.update, 0);
|
||||
EXPECT_EQ(metaRsp.sversion, 1);
|
||||
EXPECT_EQ(metaRsp.tversion, 0);
|
||||
EXPECT_GT(metaRsp.suid, 0);
|
||||
|
|
|
@ -33,24 +33,22 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) {
|
|||
SCreateDbReq createReq = {0};
|
||||
strcpy(createReq.db, dbname);
|
||||
createReq.numOfVgroups = 2;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.buffer = -1;
|
||||
createReq.pageSize = -1;
|
||||
createReq.pages = -1;
|
||||
createReq.daysPerFile = 10 * 1440;
|
||||
createReq.daysToKeep0 = 3650 * 1440;
|
||||
createReq.daysToKeep1 = 3650 * 1440;
|
||||
createReq.daysToKeep2 = 3650 * 1440;
|
||||
createReq.minRows = 100;
|
||||
createReq.maxRows = 4096;
|
||||
createReq.commitTime = 3600;
|
||||
createReq.fsyncPeriod = 3000;
|
||||
createReq.walLevel = 1;
|
||||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ttl = 1;
|
||||
createReq.ignoreExist = 1;
|
||||
|
||||
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
|
|
|
@ -286,24 +286,22 @@ TEST_F(MndTestUser, 03_Alter_User) {
|
|||
SCreateDbReq createReq = {0};
|
||||
strcpy(createReq.db, "1.d2");
|
||||
createReq.numOfVgroups = 2;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.buffer = -1;
|
||||
createReq.pageSize = -1;
|
||||
createReq.pages = -1;
|
||||
createReq.daysPerFile = 10 * 1440;
|
||||
createReq.daysToKeep0 = 3650 * 1440;
|
||||
createReq.daysToKeep1 = 3650 * 1440;
|
||||
createReq.daysToKeep2 = 3650 * 1440;
|
||||
createReq.minRows = 100;
|
||||
createReq.maxRows = 4096;
|
||||
createReq.commitTime = 3600;
|
||||
createReq.fsyncPeriod = 3000;
|
||||
createReq.walLevel = 1;
|
||||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ttl = 1;
|
||||
createReq.ignoreExist = 1;
|
||||
|
||||
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SQWorkerMgmt SQHandle;
|
||||
typedef struct SQWorker SQHandle;
|
||||
|
||||
typedef struct SQnode {
|
||||
int32_t qndId;
|
||||
|
|
|
@ -89,16 +89,16 @@ int metaTbCursorNext(SMTbCursor *pTbCur);
|
|||
#endif
|
||||
|
||||
// tsdb
|
||||
typedef struct STsdb STsdb;
|
||||
// typedef struct STsdb STsdb;
|
||||
typedef void *tsdbReaderT;
|
||||
|
||||
#define BLOCK_LOAD_OFFSET_SEQ_ORDER 1
|
||||
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
|
||||
#define BLOCK_LOAD_TABLE_RR_ORDER 3
|
||||
|
||||
tsdbReaderT *tsdbQueryTables(STsdb *tsdb, SQueryTableDataCond *pCond, STableGroupInfo *tableInfoGroup, uint64_t qId,
|
||||
tsdbReaderT *tsdbQueryTables(SVnode *pVnode, SQueryTableDataCond *pCond, STableGroupInfo *tableInfoGroup, uint64_t qId,
|
||||
uint64_t taskId);
|
||||
tsdbReaderT tsdbQueryCacheLast(STsdb *tsdb, SQueryTableDataCond *pCond, STableGroupInfo *groupList, uint64_t qId,
|
||||
tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STableGroupInfo *groupList, uint64_t qId,
|
||||
void *pMemRef);
|
||||
int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT *pReader, STableBlockDistInfo *pTableBlockInfo);
|
||||
bool isTsdbCacheLastRow(tsdbReaderT *pReader);
|
||||
|
@ -113,7 +113,7 @@ SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumn
|
|||
void tsdbResetReadHandle(tsdbReaderT queryHandle, SQueryTableDataCond *pCond);
|
||||
void tsdbDestroyTableGroup(STableGroupInfo *pGroupList);
|
||||
int32_t tsdbGetOneTableGroup(void *pMeta, uint64_t uid, TSKEY startKey, STableGroupInfo *pGroupInfo);
|
||||
int32_t tsdbGetTableGroupFromIdList(STsdb *tsdb, SArray *pTableIdList, STableGroupInfo *pGroupInfo);
|
||||
int32_t tsdbGetTableGroupFromIdList(SVnode *pVnode, SArray *pTableIdList, STableGroupInfo *pGroupInfo);
|
||||
|
||||
// tq
|
||||
|
||||
|
@ -154,7 +154,6 @@ struct SVnodeCfg {
|
|||
int32_t szCache;
|
||||
uint64_t szBuf;
|
||||
bool isHeap;
|
||||
int8_t streamMode;
|
||||
bool isWeak;
|
||||
STsdbCfg tsdbCfg;
|
||||
SWalCfg walCfg;
|
||||
|
|
|
@ -52,7 +52,7 @@ typedef struct STsdb STsdb;
|
|||
typedef struct STQ STQ;
|
||||
typedef struct SVState SVState;
|
||||
typedef struct SVBufPool SVBufPool;
|
||||
typedef struct SQWorkerMgmt SQHandle;
|
||||
typedef struct SQWorker SQHandle;
|
||||
|
||||
#define VNODE_META_DIR "meta"
|
||||
#define VNODE_TSDB_DIR "tsdb"
|
||||
|
@ -88,14 +88,19 @@ int32_t metaCreateTSma(SMeta* pMeta, SSmaCfg* pCfg);
|
|||
int32_t metaDropTSma(SMeta* pMeta, int64_t indexUid);
|
||||
|
||||
// tsdb
|
||||
int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb);
|
||||
int tsdbClose(STsdb* pTsdb);
|
||||
int tsdbBegin(STsdb* pTsdb);
|
||||
int tsdbCommit(STsdb* pTsdb);
|
||||
int32_t tsdbUpdateSmaWindow(STsdb* pTsdb, SSubmitReq* pMsg, int64_t version);
|
||||
int32_t tsdbCreateTSma(STsdb* pTsdb, char* pMsg);
|
||||
int32_t tsdbInsertTSmaData(STsdb* pTsdb, int64_t indexUid, const char* msg);
|
||||
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
||||
int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb);
|
||||
int tsdbClose(STsdb* pTsdb);
|
||||
int tsdbBegin(STsdb* pTsdb);
|
||||
int tsdbCommit(STsdb* pTsdb);
|
||||
int32_t tsdbUpdateSmaWindow(STsdb* pTsdb, SSubmitReq* pMsg, int64_t version);
|
||||
int32_t tsdbCreateTSma(STsdb* pTsdb, char* pMsg);
|
||||
int32_t tsdbInsertTSmaData(STsdb* pTsdb, int64_t indexUid, const char* msg);
|
||||
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
||||
tsdbReaderT* tsdbQueryTablesT(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||
uint64_t taskId);
|
||||
tsdbReaderT tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||
void* pMemRef);
|
||||
int32_t tsdbGetTableGroupFromIdListT(STsdb* tsdb, SArray* pTableIdList, STableGroupInfo* pGroupInfo);
|
||||
|
||||
// tq
|
||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal);
|
||||
|
|
|
@ -161,7 +161,7 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
|
|||
|
||||
// decode
|
||||
pBuf = pVal;
|
||||
pSW = taosMemoryMalloc(sizeof(pSW));
|
||||
pSW = taosMemoryMalloc(sizeof(SSchemaWrapper));
|
||||
|
||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pVal, vLen, TD_DECODER);
|
||||
tDecodeSSchemaWrapper(&coder, pSW);
|
||||
|
@ -451,4 +451,4 @@ void *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid, bool isDecode) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -864,7 +864,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int32_t parallel) {
|
|||
}
|
||||
|
||||
int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
|
||||
SStreamTask* pTask = taosMemoryMalloc(sizeof(SStreamTask));
|
||||
SStreamTask* pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
|
||||
if (pTask == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -91,16 +91,8 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
|
|||
int32_t sversion = 0;
|
||||
if (pHandle->sver != sversion) {
|
||||
pHandle->pSchema = metaGetTbTSchema(pHandle->pVnodeMeta, pHandle->msgIter.uid, sversion);
|
||||
#if 0
|
||||
tb_uid_t quid;
|
||||
STbCfg* pTbCfg = metaGetTbInfoByUid(pHandle->pVnodeMeta, pHandle->msgIter.uid);
|
||||
if (pTbCfg->type == META_CHILD_TABLE) {
|
||||
quid = pTbCfg->ctbCfg.suid;
|
||||
} else {
|
||||
quid = pHandle->msgIter.uid;
|
||||
}
|
||||
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, quid, sversion, true);
|
||||
#endif
|
||||
|
||||
// this interface use suid instead of uid
|
||||
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, pHandle->msgIter.suid, sversion, true);
|
||||
pHandle->sver = sversion;
|
||||
}
|
||||
|
|
|
@ -922,7 +922,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
|||
STColumn *pColumn = pSchema->columns + ncol;
|
||||
SDataCol *pDataCol = pDataCols->cols + ncol;
|
||||
SBlockCol *pBlockCol = pBlockData->cols + nColsNotAllNull;
|
||||
SAggrBlkCol *pAggrBlkCol = (SAggrBlkCol *)pAggrBlkData + nColsNotAllNull;
|
||||
SAggrBlkCol *pAggrBlkCol = (SAggrBlkCol *)pAggrBlkData + nColsOfBlockSma;
|
||||
|
||||
if (isAllRowsNull(pDataCol)) { // all data to commit are NULL, just ignore it
|
||||
continue;
|
||||
|
@ -951,6 +951,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
|||
} else {
|
||||
TD_SET_COL_ROWS_MISC(pBlockCol);
|
||||
}
|
||||
++nColsOfBlockSma;
|
||||
} else if (tdIsBitmapBlkNorm(pDataCol->pBitmap, rowsToWrite, pDataCols->bitmapMode)) {
|
||||
// check if all rows normal
|
||||
TD_SET_COL_ROWS_NORM(pBlockCol);
|
||||
|
@ -959,10 +960,6 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
|||
}
|
||||
|
||||
++nColsNotAllNull;
|
||||
|
||||
if (isSuper && pColumn->sma) {
|
||||
++nColsOfBlockSma;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(nColsNotAllNull >= 0 && nColsNotAllNull <= pDataCols->numOfCols);
|
||||
|
|
|
@ -422,7 +422,7 @@ _end:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
tsdbReaderT* tsdbQueryTables(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||
tsdbReaderT* tsdbQueryTablesT(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||
uint64_t taskId) {
|
||||
STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(tsdb, pCond, qId, taskId);
|
||||
if (pTsdbReadHandle == NULL) {
|
||||
|
@ -535,7 +535,7 @@ tsdbReaderT tsdbQueryLastRow(STsdb* tsdb, SQueryTableDataCond* pCond, STableGrou
|
|||
return NULL;
|
||||
}
|
||||
|
||||
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbQueryTables(tsdb, pCond, groupList, qId, taskId);
|
||||
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbQueryTablesT(tsdb, pCond, groupList, qId, taskId);
|
||||
if (pTsdbReadHandle == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -555,8 +555,8 @@ tsdbReaderT tsdbQueryLastRow(STsdb* tsdb, SQueryTableDataCond* pCond, STableGrou
|
|||
}
|
||||
|
||||
#if 0
|
||||
tsdbReaderT tsdbQueryCacheLast(STsdb *tsdb, SQueryTableDataCond *pCond, STableGroupInfo *groupList, uint64_t qId, STsdbMemTable* pMemRef) {
|
||||
STsdbReadHandle *pTsdbReadHandle = (STsdbReadHandle*) tsdbQueryTables(tsdb, pCond, groupList, qId, pMemRef);
|
||||
tsdbReaderT tsdbQueryCacheLastT(STsdb *tsdb, SQueryTableDataCond *pCond, STableGroupInfo *groupList, uint64_t qId, STsdbMemTable* pMemRef) {
|
||||
STsdbReadHandle *pTsdbReadHandle = (STsdbReadHandle*) tsdbQueryTablesT(tsdb, pCond, groupList, qId, pMemRef);
|
||||
if (pTsdbReadHandle == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ tsdbReaderT tsdbQueryRowsInExternalWindow(STsdb* tsdb, SQueryTableDataCond* pCon
|
|||
}
|
||||
}
|
||||
|
||||
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbQueryTables(tsdb, pCond, pNew, qId, taskId);
|
||||
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbQueryTablesT(tsdb, pCond, pNew, qId, taskId);
|
||||
pTsdbReadHandle->loadExternalRow = true;
|
||||
pTsdbReadHandle->currentLoadExternalRows = true;
|
||||
|
||||
|
@ -3717,7 +3717,7 @@ _error:
|
|||
}
|
||||
|
||||
#if 0
|
||||
int32_t tsdbGetTableGroupFromIdList(STsdb* tsdb, SArray* pTableIdList, STableGroupInfo* pGroupInfo) {
|
||||
int32_t tsdbGetTableGroupFromIdListT(STsdb* tsdb, SArray* pTableIdList, STableGroupInfo* pGroupInfo) {
|
||||
if (tsdbRLockRepoMeta(tsdb) < 0) {
|
||||
return terrno;
|
||||
}
|
||||
|
|
|
@ -472,7 +472,7 @@ void tsdbGetBlockStatis(SReadH *pReadh, SColumnDataAgg *pStatis, int numOfCols,
|
|||
SAggrBlkData *pAggrBlkData = pReadh->pAggrBlkData;
|
||||
|
||||
for (int i = 0, j = 0; i < numOfCols;) {
|
||||
if (j >= pBlock->numOfCols) {
|
||||
if (j >= pBlock->numOfBSma) {
|
||||
pStatis[i].numOfNull = -1;
|
||||
++i;
|
||||
continue;
|
||||
|
|
|
@ -23,7 +23,6 @@ const SVnodeCfg vnodeCfgDefault = {
|
|||
.szCache = 256,
|
||||
.szBuf = 96 * 1024 * 1024,
|
||||
.isHeap = false,
|
||||
.streamMode = 0,
|
||||
.isWeak = 0,
|
||||
.tsdbCfg = {.precision = TSDB_TIME_PRECISION_MILLI,
|
||||
.update = 0,
|
||||
|
@ -56,7 +55,6 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
|||
if (tjsonAddIntegerToObject(pJson, "szCache", pCfg->szCache) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "szBuf", pCfg->szBuf) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "isHeap", pCfg->isHeap) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "streamMode", pCfg->streamMode) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "isWeak", pCfg->isWeak) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1;
|
||||
if (tjsonAddIntegerToObject(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1;
|
||||
|
@ -104,7 +102,6 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
|||
if (tjsonGetNumberValue(pJson, "szCache", pCfg->szCache) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "szBuf", pCfg->szBuf) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "isHeap", pCfg->isHeap) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "streamMode", pCfg->streamMode) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "isWeak", pCfg->isWeak) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1;
|
||||
if (tjsonGetNumberValue(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1;
|
||||
|
|
|
@ -147,4 +147,24 @@ void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId) {
|
|||
if (vgId) {
|
||||
*vgId = TD_VID(pVnode);
|
||||
}
|
||||
}
|
||||
|
||||
// wrapper of tsdb read interface
|
||||
// TODO: use FORCE_INLINE if possible later
|
||||
tsdbReaderT *tsdbQueryTables(SVnode *pVnode, SQueryTableDataCond *pCond, STableGroupInfo *tableInfoGroup, uint64_t qId,
|
||||
uint64_t taskId) {
|
||||
return tsdbQueryTablesT(pVnode->pTsdb, pCond, tableInfoGroup, qId, taskId);
|
||||
}
|
||||
tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STableGroupInfo *groupList, uint64_t qId,
|
||||
void *pMemRef) {
|
||||
#if 0
|
||||
return tsdbQueryCacheLastT(pVnode->pTsdb, pCond, groupList, qId, pMemRef);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
int32_t tsdbGetTableGroupFromIdList(SVnode *pVnode, SArray *pTableIdList, STableGroupInfo *pGroupInfo) {
|
||||
#if 0
|
||||
return tsdbGetTableGroupFromIdListT(pVnode->pTsdb, pTableIdList, pGroupInfo);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
|
@ -45,6 +45,47 @@ int vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs, int64_t *version) {
|
|||
#endif
|
||||
return 0;
|
||||
}
|
||||
static void tdSRowDemo() {
|
||||
#define DEMO_N_COLS 3
|
||||
|
||||
int16_t schemaVersion = 0;
|
||||
int32_t numOfCols = DEMO_N_COLS; // ts + int
|
||||
SRowBuilder rb = {0};
|
||||
|
||||
SSchema schema[DEMO_N_COLS] = {
|
||||
{.type = TSDB_DATA_TYPE_TIMESTAMP, .colId = 1, .name = "ts", .bytes = 8, .flags = SCHEMA_SMA_ON},
|
||||
{.type = TSDB_DATA_TYPE_INT, .colId = 2, .name = "c1", .bytes = 4, .flags = SCHEMA_SMA_ON},
|
||||
{.type = TSDB_DATA_TYPE_INT, .colId = 3, .name = "c2", .bytes = 4, .flags = SCHEMA_SMA_ON}};
|
||||
|
||||
SSchema *pSchema = schema;
|
||||
STSchema *pTSChema = tdGetSTSChemaFromSSChema(&pSchema, numOfCols);
|
||||
|
||||
tdSRowInit(&rb, schemaVersion);
|
||||
tdSRowSetTpInfo(&rb, numOfCols, pTSChema->flen);
|
||||
int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSChema);
|
||||
void *row = taosMemoryCalloc(1, maxLen); // make sure the buffer is enough
|
||||
|
||||
// set row buf
|
||||
tdSRowResetBuf(&rb, row);
|
||||
|
||||
for (int32_t idx = 0; idx < pTSChema->numOfCols; ++idx) {
|
||||
STColumn *pColumn = pTSChema->columns + idx;
|
||||
if (idx == 0) {
|
||||
int64_t tsKey = 1651234567;
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, &tsKey, true, pColumn->offset, idx);
|
||||
} else if (idx == 1) {
|
||||
int32_t val1 = 10;
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, &val1, true, pColumn->offset, idx);
|
||||
} else {
|
||||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, true, pColumn->offset, idx);
|
||||
}
|
||||
}
|
||||
|
||||
// print
|
||||
tdSRowPrint(row, pTSChema, __func__);
|
||||
|
||||
taosMemoryFree(pTSChema);
|
||||
}
|
||||
|
||||
int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp) {
|
||||
void *ptr = NULL;
|
||||
|
@ -141,8 +182,10 @@ _err:
|
|||
|
||||
int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
vTrace("message in vnode query queue is processing");
|
||||
#if 0
|
||||
SReadHandle handle = {.reader = pVnode->pTsdb, .meta = pVnode->pMeta, .config = &pVnode->config, .vnode = pVnode};
|
||||
|
||||
#endif
|
||||
SReadHandle handle = {.meta = pVnode->pMeta, .config = &pVnode->config, .vnode = pVnode};
|
||||
switch (pMsg->msgType) {
|
||||
case TDMT_VND_QUERY:
|
||||
return qWorkerProcessQueryMsg(&handle, pVnode->pQuery, pMsg);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "query.h"
|
||||
#include "tname.h"
|
||||
#include "catalogInt.h"
|
||||
#include "systable.h"
|
||||
|
||||
int32_t ctgActUpdateVg(SCtgMetaAction *action);
|
||||
int32_t ctgActUpdateTbl(SCtgMetaAction *action);
|
||||
|
|
|
@ -97,24 +97,22 @@ void sendCreateDbMsg(void *shandle, SEpSet *pEpSet) {
|
|||
SCreateDbReq createReq = {0};
|
||||
strcpy(createReq.db, "1.db1");
|
||||
createReq.numOfVgroups = 2;
|
||||
createReq.cacheBlockSize = 16;
|
||||
createReq.totalBlocks = 10;
|
||||
createReq.buffer = -1;
|
||||
createReq.pageSize = -1;
|
||||
createReq.pages = -1;
|
||||
createReq.daysPerFile = 10;
|
||||
createReq.daysToKeep0 = 3650;
|
||||
createReq.daysToKeep1 = 3650;
|
||||
createReq.daysToKeep2 = 3650;
|
||||
createReq.minRows = 100;
|
||||
createReq.maxRows = 4096;
|
||||
createReq.commitTime = 3600;
|
||||
createReq.fsyncPeriod = 3000;
|
||||
createReq.walLevel = 1;
|
||||
createReq.precision = 0;
|
||||
createReq.compression = 2;
|
||||
createReq.replications = 1;
|
||||
createReq.strict = 1;
|
||||
createReq.update = 0;
|
||||
createReq.cacheLastRow = 0;
|
||||
createReq.ttl = 1;
|
||||
createReq.ignoreExist = 1;
|
||||
|
||||
int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq);
|
||||
|
@ -254,7 +252,6 @@ void ctgTestBuildSTableMetaRsp(STableMetaRsp *rspMsg) {
|
|||
rspMsg->numOfColumns = ctgTestColNum;
|
||||
rspMsg->precision = 1 + 1;
|
||||
rspMsg->tableType = TSDB_SUPER_TABLE;
|
||||
rspMsg->update = 1 + 1;
|
||||
rspMsg->sversion = ctgTestSVersion + 1;
|
||||
rspMsg->tversion = ctgTestTVersion + 1;
|
||||
rspMsg->suid = ctgTestSuid + 1;
|
||||
|
@ -333,7 +330,6 @@ void ctgTestRspTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *
|
|||
metaRsp.numOfColumns = ctgTestColNum;
|
||||
metaRsp.precision = 1;
|
||||
metaRsp.tableType = TSDB_NORMAL_TABLE;
|
||||
metaRsp.update = 1;
|
||||
metaRsp.sversion = ctgTestSVersion;
|
||||
metaRsp.tversion = ctgTestTVersion;
|
||||
metaRsp.suid = 0;
|
||||
|
@ -379,7 +375,6 @@ void ctgTestRspCTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg
|
|||
metaRsp.numOfColumns = ctgTestColNum;
|
||||
metaRsp.precision = 1;
|
||||
metaRsp.tableType = TSDB_CHILD_TABLE;
|
||||
metaRsp.update = 1;
|
||||
metaRsp.sversion = ctgTestSVersion;
|
||||
metaRsp.tversion = ctgTestTVersion;
|
||||
metaRsp.suid = 0x0000000000000002;
|
||||
|
@ -426,7 +421,6 @@ void ctgTestRspSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg
|
|||
metaRsp.numOfColumns = ctgTestColNum;
|
||||
metaRsp.precision = 1;
|
||||
metaRsp.tableType = TSDB_SUPER_TABLE;
|
||||
metaRsp.update = 1;
|
||||
metaRsp.sversion = ctgTestSVersion;
|
||||
metaRsp.tversion = ctgTestTVersion;
|
||||
metaRsp.suid = ctgTestSuid;
|
||||
|
@ -475,7 +469,6 @@ void ctgTestRspMultiSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRp
|
|||
metaRsp.numOfColumns = ctgTestColNum;
|
||||
metaRsp.precision = 1;
|
||||
metaRsp.tableType = TSDB_SUPER_TABLE;
|
||||
metaRsp.update = 1;
|
||||
metaRsp.sversion = ctgTestSVersion;
|
||||
metaRsp.tversion = ctgTestTVersion;
|
||||
metaRsp.suid = ctgTestSuid + idx;
|
||||
|
|
|
@ -375,6 +375,7 @@ typedef struct SStreamBlockScanInfo {
|
|||
uint64_t numOfExec; // execution times
|
||||
void* readerHandle; // stream block reader handle
|
||||
SArray* pColMatchInfo; //
|
||||
SNode* pCondition;
|
||||
} SStreamBlockScanInfo;
|
||||
|
||||
typedef struct SSysTableScanInfo {
|
||||
|
@ -640,6 +641,7 @@ int32_t getTableScanOrder(SOperatorInfo* pOperator);
|
|||
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
||||
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset);
|
||||
void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols);
|
||||
|
||||
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
|
@ -671,7 +673,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
|
|||
const STableGroupInfo* pTableGroupInfo);
|
||||
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* pResBlock, SArray* pColList,
|
||||
SArray* pTableIdList, SExecTaskInfo* pTaskInfo);
|
||||
SArray* pTableIdList, SExecTaskInfo* pTaskInfo, SNode* pConditions);
|
||||
|
||||
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
||||
SInterval* pInterval, SSDataBlock* pResBlock, int32_t fillType, char* fillVal,
|
||||
|
@ -694,7 +696,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
|
|||
SExprInfo* pExpr, int32_t numOfOutput);
|
||||
#endif
|
||||
|
||||
void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
|
||||
int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
|
||||
int32_t numOfOutput, SArray* pPseudoList);
|
||||
|
||||
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order, bool createDummyCol);
|
||||
|
|
|
@ -31,6 +31,7 @@ typedef struct SDataDispatchBuf {
|
|||
typedef struct SDataCacheEntry {
|
||||
int32_t dataLen;
|
||||
int32_t numOfRows;
|
||||
int32_t numOfCols;
|
||||
int8_t compressed;
|
||||
char data[];
|
||||
} SDataCacheEntry;
|
||||
|
@ -76,6 +77,7 @@ static void toDataCacheEntry(const SDataDispatchHandle* pHandle, const SInputDat
|
|||
SDataCacheEntry* pEntry = (SDataCacheEntry*)pBuf->pData;
|
||||
pEntry->compressed = (int8_t)needCompress(pInput->pData, numOfCols);
|
||||
pEntry->numOfRows = pInput->pData->info.rows;
|
||||
pEntry->numOfCols = pInput->pData->info.numOfCols;
|
||||
pEntry->dataLen = 0;
|
||||
|
||||
pBuf->useSize = sizeof(SRetrieveTableRsp);
|
||||
|
@ -169,6 +171,7 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
|
|||
SDataCacheEntry* pEntry = (SDataCacheEntry*)(pDispatcher->nextOutput.pData);
|
||||
memcpy(pOutput->pData, pEntry->data, pEntry->dataLen);
|
||||
pOutput->numOfRows = pEntry->numOfRows;
|
||||
pOutput->numOfCols = pEntry->numOfCols;
|
||||
pOutput->compressed = pEntry->compressed;
|
||||
taosMemoryFreeClear(pDispatcher->nextOutput.pData); // todo persistent
|
||||
pOutput->bufStatus = updateStatus(pDispatcher);
|
||||
|
|
|
@ -227,8 +227,8 @@ int32_t operatorDummyOpenFn(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn,
|
||||
__optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode,
|
||||
__optr_decode_fn_t decode, __optr_get_explain_fn_t explain) {
|
||||
__optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode,
|
||||
__optr_decode_fn_t decode, __optr_get_explain_fn_t explain) {
|
||||
SOperatorFpSet fpSet = {
|
||||
._openFn = openFn,
|
||||
.getNextFn = nextFn,
|
||||
|
@ -441,8 +441,8 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId,
|
|||
* +----------+---------------+
|
||||
*/
|
||||
static SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, int64_t uid,
|
||||
char* pData, int16_t bytes, bool masterscan, uint64_t groupId,
|
||||
SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup) {
|
||||
char* pData, int16_t bytes, bool masterscan, uint64_t groupId,
|
||||
SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup) {
|
||||
SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId);
|
||||
|
||||
SResultRowPosition* p1 =
|
||||
|
@ -463,9 +463,9 @@ static SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowI
|
|||
}
|
||||
}
|
||||
|
||||
// 1. close current opened time window
|
||||
// 1. close current opened time window
|
||||
if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId &&
|
||||
pResult->offset != pResultRowInfo->cur.offset))) {
|
||||
pResult->offset != pResultRowInfo->cur.offset))) {
|
||||
// todo extract function
|
||||
SResultRowPosition pos = pResultRowInfo->cur;
|
||||
SFilePage* pPage = getBufPage(pResultBuf, pos.pageId);
|
||||
|
@ -482,7 +482,8 @@ static SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowI
|
|||
|
||||
// add a new result set for a new group
|
||||
SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset};
|
||||
taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, sizeof(SResultRowPosition));
|
||||
taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos,
|
||||
sizeof(SResultRowPosition));
|
||||
}
|
||||
|
||||
// 2. set the new time window to be the new active time window
|
||||
|
@ -646,7 +647,7 @@ static int32_t setResultOutputBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_
|
|||
SExecTaskInfo* pTaskInfo) {
|
||||
assert(win->skey <= win->ekey);
|
||||
SResultRow* pResultRow = doSetResultOutBufByKey(pAggSup->pResultBuf, pResultRowInfo, id, (char*)&win->skey,
|
||||
TSDB_KEYSIZE, masterscan, tableGroupId, pTaskInfo, true, pAggSup);
|
||||
TSDB_KEYSIZE, masterscan, tableGroupId, pTaskInfo, true, pAggSup);
|
||||
|
||||
if (pResultRow == NULL) {
|
||||
*pResult = NULL;
|
||||
|
@ -1034,8 +1035,8 @@ void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlo
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam,
|
||||
int32_t paramIndex, int32_t numOfRows) {
|
||||
static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunctParam* pFuncParam, int32_t paramIndex,
|
||||
int32_t numOfRows) {
|
||||
SColumnInfoData* pColInfo = NULL;
|
||||
if (pInput->pData[paramIndex] == NULL) {
|
||||
pColInfo = taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
||||
|
@ -1066,9 +1067,9 @@ static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunc
|
|||
colDataAppendDouble(pColInfo, i, &v);
|
||||
}
|
||||
} else if (type == TSDB_DATA_TYPE_VARCHAR) {
|
||||
char *tmp = taosMemoryMalloc(pFuncParam->param.nLen + VARSTR_HEADER_SIZE);
|
||||
char* tmp = taosMemoryMalloc(pFuncParam->param.nLen + VARSTR_HEADER_SIZE);
|
||||
STR_WITH_SIZE_TO_VARSTR(tmp, pFuncParam->param.pz, pFuncParam->param.nLen);
|
||||
for(int32_t i = 0; i < numOfRows; ++i) {
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
colDataAppend(pColInfo, i, tmp, false);
|
||||
}
|
||||
}
|
||||
|
@ -1081,9 +1082,9 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
for (int32_t i = 0; i < pOperator->numOfOutput; ++i) {
|
||||
pCtx[i].order = order;
|
||||
pCtx[i].size = pBlock->info.rows;
|
||||
pCtx[i].pSrcBlock = pBlock;
|
||||
pCtx[i].order = order;
|
||||
pCtx[i].size = pBlock->info.rows;
|
||||
pCtx[i].pSrcBlock = pBlock;
|
||||
pCtx[i].currentStage = MAIN_SCAN;
|
||||
|
||||
SInputColumnInfoData* pInput = &pCtx[i].input;
|
||||
|
@ -1177,7 +1178,7 @@ static void setPseudoOutputColInfo(SSDataBlock* pResult, SqlFunctionCtx* pCtx, S
|
|||
}
|
||||
}
|
||||
|
||||
void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
|
||||
int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
|
||||
int32_t numOfOutput, SArray* pPseudoList) {
|
||||
setPseudoOutputColInfo(pResult, pCtx, pPseudoList);
|
||||
pResult->info.groupId = pSrcBlock->info.groupId;
|
||||
|
@ -1217,7 +1218,7 @@ void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock*
|
|||
taosArrayPush(pBlockList, &pSrcBlock);
|
||||
|
||||
SColumnInfoData* pResColData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||
SColumnInfoData idata = {.info = pResColData->info};
|
||||
SColumnInfoData idata = {.info = pResColData->info, .hasNull = true};
|
||||
|
||||
SScalarParam dest = {.columnData = &idata};
|
||||
scalarCalculate(pExpr[k].pExpr->_optrRoot.pRootNode, pBlockList, &dest);
|
||||
|
@ -1254,10 +1255,14 @@ void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock*
|
|||
taosArrayPush(pBlockList, &pSrcBlock);
|
||||
|
||||
SColumnInfoData* pResColData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||
SColumnInfoData idata = {.info = pResColData->info};
|
||||
SColumnInfoData idata = {.info = pResColData->info, .hasNull = true};
|
||||
|
||||
SScalarParam dest = {.columnData = &idata};
|
||||
scalarCalculate((SNode*)pExpr[k].pExpr->_function.pFunctNode, pBlockList, &dest);
|
||||
int32_t code = scalarCalculate((SNode*)pExpr[k].pExpr->_function.pFunctNode, pBlockList, &dest);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(pBlockList);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t startOffset = createNewColModel ? 0 : pResult->info.rows;
|
||||
colDataMergeCol(pResColData, startOffset, &idata, dest.numOfRows);
|
||||
|
@ -1273,6 +1278,8 @@ void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock*
|
|||
if (!createNewColModel) {
|
||||
pResult->info.rows += numOfRows;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void doTimeWindowInterpolation(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SArray* pDataBlock, TSKEY prevTs,
|
||||
|
@ -1421,7 +1428,7 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc
|
|||
if (!done) { // it is not interpolated, now start to generated the interpolated value
|
||||
int32_t startRowIndex = startPos;
|
||||
bool interp = setTimeWindowInterpolationStartTs(pOperatorInfo, pCtx, startRowIndex, pBlock->info.rows,
|
||||
pBlock->pDataBlock, tsCols, win);
|
||||
pBlock->pDataBlock, tsCols, win);
|
||||
if (interp) {
|
||||
setResultRowInterpo(pResult, RESULT_ROW_START_INTERP);
|
||||
}
|
||||
|
@ -1482,8 +1489,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
|||
|
||||
SResultRow* pResult = NULL;
|
||||
int32_t ret = setResultOutputBufByKey_rv(pResultRowInfo, pSDataBlock->info.uid, &win, masterScan, &pResult,
|
||||
tableGroupId, pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset,
|
||||
&pInfo->aggSup, pTaskInfo);
|
||||
tableGroupId, pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset,
|
||||
&pInfo->aggSup, pTaskInfo);
|
||||
if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -1491,8 +1498,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
|||
if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
|
||||
SResKeyPos* pos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t));
|
||||
pos->groupId = tableGroupId;
|
||||
pos->pos = (SResultRowPosition) {.pageId = pResult->pageId, .offset = pResult->offset};
|
||||
*(int64_t*) pos->key = pResult->win.skey;
|
||||
pos->pos = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
|
||||
*(int64_t*)pos->key = pResult->win.skey;
|
||||
|
||||
taosArrayPush(pUpdated, &pos);
|
||||
}
|
||||
|
@ -1569,8 +1576,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
|||
if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
|
||||
SResKeyPos* pos = taosMemoryMalloc(sizeof(SResKeyPos) + sizeof(uint64_t));
|
||||
pos->groupId = tableGroupId;
|
||||
pos->pos = (SResultRowPosition) {.pageId = pResult->pageId, .offset = pResult->offset};
|
||||
*(int64_t*) pos->key = pResult->win.skey;
|
||||
pos->pos = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
|
||||
*(int64_t*)pos->key = pResult->win.skey;
|
||||
|
||||
taosArrayPush(pUpdated, &pos);
|
||||
}
|
||||
|
@ -1706,7 +1713,7 @@ int32_t setGroupResultOutputBuf(SOptrBasicInfo* binfo, int32_t numOfCols, char*
|
|||
SqlFunctionCtx* pCtx = binfo->pCtx;
|
||||
|
||||
SResultRow* pResultRow = doSetResultOutBufByKey(pBuf, pResultRowInfo, groupId, (char*)pData, bytes, true, groupId,
|
||||
pTaskInfo, false, pAggSup);
|
||||
pTaskInfo, false, pAggSup);
|
||||
assert(pResultRow != NULL);
|
||||
|
||||
setResultRowKey(pResultRow, pData, type);
|
||||
|
@ -1890,7 +1897,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
|||
|
||||
pCtx->functionId = -1;
|
||||
pCtx->curBufPage = -1;
|
||||
pCtx->pExpr = pExpr;
|
||||
pCtx->pExpr = pExpr;
|
||||
|
||||
if (pExpr->pExpr->nodeType == QUERY_NODE_FUNCTION) {
|
||||
SFuncExecEnv env = {0};
|
||||
|
@ -1901,7 +1908,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
|||
if (!isUdaf) {
|
||||
fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet);
|
||||
} else {
|
||||
char *udfName = pExpr->pExpr->_function.pFunctNode->functionName;
|
||||
char* udfName = pExpr->pExpr->_function.pFunctNode->functionName;
|
||||
strncpy(pCtx->udfName, udfName, strlen(udfName));
|
||||
fmGetUdafExecFuncs(pCtx->functionId, &pCtx->fpSet);
|
||||
}
|
||||
|
@ -1926,9 +1933,9 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
|||
pCtx->pTsOutput = NULL;
|
||||
pCtx->resDataInfo.bytes = pFunct->resSchema.bytes;
|
||||
pCtx->resDataInfo.type = pFunct->resSchema.type;
|
||||
pCtx->order = TSDB_ORDER_ASC;
|
||||
pCtx->order = TSDB_ORDER_ASC;
|
||||
pCtx->start.key = INT64_MIN;
|
||||
pCtx->end.key = INT64_MIN;
|
||||
pCtx->end.key = INT64_MIN;
|
||||
pCtx->numOfParams = pExpr->base.numOfParams;
|
||||
|
||||
pCtx->param = pFunct->pParam;
|
||||
|
@ -2719,7 +2726,7 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t
|
|||
int64_t tid = 0;
|
||||
int64_t groupId = 0;
|
||||
SResultRow* pRow = doSetResultOutBufByKey(pSup->pResultBuf, pResultRowInfo, tid, (char*)&tid, sizeof(tid), true,
|
||||
groupId, pTaskInfo, false, pSup);
|
||||
groupId, pTaskInfo, false, pSup);
|
||||
|
||||
for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) {
|
||||
struct SResultRowEntryInfo* pEntry = getResultCell(pRow, i, rowCellInfoOffset);
|
||||
|
@ -2866,24 +2873,24 @@ void finalizeUpdatedResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbased
|
|||
size_t num = taosArrayGetSize(pUpdateList);
|
||||
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SResKeyPos * pPos = taosArrayGetP(pUpdateList, i);
|
||||
SResKeyPos* pPos = taosArrayGetP(pUpdateList, i);
|
||||
|
||||
SFilePage* bufPage = getBufPage(pBuf, pPos->pos.pageId);
|
||||
SResultRow* pRow = (SResultRow*)((char*)bufPage + pPos->pos.offset);
|
||||
//
|
||||
//
|
||||
for (int32_t j = 0; j < numOfOutput; ++j) {
|
||||
pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset);
|
||||
//
|
||||
//
|
||||
struct SResultRowEntryInfo* pResInfo = pCtx[j].resultInfo;
|
||||
// if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (pCtx[j].fpSet.process) { // TODO set the dummy function.
|
||||
//// pCtx[j].fpSet.finalize(&pCtx[j]);
|
||||
// pResInfo->initialized = true;
|
||||
// }
|
||||
//
|
||||
// if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (pCtx[j].fpSet.process) { // TODO set the dummy function.
|
||||
//// pCtx[j].fpSet.finalize(&pCtx[j]);
|
||||
// pResInfo->initialized = true;
|
||||
// }
|
||||
//
|
||||
if (pRow->numOfRows < pResInfo->numOfRes) {
|
||||
pRow->numOfRows = pResInfo->numOfRes;
|
||||
}
|
||||
|
@ -3005,9 +3012,8 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, u
|
|||
SqlFunctionCtx* pCtx = pAggInfo->binfo.pCtx;
|
||||
int32_t* rowCellInfoOffset = pAggInfo->binfo.rowCellInfoOffset;
|
||||
|
||||
SResultRow* pResultRow =
|
||||
doSetResultOutBufByKey(pAggInfo->aggSup.pResultBuf, pResultRowInfo, uid, (char*)&groupId, sizeof(groupId),
|
||||
true, groupId, pTaskInfo, false, &pAggInfo->aggSup);
|
||||
SResultRow* pResultRow = doSetResultOutBufByKey(pAggInfo->aggSup.pResultBuf, pResultRowInfo, uid, (char*)&groupId,
|
||||
sizeof(groupId), true, groupId, pTaskInfo, false, &pAggInfo->aggSup);
|
||||
assert(pResultRow != NULL);
|
||||
|
||||
/*
|
||||
|
@ -3105,8 +3111,8 @@ int32_t doCopyToSDataBlock(SSDataBlock* pBlock, SExprInfo* pExprInfo, SDiskbased
|
|||
}
|
||||
|
||||
for (int32_t i = start; (i < numOfRows) && (i >= 0); i += step) {
|
||||
SResKeyPos *pPos = taosArrayGetP(pGroupResInfo->pRows, i);
|
||||
SFilePage* page = getBufPage(pBuf, pPos->pos.pageId);
|
||||
SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i);
|
||||
SFilePage* page = getBufPage(pBuf, pPos->pos.pageId);
|
||||
|
||||
SResultRow* pRow = (SResultRow*)((char*)page + pPos->pos.offset);
|
||||
if (pRow->numOfRows == 0) {
|
||||
|
@ -3668,6 +3674,7 @@ int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code)
|
|||
SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp;
|
||||
pRsp->numOfRows = htonl(pRsp->numOfRows);
|
||||
pRsp->compLen = htonl(pRsp->compLen);
|
||||
pRsp->numOfCols = htonl(pRsp->numOfCols);
|
||||
pRsp->useconds = htobe64(pRsp->useconds);
|
||||
} else {
|
||||
pSourceDataInfo->code = code;
|
||||
|
@ -3746,12 +3753,12 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
|||
}
|
||||
|
||||
// NOTE: sources columns are more than the destination SSDatablock columns.
|
||||
static void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols) {
|
||||
void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols) {
|
||||
size_t numOfSrcCols = taosArrayGetSize(pCols);
|
||||
ASSERT(numOfSrcCols >= pBlock->info.numOfCols);
|
||||
|
||||
int32_t i = 0, j = 0;
|
||||
while(i < numOfSrcCols && j < taosArrayGetSize(pColMatchInfo)) {
|
||||
while (i < numOfSrcCols && j < taosArrayGetSize(pColMatchInfo)) {
|
||||
SColumnInfoData* p = taosArrayGet(pCols, i);
|
||||
SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, j);
|
||||
if (!pmInfo->output) {
|
||||
|
@ -3777,10 +3784,10 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
|||
blockDataEnsureCapacity(pRes, numOfRows);
|
||||
|
||||
if (pColList == NULL) { // data from other sources
|
||||
int32_t dataLen = *(int32_t*) pData;
|
||||
int32_t dataLen = *(int32_t*)pData;
|
||||
pData += sizeof(int32_t);
|
||||
|
||||
pRes->info.groupId = *(uint64_t*) pData;
|
||||
pRes->info.groupId = *(uint64_t*)pData;
|
||||
pData += sizeof(uint64_t);
|
||||
|
||||
int32_t* colLen = (int32_t*)pData;
|
||||
|
@ -3810,8 +3817,8 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
|||
memcpy(pColInfoData->pData, pStart, colLen[i]);
|
||||
}
|
||||
|
||||
//TODO setting this flag to true temporarily so aggregate function on stable will
|
||||
//examine NULL value for non-primary key column
|
||||
// TODO setting this flag to true temporarily so aggregate function on stable will
|
||||
// examine NULL value for non-primary key column
|
||||
pColInfoData->hasNull = true;
|
||||
pStart += colLen[i];
|
||||
}
|
||||
|
@ -3847,11 +3854,11 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
|||
|
||||
blockDataEnsureCapacity(&block, numOfRows);
|
||||
|
||||
int32_t dataLen = *(int32_t*) pStart;
|
||||
uint64_t groupId = *(uint64_t*) (pStart + sizeof(int32_t));
|
||||
int32_t dataLen = *(int32_t*)pStart;
|
||||
uint64_t groupId = *(uint64_t*)(pStart + sizeof(int32_t));
|
||||
pStart += sizeof(int32_t) + sizeof(uint64_t);
|
||||
|
||||
int32_t* colLen = (int32_t*) (pStart);
|
||||
int32_t* colLen = (int32_t*)(pStart);
|
||||
pStart += sizeof(int32_t) * numOfCols;
|
||||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
|
@ -3877,7 +3884,7 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
|||
}
|
||||
|
||||
// data from mnode
|
||||
relocateColumnData(pRes, pColList, block.pDataBlock);
|
||||
relocateColumnData(pRes, pColList, block.pDataBlock);
|
||||
}
|
||||
|
||||
pRes->info.rows = numOfRows;
|
||||
|
@ -3951,7 +3958,7 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
|||
SRetrieveTableRsp* pTableRsp = pDataInfo->pRsp;
|
||||
code =
|
||||
setSDataBlockFromFetchRsp(pExchangeInfo->pResult, pLoadInfo, pTableRsp->numOfRows, pTableRsp->data,
|
||||
pTableRsp->compLen, pOperator->numOfOutput, startTs, &pDataInfo->totalRows, NULL);
|
||||
pTableRsp->compLen, pTableRsp->numOfCols, startTs, &pDataInfo->totalRows, NULL);
|
||||
if (code != 0) {
|
||||
goto _error;
|
||||
}
|
||||
|
@ -4086,7 +4093,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
|
|||
SRetrieveTableRsp* pTableRsp = pDataInfo->pRsp;
|
||||
int32_t code =
|
||||
setSDataBlockFromFetchRsp(pExchangeInfo->pResult, pLoadInfo, pTableRsp->numOfRows, pTableRsp->data,
|
||||
pTableRsp->compLen, pOperator->numOfOutput, startTs, &pDataInfo->totalRows, NULL);
|
||||
pTableRsp->compLen, pTableRsp->numOfCols, startTs, &pDataInfo->totalRows, NULL);
|
||||
|
||||
if (pRsp->completed == 1) {
|
||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " numOfRows:%d, rowsOfSource:%" PRIu64
|
||||
|
@ -4226,8 +4233,8 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock
|
|||
pOperator->numOfOutput = pBlock->info.numOfCols;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL, destroyExchangeOperatorInfo,
|
||||
NULL, NULL, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL,
|
||||
destroyExchangeOperatorInfo, NULL, NULL, NULL);
|
||||
|
||||
#if 1
|
||||
{ // todo refactor
|
||||
|
@ -4716,8 +4723,8 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR
|
|||
pOperator->info = pInfo;
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSort, NULL, NULL, destroyOrderOperatorInfo,
|
||||
NULL, NULL, NULL);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doSort, NULL, NULL, destroyOrderOperatorInfo, NULL, NULL, NULL);
|
||||
|
||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||
return pOperator;
|
||||
|
@ -4771,8 +4778,12 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
|||
|
||||
// there is an scalar expression that needs to be calculated before apply the group aggregation.
|
||||
if (pAggInfo->pScalarExprInfo != NULL) {
|
||||
projectApplyFunctions(pAggInfo->pScalarExprInfo, pBlock, pBlock, pAggInfo->pScalarCtx, pAggInfo->numOfScalarExpr,
|
||||
int32_t code = projectApplyFunctions(pAggInfo->pScalarExprInfo, pBlock, pBlock, pAggInfo->pScalarCtx, pAggInfo->numOfScalarExpr,
|
||||
NULL);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
pTaskInfo->code = code;
|
||||
longjmp(pTaskInfo->env, pTaskInfo->code);
|
||||
}
|
||||
}
|
||||
|
||||
// the pDataBlock are always the same one, no need to call this again
|
||||
|
@ -4933,8 +4944,8 @@ bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter* pSup, SOptrBasi
|
|||
initResultRow(resultRow);
|
||||
prepareResultListBuffer(&pInfo->resultRowInfo, pOperator->pTaskInfo->env);
|
||||
// pInfo->resultRowInfo.cur = pInfo->resultRowInfo.size;
|
||||
// pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] =
|
||||
// (SResultRowPosition){.pageId = resultRow->pageId, .offset = resultRow->offset};
|
||||
// pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] =
|
||||
// (SResultRowPosition){.pageId = resultRow->pageId, .offset = resultRow->offset};
|
||||
pInfo->resultRowInfo.cur = (SResultRowPosition){.pageId = resultRow->pageId, .offset = resultRow->offset};
|
||||
}
|
||||
|
||||
|
@ -4946,13 +4957,13 @@ bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter* pSup, SOptrBasi
|
|||
|
||||
enum {
|
||||
PROJECT_RETRIEVE_CONTINUE = 0x1,
|
||||
PROJECT_RETRIEVE_DONE = 0x2,
|
||||
PROJECT_RETRIEVE_DONE = 0x2,
|
||||
};
|
||||
|
||||
static int32_t handleLimitOffset(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||
SProjectOperatorInfo* pProjectInfo = pOperator->info;
|
||||
SOptrBasicInfo* pInfo = &pProjectInfo->binfo;
|
||||
SSDataBlock* pRes = pInfo->pRes;
|
||||
SSDataBlock* pRes = pInfo->pRes;
|
||||
|
||||
if (pProjectInfo->curSOffset > 0) {
|
||||
if (pProjectInfo->groupId == 0) { // it is the first group
|
||||
|
@ -5015,9 +5026,10 @@ static int32_t handleLimitOffset(SOperatorInfo* pOperator, SSDataBlock* pBlock)
|
|||
// todo optimize performance
|
||||
// If there are slimit/soffset value exists, multi-round result can not be packed into one group, since the
|
||||
// they may not belong to the same group the limit/offset value is not valid in this case.
|
||||
if (pRes->info.rows >= pOperator->resultInfo.threshold || pProjectInfo->slimit.offset != -1 || pProjectInfo->slimit.limit != -1) {
|
||||
if (pRes->info.rows >= pOperator->resultInfo.threshold || pProjectInfo->slimit.offset != -1 ||
|
||||
pProjectInfo->slimit.limit != -1) {
|
||||
return PROJECT_RETRIEVE_DONE;
|
||||
} else { // not full enough, continue to accumulate the output data in the buffer.
|
||||
} else { // not full enough, continue to accumulate the output data in the buffer.
|
||||
return PROJECT_RETRIEVE_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
@ -5101,7 +5113,7 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup)
|
|||
int32_t status = handleLimitOffset(pOperator, pBlock);
|
||||
if (status == PROJECT_RETRIEVE_CONTINUE) {
|
||||
continue;
|
||||
} else if (status == PROJECT_RETRIEVE_DONE) {
|
||||
} else if (status == PROJECT_RETRIEVE_DONE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5291,7 +5303,7 @@ static SSDataBlock* doAllIntervalAgg(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||
// finalizeQueryResult(pSliceInfo->binfo.pCtx, pOperator->numOfOutput);
|
||||
|
||||
// initGroupedResultInfo(&pSliceInfo->groupResInfo, &pSliceInfo->binfo.resultRowInfo);
|
||||
// initGroupedResultInfo(&pSliceInfo->groupResInfo, &pSliceInfo->binfo.resultRowInfo);
|
||||
// doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pSliceInfo->pRes);
|
||||
|
||||
if (pSliceInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pSliceInfo->groupResInfo)) {
|
||||
|
@ -5342,7 +5354,7 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
|
|||
finalizeMultiTupleQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->aggSup.pResultBuf,
|
||||
&pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset);
|
||||
|
||||
// initGroupedResultInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo);
|
||||
// initGroupedResultInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo);
|
||||
OPTR_SET_OPENED(pOperator);
|
||||
|
||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||
|
@ -5684,8 +5696,8 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n
|
|||
pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput);
|
||||
pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t));
|
||||
pAggSup->pResultRowHashTable = taosHashInit(10, hashFn, true, HASH_NO_LOCK);
|
||||
// pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK);
|
||||
// pAggSup->pResultRowArrayList = taosArrayInit(10, sizeof(SResultRowCell));
|
||||
// pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK);
|
||||
// pAggSup->pResultRowArrayList = taosArrayInit(10, sizeof(SResultRowCell));
|
||||
|
||||
if (pAggSup->keyBuf == NULL /*|| pAggSup->pResultRowArrayList == NULL || pAggSup->pResultRowListSet == NULL*/ ||
|
||||
pAggSup->pResultRowHashTable == NULL) {
|
||||
|
@ -5703,8 +5715,8 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n
|
|||
static void cleanupAggSup(SAggSupporter* pAggSup) {
|
||||
taosMemoryFreeClear(pAggSup->keyBuf);
|
||||
taosHashCleanup(pAggSup->pResultRowHashTable);
|
||||
// taosHashCleanup(pAggSup->pResultRowListSet);
|
||||
// taosArrayDestroy(pAggSup->pResultRowArrayList);
|
||||
// taosHashCleanup(pAggSup->pResultRowListSet);
|
||||
// taosArrayDestroy(pAggSup->pResultRowArrayList);
|
||||
destroyDiskbasedBuf(pAggSup->pResultBuf);
|
||||
}
|
||||
|
||||
|
@ -5715,7 +5727,7 @@ int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInf
|
|||
|
||||
doInitAggInfoSup(pAggSup, pBasicInfo->pCtx, numOfCols, keyBufSize, pkey);
|
||||
|
||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
pBasicInfo->pCtx[i].pBuf = pAggSup->pResultBuf;
|
||||
}
|
||||
|
||||
|
@ -5732,6 +5744,10 @@ void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows) {
|
|||
}
|
||||
|
||||
static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInfo) {
|
||||
if (pTableGroupInfo->numOfTables == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
STableQueryInfo* pTableQueryInfo = taosMemoryCalloc(pTableGroupInfo->numOfTables, sizeof(STableQueryInfo));
|
||||
if (pTableQueryInfo == NULL) {
|
||||
return NULL;
|
||||
|
@ -5757,7 +5773,8 @@ static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInf
|
|||
|
||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||
SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo,
|
||||
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) {
|
||||
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo,
|
||||
const STableGroupInfo* pTableGroupInfo) {
|
||||
SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
|
@ -5771,7 +5788,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
int32_t code =
|
||||
initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, pResultBlock, keyBufSize, pTaskInfo->id.str);
|
||||
pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
|
||||
if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) {
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
|
@ -5926,8 +5943,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
|
|||
pOperator->pExpr = pExprInfo;
|
||||
pOperator->numOfOutput = num;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doProjectOperation, NULL, NULL, destroyProjectOperatorInfo,
|
||||
NULL, NULL, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doProjectOperation, NULL, NULL,
|
||||
destroyProjectOperatorInfo, NULL, NULL, NULL);
|
||||
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||
|
@ -5952,12 +5969,12 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
goto _error;
|
||||
}
|
||||
|
||||
pInfo->order = TSDB_ORDER_ASC;
|
||||
pInfo->interval = *pInterval;
|
||||
// pInfo->execModel = OPTR_EXEC_MODEL_STREAM;
|
||||
pInfo->execModel = pTaskInfo->execModel;
|
||||
pInfo->win = pTaskInfo->window;
|
||||
pInfo->twAggSup = *pTwAggSupp;
|
||||
pInfo->order = TSDB_ORDER_ASC;
|
||||
pInfo->interval = *pInterval;
|
||||
// pInfo->execModel = OPTR_EXEC_MODEL_STREAM;
|
||||
pInfo->execModel = pTaskInfo->execModel;
|
||||
pInfo->win = pTaskInfo->window;
|
||||
pInfo->twAggSup = *pTwAggSupp;
|
||||
pInfo->primaryTsIndex = primaryTsSlotId;
|
||||
|
||||
int32_t numOfRows = 4096;
|
||||
|
@ -5984,8 +6001,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
pOperator->numOfOutput = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, doStreamIntervalAgg, NULL, destroyIntervalOperatorInfo,
|
||||
aggEncodeResultRow, aggDecodeResultRow, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, doStreamIntervalAgg, NULL,
|
||||
destroyIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -6004,18 +6021,19 @@ _error:
|
|||
|
||||
SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
||||
STimeWindowAggSupp *pTwAggSupp, const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo) {
|
||||
STimeWindowAggSupp* pTwAggSupp, const STableGroupInfo* pTableGroupInfo,
|
||||
SExecTaskInfo* pTaskInfo) {
|
||||
STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pInfo->order = TSDB_ORDER_ASC;
|
||||
pInfo->interval = *pInterval;
|
||||
pInfo->execModel = OPTR_EXEC_MODEL_STREAM;
|
||||
pInfo->win = pTaskInfo->window;
|
||||
pInfo->twAggSup = *pTwAggSupp;
|
||||
pInfo->order = TSDB_ORDER_ASC;
|
||||
pInfo->interval = *pInterval;
|
||||
pInfo->execModel = OPTR_EXEC_MODEL_STREAM;
|
||||
pInfo->win = pTaskInfo->window;
|
||||
pInfo->twAggSup = *pTwAggSupp;
|
||||
pInfo->primaryTsIndex = primaryTsSlotId;
|
||||
|
||||
int32_t numOfRows = 4096;
|
||||
|
@ -6042,8 +6060,8 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
|
|||
pOperator->numOfOutput = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doStreamIntervalAgg, doStreamIntervalAgg, NULL, destroyIntervalOperatorInfo,
|
||||
aggEncodeResultRow, aggDecodeResultRow, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doStreamIntervalAgg, doStreamIntervalAgg, NULL,
|
||||
destroyIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -6052,13 +6070,12 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
|
|||
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
_error:
|
||||
destroyIntervalOperatorInfo(pInfo, numOfCols);
|
||||
taosMemoryFreeClear(pInfo);
|
||||
taosMemoryFreeClear(pOperator);
|
||||
pTaskInfo->code = code;
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||
|
@ -6122,8 +6139,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
|
|||
pOperator->pTaskInfo = pTaskInfo;
|
||||
pOperator->info = pInfo;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStateWindowAgg, NULL, NULL, destroyStateWindowOperatorInfo,
|
||||
aggEncodeResultRow, aggDecodeResultRow, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStateWindowAgg, NULL, NULL,
|
||||
destroyStateWindowOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
|
||||
|
||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||
return pOperator;
|
||||
|
@ -6168,8 +6185,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
|
|||
pOperator->numOfOutput = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSessionWindowAgg, NULL, NULL, destroySWindowOperatorInfo,
|
||||
aggEncodeResultRow, aggDecodeResultRow, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSessionWindowAgg, NULL, NULL,
|
||||
destroySWindowOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
|
@ -6257,8 +6274,8 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
|
|||
pOperator->numOfOutput = numOfCols;
|
||||
pOperator->info = pInfo;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, NULL, destroySFillOperatorInfo,
|
||||
NULL, NULL, NULL);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, NULL, destroySFillOperatorInfo, NULL, NULL, NULL);
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
return pOperator;
|
||||
|
@ -6269,7 +6286,6 @@ _error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static int32_t getColumnIndexInSource(SQueriedTableInfo* pTableInfo, SExprBasicInfo* pExpr, SColumnInfo* pTagCols) {
|
||||
int32_t j = 0;
|
||||
|
||||
|
@ -6467,11 +6483,11 @@ static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableSc
|
|||
|
||||
static SInterval extractIntervalInfo(const STableScanPhysiNode* pTableScanNode) {
|
||||
SInterval interval = {
|
||||
.interval = pTableScanNode->interval,
|
||||
.sliding = pTableScanNode->sliding,
|
||||
.interval = pTableScanNode->interval,
|
||||
.sliding = pTableScanNode->sliding,
|
||||
.intervalUnit = pTableScanNode->intervalUnit,
|
||||
.slidingUnit = pTableScanNode->slidingUnit,
|
||||
.offset = pTableScanNode->offset,
|
||||
.slidingUnit = pTableScanNode->slidingUnit,
|
||||
.offset = pTableScanNode->offset,
|
||||
};
|
||||
|
||||
return interval;
|
||||
|
@ -6486,7 +6502,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode;
|
||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
int32_t numOfCols = 0;
|
||||
tsdbReaderT pDataReader = doCreateDataReader(pTableScanNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId);
|
||||
if (pDataReader == NULL && terrno != 0) {
|
||||
return NULL;
|
||||
|
@ -6497,14 +6513,15 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
|
||||
|
||||
SQueryTableDataCond cond = {0};
|
||||
int32_t code = initQueryTableDataCond(&cond, pTableScanNode);
|
||||
int32_t code = initQueryTableDataCond(&cond, pTableScanNode);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SInterval interval = extractIntervalInfo(pTableScanNode);
|
||||
return createTableScanOperatorInfo(pDataReader, &cond, numOfCols, pTableScanNode->dataRequired, pTableScanNode->scanSeq, pColList,
|
||||
pResBlock, pScanPhyNode->node.pConditions, &interval, pTableScanNode->ratio, pTaskInfo);
|
||||
return createTableScanOperatorInfo(pDataReader, &cond, numOfCols, pTableScanNode->dataRequired,
|
||||
pTableScanNode->scanSeq, pColList, pResBlock, pScanPhyNode->node.pConditions,
|
||||
&interval, pTableScanNode->ratio, pTaskInfo);
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode;
|
||||
SSDataBlock* pResBlock = createResDataBlock(pExchange->node.pOutputDataBlockDesc);
|
||||
|
@ -6512,27 +6529,30 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
||||
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; // simple child table.
|
||||
|
||||
int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId);
|
||||
int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo,
|
||||
queryId, taskId);
|
||||
SArray* tableIdList = extractTableIdList(pTableGroupInfo);
|
||||
|
||||
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
SArray* pCols = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
||||
SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle->reader, pResBlock, pCols, tableIdList, pTaskInfo);
|
||||
SOperatorInfo* pOperator =
|
||||
createStreamScanOperatorInfo(pHandle->reader, pResBlock, pCols, tableIdList, pTaskInfo, pScanPhyNode->node.pConditions);
|
||||
taosArrayDestroy(tableIdList);
|
||||
return pOperator;
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
||||
SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode;
|
||||
SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan;
|
||||
SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan;
|
||||
|
||||
SSDataBlock* pResBlock = createResDataBlock(pScanNode->node.pOutputDataBlockDesc);
|
||||
|
||||
int32_t numOfOutputCols = 0;
|
||||
SArray* colList = extractColMatchInfo(pScanNode->pScanCols, pScanNode->node.pOutputDataBlockDesc, &numOfOutputCols);
|
||||
SArray* colList =
|
||||
extractColMatchInfo(pScanNode->pScanCols, pScanNode->node.pOutputDataBlockDesc, &numOfOutputCols);
|
||||
SOperatorInfo* pOperator = createSysTableScanOperatorInfo(
|
||||
pHandle, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet,
|
||||
colList, pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId);
|
||||
pHandle, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet, colList,
|
||||
pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId);
|
||||
return pOperator;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
|
@ -6649,8 +6669,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
return pOptr;
|
||||
}
|
||||
|
||||
|
||||
static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode) {
|
||||
static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode) {
|
||||
pCond->loadExternalRows = false;
|
||||
|
||||
pCond->order = pTableScanNode->scanSeq[0] > 0 ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||
|
@ -6664,7 +6683,7 @@ static int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableS
|
|||
pCond->twindow = pTableScanNode->scanRange;
|
||||
|
||||
#if 1
|
||||
//todo work around a problem, remove it later
|
||||
// todo work around a problem, remove it later
|
||||
if ((pCond->order == TSDB_ORDER_ASC && pCond->twindow.skey > pCond->twindow.ekey) ||
|
||||
(pCond->order == TSDB_ORDER_DESC && pCond->twindow.skey < pCond->twindow.ekey)) {
|
||||
TSWAP(pCond->twindow.skey, pCond->twindow.ekey);
|
||||
|
@ -6708,22 +6727,22 @@ SArray* extractColumnInfo(SNodeList* pNodeList) {
|
|||
|
||||
// todo extract method
|
||||
SColumn c = {0};
|
||||
c.slotId = pColNode->slotId;
|
||||
c.colId = pColNode->colId;
|
||||
c.type = pColNode->node.resType.type;
|
||||
c.bytes = pColNode->node.resType.bytes;
|
||||
c.scale = pColNode->node.resType.scale;
|
||||
c.slotId = pColNode->slotId;
|
||||
c.colId = pColNode->colId;
|
||||
c.type = pColNode->node.resType.type;
|
||||
c.bytes = pColNode->node.resType.bytes;
|
||||
c.scale = pColNode->node.resType.scale;
|
||||
c.precision = pColNode->node.resType.precision;
|
||||
|
||||
taosArrayPush(pList, &c);
|
||||
} else if (nodeType(pNode->pExpr) == QUERY_NODE_VALUE) {
|
||||
SValueNode* pValNode = (SValueNode*) pNode->pExpr;
|
||||
SColumn c = {0};
|
||||
SValueNode* pValNode = (SValueNode*)pNode->pExpr;
|
||||
SColumn c = {0};
|
||||
c.slotId = pNode->slotId;
|
||||
c.colId = pNode->slotId;
|
||||
c.type = pValNode->node.type;
|
||||
c.bytes = pValNode->node.resType.bytes;
|
||||
c.scale = pValNode->node.resType.scale;
|
||||
c.colId = pNode->slotId;
|
||||
c.type = pValNode->node.type;
|
||||
c.bytes = pValNode->node.resType.bytes;
|
||||
c.scale = pValNode->node.resType.scale;
|
||||
c.precision = pValNode->node.resType.precision;
|
||||
|
||||
taosArrayPush(pList, &c);
|
||||
|
@ -6906,8 +6925,10 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle*
|
|||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
#if 0
|
||||
return tsdbQueryTables(pHandle->reader, &cond, pTableGroupInfo, queryId, taskId);
|
||||
#endif
|
||||
return tsdbQueryTables(pHandle->vnode, &cond, pTableGroupInfo, queryId, taskId);
|
||||
|
||||
_error:
|
||||
terrno = code;
|
||||
|
@ -6925,7 +6946,8 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
|||
goto _complete;
|
||||
}
|
||||
|
||||
(*pTaskInfo)->pRoot = createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, &(*pTaskInfo)->tableqinfoGroupInfo);
|
||||
(*pTaskInfo)->pRoot =
|
||||
createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, queryId, taskId, &(*pTaskInfo)->tableqinfoGroupInfo);
|
||||
if (NULL == (*pTaskInfo)->pRoot) {
|
||||
code = terrno;
|
||||
goto _complete;
|
||||
|
@ -7263,8 +7285,8 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
|
|||
pOperator->info = pInfo;
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, NULL, destroyBasicOperatorInfo,
|
||||
NULL, NULL, NULL);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, NULL, destroyBasicOperatorInfo, NULL, NULL, NULL);
|
||||
int32_t code = appendDownstream(pOperator, pDownstream, numOfDownstream);
|
||||
return pOperator;
|
||||
|
||||
|
|
|
@ -54,7 +54,9 @@ typedef struct SIFParam {
|
|||
|
||||
typedef int32_t (*sif_func_t)(SNode *left, SNode *rigth, SIFParam *output);
|
||||
// construct tag filter operator later
|
||||
static void destroyTagFilterOperatorInfo(void *param) { STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param; }
|
||||
static void destroyTagFilterOperatorInfo(void *param) {
|
||||
STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param;
|
||||
}
|
||||
|
||||
static void sifFreeParam(SIFParam *param) {
|
||||
if (param == NULL) return;
|
||||
|
@ -62,8 +64,9 @@ static void sifFreeParam(SIFParam *param) {
|
|||
}
|
||||
|
||||
static int32_t sifGetOperParamNum(EOperatorType ty) {
|
||||
if (OP_TYPE_IS_NULL == ty || OP_TYPE_IS_NOT_NULL == ty || OP_TYPE_IS_TRUE == ty || OP_TYPE_IS_NOT_TRUE == ty || OP_TYPE_IS_FALSE == ty ||
|
||||
OP_TYPE_IS_NOT_FALSE == ty || OP_TYPE_IS_UNKNOWN == ty || OP_TYPE_IS_NOT_UNKNOWN == ty || OP_TYPE_MINUS == ty) {
|
||||
if (OP_TYPE_IS_NULL == ty || OP_TYPE_IS_NOT_NULL == ty || OP_TYPE_IS_TRUE == ty || OP_TYPE_IS_NOT_TRUE == ty ||
|
||||
OP_TYPE_IS_FALSE == ty || OP_TYPE_IS_NOT_FALSE == ty || OP_TYPE_IS_UNKNOWN == ty ||
|
||||
OP_TYPE_IS_NOT_UNKNOWN == ty || OP_TYPE_MINUS == ty) {
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
|
@ -267,7 +270,8 @@ _return:
|
|||
|
||||
static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||
if (NULL == node->pParameterList || node->pParameterList->length <= 0) {
|
||||
qError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0);
|
||||
qError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList,
|
||||
node->pParameterList ? node->pParameterList->length : 0);
|
||||
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||
}
|
||||
|
||||
|
@ -341,7 +345,8 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) {
|
|||
}
|
||||
|
||||
EDealRes sifCalcWalker(SNode *node, void *context) {
|
||||
if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) || QUERY_NODE_COLUMN == nodeType(node)) {
|
||||
if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) ||
|
||||
QUERY_NODE_COLUMN == nodeType(node)) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
SIFCtx *ctx = (SIFCtx *)context;
|
||||
|
@ -383,21 +388,20 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
|
|||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
}
|
||||
nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx);
|
||||
if (ctx.code != TSDB_CODE_SUCCESS) {
|
||||
return ctx.code;
|
||||
}
|
||||
SIF_ERR_RET(ctx.code);
|
||||
|
||||
if (pDst) {
|
||||
SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
||||
if (res == NULL) {
|
||||
qError("no valid res in hash, node:(%p), type(%d)", (void *)&pNode, nodeType(pNode));
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
}
|
||||
taosArrayAddAll(pDst->result, res->result);
|
||||
|
||||
sifFreeParam(res);
|
||||
taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
SIF_RET(code);
|
||||
}
|
||||
|
||||
int32_t doFilterTag(const SNode *pFilterNode, SArray *result) {
|
||||
|
@ -407,22 +411,14 @@ int32_t doFilterTag(const SNode *pFilterNode, SArray *result) {
|
|||
|
||||
SFilterInfo *filter = NULL;
|
||||
// todo move to the initialization function
|
||||
int32_t code = filterInitFromNode((SNode *)pFilterNode, &filter, 0);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
|
||||
|
||||
SIFParam param = {0};
|
||||
code = sifCalculate((SNode *)pFilterNode, ¶m);
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
SIF_ERR_RET(sifCalculate((SNode *)pFilterNode, ¶m));
|
||||
|
||||
taosArrayAddAll(result, param.result);
|
||||
sifFreeParam(¶m);
|
||||
|
||||
return code;
|
||||
SIF_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <common/ttime.h>
|
||||
#include "common/ttime.h"
|
||||
#include "filter.h"
|
||||
#include "function.h"
|
||||
#include "functionMgt.h"
|
||||
|
@ -21,7 +21,7 @@
|
|||
#include "querynodes.h"
|
||||
#include "tglobal.h"
|
||||
#include "tname.h"
|
||||
#include "vnode.h"
|
||||
#include "systable.h"
|
||||
|
||||
#include "tdatablock.h"
|
||||
#include "tmsg.h"
|
||||
|
@ -36,6 +36,9 @@
|
|||
#define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN)
|
||||
#define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC))
|
||||
|
||||
int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo);
|
||||
|
||||
int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size, const char* dbName);
|
||||
void switchCtxOrder(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
SWITCH_ORDER(pCtx[i].order);
|
||||
|
@ -65,21 +68,6 @@ static void setupQueryRangeForReverseScan(STableScanInfo* pTableScanInfo) {
|
|||
#endif
|
||||
}
|
||||
|
||||
// relocated the column data according to the slotId
|
||||
static void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols) {
|
||||
int32_t numOfCols = pBlock->info.numOfCols;
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData* p = taosArrayGet(pCols, i);
|
||||
SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, i);
|
||||
if (!pmInfo->output) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ASSERT(pmInfo->colId == p->info.colId);
|
||||
taosArraySet(pBlock->pDataBlock, pmInfo->targetSlotId, p);
|
||||
}
|
||||
}
|
||||
|
||||
static void getNextTimeWindow(SInterval* pInterval, STimeWindow* tw, int32_t order) {
|
||||
int32_t factor = GET_FORWARD_DIRECTION_FACTOR(order);
|
||||
if (pInterval->intervalUnit != 'n' && pInterval->intervalUnit != 'y') {
|
||||
|
@ -244,11 +232,6 @@ int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo,
|
|||
}
|
||||
|
||||
relocateColumnData(pBlock, pTableScanInfo->pColMatchInfo, pCols);
|
||||
|
||||
// reset the block to be 0 by default, this blockId is assigned by physical plan and is used by direct upstream
|
||||
// operator.
|
||||
pBlock->info.blockId = 0;
|
||||
|
||||
doFilter(pTableScanInfo->pFilterNode, pBlock);
|
||||
if (pBlock->info.rows == 0) {
|
||||
pCost->filterOutBlocks += 1;
|
||||
|
@ -531,6 +514,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup)
|
|||
// NOTE: this operator does never check if current status is done or not
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SStreamBlockScanInfo* pInfo = pOperator->info;
|
||||
int32_t rows = 0;
|
||||
|
||||
pTaskInfo->code = pOperator->fpSet._openFn(pOperator);
|
||||
if (pTaskInfo->code != TSDB_CODE_SUCCESS || pOperator->status == OP_EXEC_DONE) {
|
||||
|
@ -597,6 +581,8 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup)
|
|||
pTaskInfo->code = terrno;
|
||||
return NULL;
|
||||
}
|
||||
rows = pBlockInfo->rows;
|
||||
doFilter(pInfo->pCondition, pInfo->pRes);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -605,16 +591,16 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup)
|
|||
pInfo->numOfExec++;
|
||||
pInfo->numOfRows += pBlockInfo->rows;
|
||||
|
||||
if (pBlockInfo->rows == 0) {
|
||||
if (rows == 0) {
|
||||
pOperator->status = OP_EXEC_DONE;
|
||||
}
|
||||
|
||||
return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes;
|
||||
return (rows == 0) ? NULL : pInfo->pRes;
|
||||
}
|
||||
}
|
||||
|
||||
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* pResBlock, SArray* pColList,
|
||||
SArray* pTableIdList, SExecTaskInfo* pTaskInfo) {
|
||||
SArray* pTableIdList, SExecTaskInfo* pTaskInfo, SNode* pCondition) {
|
||||
SStreamBlockScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamBlockScanInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
|
@ -652,6 +638,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock*
|
|||
|
||||
pInfo->readerHandle = streamReadHandle;
|
||||
pInfo->pRes = pResBlock;
|
||||
pInfo->pCondition = pCondition;
|
||||
|
||||
pOperator->name = "StreamBlockScanOperator";
|
||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
||||
|
@ -788,7 +775,12 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) {
|
|||
continue;
|
||||
}
|
||||
|
||||
colDataAppend(pDest, numOfRow, colDataGetData(pSrc, j), false);
|
||||
if (colDataIsNull_s(pSrc, j)) {
|
||||
colDataAppendNULL(pDest, numOfRow);
|
||||
} else {
|
||||
colDataAppend(pDest, numOfRow, colDataGetData(pSrc, j), false);
|
||||
}
|
||||
|
||||
numOfRow += 1;
|
||||
}
|
||||
} else {
|
||||
|
@ -802,6 +794,67 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) {
|
|||
return pInfo->pRes->info.rows == 0 ? NULL : pInfo->pRes;
|
||||
}
|
||||
|
||||
static SSDataBlock* buildSysTableMetaBlock() {
|
||||
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||
pBlock->info.numOfCols = 10;
|
||||
pBlock->info.hasVarCol = true;
|
||||
|
||||
pBlock->pDataBlock = taosArrayInit(pBlock->info.numOfCols, sizeof(SColumnInfoData));
|
||||
|
||||
SColumnInfoData colInfoData = {0};
|
||||
colInfoData.info.colId = 1;
|
||||
colInfoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
colInfoData.info.bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||
|
||||
colInfoData.info.colId = 2;
|
||||
colInfoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
colInfoData.info.bytes = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||
|
||||
colInfoData.info.colId = 3;
|
||||
colInfoData.info.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
colInfoData.info.bytes = 8;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||
|
||||
colInfoData.info.colId = 4;
|
||||
colInfoData.info.type = TSDB_DATA_TYPE_INT;
|
||||
colInfoData.info.bytes = 4;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||
|
||||
colInfoData.info.colId = 5;
|
||||
colInfoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
colInfoData.info.bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||
|
||||
colInfoData.info.colId = 6;
|
||||
colInfoData.info.type = TSDB_DATA_TYPE_BIGINT;
|
||||
colInfoData.info.bytes = 8;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||
|
||||
colInfoData.info.colId = 7;
|
||||
colInfoData.info.type = TSDB_DATA_TYPE_INT;
|
||||
colInfoData.info.bytes = 4;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||
|
||||
colInfoData.info.colId = 8;
|
||||
colInfoData.info.type = TSDB_DATA_TYPE_INT;
|
||||
colInfoData.info.bytes = 4;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||
|
||||
colInfoData.info.colId = 9;
|
||||
colInfoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
colInfoData.info.bytes = 512 + VARSTR_HEADER_SIZE;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||
|
||||
colInfoData.info.colId = 10;
|
||||
colInfoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
colInfoData.info.bytes = 20 + VARSTR_HEADER_SIZE;
|
||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||
|
||||
return pBlock;
|
||||
}
|
||||
|
||||
static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||
// build message and send to mnode to fetch the content of system tables.
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
@ -810,115 +863,135 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
// retrieve local table list info from vnode
|
||||
const char* name = tNameGetTableName(&pInfo->name);
|
||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||
if (pInfo->pCur == NULL) {
|
||||
pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta);
|
||||
}
|
||||
// the retrieve is executed on the mnode, so return tables that belongs to the information schema database.
|
||||
if (pInfo->readHandle.mnd != NULL) {
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
buildSysDbTableInfo(pInfo);
|
||||
|
||||
int32_t tableNameSlotId = 1;
|
||||
SColumnInfoData* pTableNameCol = taosArrayGet(pInfo->pRes->pDataBlock, tableNameSlotId);
|
||||
doFilterResult(pInfo);
|
||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||
|
||||
int32_t numOfRows = 0;
|
||||
pOperator->status = OP_EXEC_DONE;
|
||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||
} else {
|
||||
if (pInfo->pCur == NULL) {
|
||||
pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta);
|
||||
}
|
||||
|
||||
const char* db = NULL;
|
||||
int32_t vgId = 0;
|
||||
vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId);
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
|
||||
SName sn = {0};
|
||||
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
tNameFromString(&sn, db, T_NAME_ACCT|T_NAME_DB);
|
||||
int32_t numOfRows = 0;
|
||||
|
||||
tNameGetDbName(&sn, varDataVal(dbname));
|
||||
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||
const char* db = NULL;
|
||||
int32_t vgId = 0;
|
||||
vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId);
|
||||
|
||||
char n[TSDB_TABLE_NAME_LEN] = {0};
|
||||
while (metaTbCursorNext(pInfo->pCur) == 0) {
|
||||
STR_TO_VARSTR(n, pInfo->pCur->mr.me.name);
|
||||
colDataAppend(pTableNameCol, numOfRows, n, false);
|
||||
SName sn = {0};
|
||||
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
|
||||
|
||||
int32_t tableType = pInfo->pCur->mr.me.type;
|
||||
tNameGetDbName(&sn, varDataVal(dbname));
|
||||
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||
|
||||
// database name
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 0);
|
||||
colDataAppend(pColInfoData, numOfRows, dbname, false);
|
||||
SSDataBlock* p = buildSysTableMetaBlock();
|
||||
blockDataEnsureCapacity(p, pInfo->capacity);
|
||||
|
||||
// vgId
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 6);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*) &vgId, false);
|
||||
char n[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
while (metaTbCursorNext(pInfo->pCur) == 0) {
|
||||
STR_TO_VARSTR(n, pInfo->pCur->mr.me.name);
|
||||
|
||||
// table comment
|
||||
// todo: set the correct comment
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 8);
|
||||
colDataAppendNULL(pColInfoData, numOfRows);
|
||||
// table name
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(p->pDataBlock, 0);
|
||||
colDataAppend(pColInfoData, numOfRows, n, false);
|
||||
|
||||
char str[256] = {0};
|
||||
if (tableType == TSDB_CHILD_TABLE) {
|
||||
SMetaReader mr = {0};
|
||||
metaReaderInit(&mr, pInfo->readHandle.meta, 0);
|
||||
metaGetTableEntryByUid(&mr, pInfo->pCur->mr.me.ctbEntry.suid);
|
||||
// database name
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 1);
|
||||
colDataAppend(pColInfoData, numOfRows, dbname, false);
|
||||
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 3);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*) &mr.me.stbEntry.schema.nCols, false);
|
||||
// vgId
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 6);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*)&vgId, false);
|
||||
|
||||
// create time
|
||||
int64_t ts = pInfo->pCur->mr.me.ctbEntry.ctime;
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 2);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*) &ts, false);
|
||||
|
||||
// super table name
|
||||
STR_TO_VARSTR(str, mr.me.name);
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 4);
|
||||
colDataAppend(pColInfoData, numOfRows, str, false);
|
||||
metaReaderClear(&mr);
|
||||
|
||||
// uid
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 5);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.uid, false);
|
||||
|
||||
// ttl
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 7);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.ctbEntry.ttlDays, false);
|
||||
|
||||
STR_TO_VARSTR(str, "CHILD_TABLE");
|
||||
} else if (tableType == TSDB_NORMAL_TABLE) {
|
||||
// create time
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 2);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.ntbEntry.ctime, false);
|
||||
|
||||
// number of columns
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 3);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.ntbEntry.schema.nCols, false);
|
||||
|
||||
// super table name
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 4);
|
||||
// table comment
|
||||
// todo: set the correct comment
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 8);
|
||||
colDataAppendNULL(pColInfoData, numOfRows);
|
||||
|
||||
// uid
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 5);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.uid, false);
|
||||
char str[256] = {0};
|
||||
int32_t tableType = pInfo->pCur->mr.me.type;
|
||||
if (tableType == TSDB_CHILD_TABLE) {
|
||||
// create time
|
||||
int64_t ts = pInfo->pCur->mr.me.ctbEntry.ctime;
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 2);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*)&ts, false);
|
||||
|
||||
// ttl
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 7);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*) &pInfo->pCur->mr.me.ntbEntry.ttlDays, false);
|
||||
SMetaReader mr = {0};
|
||||
metaReaderInit(&mr, pInfo->readHandle.meta, 0);
|
||||
metaGetTableEntryByUid(&mr, pInfo->pCur->mr.me.ctbEntry.suid);
|
||||
|
||||
STR_TO_VARSTR(str, "NORMAL_TABLE");
|
||||
// number of columns
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 3);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*)&mr.me.stbEntry.schema.nCols, false);
|
||||
|
||||
// super table name
|
||||
STR_TO_VARSTR(str, mr.me.name);
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 4);
|
||||
colDataAppend(pColInfoData, numOfRows, str, false);
|
||||
metaReaderClear(&mr);
|
||||
|
||||
// uid
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 5);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.uid, false);
|
||||
|
||||
// ttl
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 7);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ctbEntry.ttlDays, false);
|
||||
|
||||
STR_TO_VARSTR(str, "CHILD_TABLE");
|
||||
} else if (tableType == TSDB_NORMAL_TABLE) {
|
||||
// create time
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 2);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ntbEntry.ctime, false);
|
||||
|
||||
// number of columns
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 3);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ntbEntry.schema.nCols, false);
|
||||
|
||||
// super table name
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 4);
|
||||
colDataAppendNULL(pColInfoData, numOfRows);
|
||||
|
||||
// uid
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 5);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.uid, false);
|
||||
|
||||
// ttl
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 7);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*)&pInfo->pCur->mr.me.ntbEntry.ttlDays, false);
|
||||
|
||||
STR_TO_VARSTR(str, "NORMAL_TABLE");
|
||||
}
|
||||
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 9);
|
||||
colDataAppend(pColInfoData, numOfRows, str, false);
|
||||
|
||||
if (++numOfRows >= pInfo->capacity) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 9);
|
||||
colDataAppend(pColInfoData, numOfRows, str, false);
|
||||
p->info.rows = numOfRows;
|
||||
pInfo->pRes->info.rows = numOfRows;
|
||||
|
||||
if (++numOfRows >= pInfo->capacity) {
|
||||
break;
|
||||
}
|
||||
relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock);
|
||||
doFilterResult(pInfo);
|
||||
|
||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||
}
|
||||
|
||||
pInfo->loadInfo.totalRows += numOfRows;
|
||||
pInfo->pRes->info.rows = numOfRows;
|
||||
|
||||
// pInfo->elapsedTime;
|
||||
// pInfo->totalBytes;
|
||||
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
|
||||
} else { // load the meta from mnode of the given epset
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
|
@ -988,6 +1061,67 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo) {
|
||||
SSDataBlock* p = buildSysTableMetaBlock();
|
||||
blockDataEnsureCapacity(p, pInfo->capacity);
|
||||
|
||||
size_t size = 0;
|
||||
const SSysTableMeta* pSysDbTableMeta = NULL;
|
||||
|
||||
getInfosDbMeta(&pSysDbTableMeta, &size);
|
||||
p->info.rows = buildDbTableInfoBlock(p, pSysDbTableMeta, size, TSDB_INFORMATION_SCHEMA_DB);
|
||||
|
||||
getPerfDbMeta(&pSysDbTableMeta, &size);
|
||||
p->info.rows = buildDbTableInfoBlock(p, pSysDbTableMeta, size, TSDB_PERFORMANCE_SCHEMA_DB);
|
||||
|
||||
relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock);
|
||||
// blockDataDestroy(p); todo handle memory leak
|
||||
|
||||
pInfo->pRes->info.rows = p->info.rows;
|
||||
return p->info.rows;
|
||||
}
|
||||
|
||||
int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size, const char* dbName) {
|
||||
char n[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
int32_t numOfRows = p->info.rows;
|
||||
|
||||
for(int32_t i = 0; i < size; ++i) {
|
||||
const SSysTableMeta* pm = &pSysDbTableMeta[i];
|
||||
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(p->pDataBlock, 0);
|
||||
|
||||
STR_TO_VARSTR(n, pm->name);
|
||||
colDataAppend(pColInfoData, numOfRows, n, false);
|
||||
|
||||
// database name
|
||||
STR_TO_VARSTR(n, dbName);
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 1);
|
||||
colDataAppend(pColInfoData, numOfRows, n, false);
|
||||
|
||||
// create time
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 2);
|
||||
colDataAppendNULL(pColInfoData, numOfRows);
|
||||
|
||||
// number of columns
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 3);
|
||||
colDataAppend(pColInfoData, numOfRows, (char*)&pm->colNum, false);
|
||||
|
||||
for(int32_t j = 4; j <= 8; ++j) {
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, j);
|
||||
colDataAppendNULL(pColInfoData, numOfRows);
|
||||
}
|
||||
|
||||
STR_TO_VARSTR(n, "SYSTEM_TABLE");
|
||||
|
||||
pColInfoData = taosArrayGet(p->pDataBlock, 9);
|
||||
colDataAppend(pColInfoData, numOfRows, n, false);
|
||||
|
||||
numOfRows += 1;
|
||||
}
|
||||
|
||||
return numOfRows;
|
||||
}
|
||||
|
||||
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSDataBlock* pResBlock, const SName* pName,
|
||||
SNode* pCondition, SEpSet epset, SArray* colList,
|
||||
SExecTaskInfo* pTaskInfo, bool showRewrite, int32_t accountId) {
|
||||
|
|
|
@ -68,6 +68,11 @@ bool getTopBotFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv);
|
|||
int32_t topFunction(SqlFunctionCtx *pCtx);
|
||||
int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
||||
bool getSpreadFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||
bool spreadFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||
int32_t spreadFunction(SqlFunctionCtx* pCtx);
|
||||
int32_t spreadFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -212,7 +212,16 @@ static int32_t translateBottom(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
}
|
||||
|
||||
static int32_t translateSpread(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
// todo
|
||||
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) && TSDB_DATA_TYPE_TIMESTAMP != 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;
|
||||
}
|
||||
|
||||
|
@ -248,7 +257,7 @@ static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
}
|
||||
|
||||
pFunc->node.resType =
|
||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_SMALLINT].bytes, .type = TSDB_DATA_TYPE_SMALLINT};
|
||||
(SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -431,435 +440,541 @@ static int32_t translateToJson(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
}
|
||||
|
||||
const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||
{.name = "count",
|
||||
.type = FUNCTION_TYPE_COUNT,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||
.translateFunc = translateCount,
|
||||
.dataRequiredFunc = countDataRequired,
|
||||
.getEnvFunc = getCountFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = countFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{.name = "sum",
|
||||
.type = FUNCTION_TYPE_SUM,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||
.translateFunc = translateSum,
|
||||
.dataRequiredFunc = statisDataRequired,
|
||||
.getEnvFunc = getSumFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = sumFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{.name = "min",
|
||||
.type = FUNCTION_TYPE_MIN,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||
.translateFunc = translateInOutNum,
|
||||
.dataRequiredFunc = statisDataRequired,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = minFunctionSetup,
|
||||
.processFunc = minFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{.name = "max",
|
||||
.type = FUNCTION_TYPE_MAX,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||
.translateFunc = translateInOutNum,
|
||||
.dataRequiredFunc = statisDataRequired,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{.name = "stddev",
|
||||
.type = FUNCTION_TYPE_STDDEV,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = getStddevFuncEnv,
|
||||
.initFunc = stddevFunctionSetup,
|
||||
.processFunc = stddevFunction,
|
||||
.finalizeFunc = stddevFinalize},
|
||||
{.name = "avg",
|
||||
.type = FUNCTION_TYPE_AVG,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = getAvgFuncEnv,
|
||||
.initFunc = avgFunctionSetup,
|
||||
.processFunc = avgFunction,
|
||||
.finalizeFunc = avgFinalize},
|
||||
{.name = "percentile",
|
||||
.type = FUNCTION_TYPE_PERCENTILE,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translatePercentile,
|
||||
.getEnvFunc = getPercentileFuncEnv,
|
||||
.initFunc = percentileFunctionSetup,
|
||||
.processFunc = percentileFunction,
|
||||
.finalizeFunc = percentileFinalize},
|
||||
{.name = "apercentile",
|
||||
.type = FUNCTION_TYPE_APERCENTILE,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateApercentile,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{
|
||||
.name = "top",
|
||||
.type = FUNCTION_TYPE_TOP,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateTop,
|
||||
.getEnvFunc = getTopBotFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = topFunction,
|
||||
.finalizeFunc = topBotFinalize,
|
||||
},
|
||||
{.name = "bottom",
|
||||
.type = FUNCTION_TYPE_BOTTOM,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateBottom,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{.name = "spread",
|
||||
.type = FUNCTION_TYPE_SPREAD,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateSpread,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{.name = "last_row",
|
||||
.type = FUNCTION_TYPE_LAST_ROW,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
||||
.translateFunc = translateLastRow,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{.name = "first",
|
||||
.type = FUNCTION_TYPE_FIRST,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
||||
.translateFunc = translateFirstLast,
|
||||
.getEnvFunc = getFirstLastFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = firstFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{.name = "last",
|
||||
.type = FUNCTION_TYPE_LAST,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
||||
.translateFunc = translateFirstLast,
|
||||
.getEnvFunc = getFirstLastFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = lastFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{.name = "diff",
|
||||
.type = FUNCTION_TYPE_DIFF,
|
||||
.classification = FUNC_MGT_NONSTANDARD_SQL_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = getDiffFuncEnv,
|
||||
.initFunc = diffFunctionSetup,
|
||||
.processFunc = diffFunction,
|
||||
.finalizeFunc = functionFinalize},
|
||||
{.name = "abs",
|
||||
.type = FUNCTION_TYPE_ABS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = absFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "log",
|
||||
.type = FUNCTION_TYPE_LOG,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateIn2NumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = logFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "pow",
|
||||
.type = FUNCTION_TYPE_POW,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateIn2NumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = powFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "sqrt",
|
||||
.type = FUNCTION_TYPE_SQRT,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = sqrtFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "ceil",
|
||||
.type = FUNCTION_TYPE_CEIL,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = ceilFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "floor",
|
||||
.type = FUNCTION_TYPE_FLOOR,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = floorFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "round",
|
||||
.type = FUNCTION_TYPE_ROUND,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = roundFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "sin",
|
||||
.type = FUNCTION_TYPE_SIN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = sinFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "cos",
|
||||
.type = FUNCTION_TYPE_COS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = cosFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "tan",
|
||||
.type = FUNCTION_TYPE_TAN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = tanFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "asin",
|
||||
.type = FUNCTION_TYPE_ASIN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = asinFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "acos",
|
||||
.type = FUNCTION_TYPE_ACOS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = acosFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "atan",
|
||||
.type = FUNCTION_TYPE_ATAN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = atanFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "length",
|
||||
.type = FUNCTION_TYPE_LENGTH,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateLength,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = lengthFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "char_length",
|
||||
.type = FUNCTION_TYPE_CHAR_LENGTH,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateLength,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = charLengthFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "concat",
|
||||
.type = FUNCTION_TYPE_CONCAT,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateConcat,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = concatFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "concat_ws",
|
||||
.type = FUNCTION_TYPE_CONCAT_WS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateConcatWs,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = concatWsFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "lower",
|
||||
.type = FUNCTION_TYPE_LOWER,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = lowerFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "upper",
|
||||
.type = FUNCTION_TYPE_UPPER,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = upperFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "ltrim",
|
||||
.type = FUNCTION_TYPE_LTRIM,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = ltrimFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "rtrim",
|
||||
.type = FUNCTION_TYPE_RTRIM,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = rtrimFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "substr",
|
||||
.type = FUNCTION_TYPE_SUBSTR,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateSubstr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = substrFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "cast",
|
||||
.type = FUNCTION_TYPE_CAST,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateCast,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = castFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "to_iso8601",
|
||||
.type = FUNCTION_TYPE_TO_ISO8601,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateToIso8601,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = toISO8601Function,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "to_unixtimestamp",
|
||||
.type = FUNCTION_TYPE_TO_UNIXTIMESTAMP,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateToUnixtimestamp,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = toUnixtimestampFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "timetruncate",
|
||||
.type = FUNCTION_TYPE_TIMETRUNCATE,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateTimeTruncate,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = timeTruncateFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "timediff",
|
||||
.type = FUNCTION_TYPE_TIMEDIFF,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateTimeDiff,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = timeDiffFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "now",
|
||||
.type = FUNCTION_TYPE_NOW,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = nowFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "today",
|
||||
.type = FUNCTION_TYPE_TODAY,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = todayFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "timezone",
|
||||
.type = FUNCTION_TYPE_TIMEZONE,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateTimezone,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = timezoneFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "_rowts",
|
||||
.type = FUNCTION_TYPE_ROWTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "tbname",
|
||||
.type = FUNCTION_TYPE_TBNAME,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_SCAN_PC_FUNC,
|
||||
.translateFunc = translateTbnameColumn,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "_qstartts",
|
||||
.type = FUNCTION_TYPE_QSTARTTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = qStartTsFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "_qendts",
|
||||
.type = FUNCTION_TYPE_QENDTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = qEndTsFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "_wstartts",
|
||||
.type = FUNCTION_TYPE_WSTARTTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winStartTsFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "_wendts",
|
||||
.type = FUNCTION_TYPE_WENDTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winEndTsFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "_wduration",
|
||||
.type = FUNCTION_TYPE_WDURATION,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateWduration,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winDurFunction,
|
||||
.finalizeFunc = NULL},
|
||||
{.name = "to_json",
|
||||
.type = FUNCTION_TYPE_TO_JSON,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateToJson,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = toJsonFunction,
|
||||
.finalizeFunc = NULL}};
|
||||
{
|
||||
.name = "count",
|
||||
.type = FUNCTION_TYPE_COUNT,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||
.translateFunc = translateCount,
|
||||
.dataRequiredFunc = countDataRequired,
|
||||
.getEnvFunc = getCountFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = countFunction,
|
||||
.finalizeFunc = functionFinalize
|
||||
},
|
||||
{
|
||||
.name = "sum",
|
||||
.type = FUNCTION_TYPE_SUM,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||
.translateFunc = translateSum,
|
||||
.dataRequiredFunc = statisDataRequired,
|
||||
.getEnvFunc = getSumFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = sumFunction,
|
||||
.finalizeFunc = functionFinalize
|
||||
},
|
||||
{
|
||||
.name = "min",
|
||||
.type = FUNCTION_TYPE_MIN,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||
.translateFunc = translateInOutNum,
|
||||
.dataRequiredFunc = statisDataRequired,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = minFunctionSetup,
|
||||
.processFunc = minFunction,
|
||||
.finalizeFunc = functionFinalize
|
||||
},
|
||||
{
|
||||
.name = "max",
|
||||
.type = FUNCTION_TYPE_MAX,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||
.translateFunc = translateInOutNum,
|
||||
.dataRequiredFunc = statisDataRequired,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
.finalizeFunc = functionFinalize
|
||||
},
|
||||
{
|
||||
.name = "stddev",
|
||||
.type = FUNCTION_TYPE_STDDEV,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = getStddevFuncEnv,
|
||||
.initFunc = stddevFunctionSetup,
|
||||
.processFunc = stddevFunction,
|
||||
.finalizeFunc = stddevFinalize
|
||||
},
|
||||
{
|
||||
.name = "avg",
|
||||
.type = FUNCTION_TYPE_AVG,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = getAvgFuncEnv,
|
||||
.initFunc = avgFunctionSetup,
|
||||
.processFunc = avgFunction,
|
||||
.finalizeFunc = avgFinalize
|
||||
},
|
||||
{
|
||||
.name = "percentile",
|
||||
.type = FUNCTION_TYPE_PERCENTILE,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translatePercentile,
|
||||
.getEnvFunc = getPercentileFuncEnv,
|
||||
.initFunc = percentileFunctionSetup,
|
||||
.processFunc = percentileFunction,
|
||||
.finalizeFunc = percentileFinalize
|
||||
},
|
||||
{
|
||||
.name = "apercentile",
|
||||
.type = FUNCTION_TYPE_APERCENTILE,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateApercentile,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
.finalizeFunc = functionFinalize
|
||||
},
|
||||
{
|
||||
.name = "top",
|
||||
.type = FUNCTION_TYPE_TOP,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateTop,
|
||||
.getEnvFunc = getTopBotFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = topFunction,
|
||||
.finalizeFunc = topBotFinalize,
|
||||
},
|
||||
{
|
||||
.name = "bottom",
|
||||
.type = FUNCTION_TYPE_BOTTOM,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateBottom,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
.finalizeFunc = functionFinalize
|
||||
},
|
||||
{
|
||||
.name = "spread",
|
||||
.type = FUNCTION_TYPE_SPREAD,
|
||||
.classification = FUNC_MGT_AGG_FUNC,
|
||||
.translateFunc = translateSpread,
|
||||
.dataRequiredFunc = statisDataRequired,
|
||||
.getEnvFunc = getSpreadFuncEnv,
|
||||
.initFunc = spreadFunctionSetup,
|
||||
.processFunc = spreadFunction,
|
||||
.finalizeFunc = spreadFinalize
|
||||
},
|
||||
{
|
||||
.name = "last_row",
|
||||
.type = FUNCTION_TYPE_LAST_ROW,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
||||
.translateFunc = translateLastRow,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = maxFunctionSetup,
|
||||
.processFunc = maxFunction,
|
||||
.finalizeFunc = functionFinalize
|
||||
},
|
||||
{
|
||||
.name = "first",
|
||||
.type = FUNCTION_TYPE_FIRST,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
||||
.translateFunc = translateFirstLast,
|
||||
.getEnvFunc = getFirstLastFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = firstFunction,
|
||||
.finalizeFunc = functionFinalize
|
||||
},
|
||||
{
|
||||
.name = "last",
|
||||
.type = FUNCTION_TYPE_LAST,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC,
|
||||
.translateFunc = translateFirstLast,
|
||||
.getEnvFunc = getFirstLastFuncEnv,
|
||||
.initFunc = functionSetup,
|
||||
.processFunc = lastFunction,
|
||||
.finalizeFunc = functionFinalize
|
||||
},
|
||||
{
|
||||
.name = "diff",
|
||||
.type = FUNCTION_TYPE_DIFF,
|
||||
.classification = FUNC_MGT_NONSTANDARD_SQL_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = getDiffFuncEnv,
|
||||
.initFunc = diffFunctionSetup,
|
||||
.processFunc = diffFunction,
|
||||
.finalizeFunc = functionFinalize
|
||||
},
|
||||
{
|
||||
.name = "abs",
|
||||
.type = FUNCTION_TYPE_ABS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = absFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "log",
|
||||
.type = FUNCTION_TYPE_LOG,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateIn2NumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = logFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "pow",
|
||||
.type = FUNCTION_TYPE_POW,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateIn2NumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = powFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "sqrt",
|
||||
.type = FUNCTION_TYPE_SQRT,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = sqrtFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "ceil",
|
||||
.type = FUNCTION_TYPE_CEIL,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = ceilFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "floor",
|
||||
.type = FUNCTION_TYPE_FLOOR,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = floorFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "round",
|
||||
.type = FUNCTION_TYPE_ROUND,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = roundFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "sin",
|
||||
.type = FUNCTION_TYPE_SIN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = sinFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "cos",
|
||||
.type = FUNCTION_TYPE_COS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = cosFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "tan",
|
||||
.type = FUNCTION_TYPE_TAN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = tanFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "asin",
|
||||
.type = FUNCTION_TYPE_ASIN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = asinFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "acos",
|
||||
.type = FUNCTION_TYPE_ACOS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = acosFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "atan",
|
||||
.type = FUNCTION_TYPE_ATAN,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateInNumOutDou,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = atanFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "length",
|
||||
.type = FUNCTION_TYPE_LENGTH,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateLength,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = lengthFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "char_length",
|
||||
.type = FUNCTION_TYPE_CHAR_LENGTH,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateLength,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = charLengthFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "concat",
|
||||
.type = FUNCTION_TYPE_CONCAT,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateConcat,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = concatFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "concat_ws",
|
||||
.type = FUNCTION_TYPE_CONCAT_WS,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateConcatWs,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = concatWsFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "lower",
|
||||
.type = FUNCTION_TYPE_LOWER,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = lowerFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "upper",
|
||||
.type = FUNCTION_TYPE_UPPER,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = upperFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "ltrim",
|
||||
.type = FUNCTION_TYPE_LTRIM,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = ltrimFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "rtrim",
|
||||
.type = FUNCTION_TYPE_RTRIM,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateInOutStr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = rtrimFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "substr",
|
||||
.type = FUNCTION_TYPE_SUBSTR,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
|
||||
.translateFunc = translateSubstr,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = substrFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "cast",
|
||||
.type = FUNCTION_TYPE_CAST,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateCast,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = castFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "to_iso8601",
|
||||
.type = FUNCTION_TYPE_TO_ISO8601,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateToIso8601,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = toISO8601Function,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "to_unixtimestamp",
|
||||
.type = FUNCTION_TYPE_TO_UNIXTIMESTAMP,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateToUnixtimestamp,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = toUnixtimestampFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "timetruncate",
|
||||
.type = FUNCTION_TYPE_TIMETRUNCATE,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateTimeTruncate,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = timeTruncateFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "timediff",
|
||||
.type = FUNCTION_TYPE_TIMEDIFF,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateTimeDiff,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = timeDiffFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "now",
|
||||
.type = FUNCTION_TYPE_NOW,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = nowFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "today",
|
||||
.type = FUNCTION_TYPE_TODAY,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = todayFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "timezone",
|
||||
.type = FUNCTION_TYPE_TIMEZONE,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateTimezone,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = timezoneFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_rowts",
|
||||
.type = FUNCTION_TYPE_ROWTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "tbname",
|
||||
.type = FUNCTION_TYPE_TBNAME,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
|
||||
.translateFunc = translateTbnameColumn,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = NULL,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_qstartts",
|
||||
.type = FUNCTION_TYPE_QSTARTTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = qStartTsFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_qendts",
|
||||
.type = FUNCTION_TYPE_QENDTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = qEndTsFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_wstartts",
|
||||
.type = FUNCTION_TYPE_WSTARTTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winStartTsFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_wendts",
|
||||
.type = FUNCTION_TYPE_WENDTS,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateTimePseudoColumn,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winEndTsFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "_wduration",
|
||||
.type = FUNCTION_TYPE_WDURATION,
|
||||
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
|
||||
.translateFunc = translateWduration,
|
||||
.getEnvFunc = getTimePseudoFuncEnv,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = winDurFunction,
|
||||
.finalizeFunc = NULL
|
||||
},
|
||||
{
|
||||
.name = "to_json",
|
||||
.type = FUNCTION_TYPE_TO_JSON,
|
||||
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||
.translateFunc = translateToJson,
|
||||
.getEnvFunc = NULL,
|
||||
.initFunc = NULL,
|
||||
.sprocessFunc = toJsonFunction,
|
||||
.finalizeFunc = NULL
|
||||
}
|
||||
};
|
||||
|
||||
const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFuncDefinition));
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -588,6 +588,259 @@ static int32_t jsonToLogicSortNode(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkPartitionLogicPlanPartitionKeys = "PartitionKeys";
|
||||
|
||||
static int32_t logicPartitionNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SPartitionLogicNode* pNode = (const SPartitionLogicNode*)pObj;
|
||||
|
||||
int32_t code = logicPlanNodeToJson(pObj, pJson);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkPartitionLogicPlanPartitionKeys, pNode->pPartitionKeys);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToLogicPartitionNode(const SJson* pJson, void* pObj) {
|
||||
SPartitionLogicNode* pNode = (SPartitionLogicNode*)pObj;
|
||||
|
||||
int32_t code = jsonToLogicPlanNode(pJson, pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkPartitionLogicPlanPartitionKeys, &pNode->pPartitionKeys);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkSubplanIdQueryId = "QueryId";
|
||||
static const char* jkSubplanIdGroupId = "GroupId";
|
||||
static const char* jkSubplanIdSubplanId = "SubplanId";
|
||||
|
||||
static int32_t subplanIdToJson(const void* pObj, SJson* pJson) {
|
||||
const SSubplanId* pNode = (const SSubplanId*)pObj;
|
||||
|
||||
int32_t code = tjsonAddIntegerToObject(pJson, jkSubplanIdQueryId, pNode->queryId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkSubplanIdGroupId, pNode->groupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkSubplanIdSubplanId, pNode->subplanId);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToSubplanId(const SJson* pJson, void* pObj) {
|
||||
SSubplanId* pNode = (SSubplanId*)pObj;
|
||||
|
||||
int32_t code = tjsonGetUBigIntValue(pJson, jkSubplanIdQueryId, &pNode->queryId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkSubplanIdGroupId, &pNode->groupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkSubplanIdSubplanId, &pNode->subplanId);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkEndPointFqdn = "Fqdn";
|
||||
static const char* jkEndPointPort = "Port";
|
||||
|
||||
static int32_t epToJson(const void* pObj, SJson* pJson) {
|
||||
const SEp* pNode = (const SEp*)pObj;
|
||||
|
||||
int32_t code = tjsonAddStringToObject(pJson, jkEndPointFqdn, pNode->fqdn);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkEndPointPort, pNode->port);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToEp(const SJson* pJson, void* pObj) {
|
||||
SEp* pNode = (SEp*)pObj;
|
||||
|
||||
int32_t code = tjsonGetStringValue(pJson, jkEndPointFqdn, pNode->fqdn);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetSmallIntValue(pJson, jkEndPointPort, &pNode->port);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkEpSetInUse = "InUse";
|
||||
static const char* jkEpSetNumOfEps = "NumOfEps";
|
||||
static const char* jkEpSetEps = "Eps";
|
||||
|
||||
static int32_t epSetToJson(const void* pObj, SJson* pJson) {
|
||||
const SEpSet* pNode = (const SEpSet*)pObj;
|
||||
|
||||
int32_t code = tjsonAddIntegerToObject(pJson, jkEpSetInUse, pNode->inUse);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkEpSetNumOfEps, pNode->numOfEps);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddArray(pJson, jkEpSetEps, epToJson, pNode->eps, sizeof(SEp), pNode->numOfEps);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToEpSet(const SJson* pJson, void* pObj) {
|
||||
SEpSet* pNode = (SEpSet*)pObj;
|
||||
|
||||
int32_t code = tjsonGetTinyIntValue(pJson, jkEpSetInUse, &pNode->inUse);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetTinyIntValue(pJson, jkEpSetNumOfEps, &pNode->numOfEps);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonToArray(pJson, jkEpSetEps, jsonToEp, pNode->eps, sizeof(SEp));
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkVgroupInfoVgId = "VgId";
|
||||
static const char* jkVgroupInfoHashBegin = "HashBegin";
|
||||
static const char* jkVgroupInfoHashEnd = "HashEnd";
|
||||
static const char* jkVgroupInfoEpSet = "EpSet";
|
||||
static const char* jkVgroupInfoNumOfTable = "NumOfTable";
|
||||
|
||||
static int32_t vgroupInfoToJson(const void* pObj, SJson* pJson) {
|
||||
const SVgroupInfo* pNode = (const SVgroupInfo*)pObj;
|
||||
|
||||
int32_t code = tjsonAddIntegerToObject(pJson, jkVgroupInfoVgId, pNode->vgId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkVgroupInfoHashBegin, pNode->hashBegin);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkVgroupInfoHashEnd, pNode->hashEnd);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkVgroupInfoEpSet, epSetToJson, &pNode->epSet);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkVgroupInfoNumOfTable, pNode->numOfTable);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToVgroupInfo(const SJson* pJson, void* pObj) {
|
||||
SVgroupInfo* pNode = (SVgroupInfo*)pObj;
|
||||
|
||||
int32_t code = tjsonGetIntValue(pJson, jkVgroupInfoVgId, &pNode->vgId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetUIntValue(pJson, jkVgroupInfoHashBegin, &pNode->hashBegin);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetUIntValue(pJson, jkVgroupInfoHashEnd, &pNode->hashEnd);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonToObject(pJson, jkVgroupInfoEpSet, jsonToEpSet, &pNode->epSet);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkVgroupInfoNumOfTable, &pNode->numOfTable);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkVgroupsInfoNum = "Num";
|
||||
static const char* jkVgroupsInfoVgroups = "Vgroups";
|
||||
|
||||
static int32_t vgroupsInfoToJson(const void* pObj, SJson* pJson) {
|
||||
const SVgroupsInfo* pNode = (const SVgroupsInfo*)pObj;
|
||||
|
||||
int32_t code = tjsonAddIntegerToObject(pJson, jkVgroupsInfoNum, pNode->numOfVgroups);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddArray(pJson, jkVgroupsInfoVgroups, vgroupInfoToJson, pNode->vgroups, sizeof(SVgroupInfo),
|
||||
pNode->numOfVgroups);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToVgroupsInfo(const SJson* pJson, void* pObj) {
|
||||
SVgroupsInfo* pNode = (SVgroupsInfo*)pObj;
|
||||
|
||||
int32_t code = tjsonGetIntValue(pJson, jkVgroupsInfoNum, &pNode->numOfVgroups);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonToArray(pJson, jkVgroupsInfoVgroups, jsonToVgroupInfo, pNode->vgroups, sizeof(SVgroupInfo));
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkLogicSubplanId = "Id";
|
||||
static const char* jkLogicSubplanChildren = "Children";
|
||||
static const char* jkLogicSubplanRootNode = "RootNode";
|
||||
static const char* jkLogicSubplanType = "SubplanType";
|
||||
static const char* jkLogicSubplanVgroupsSize = "VgroupsSize";
|
||||
static const char* jkLogicSubplanVgroups = "Vgroups";
|
||||
static const char* jkLogicSubplanLevel = "Level";
|
||||
static const char* jkLogicSubplanSplitFlag = "SplitFlag";
|
||||
|
||||
static int32_t logicSubplanToJson(const void* pObj, SJson* pJson) {
|
||||
const SLogicSubplan* pNode = (const SLogicSubplan*)pObj;
|
||||
|
||||
int32_t code = tjsonAddObject(pJson, jkLogicSubplanId, subplanIdToJson, &pNode->id);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodeListToJson(pJson, jkLogicSubplanChildren, pNode->pChildren);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkLogicSubplanRootNode, nodeToJson, pNode->pNode);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkLogicSubplanType, pNode->subplanType);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkLogicSubplanVgroupsSize, VGROUPS_INFO_SIZE(pNode->pVgroupList));
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkLogicSubplanVgroups, vgroupsInfoToJson, pNode->pVgroupList);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkLogicSubplanLevel, pNode->level);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkLogicSubplanSplitFlag, pNode->splitFlag);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToLogicSubplan(const SJson* pJson, void* pObj) {
|
||||
SLogicSubplan* pNode = (SLogicSubplan*)pObj;
|
||||
|
||||
int32_t code = tjsonToObject(pJson, jkLogicSubplanId, jsonToSubplanId, &pNode->id);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkLogicSubplanChildren, &pNode->pChildren);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkLogicSubplanRootNode, (SNode**)&pNode->pNode);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetNumberValue(pJson, jkLogicSubplanType, pNode->subplanType);
|
||||
}
|
||||
int32_t objSize = 0;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkLogicSubplanVgroupsSize, &objSize);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonMakeObject(pJson, jkLogicSubplanVgroups, jsonToVgroupsInfo, (void**)&pNode->pVgroupList, objSize);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkLogicSubplanLevel, &pNode->level);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkLogicSubplanSplitFlag, &pNode->splitFlag);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkJoinLogicPlanJoinType = "JoinType";
|
||||
static const char* jkJoinLogicPlanOnConditions = "OnConditions";
|
||||
|
||||
|
@ -837,63 +1090,6 @@ static int32_t physiStreamScanNodeToJson(const void* pObj, SJson* pJson) { retur
|
|||
|
||||
static int32_t jsonToPhysiStreamScanNode(const SJson* pJson, void* pObj) { return jsonToPhysiScanNode(pJson, pObj); }
|
||||
|
||||
static const char* jkEndPointFqdn = "Fqdn";
|
||||
static const char* jkEndPointPort = "Port";
|
||||
|
||||
static int32_t epToJson(const void* pObj, SJson* pJson) {
|
||||
const SEp* pNode = (const SEp*)pObj;
|
||||
|
||||
int32_t code = tjsonAddStringToObject(pJson, jkEndPointFqdn, pNode->fqdn);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkEndPointPort, pNode->port);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToEp(const SJson* pJson, void* pObj) {
|
||||
SEp* pNode = (SEp*)pObj;
|
||||
|
||||
int32_t code = tjsonGetStringValue(pJson, jkEndPointFqdn, pNode->fqdn);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetSmallIntValue(pJson, jkEndPointPort, &pNode->port);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkEpSetInUse = "InUse";
|
||||
static const char* jkEpSetNumOfEps = "NumOfEps";
|
||||
static const char* jkEpSetEps = "Eps";
|
||||
|
||||
static int32_t epSetToJson(const void* pObj, SJson* pJson) {
|
||||
const SEpSet* pNode = (const SEpSet*)pObj;
|
||||
|
||||
int32_t code = tjsonAddIntegerToObject(pJson, jkEpSetInUse, pNode->inUse);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkEpSetNumOfEps, pNode->numOfEps);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddArray(pJson, jkEpSetEps, epToJson, pNode->eps, sizeof(SEp), pNode->numOfEps);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToEpSet(const SJson* pJson, void* pObj) {
|
||||
SEpSet* pNode = (SEpSet*)pObj;
|
||||
|
||||
int32_t code = tjsonGetTinyIntValue(pJson, jkEpSetInUse, &pNode->inUse);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetTinyIntValue(pJson, jkEpSetNumOfEps, &pNode->numOfEps);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonToArray(pJson, jkEpSetEps, jsonToEp, pNode->eps, sizeof(SEp));
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkSysTableScanPhysiPlanMnodeEpSet = "MnodeEpSet";
|
||||
static const char* jkSysTableScanPhysiPlanShowRewrite = "ShowRewrite";
|
||||
static const char* jkSysTableScanPhysiPlanAccountId = "AccountId";
|
||||
|
@ -1342,38 +1538,6 @@ static int32_t physiDispatchNodeToJson(const void* pObj, SJson* pJson) { return
|
|||
|
||||
static int32_t jsonToPhysiDispatchNode(const SJson* pJson, void* pObj) { return jsonToPhysicDataSinkNode(pJson, pObj); }
|
||||
|
||||
static const char* jkSubplanIdQueryId = "QueryId";
|
||||
static const char* jkSubplanIdGroupId = "GroupId";
|
||||
static const char* jkSubplanIdSubplanId = "SubplanId";
|
||||
|
||||
static int32_t subplanIdToJson(const void* pObj, SJson* pJson) {
|
||||
const SSubplanId* pNode = (const SSubplanId*)pObj;
|
||||
|
||||
int32_t code = tjsonAddIntegerToObject(pJson, jkSubplanIdQueryId, pNode->queryId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkSubplanIdGroupId, pNode->groupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkSubplanIdSubplanId, pNode->subplanId);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToSubplanId(const SJson* pJson, void* pObj) {
|
||||
SSubplanId* pNode = (SSubplanId*)pObj;
|
||||
|
||||
int32_t code = tjsonGetUBigIntValue(pJson, jkSubplanIdQueryId, &pNode->queryId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkSubplanIdGroupId, &pNode->groupId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkSubplanIdSubplanId, &pNode->subplanId);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkQueryNodeAddrId = "Id";
|
||||
static const char* jkQueryNodeAddrInUse = "InUse";
|
||||
static const char* jkQueryNodeAddrNumOfEps = "NumOfEps";
|
||||
|
@ -1747,23 +1911,51 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) {
|
|||
break;
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
code = tjsonGetBoolValue(pJson, jkValueDatum, &pNode->datum.b);
|
||||
*(bool*)&pNode->typeData = pNode->datum.b;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
|
||||
*(int8_t*)&pNode->typeData = pNode->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
|
||||
*(int16_t*)&pNode->typeData = pNode->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
|
||||
*(int32_t*)&pNode->typeData = pNode->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
|
||||
*(int64_t*)&pNode->typeData = pNode->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
code = tjsonGetBigIntValue(pJson, jkValueDatum, &pNode->datum.i);
|
||||
*(int64_t*)&pNode->typeData = pNode->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
code = tjsonGetUBigIntValue(pJson, jkValueDatum, &pNode->datum.u);
|
||||
*(uint8_t*)&pNode->typeData = pNode->datum.u;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
code = tjsonGetUBigIntValue(pJson, jkValueDatum, &pNode->datum.u);
|
||||
*(uint16_t*)&pNode->typeData = pNode->datum.u;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
code = tjsonGetUBigIntValue(pJson, jkValueDatum, &pNode->datum.u);
|
||||
*(uint32_t*)&pNode->typeData = pNode->datum.u;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
code = tjsonGetUBigIntValue(pJson, jkValueDatum, &pNode->datum.u);
|
||||
*(uint64_t*)&pNode->typeData = pNode->datum.u;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
code = tjsonGetDoubleValue(pJson, jkValueDatum, &pNode->datum.d);
|
||||
*(float*)&pNode->typeData = pNode->datum.d;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
code = tjsonGetDoubleValue(pJson, jkValueDatum, &pNode->datum.d);
|
||||
*(double*)&pNode->typeData = pNode->datum.d;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
|
@ -1964,78 +2156,6 @@ static int32_t jsonToTableNode(const SJson* pJson, void* pObj) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkVgroupInfoVgId = "VgId";
|
||||
static const char* jkVgroupInfoHashBegin = "HashBegin";
|
||||
static const char* jkVgroupInfoHashEnd = "HashEnd";
|
||||
static const char* jkVgroupInfoEpSet = "EpSet";
|
||||
static const char* jkVgroupInfoNumOfTable = "NumOfTable";
|
||||
|
||||
static int32_t vgroupInfoToJson(const void* pObj, SJson* pJson) {
|
||||
const SVgroupInfo* pNode = (const SVgroupInfo*)pObj;
|
||||
|
||||
int32_t code = tjsonAddIntegerToObject(pJson, jkVgroupInfoVgId, pNode->vgId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkVgroupInfoHashBegin, pNode->hashBegin);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkVgroupInfoHashEnd, pNode->hashEnd);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkVgroupInfoEpSet, epSetToJson, &pNode->epSet);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkVgroupInfoNumOfTable, pNode->numOfTable);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToVgroupInfo(const SJson* pJson, void* pObj) {
|
||||
SVgroupInfo* pNode = (SVgroupInfo*)pObj;
|
||||
|
||||
int32_t code = tjsonGetIntValue(pJson, jkVgroupInfoVgId, &pNode->vgId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetUIntValue(pJson, jkVgroupInfoHashBegin, &pNode->hashBegin);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetUIntValue(pJson, jkVgroupInfoHashEnd, &pNode->hashEnd);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonToObject(pJson, jkVgroupInfoEpSet, jsonToEpSet, &pNode->epSet);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkVgroupInfoNumOfTable, &pNode->numOfTable);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkVgroupsInfoNum = "Num";
|
||||
static const char* jkVgroupsInfoVgroups = "Vgroups";
|
||||
|
||||
static int32_t vgroupsInfoToJson(const void* pObj, SJson* pJson) {
|
||||
const SVgroupsInfo* pNode = (const SVgroupsInfo*)pObj;
|
||||
|
||||
int32_t code = tjsonAddIntegerToObject(pJson, jkVgroupsInfoNum, pNode->numOfVgroups);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddArray(pJson, jkVgroupsInfoVgroups, vgroupInfoToJson, pNode->vgroups, sizeof(SVgroupInfo),
|
||||
pNode->numOfVgroups);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToVgroupsInfo(const SJson* pJson, void* pObj) {
|
||||
SVgroupsInfo* pNode = (SVgroupsInfo*)pObj;
|
||||
|
||||
int32_t code = tjsonGetIntValue(pJson, jkVgroupsInfoNum, &pNode->numOfVgroups);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonToArray(pJson, jkVgroupsInfoVgroups, jsonToVgroupInfo, pNode->vgroups, sizeof(SVgroupInfo));
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkRealTableMetaSize = "MetaSize";
|
||||
static const char* jkRealTableMeta = "Meta";
|
||||
static const char* jkRealTableVgroupsInfoSize = "VgroupsInfoSize";
|
||||
|
@ -2582,7 +2702,10 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
break;
|
||||
case QUERY_NODE_LOGIC_PLAN_SORT:
|
||||
return logicSortNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_LOGIC_PLAN_PARTITION:
|
||||
return logicPartitionNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_LOGIC_SUBPLAN:
|
||||
return logicSubplanToJson(pObj, pJson);
|
||||
case QUERY_NODE_LOGIC_PLAN:
|
||||
break;
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||
|
@ -2667,6 +2790,10 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
return jsonToLogicProjectNode(pJson, pObj);
|
||||
case QUERY_NODE_LOGIC_PLAN_SORT:
|
||||
return jsonToLogicSortNode(pJson, pObj);
|
||||
case QUERY_NODE_LOGIC_PLAN_PARTITION:
|
||||
return jsonToLogicPartitionNode(pJson, pObj);
|
||||
case QUERY_NODE_LOGIC_SUBPLAN:
|
||||
return jsonToLogicSubplan(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
|
||||
return jsonToPhysiTagScanNode(pJson, pObj);
|
||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
|
||||
|
|
|
@ -871,21 +871,18 @@ void nodesClearList(SNodeList* pList) {
|
|||
void* nodesGetValueFromNode(SValueNode* pNode) {
|
||||
switch (pNode->node.resType.type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
return (void*)&pNode->datum.b;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
return (void*)&pNode->datum.i;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
return (void*)&pNode->datum.u;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
return (void*)&pNode->datum.d;
|
||||
return (void*)&pNode->typeData;
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
|
@ -897,6 +894,68 @@ void* nodesGetValueFromNode(SValueNode* pNode) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int32_t nodesSetValueNodeValue(SValueNode* pNode, void *value) {
|
||||
switch (pNode->node.resType.type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
pNode->datum.b = *(bool*)value;
|
||||
*(bool*)&pNode->typeData = pNode->datum.b;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
pNode->datum.i = *(int8_t*)value;
|
||||
*(int8_t*)&pNode->typeData = pNode->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
pNode->datum.i = *(int16_t*)value;
|
||||
*(int16_t*)&pNode->typeData = pNode->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
pNode->datum.i = *(int32_t*)value;
|
||||
*(int32_t*)&pNode->typeData = pNode->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
pNode->datum.i = *(int64_t*)value;
|
||||
*(int64_t*)&pNode->typeData = pNode->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
pNode->datum.i = *(int64_t*)value;
|
||||
*(int64_t*)&pNode->typeData = pNode->datum.i;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
pNode->datum.u = *(int8_t*)value;
|
||||
*(int8_t*)&pNode->typeData = pNode->datum.u;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
pNode->datum.u = *(int16_t*)value;
|
||||
*(int16_t*)&pNode->typeData = pNode->datum.u;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
pNode->datum.u = *(int32_t*)value;
|
||||
*(int32_t*)&pNode->typeData = pNode->datum.u;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
pNode->datum.u = *(uint64_t*)value;
|
||||
*(uint64_t*)&pNode->typeData = pNode->datum.u;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
pNode->datum.d = *(float*)value;
|
||||
*(float*)&pNode->typeData = pNode->datum.d;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
pNode->datum.d = *(double*)value;
|
||||
*(double*)&pNode->typeData = pNode->datum.d;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
pNode->datum.p = (char*)value;
|
||||
break;
|
||||
default:
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char* nodesGetStrValueFromNode(SValueNode* pNode) {
|
||||
switch (pNode->node.resType.type) {
|
||||
case TSDB_DATA_TYPE_BOOL: {
|
||||
|
@ -1090,30 +1149,31 @@ static EDealRes collectColumns(SNode* pNode, void* pContext) {
|
|||
int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char* pTableAlias, ECollectColType type,
|
||||
SNodeList** pCols) {
|
||||
if (NULL == pSelect || NULL == pCols) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SCollectColumnsCxt cxt = {
|
||||
.errCode = TSDB_CODE_SUCCESS,
|
||||
.pTableAlias = pTableAlias,
|
||||
.collectType = type,
|
||||
.pCols = nodesMakeList(),
|
||||
.pCols = (NULL == *pCols ? nodesMakeList() : *pCols),
|
||||
.pColHash = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK)};
|
||||
if (NULL == cxt.pCols || NULL == cxt.pColHash) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*pCols = NULL;
|
||||
nodesWalkSelectStmt(pSelect, clause, collectColumns, &cxt);
|
||||
taosHashCleanup(cxt.pColHash);
|
||||
if (TSDB_CODE_SUCCESS != cxt.errCode) {
|
||||
nodesDestroyList(cxt.pCols);
|
||||
return cxt.errCode;
|
||||
}
|
||||
if (0 == LIST_LENGTH(cxt.pCols)) {
|
||||
if (LIST_LENGTH(cxt.pCols) > 0) {
|
||||
*pCols = cxt.pCols;
|
||||
} else {
|
||||
nodesDestroyList(cxt.pCols);
|
||||
cxt.pCols = NULL;
|
||||
}
|
||||
*pCols = cxt.pCols;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1134,7 +1194,7 @@ static EDealRes collectFuncs(SNode* pNode, void* pContext) {
|
|||
|
||||
int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNodeList** pFuncs) {
|
||||
if (NULL == pSelect || NULL == pFuncs) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SCollectFuncsCxt cxt = {
|
||||
|
@ -1157,6 +1217,46 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
typedef struct SCollectSpecialNodesCxt {
|
||||
int32_t errCode;
|
||||
ENodeType type;
|
||||
SNodeList* pNodes;
|
||||
} SCollectSpecialNodesCxt;
|
||||
|
||||
static EDealRes collectSpecialNodes(SNode* pNode, void* pContext) {
|
||||
SCollectSpecialNodesCxt* pCxt = (SCollectSpecialNodesCxt*)pContext;
|
||||
if (pCxt->type == nodeType(pNode)) {
|
||||
pCxt->errCode = nodesListStrictAppend(pCxt->pNodes, nodesCloneNode(pNode));
|
||||
return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR);
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
int32_t nodesCollectSpecialNodes(SSelectStmt* pSelect, ESqlClause clause, ENodeType type, SNodeList** pNodes) {
|
||||
if (NULL == pSelect || NULL == pNodes) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SCollectSpecialNodesCxt cxt = {
|
||||
.errCode = TSDB_CODE_SUCCESS, .type = type, .pNodes = (NULL == *pNodes ? nodesMakeList() : *pNodes)};
|
||||
if (NULL == cxt.pNodes) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
*pNodes = NULL;
|
||||
nodesWalkSelectStmt(pSelect, SQL_CLAUSE_GROUP_BY, collectSpecialNodes, &cxt);
|
||||
if (TSDB_CODE_SUCCESS != cxt.errCode) {
|
||||
nodesDestroyList(cxt.pNodes);
|
||||
return cxt.errCode;
|
||||
}
|
||||
if (LIST_LENGTH(cxt.pNodes) > 0) {
|
||||
*pNodes = cxt.pNodes;
|
||||
} else {
|
||||
nodesDestroyList(cxt.pNodes);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char* getFillModeString(EFillMode mode) {
|
||||
switch (mode) {
|
||||
case FILL_MODE_NONE:
|
||||
|
|
|
@ -30,9 +30,9 @@ typedef struct SAstCreateContext {
|
|||
SParseContext* pQueryCxt;
|
||||
SMsgBuf msgBuf;
|
||||
bool notSupport;
|
||||
bool valid;
|
||||
SNode* pRootNode;
|
||||
int16_t placeholderNo;
|
||||
int32_t errCode;
|
||||
} SAstCreateContext;
|
||||
|
||||
typedef enum EDatabaseOptionType {
|
||||
|
|
|
@ -23,13 +23,12 @@
|
|||
}
|
||||
|
||||
%syntax_error {
|
||||
if (pCxt->valid) {
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
if(TOKEN.z) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z);
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z);
|
||||
} else {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL);
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL);
|
||||
}
|
||||
pCxt->valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,8 +41,8 @@
|
|||
%left NK_CONCAT.
|
||||
|
||||
/************************************************ create/alter account *****************************************/
|
||||
cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
cmd ::= ALTER ACCOUNT NK_ID alter_account_options. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options. { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
cmd ::= ALTER ACCOUNT NK_ID alter_account_options. { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
|
||||
%type account_options { int32_t }
|
||||
%destructor account_options { }
|
||||
|
@ -323,7 +322,7 @@ cmd ::= SHOW QNODES.
|
|||
cmd ::= SHOW FUNCTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); }
|
||||
cmd ::= SHOW INDEXES FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, A, B); }
|
||||
cmd ::= SHOW STREAMS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); }
|
||||
cmd ::= SHOW ACCOUNTS. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
cmd ::= SHOW ACCOUNTS. { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
cmd ::= SHOW APPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); }
|
||||
cmd ::= SHOW CONNECTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT, NULL, NULL); }
|
||||
cmd ::= SHOW LICENCE. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); }
|
||||
|
@ -491,7 +490,7 @@ signed_literal(A) ::= NK_STRING(B).
|
|||
signed_literal(A) ::= NK_BOOL(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B); }
|
||||
signed_literal(A) ::= TIMESTAMP NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &B); }
|
||||
signed_literal(A) ::= duration_literal(B). { A = releaseRawExprNode(pCxt, B); }
|
||||
signed_literal(A) ::= NULL. { A = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); }
|
||||
signed_literal(A) ::= NULL(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &B); }
|
||||
signed_literal(A) ::= literal_func(B). { A = releaseRawExprNode(pCxt, B); }
|
||||
|
||||
%type literal_list { SNodeList* }
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define CHECK_OUT_OF_MEM(p) \
|
||||
do { \
|
||||
if (NULL == (p)) { \
|
||||
pCxt->valid = false; \
|
||||
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; \
|
||||
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "Out of memory"); \
|
||||
return NULL; \
|
||||
} \
|
||||
|
@ -30,7 +30,7 @@
|
|||
#define CHECK_RAW_EXPR_NODE(node) \
|
||||
do { \
|
||||
if (NULL == (node) || QUERY_NODE_RAW_EXPR != nodeType(node)) { \
|
||||
pCxt->valid = false; \
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; \
|
||||
return NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -42,9 +42,9 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
|
|||
pCxt->msgBuf.buf = pParseCxt->pMsg;
|
||||
pCxt->msgBuf.len = pParseCxt->msgLen;
|
||||
pCxt->notSupport = false;
|
||||
pCxt->valid = true;
|
||||
pCxt->pRootNode = NULL;
|
||||
pCxt->placeholderNo = 0;
|
||||
pCxt->errCode = TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void copyStringFormStringToken(SToken* pToken, char* pBuf, int32_t len) {
|
||||
|
@ -63,42 +63,38 @@ static void trimEscape(SToken* pName) {
|
|||
|
||||
static bool checkUserName(SAstCreateContext* pCxt, SToken* pUserName) {
|
||||
if (NULL == pUserName) {
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
} else {
|
||||
if (pUserName->n >= TSDB_USER_LEN) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||
}
|
||||
}
|
||||
if (pCxt->valid) {
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
trimEscape(pUserName);
|
||||
}
|
||||
return pCxt->valid;
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||
}
|
||||
|
||||
static bool checkPassword(SAstCreateContext* pCxt, const SToken* pPasswordToken, char* pPassword) {
|
||||
if (NULL == pPasswordToken) {
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
} else if (pPasswordToken->n >= (TSDB_USET_PASSWORD_LEN - 2)) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||
} else {
|
||||
strncpy(pPassword, pPasswordToken->z, pPasswordToken->n);
|
||||
strdequote(pPassword);
|
||||
if (strtrim(pPassword) <= 0) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_PASSWD_EMPTY);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_PASSWD_EMPTY);
|
||||
}
|
||||
}
|
||||
return pCxt->valid;
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||
}
|
||||
|
||||
static bool checkAndSplitEndpoint(SAstCreateContext* pCxt, const SToken* pEp, char* pFqdn, int32_t* pPort) {
|
||||
if (NULL == pEp) {
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
} else if (pEp->n >= TSDB_FQDN_LEN + 2 + 6) { // format 'fqdn:port'
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||
} else {
|
||||
char ep[TSDB_FQDN_LEN + 2 + 6];
|
||||
strncpy(ep, pEp->z, pEp->n);
|
||||
|
@ -106,66 +102,59 @@ static bool checkAndSplitEndpoint(SAstCreateContext* pCxt, const SToken* pEp, ch
|
|||
strtrim(ep);
|
||||
char* pColon = strchr(ep, ':');
|
||||
if (NULL == pColon) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ENDPOINT);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ENDPOINT);
|
||||
} else {
|
||||
strncpy(pFqdn, ep, pColon - ep);
|
||||
*pPort = strtol(pColon + 1, NULL, 10);
|
||||
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pCxt->valid;
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||
}
|
||||
|
||||
static bool checkFqdn(SAstCreateContext* pCxt, const SToken* pFqdn) {
|
||||
if (NULL == pFqdn) {
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
} else {
|
||||
if (pFqdn->n >= TSDB_FQDN_LEN) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||
}
|
||||
}
|
||||
return pCxt->valid;
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||
}
|
||||
|
||||
static bool checkPort(SAstCreateContext* pCxt, const SToken* pPortToken, int32_t* pPort) {
|
||||
if (NULL == pPortToken) {
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
} else {
|
||||
*pPort = strtol(pPortToken->z, NULL, 10);
|
||||
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_PORT);
|
||||
}
|
||||
}
|
||||
return pCxt->valid;
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||
}
|
||||
|
||||
static bool checkDbName(SAstCreateContext* pCxt, SToken* pDbName, bool query) {
|
||||
if (NULL == pDbName) {
|
||||
if (query && NULL == pCxt->pQueryCxt->db) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DB_NOT_SPECIFIED);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DB_NOT_SPECIFIED);
|
||||
}
|
||||
} else {
|
||||
trimEscape(pDbName);
|
||||
if (pDbName->n >= TSDB_DB_NAME_LEN) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pDbName->z);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pDbName->z);
|
||||
}
|
||||
}
|
||||
return pCxt->valid;
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||
}
|
||||
|
||||
static bool checkTableName(SAstCreateContext* pCxt, SToken* pTableName) {
|
||||
trimEscape(pTableName);
|
||||
if (NULL != pTableName && pTableName->n >= TSDB_TABLE_NAME_LEN) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pTableName->z);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pTableName->z);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -174,8 +163,7 @@ static bool checkTableName(SAstCreateContext* pCxt, SToken* pTableName) {
|
|||
static bool checkColumnName(SAstCreateContext* pCxt, SToken* pColumnName) {
|
||||
trimEscape(pColumnName);
|
||||
if (NULL != pColumnName && pColumnName->n >= TSDB_COL_NAME_LEN) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pColumnName->z);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pColumnName->z);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -184,8 +172,7 @@ static bool checkColumnName(SAstCreateContext* pCxt, SToken* pColumnName) {
|
|||
static bool checkIndexName(SAstCreateContext* pCxt, SToken* pIndexName) {
|
||||
trimEscape(pIndexName);
|
||||
if (NULL != pIndexName && pIndexName->n >= TSDB_INDEX_NAME_LEN) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pIndexName->z);
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pIndexName->z);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -224,7 +211,7 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
|
|||
|
||||
SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
|
||||
if (NULL == pNode || QUERY_NODE_RAW_EXPR != nodeType(pNode)) {
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
return nil_token;
|
||||
}
|
||||
SRawExprNode* target = (SRawExprNode*)pNode;
|
||||
|
@ -235,16 +222,12 @@ SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
|
|||
SNodeList* createNodeList(SAstCreateContext* pCxt, SNode* pNode) {
|
||||
SNodeList* list = nodesMakeList();
|
||||
CHECK_OUT_OF_MEM(list);
|
||||
if (TSDB_CODE_SUCCESS != nodesListAppend(list, pNode)) {
|
||||
pCxt->valid = false;
|
||||
}
|
||||
pCxt->errCode = nodesListAppend(list, pNode);
|
||||
return list;
|
||||
}
|
||||
|
||||
SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode) {
|
||||
if (TSDB_CODE_SUCCESS != nodesListAppend(pList, pNode)) {
|
||||
pCxt->valid = false;
|
||||
}
|
||||
pCxt->errCode = nodesListAppend(pList, pNode);
|
||||
return pList;
|
||||
}
|
||||
|
||||
|
@ -381,10 +364,10 @@ SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType d
|
|||
strcpy(func->functionName, "cast");
|
||||
func->node.resType = dt;
|
||||
if (TSDB_DATA_TYPE_BINARY == dt.type) {
|
||||
func->node.resType.bytes += 2;
|
||||
func->node.resType.bytes += 2;
|
||||
} else if (TSDB_DATA_TYPE_NCHAR == dt.type) {
|
||||
func->node.resType.bytes = func->node.resType.bytes * TSDB_NCHAR_SIZE + 2;
|
||||
}
|
||||
}
|
||||
nodesListMakeAppend(&func->pParameterList, pExpr);
|
||||
return (SNode*)func;
|
||||
}
|
||||
|
@ -531,7 +514,7 @@ SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode) {
|
|||
}
|
||||
|
||||
SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* pAlias) {
|
||||
if (NULL == pNode || !pCxt->valid) {
|
||||
if (NULL == pNode || TSDB_CODE_SUCCESS != pCxt->errCode) {
|
||||
return pNode;
|
||||
}
|
||||
int32_t len = TMIN(sizeof(((SExprNode*)pNode)->aliasName) - 1, pAlias->n);
|
||||
|
@ -995,7 +978,7 @@ static bool needDbShowStmt(ENodeType type) {
|
|||
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern) {
|
||||
if (needDbShowStmt(type) && NULL == pDbName && NULL == pCxt->pQueryCxt->db) {
|
||||
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "db not specified");
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
SShowStmt* pStmt = nodesMakeNode(type);
|
||||
|
@ -1256,7 +1239,7 @@ SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups) {
|
|||
SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName,
|
||||
const SToken* pLibPath, SDataType dataType, int32_t bufSize) {
|
||||
if (pLibPath->n <= 2) {
|
||||
pCxt->valid = false;
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
SCreateFunctionStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT);
|
||||
|
|
|
@ -53,20 +53,20 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
|
|||
}
|
||||
case TK_NK_ILLEGAL: {
|
||||
snprintf(cxt.pQueryCxt->pMsg, cxt.pQueryCxt->msgLen, "unrecognized token: \"%s\"", t0.z);
|
||||
cxt.valid = false;
|
||||
cxt.errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
goto abort_parse;
|
||||
}
|
||||
case TK_NK_HEX:
|
||||
case TK_NK_OCT:
|
||||
case TK_NK_BIN: {
|
||||
snprintf(cxt.pQueryCxt->pMsg, cxt.pQueryCxt->msgLen, "unsupported token: \"%s\"", t0.z);
|
||||
cxt.valid = false;
|
||||
cxt.errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
goto abort_parse;
|
||||
}
|
||||
default:
|
||||
Parse(pParser, t0.type, t0, &cxt);
|
||||
// ParseTrace(stdout, "");
|
||||
if (!cxt.valid) {
|
||||
if (TSDB_CODE_SUCCESS != cxt.errCode) {
|
||||
goto abort_parse;
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
|
|||
|
||||
abort_parse:
|
||||
ParseFree(pParser, (FFree)taosMemoryFree);
|
||||
if (cxt.valid) {
|
||||
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
||||
*pQuery = taosMemoryCalloc(1, sizeof(SQuery));
|
||||
if (NULL == *pQuery) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -82,5 +82,5 @@ abort_parse:
|
|||
(*pQuery)->pRoot = cxt.pRootNode;
|
||||
(*pQuery)->placeholderNum = cxt.placeholderNo;
|
||||
}
|
||||
return cxt.valid ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED;
|
||||
return cxt.errCode;
|
||||
}
|
||||
|
|
|
@ -208,6 +208,23 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SNodeList* pProject
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t calcConstGroupBy(SCalcConstContext* pCxt, SSelectStmt* pSelect) {
|
||||
int32_t code = calcConstList(pSelect->pGroupByList);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pSelect->pGroupByList) {
|
||||
SNode* pGroupPara = NULL;
|
||||
FOREACH(pGroupPara, ((SGroupingSetNode*)pNode)->pParameterList) {
|
||||
if (QUERY_NODE_VALUE != nodeType(pGroupPara)) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
DESTORY_LIST(pSelect->pGroupByList);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) {
|
||||
int32_t code = calcConstProjections(pCxt, pSelect->pProjectionList, subquery);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
|
|
@ -47,6 +47,7 @@ static SKeyword keywordTable[] = {
|
|||
{"BNODE", TK_BNODE},
|
||||
{"BNODES", TK_BNODES},
|
||||
{"BOOL", TK_BOOL},
|
||||
{"BUFFER", TK_BUFFER},
|
||||
{"BUFSIZE", TK_BUFSIZE},
|
||||
{"BY", TK_BY},
|
||||
{"CACHE", TK_CACHE},
|
||||
|
@ -132,6 +133,8 @@ static SKeyword keywordTable[] = {
|
|||
{"OUTPUTTYPE", TK_OUTPUTTYPE},
|
||||
{"PARTITION", TK_PARTITION},
|
||||
{"PASS", TK_PASS},
|
||||
{"PAGES", TK_PAGES},
|
||||
{"PAGESIZE", TK_PAGESIZE},
|
||||
{"PORT", TK_PORT},
|
||||
{"PPS", TK_PPS},
|
||||
{"PRECISION", TK_PRECISION},
|
||||
|
|
|
@ -20,11 +20,12 @@
|
|||
#include "functionMgt.h"
|
||||
#include "parUtil.h"
|
||||
#include "scalar.h"
|
||||
#include "systable.h"
|
||||
#include "tglobal.h"
|
||||
#include "ttime.h"
|
||||
|
||||
#define generateDealNodeErrMsg(pCxt, code, ...) \
|
||||
(pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, code, ##__VA_ARGS__) ? DEAL_RES_ERROR : DEAL_RES_ERROR)
|
||||
(pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, code, ##__VA_ARGS__), DEAL_RES_ERROR)
|
||||
|
||||
typedef struct STranslateContext {
|
||||
SParseContext* pParseCxt;
|
||||
|
@ -465,27 +466,66 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
|||
break;
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
pVal->datum.b = (0 == strcasecmp(pVal->literal, "true"));
|
||||
*(bool*)&pVal->typeData = pVal->datum.b;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
case TSDB_DATA_TYPE_TINYINT:{
|
||||
char* endPtr = NULL;
|
||||
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
|
||||
*(int8_t*)&pVal->typeData = pVal->datum.i;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_SMALLINT:{
|
||||
char* endPtr = NULL;
|
||||
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
|
||||
*(int16_t*)&pVal->typeData = pVal->datum.i;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_INT:{
|
||||
char* endPtr = NULL;
|
||||
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
|
||||
*(int32_t*)&pVal->typeData = pVal->datum.i;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_BIGINT: {
|
||||
char* endPtr = NULL;
|
||||
pVal->datum.i = strtoll(pVal->literal, &endPtr, 10);
|
||||
*(int64_t*)&pVal->typeData = pVal->datum.i;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UTINYINT:{
|
||||
char* endPtr = NULL;
|
||||
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
|
||||
*(uint8_t*)&pVal->typeData = pVal->datum.u;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_USMALLINT:{
|
||||
char* endPtr = NULL;
|
||||
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
|
||||
*(uint16_t*)&pVal->typeData = pVal->datum.u;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UINT:{
|
||||
char* endPtr = NULL;
|
||||
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
|
||||
*(uint32_t*)&pVal->typeData = pVal->datum.u;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
char* endPtr = NULL;
|
||||
pVal->datum.u = strtoull(pVal->literal, &endPtr, 10);
|
||||
*(uint64_t*)&pVal->typeData = pVal->datum.u;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_FLOAT:{
|
||||
char* endPtr = NULL;
|
||||
pVal->datum.d = strtold(pVal->literal, &endPtr);
|
||||
*(float*)&pVal->typeData = pVal->datum.d;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
char* endPtr = NULL;
|
||||
pVal->datum.d = strtold(pVal->literal, &endPtr);
|
||||
*(double*)&pVal->typeData = pVal->datum.d;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
|
@ -503,6 +543,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
|||
TSDB_CODE_SUCCESS) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||
}
|
||||
*(int64_t*)&pVal->typeData = pVal->datum.i;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
|
@ -780,17 +821,17 @@ static int32_t setSysTableVgroupList(STranslateContext* pCxt, SName* pName, SRea
|
|||
SArray* vgroupList = NULL;
|
||||
if ('\0' != pRealTable->qualDbName[0]) {
|
||||
// todo release after mnode can be processed
|
||||
// if (0 != strcmp(pRealTable->qualDbName, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||
code = getDBVgInfo(pCxt, pRealTable->qualDbName, &vgroupList);
|
||||
// }
|
||||
if (0 != strcmp(pRealTable->qualDbName, TSDB_INFORMATION_SCHEMA_DB)) {
|
||||
code = getDBVgInfo(pCxt, pRealTable->qualDbName, &vgroupList);
|
||||
}
|
||||
} else {
|
||||
code = getDBVgInfoImpl(pCxt, pName, &vgroupList);
|
||||
}
|
||||
|
||||
// todo release after mnode can be processed
|
||||
// if (TSDB_CODE_SUCCESS == code) {
|
||||
// code = addMnodeToVgroupList(&pCxt->pParseCxt->mgmtEpSet, &vgroupList);
|
||||
// }
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = addMnodeToVgroupList(&pCxt->pParseCxt->mgmtEpSet, &vgroupList);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = toVgroupsInfo(vgroupList, &pRealTable->pVgroupList);
|
||||
|
@ -1539,26 +1580,24 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
|
|||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||
tNameGetFullDbName(&name, pReq->db);
|
||||
pReq->numOfVgroups = pStmt->pOptions->numOfVgroups;
|
||||
pReq->numOfStables = pStmt->pOptions->singleStable;
|
||||
pReq->buffer = pStmt->pOptions->buffer;
|
||||
pReq->pageSize = pStmt->pOptions->pagesize;
|
||||
pReq->pages = pStmt->pOptions->pages;
|
||||
pReq->daysPerFile = pStmt->pOptions->daysPerFile;
|
||||
pReq->daysToKeep0 = pStmt->pOptions->keep[0];
|
||||
pReq->daysToKeep1 = pStmt->pOptions->keep[1];
|
||||
pReq->daysToKeep2 = pStmt->pOptions->keep[2];
|
||||
pReq->minRows = pStmt->pOptions->minRowsPerBlock;
|
||||
pReq->maxRows = pStmt->pOptions->maxRowsPerBlock;
|
||||
pReq->commitTime = -1;
|
||||
pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod;
|
||||
pReq->walLevel = pStmt->pOptions->walLevel;
|
||||
pReq->precision = pStmt->pOptions->precision;
|
||||
pReq->compression = pStmt->pOptions->compressionLevel;
|
||||
pReq->replications = pStmt->pOptions->replica;
|
||||
pReq->update = -1;
|
||||
pReq->strict = pStmt->pOptions->strict;
|
||||
pReq->cacheLastRow = pStmt->pOptions->cachelast;
|
||||
pReq->ignoreExist = pStmt->ignoreExists;
|
||||
pReq->singleSTable = pStmt->pOptions->singleStable;
|
||||
pReq->strict = pStmt->pOptions->strict;
|
||||
// pStmt->pOptions->buffer;
|
||||
// pStmt->pOptions->pages;
|
||||
// pStmt->pOptions->pagesize;
|
||||
return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq);
|
||||
}
|
||||
|
||||
|
@ -1677,11 +1716,12 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions,
|
||||
bool alter) {
|
||||
static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions) {
|
||||
int32_t daysPerFile = pOptions->daysPerFile;
|
||||
int32_t daysToKeep0 = pOptions->keep[0];
|
||||
if (alter && (-1 == daysPerFile || -1 == daysToKeep0)) {
|
||||
if (-1 == daysPerFile && -1 == daysToKeep0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else if (-1 == daysPerFile || -1 == daysToKeep0) {
|
||||
SDbCfgInfo dbCfg;
|
||||
int32_t code = getDBCfg(pCxt, pDbName, &dbCfg);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
|
@ -1696,9 +1736,9 @@ static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbNa
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions,
|
||||
bool alter) {
|
||||
int32_t code = checkRangeOption(pCxt, "buffer", pOptions->buffer, TSDB_MIN_BUFFER_PER_VNODE, INT32_MAX);
|
||||
static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName, SDatabaseOptions* pOptions) {
|
||||
int32_t code =
|
||||
checkRangeOption(pCxt, "buffer", pOptions->buffer, TSDB_MIN_BUFFER_PER_VNODE, TSDB_MAX_BUFFER_PER_VNODE);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkRangeOption(pCxt, "cacheLast", pOptions->cachelast, TSDB_MIN_DB_CACHE_LAST_ROW,
|
||||
TSDB_MAX_DB_CACHE_LAST_ROW);
|
||||
|
@ -1724,7 +1764,7 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
|
|||
code = checkDbKeepOption(pCxt, pOptions);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, INT32_MAX);
|
||||
code = checkRangeOption(pCxt, "pages", pOptions->pages, TSDB_MIN_PAGES_PER_VNODE, TSDB_MAX_PAGES_PER_VNODE);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkRangeOption(pCxt, "pagesize", pOptions->pagesize, TSDB_MIN_PAGESIZE_PER_VNODE,
|
||||
|
@ -1753,13 +1793,13 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
|
|||
code = checkDbRetentionsOption(pCxt, pOptions->pRetentions);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = checkOptionsDependency(pCxt, pDbName, pOptions, alter);
|
||||
code = checkOptionsDependency(pCxt, pDbName, pOptions);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt) {
|
||||
return checkDatabaseOptions(pCxt, pStmt->dbName, pStmt->pOptions, false);
|
||||
return checkDatabaseOptions(pCxt, pStmt->dbName, pStmt->pOptions);
|
||||
}
|
||||
|
||||
typedef int32_t (*FSerializeFunc)(void* pBuf, int32_t bufLen, void* pReq);
|
||||
|
@ -1810,21 +1850,23 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
|
|||
SName name = {0};
|
||||
tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
|
||||
tNameGetFullDbName(&name, pReq->db);
|
||||
// pStmt->pOptions->buffer
|
||||
pReq->cacheLastRow = pStmt->pOptions->cachelast;
|
||||
pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod;
|
||||
pReq->buffer = pStmt->pOptions->buffer;
|
||||
pReq->pageSize = -1;
|
||||
pReq->pages = pStmt->pOptions->pages;
|
||||
pReq->daysPerFile = -1;
|
||||
pReq->daysToKeep0 = pStmt->pOptions->keep[0];
|
||||
pReq->daysToKeep1 = pStmt->pOptions->keep[1];
|
||||
pReq->daysToKeep2 = pStmt->pOptions->keep[2];
|
||||
// pStmt->pOptions->pages
|
||||
pReq->replications = pStmt->pOptions->replica;
|
||||
pReq->strict = pStmt->pOptions->strict;
|
||||
pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod;
|
||||
pReq->walLevel = pStmt->pOptions->walLevel;
|
||||
pReq->strict = pStmt->pOptions->strict;
|
||||
pReq->cacheLastRow = pStmt->pOptions->cachelast;
|
||||
pReq->replications = pStmt->pOptions->replica;
|
||||
return;
|
||||
}
|
||||
|
||||
static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt) {
|
||||
int32_t code = checkDatabaseOptions(pCxt, pStmt->dbName, pStmt->pOptions, true);
|
||||
int32_t code = checkDatabaseOptions(pCxt, pStmt->dbName, pStmt->pOptions);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -3021,11 +3021,11 @@ static YYACTIONTYPE yy_reduce(
|
|||
/********** Begin reduce actions **********************************************/
|
||||
YYMINORTYPE yylhsminor;
|
||||
case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */
|
||||
{ pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
yy_destructor(yypParser,232,&yymsp[0].minor);
|
||||
break;
|
||||
case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */
|
||||
{ pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
yy_destructor(yypParser,233,&yymsp[0].minor);
|
||||
break;
|
||||
case 2: /* account_options ::= */
|
||||
|
@ -3591,7 +3591,7 @@ static YYACTIONTYPE yy_reduce(
|
|||
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); }
|
||||
break;
|
||||
case 178: /* cmd ::= SHOW ACCOUNTS */
|
||||
{ pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
|
||||
break;
|
||||
case 179: /* cmd ::= SHOW APPS */
|
||||
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); }
|
||||
|
@ -3902,7 +3902,8 @@ static YYACTIONTYPE yy_reduce(
|
|||
yymsp[0].minor.yy662 = yylhsminor.yy662;
|
||||
break;
|
||||
case 272: /* signed_literal ::= NULL */
|
||||
{ yymsp[0].minor.yy662 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); }
|
||||
{ yylhsminor.yy662 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); }
|
||||
yymsp[0].minor.yy662 = yylhsminor.yy662;
|
||||
break;
|
||||
case 291: /* expression ::= NK_LP expression NK_RP */
|
||||
case 355: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==355);
|
||||
|
@ -4352,13 +4353,12 @@ static void yy_syntax_error(
|
|||
#define TOKEN yyminor
|
||||
/************ Begin %syntax_error code ****************************************/
|
||||
|
||||
if (pCxt->valid) {
|
||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||
if(TOKEN.z) {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z);
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z);
|
||||
} else {
|
||||
generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL);
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL);
|
||||
}
|
||||
pCxt->valid = false;
|
||||
}
|
||||
/************ End %syntax_error code ******************************************/
|
||||
ParseARG_STORE /* Suppress warning about unused %extra_argument variable */
|
||||
|
|
|
@ -24,4 +24,9 @@ if(${BUILD_WINGETOPT})
|
|||
PUBLIC "${TD_SOURCE_DIR}/contrib/wingetopt/src"
|
||||
)
|
||||
target_link_libraries(parserTest PUBLIC wingetopt)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_test(
|
||||
NAME parserTest
|
||||
COMMAND parserTest
|
||||
)
|
||||
|
|
|
@ -155,16 +155,22 @@ int32_t __catalogGetDBVgInfo(SCatalog* pCtg, void* pRpc, const SEpSet* pMgmtEps,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t __catalogGetDBCfg(SCatalog* pCtg, void* pRpc, const SEpSet* pMgmtEps, const char* dbFName, SDbCfgInfo* pDbCfg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void initMetaDataEnv() {
|
||||
mockCatalogService.reset(new MockCatalogService());
|
||||
|
||||
static Stub stub;
|
||||
stub.set(catalogGetHandle, __catalogGetHandle);
|
||||
stub.set(catalogGetTableMeta, __catalogGetTableMeta);
|
||||
stub.set(catalogGetSTableMeta, __catalogGetTableMeta);
|
||||
stub.set(catalogGetTableHashVgroup, __catalogGetTableHashVgroup);
|
||||
stub.set(catalogGetTableDistVgInfo, __catalogGetTableDistVgInfo);
|
||||
stub.set(catalogGetDBVgVersion, __catalogGetDBVgVersion);
|
||||
stub.set(catalogGetDBVgInfo, __catalogGetDBVgInfo);
|
||||
stub.set(catalogGetDBCfg, __catalogGetDBCfg);
|
||||
// {
|
||||
// AddrAny any("libcatalog.so");
|
||||
// std::map<std::string,void*> result;
|
||||
|
|
|
@ -111,9 +111,8 @@ class MockCatalogServiceImpl {
|
|||
}
|
||||
|
||||
int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const {
|
||||
char db[TSDB_DB_NAME_LEN] = {0};
|
||||
tNameGetDbName(pTableName, db);
|
||||
return copyTableVgroup(db, tNameGetTableName(pTableName), vgInfo);
|
||||
vgInfo->vgId = 1;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t catalogGetTableDistVgInfo(const SName* pTableName, SArray** vgList) const {
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "parTestUtil.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ParserTest {
|
||||
|
||||
class ParserExplainToSyncdbTest : public ParserTestBase {};
|
||||
|
||||
TEST_F(ParserExplainToSyncdbTest, explain) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("explain SELECT * FROM t1");
|
||||
|
||||
run("explain analyze SELECT * FROM t1");
|
||||
|
||||
run("explain analyze verbose true ratio 0.01 SELECT * FROM t1");
|
||||
}
|
||||
|
||||
// todo kill connection
|
||||
// todo kill query
|
||||
// todo kill stream
|
||||
// todo merge vgroup
|
||||
// todo redistribute vgroup
|
||||
// todo reset query cache
|
||||
// todo syncdb
|
||||
|
||||
} // namespace ParserTest
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "parTestUtil.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ParserTest {
|
||||
|
||||
class ParserInitialATest : public ParserTestBase {};
|
||||
|
||||
TEST_F(ParserInitialATest, alterAccount) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("alter account ac_wxy pass '123456'", TSDB_CODE_PAR_EXPRIE_STATEMENT);
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialATest, alterDnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("alter dnode 1 'resetLog'");
|
||||
|
||||
run("alter dnode 1 'debugFlag' '134'");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialATest, alterDatabase) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("alter database wxy_db cachelast 1 fsync 200 wal 1");
|
||||
}
|
||||
|
||||
// todo alter local
|
||||
// todo alter stable
|
||||
// todo alter table
|
||||
|
||||
TEST_F(ParserInitialATest, alterUser) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("alter user wxy pass '123456'");
|
||||
|
||||
run("alter user wxy privilege 'write'");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialATest, bug001) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("alter database db wal 0 # td-14436", TSDB_CODE_PAR_SYNTAX_ERROR);
|
||||
}
|
||||
|
||||
} // namespace ParserTest
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "parTestUtil.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ParserTest {
|
||||
|
||||
class ParserInitialCTest : public ParserTestBase {};
|
||||
|
||||
// todo compact
|
||||
|
||||
TEST_F(ParserInitialCTest, createAccount) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create account ac_wxy pass '123456'", TSDB_CODE_PAR_EXPRIE_STATEMENT);
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createBnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create bnode on dnode 1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createDatabase) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create database wxy_db");
|
||||
|
||||
run("create database if not exists wxy_db "
|
||||
"cachelast 2 "
|
||||
"comp 1 "
|
||||
"days 100 "
|
||||
"fsync 100 "
|
||||
"maxrows 1000 "
|
||||
"minrows 100 "
|
||||
"keep 1440 "
|
||||
"precision 'ms' "
|
||||
"replica 3 "
|
||||
"wal 2 "
|
||||
"vgroups 100 "
|
||||
"single_stable 0 "
|
||||
"retentions 15s:7d,1m:21d,15m:5y");
|
||||
|
||||
run("create database if not exists wxy_db "
|
||||
"days 100m "
|
||||
"keep 1440m,300h,400d ");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createDnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create dnode abc1 port 7000");
|
||||
|
||||
run("create dnode 1.1.1.1 port 9000");
|
||||
}
|
||||
|
||||
// todo create function
|
||||
|
||||
TEST_F(ParserInitialCTest, createIndexSma) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createMnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create mnode on dnode 1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createQnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create qnode on dnode 1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createSnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create snode on dnode 1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createStable) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create stable t1(ts timestamp, c1 int) TAGS(id int)");
|
||||
|
||||
run("create stable if not exists test.t1("
|
||||
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 "
|
||||
"SMALLINT, "
|
||||
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 NCHAR(30), "
|
||||
"c15 VARCHAR(50)) "
|
||||
"TAGS (tsa TIMESTAMP, a1 INT, a2 INT UNSIGNED, a3 BIGINT, a4 BIGINT UNSIGNED, a5 FLOAT, a6 DOUBLE, a7 "
|
||||
"BINARY(20), a8 SMALLINT, "
|
||||
"a9 SMALLINT UNSIGNED COMMENT 'test column comment', a10 TINYINT, a11 TINYINT UNSIGNED, a12 BOOL, a13 NCHAR(30), "
|
||||
"a15 VARCHAR(50)) "
|
||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (min) FILE_FACTOR 0.1 DELAY 2");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createStream) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create stream s1 as select * from t1");
|
||||
|
||||
run("create stream if not exists s1 as select * from t1");
|
||||
|
||||
run("create stream s1 into st1 as select * from t1");
|
||||
|
||||
run("create stream if not exists s1 trigger window_close watermark 10s into st1 as select * from t1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createTable) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create table t1(ts timestamp, c1 int)");
|
||||
|
||||
run("create table if not exists test.t1("
|
||||
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 "
|
||||
"SMALLINT, "
|
||||
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 "
|
||||
"NCHAR(30), "
|
||||
"c15 VARCHAR(50)) "
|
||||
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3)");
|
||||
|
||||
run("create table if not exists test.t1("
|
||||
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), c8 "
|
||||
"SMALLINT, "
|
||||
"c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, c13 "
|
||||
"NCHAR(30), "
|
||||
"c15 VARCHAR(50)) "
|
||||
"TAGS (tsa TIMESTAMP, a1 INT, a2 INT UNSIGNED, a3 BIGINT, a4 BIGINT UNSIGNED, "
|
||||
"a5 FLOAT, a6 DOUBLE, a7 "
|
||||
"BINARY(20), a8 SMALLINT, "
|
||||
"a9 SMALLINT UNSIGNED COMMENT 'test column comment', a10 "
|
||||
"TINYINT, a11 TINYINT UNSIGNED, a12 BOOL, a13 NCHAR(30), "
|
||||
"a15 VARCHAR(50)) "
|
||||
"TTL 100 COMMENT 'test create "
|
||||
"table' SMA(c1, c2, c3) ROLLUP (min) FILE_FACTOR 0.1 DELAY 2");
|
||||
|
||||
run("create table if not exists t1 using st1 tags(1, 'wxy')");
|
||||
|
||||
run("create table "
|
||||
"if not exists test.t1 using test.st1 (tag1, tag2) tags(1, 'abc') "
|
||||
"if not exists test.t2 using test.st1 (tag1, tag2) tags(2, 'abc') "
|
||||
"if not exists test.t3 using test.st1 (tag1, tag2) tags(3, 'abc') ");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createTopic) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create topic tp1 as select * from t1");
|
||||
|
||||
run("create topic if not exists tp1 as select * from t1");
|
||||
|
||||
run("create topic tp1 as test");
|
||||
|
||||
run("create topic if not exists tp1 as test");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialCTest, createUser) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("create user wxy pass '123456'");
|
||||
}
|
||||
|
||||
} // namespace ParserTest
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "parTestUtil.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ParserTest {
|
||||
|
||||
class ParserInitialDTest : public ParserTestBase {};
|
||||
|
||||
// todo delete
|
||||
// todo desc
|
||||
// todo describe
|
||||
// todo drop account
|
||||
|
||||
TEST_F(ParserInitialDTest, dropBnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop bnode on dnode 1");
|
||||
}
|
||||
|
||||
// todo drop database
|
||||
// todo drop dnode
|
||||
// todo drop function
|
||||
|
||||
TEST_F(ParserInitialDTest, dropIndex) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop index index1 on t1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialDTest, dropMnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop mnode on dnode 1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialDTest, dropQnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop qnode on dnode 1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialDTest, dropSnode) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop snode on dnode 1");
|
||||
}
|
||||
|
||||
// todo drop stable
|
||||
// todo drop stream
|
||||
// todo drop table
|
||||
|
||||
TEST_F(ParserInitialDTest, dropTopic) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop topic tp1");
|
||||
|
||||
run("drop topic if exists tp1");
|
||||
}
|
||||
|
||||
TEST_F(ParserInitialDTest, dropUser) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("drop user wxy");
|
||||
}
|
||||
|
||||
} // namespace ParserTest
|
|
@ -111,6 +111,7 @@ class InsertTest : public Test {
|
|||
cxt_.pMsg = errMagBuf_;
|
||||
cxt_.msgLen = max_err_len;
|
||||
code_ = TSDB_CODE_SUCCESS;
|
||||
res_ = nullptr;
|
||||
}
|
||||
|
||||
SVnodeModifOpStmt* getVnodeModifStmt(SQuery* pQuery) { return (SVnodeModifOpStmt*)pQuery->pRoot; }
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "parTestUtil.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ParserTest {
|
||||
|
||||
class ParserSelectTest : public ParserTestBase {};
|
||||
|
||||
TEST_F(ParserSelectTest, basic) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("select * from t1");
|
||||
|
||||
run("select * from test.t1");
|
||||
|
||||
run("select ts, c1 from t1");
|
||||
|
||||
run("select ts, t.c1 from (select * from t1) t");
|
||||
|
||||
run("select * from t1 tt1, t1 tt2 where tt1.c1 = tt2.c1");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, constant) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("select 123, 20.4, 'abc', \"wxy\", timestamp '2022-02-09 17:30:20', true, false, 10s from t1");
|
||||
|
||||
run("select 1234567890123456789012345678901234567890, 20.1234567890123456789012345678901234567890, 'abc', \"wxy\", "
|
||||
"timestamp '2022-02-09 17:30:20', true, false, 15s from t1");
|
||||
|
||||
run("select 123 + 45 from t1 where 2 - 1");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, expression) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("select ts + 10s, c1 + 10, concat(c2, 'abc') from t1");
|
||||
|
||||
run("select ts > 0, c1 < 20 and c2 = 'qaz' from t1");
|
||||
|
||||
run("select ts > 0, c1 between 10 and 20 and c2 = 'qaz' from t1");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, condition) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("select c1 from t1 where ts in (true, false)");
|
||||
|
||||
run("select * from t1 where c1 > 10 and c1 is not null");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, pseudoColumn) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("select _wstartts, _wendts, count(*) from t1 interval(10s)");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, multiResFunc) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("select last(*), first(*), last_row(*) from t1");
|
||||
|
||||
run("select last(c1, c2), first(t1.*), last_row(c3) from t1");
|
||||
|
||||
run("select last(t2.*), first(t1.c1, t2.*), last_row(t1.*, t2.*) from st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, clause) {
|
||||
useDb("root", "test");
|
||||
|
||||
// group by clause
|
||||
run("select count(*) cnt from t1 where c1 > 0");
|
||||
|
||||
run("select count(*), c2 cnt from t1 where c1 > 0 group by c2");
|
||||
|
||||
run("select count(*) cnt from t1 where c1 > 0 group by c2 having count(c1) > 10");
|
||||
|
||||
run("select count(*), c1, c2 + 10, c1 + c2 cnt from t1 where c1 > 0 group by c2, c1");
|
||||
|
||||
run("select count(*), c1 + 10, c2 cnt from t1 where c1 > 0 group by c1 + 10, c2");
|
||||
|
||||
// order by clause
|
||||
run("select count(*) cnt from t1 where c1 > 0 group by c2 order by cnt");
|
||||
|
||||
run("select count(*) cnt from t1 where c1 > 0 group by c2 order by 1");
|
||||
|
||||
// distinct clause
|
||||
// run("select distinct c1, c2 from t1 where c1 > 0 order by c1");
|
||||
|
||||
// run("select distinct c1 + 10, c2 from t1 where c1 > 0 order by c1 + 10, c2");
|
||||
|
||||
// run("select distinct c1 + 10 cc1, c2 cc2 from t1 where c1 > 0 order by cc1, c2");
|
||||
|
||||
// run("select distinct count(c2) from t1 where c1 > 0 group by c1 order by count(c2)");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, window) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("select count(*) from t1 interval(10s)");
|
||||
}
|
||||
|
||||
TEST_F(ParserSelectTest, semanticError) {
|
||||
useDb("root", "test");
|
||||
|
||||
// TSDB_CODE_PAR_INVALID_COLUMN
|
||||
run("select c1, cc1 from t1", TSDB_CODE_PAR_INVALID_COLUMN, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select t1.c1, t1.cc1 from t1", TSDB_CODE_PAR_INVALID_COLUMN, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
// TSDB_CODE_PAR_TABLE_NOT_EXIST
|
||||
run("select * from t10", TSDB_CODE_PAR_TABLE_NOT_EXIST, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select * from test.t10", TSDB_CODE_PAR_TABLE_NOT_EXIST, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select t2.c1 from t1", TSDB_CODE_PAR_TABLE_NOT_EXIST, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
// TSDB_CODE_PAR_AMBIGUOUS_COLUMN
|
||||
run("select c2 from t1 tt1, t1 tt2 where tt1.c1 = tt2.c1", TSDB_CODE_PAR_AMBIGUOUS_COLUMN, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
// TSDB_CODE_PAR_WRONG_VALUE_TYPE
|
||||
run("select timestamp '2010' from t1", TSDB_CODE_PAR_WRONG_VALUE_TYPE, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
// TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
|
||||
run("select c2 from t1 tt1 join t1 tt2 on count(*) > 0", TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION,
|
||||
PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select c2 from t1 where count(*) > 0", TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select c2 from t1 group by count(*)", TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
// TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
|
||||
run("select c2 from t1 order by 0", TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select c2 from t1 order by 2", TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
// TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
|
||||
run("select count(*) cnt from t1 having c1 > 0", TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select count(*) cnt from t1 group by c2 having c1 > 0", TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION,
|
||||
PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select count(*), c1 cnt from t1 group by c2 having c2 > 0", TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION,
|
||||
PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select count(*) cnt from t1 group by c2 having c2 > 0 order by c1", TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION,
|
||||
PARSER_STAGE_TRANSLATE);
|
||||
|
||||
// TSDB_CODE_PAR_NOT_SINGLE_GROUP
|
||||
run("select count(*), c1 from t1", TSDB_CODE_PAR_NOT_SINGLE_GROUP, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select count(*) from t1 order by c1", TSDB_CODE_PAR_NOT_SINGLE_GROUP, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select c1 from t1 order by count(*)", TSDB_CODE_PAR_NOT_SINGLE_GROUP, PARSER_STAGE_TRANSLATE);
|
||||
|
||||
// TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
|
||||
run("select distinct c1, c2 from t1 where c1 > 0 order by ts", TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION,
|
||||
PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select distinct c1 from t1 where c1 > 0 order by count(c2)", TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION,
|
||||
PARSER_STAGE_TRANSLATE);
|
||||
|
||||
run("select distinct c2 from t1 where c1 > 0 order by count(c2)", TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION,
|
||||
PARSER_STAGE_TRANSLATE);
|
||||
}
|
||||
|
||||
} // namespace ParserTest
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "parTestUtil.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ParserTest {
|
||||
|
||||
class ParserShowToUseTest : public ParserTestBase {};
|
||||
|
||||
// todo show accounts
|
||||
// todo show apps
|
||||
// todo show connections
|
||||
// todo show create database
|
||||
// todo show create stable
|
||||
// todo show create table
|
||||
|
||||
TEST_F(ParserShowToUseTest, showDatabases) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show databases");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showDnodes) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show dnodes");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showFunctions) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show functions");
|
||||
}
|
||||
|
||||
// todo show licence
|
||||
|
||||
TEST_F(ParserShowToUseTest, showIndexes) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show indexes from t1");
|
||||
|
||||
run("show indexes from t1 from test");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showMnodes) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show mnodes");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showModules) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show modules");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showQnodes) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show qnodes");
|
||||
}
|
||||
|
||||
// todo show queries
|
||||
// todo show scores
|
||||
|
||||
TEST_F(ParserShowToUseTest, showStables) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show stables");
|
||||
|
||||
run("show test.stables");
|
||||
|
||||
run("show stables like 'c%'");
|
||||
|
||||
run("show test.stables like 'c%'");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showStreams) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show streams");
|
||||
}
|
||||
|
||||
TEST_F(ParserShowToUseTest, showTables) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show tables");
|
||||
|
||||
run("show test.tables");
|
||||
|
||||
run("show tables like 'c%'");
|
||||
|
||||
run("show test.tables like 'c%'");
|
||||
}
|
||||
|
||||
// todo show topics
|
||||
|
||||
TEST_F(ParserShowToUseTest, showUsers) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show users");
|
||||
}
|
||||
|
||||
// todo show variables
|
||||
|
||||
TEST_F(ParserShowToUseTest, showVgroups) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("show vgroups");
|
||||
|
||||
run("show test.vgroups");
|
||||
}
|
||||
|
||||
// todo show vnodes
|
||||
|
||||
// todo split vgroup
|
||||
|
||||
TEST_F(ParserShowToUseTest, useDatabase) {
|
||||
useDb("root", "test");
|
||||
|
||||
run("use wxy_db");
|
||||
}
|
||||
|
||||
} // namespace ParserTest
|
|
@ -30,6 +30,8 @@
|
|||
#include "parTestUtil.h"
|
||||
#include "parToken.h"
|
||||
|
||||
namespace ParserTest {
|
||||
|
||||
class ParserEnv : public testing::Environment {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
|
@ -62,9 +64,11 @@ static void parseArg(int argc, char* argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace ParserTest
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
testing::AddGlobalTestEnvironment(new ParserEnv());
|
||||
testing::AddGlobalTestEnvironment(new ParserTest::ParserEnv());
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
parseArg(argc, argv);
|
||||
ParserTest::parseArg(argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue