Merge branch '3.0' into feature/tq
This commit is contained in:
commit
1a13affb13
|
@ -1,5 +1,15 @@
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
if (NOT DEFINED TD_GRANT)
|
||||||
|
SET(TD_GRANT FALSE)
|
||||||
|
endif()
|
||||||
|
if (NOT DEFINED TD_USB_DONGLE)
|
||||||
|
SET(TD_USB_DONGLE FALSE)
|
||||||
|
endif()
|
||||||
|
IF (TD_GRANT)
|
||||||
|
ADD_DEFINITIONS(-D_GRANT)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${BUILD_TOOLS}" STREQUAL "")
|
IF ("${BUILD_TOOLS}" STREQUAL "")
|
||||||
IF (TD_LINUX)
|
IF (TD_LINUX)
|
||||||
IF (TD_ARM_32)
|
IF (TD_ARM_32)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
add_executable(tmq "")
|
add_executable(tmq "")
|
||||||
add_executable(tstream "")
|
add_executable(tstream "")
|
||||||
|
add_executable(demoapi "")
|
||||||
|
|
||||||
target_sources(tmq
|
target_sources(tmq
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
@ -10,6 +11,12 @@ target_sources(tstream
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"src/tstream.c"
|
"src/tstream.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_sources(demoapi
|
||||||
|
PRIVATE
|
||||||
|
"src/demoapi.c"
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(tmq
|
target_link_libraries(tmq
|
||||||
taos
|
taos
|
||||||
)
|
)
|
||||||
|
@ -18,6 +25,10 @@ target_link_libraries(tstream
|
||||||
taos
|
taos
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_libraries(demoapi
|
||||||
|
taos
|
||||||
|
)
|
||||||
|
|
||||||
target_include_directories(tmq
|
target_include_directories(tmq
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
|
@ -26,5 +37,11 @@ target_include_directories(tstream
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_include_directories(demoapi
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
|
)
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(tmq PROPERTIES OUTPUT_NAME tmq)
|
SET_TARGET_PROPERTIES(tmq PROPERTIES OUTPUT_NAME tmq)
|
||||||
SET_TARGET_PROPERTIES(tstream PROPERTIES OUTPUT_NAME tstream)
|
SET_TARGET_PROPERTIES(tstream PROPERTIES OUTPUT_NAME tstream)
|
||||||
|
SET_TARGET_PROPERTIES(demoapi PROPERTIES OUTPUT_NAME demoapi)
|
||||||
|
|
|
@ -0,0 +1,197 @@
|
||||||
|
// C api call sequence demo
|
||||||
|
// to compile: gcc -o apidemo apidemo.c -ltaos
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <argp.h>
|
||||||
|
|
||||||
|
#include "taos.h"
|
||||||
|
|
||||||
|
#define debugPrint(fmt, ...) \
|
||||||
|
do { if (g_args.debug_print || g_args.verbose_print) \
|
||||||
|
fprintf(stdout, "DEBG: "fmt, __VA_ARGS__); } while(0)
|
||||||
|
|
||||||
|
#define warnPrint(fmt, ...) \
|
||||||
|
do { fprintf(stderr, "\033[33m"); \
|
||||||
|
fprintf(stderr, "WARN: "fmt, __VA_ARGS__); \
|
||||||
|
fprintf(stderr, "\033[0m"); } while(0)
|
||||||
|
|
||||||
|
#define errorPrint(fmt, ...) \
|
||||||
|
do { fprintf(stderr, "\033[31m"); \
|
||||||
|
fprintf(stderr, "ERROR: "fmt, __VA_ARGS__); \
|
||||||
|
fprintf(stderr, "\033[0m"); } while(0)
|
||||||
|
|
||||||
|
#define okPrint(fmt, ...) \
|
||||||
|
do { fprintf(stderr, "\033[32m"); \
|
||||||
|
fprintf(stderr, "OK: "fmt, __VA_ARGS__); \
|
||||||
|
fprintf(stderr, "\033[0m"); } while(0)
|
||||||
|
|
||||||
|
int64_t g_num_of_tb = 2;
|
||||||
|
int64_t g_num_of_rec = 2;
|
||||||
|
|
||||||
|
static struct argp_option options[] = {
|
||||||
|
{"tables", 't', "NUMBER", 0, "Number of child tables, default is 10000."},
|
||||||
|
{"records", 'n', "NUMBER", 0,
|
||||||
|
"Number of records for each table, default is 10000."},
|
||||||
|
{0}};
|
||||||
|
|
||||||
|
static error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
||||||
|
switch (key) {
|
||||||
|
case 't':
|
||||||
|
g_num_of_tb = atoll(arg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'n':
|
||||||
|
g_num_of_rec = atoll(arg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct argp argp = {options, parse_opt, "", ""};
|
||||||
|
|
||||||
|
static void prepare_data(TAOS* taos) {
|
||||||
|
TAOS_RES *res;
|
||||||
|
res = taos_query(taos, "drop database if exists test;");
|
||||||
|
taos_free_result(res);
|
||||||
|
usleep(100000);
|
||||||
|
|
||||||
|
res = taos_query(taos, "create database test;");
|
||||||
|
taos_free_result(res);
|
||||||
|
usleep(100000);
|
||||||
|
taos_select_db(taos, "test");
|
||||||
|
|
||||||
|
res = taos_query(taos, "create table meters(ts timestamp, f float, n int, b binary(20)) tags(area int, localtion binary(20));");
|
||||||
|
taos_free_result(res);
|
||||||
|
|
||||||
|
char command[1024] = {0};
|
||||||
|
for (int64_t i = 0; i < g_num_of_tb; i ++) {
|
||||||
|
sprintf(command, "create table t%"PRId64" using meters tags(%"PRId64", '%s');",
|
||||||
|
i, i, (i%2)?"beijing":"shanghai");
|
||||||
|
res = taos_query(taos, command);
|
||||||
|
taos_free_result(res);
|
||||||
|
|
||||||
|
int64_t j = 0;
|
||||||
|
int64_t total = 0;
|
||||||
|
int64_t affected;
|
||||||
|
for (; j < g_num_of_rec -1; j ++) {
|
||||||
|
sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", %f, %"PRId64", '%c%d')",
|
||||||
|
i, 1650000000000+j, (float)j, j, 'a'+(int)j%10, rand());
|
||||||
|
res = taos_query(taos, command);
|
||||||
|
if ((res) && (0 == taos_errno(res))) {
|
||||||
|
affected = taos_affected_rows(res);
|
||||||
|
total += affected;
|
||||||
|
} else {
|
||||||
|
errorPrint("%s() LN%d: %s\n",
|
||||||
|
__func__, __LINE__, taos_errstr(res));
|
||||||
|
}
|
||||||
|
taos_free_result(res);
|
||||||
|
}
|
||||||
|
sprintf(command, "insert into t%"PRId64" values(%" PRId64 ", NULL, NULL, NULL)",
|
||||||
|
i, 1650000000000+j+1);
|
||||||
|
res = taos_query(taos, command);
|
||||||
|
if ((res) && (0 == taos_errno(res))) {
|
||||||
|
affected = taos_affected_rows(res);
|
||||||
|
total += affected;
|
||||||
|
} else {
|
||||||
|
errorPrint("%s() LN%d: %s\n",
|
||||||
|
__func__, __LINE__, taos_errstr(res));
|
||||||
|
}
|
||||||
|
taos_free_result(res);
|
||||||
|
|
||||||
|
printf("insert %"PRId64" records into t%"PRId64", total affected rows: %"PRId64"\n", j, i, total);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int print_result(TAOS_RES* res, int block) {
|
||||||
|
int64_t num_rows = 0;
|
||||||
|
TAOS_ROW row = NULL;
|
||||||
|
int num_fields = taos_num_fields(res);
|
||||||
|
TAOS_FIELD* fields = taos_fetch_fields(res);
|
||||||
|
|
||||||
|
if (block) {
|
||||||
|
warnPrint("%s() LN%d, call taos_fetch_block()\n", __func__, __LINE__);
|
||||||
|
int rows = 0;
|
||||||
|
while ((rows = taos_fetch_block(res, &row))) {
|
||||||
|
num_rows += rows;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
warnPrint("%s() LN%d, call taos_fetch_rows()\n", __func__, __LINE__);
|
||||||
|
while ((row = taos_fetch_row(res))) {
|
||||||
|
char temp[256] = {0};
|
||||||
|
taos_print_row(temp, row, fields, num_fields);
|
||||||
|
puts(temp);
|
||||||
|
num_rows ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void verify_query(TAOS* taos) {
|
||||||
|
// TODO: select count(tbname) from stable once stable query work
|
||||||
|
char command[1024] = {0};
|
||||||
|
|
||||||
|
for (int64_t i = 0; i < g_num_of_tb; i++) {
|
||||||
|
sprintf(command, "select * from t%"PRId64"", i);
|
||||||
|
TAOS_RES* res = taos_query(taos, command);
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
if (0 == taos_errno(res)) {
|
||||||
|
int field_count = taos_field_count(res);
|
||||||
|
printf("field_count: %d\n", field_count);
|
||||||
|
int* lengths = taos_fetch_lengths(res);
|
||||||
|
if (lengths) {
|
||||||
|
for (int c = 0; c < field_count; c++) {
|
||||||
|
printf("length of column %d is %d\n", c, lengths[c]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorPrint("%s() LN%d: t%"PRId64"'s lengths is NULL\n",
|
||||||
|
__func__, __LINE__, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t rows = print_result(res, i % 2);
|
||||||
|
printf("rows is: %"PRId64"\n", rows);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
errorPrint("%s() LN%d: %s\n",
|
||||||
|
__func__, __LINE__, taos_errstr(res));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorPrint("%s() LN%d: %s\n",
|
||||||
|
__func__, __LINE__, taos_errstr(res));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
const char* host = "127.0.0.1";
|
||||||
|
const char* user = "root";
|
||||||
|
const char* passwd = "taosdata";
|
||||||
|
|
||||||
|
argp_parse(&argp, argc, argv, 0, 0, NULL);
|
||||||
|
TAOS* taos = taos_connect(host, user, passwd, "", 0);
|
||||||
|
if (taos == NULL) {
|
||||||
|
printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* info = taos_get_server_info(taos);
|
||||||
|
printf("server info: %s\n", info);
|
||||||
|
info = taos_get_client_info(taos);
|
||||||
|
printf("client info: %s\n", info);
|
||||||
|
|
||||||
|
prepare_data(taos);
|
||||||
|
|
||||||
|
verify_query(taos);
|
||||||
|
|
||||||
|
taos_close(taos);
|
||||||
|
printf("done\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -222,7 +222,7 @@ typedef struct SFunctParam {
|
||||||
// the structure for sql function in select clause
|
// the structure for sql function in select clause
|
||||||
typedef struct SResSchame {
|
typedef struct SResSchame {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
int32_t colId;
|
int32_t slotId;
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
int32_t precision;
|
int32_t precision;
|
||||||
int32_t scale;
|
int32_t scale;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "tdef.h"
|
#include "tdef.h"
|
||||||
|
#include "tconfig.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -129,6 +130,7 @@ void taosCfgDynamicOptions(const char *option, const char *value);
|
||||||
void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary);
|
void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary);
|
||||||
|
|
||||||
struct SConfig *taosGetCfg();
|
struct SConfig *taosGetCfg();
|
||||||
|
int32_t taosAddClientLogCfg(SConfig *pCfg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,6 +260,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct SSchema {
|
typedef struct SSchema {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
|
int8_t index; // default is 0, not index created
|
||||||
col_id_t colId;
|
col_id_t colId;
|
||||||
int32_t bytes;
|
int32_t bytes;
|
||||||
char name[TSDB_COL_NAME_LEN];
|
char name[TSDB_COL_NAME_LEN];
|
||||||
|
@ -2015,6 +2016,7 @@ typedef struct {
|
||||||
static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) {
|
static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
||||||
|
tlen += taosEncodeFixedI8(buf, pSchema->index);
|
||||||
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
|
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
|
||||||
tlen += taosEncodeFixedI16(buf, pSchema->colId);
|
tlen += taosEncodeFixedI16(buf, pSchema->colId);
|
||||||
tlen += taosEncodeString(buf, pSchema->name);
|
tlen += taosEncodeString(buf, pSchema->name);
|
||||||
|
@ -2023,6 +2025,7 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
|
||||||
|
|
||||||
static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) {
|
static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) {
|
||||||
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
||||||
|
buf = taosDecodeFixedI8(buf, &pSchema->index);
|
||||||
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
||||||
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
||||||
buf = taosDecodeStringTo(buf, pSchema->name);
|
buf = taosDecodeStringTo(buf, pSchema->name);
|
||||||
|
@ -2031,6 +2034,7 @@ static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) {
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSchema) {
|
static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSchema) {
|
||||||
if (tEncodeI8(pEncoder, pSchema->type) < 0) return -1;
|
if (tEncodeI8(pEncoder, pSchema->type) < 0) return -1;
|
||||||
|
if (tEncodeI8(pEncoder, pSchema->index) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pSchema->bytes) < 0) return -1;
|
if (tEncodeI32(pEncoder, pSchema->bytes) < 0) return -1;
|
||||||
if (tEncodeI16(pEncoder, pSchema->colId) < 0) return -1;
|
if (tEncodeI16(pEncoder, pSchema->colId) < 0) return -1;
|
||||||
if (tEncodeCStr(pEncoder, pSchema->name) < 0) return -1;
|
if (tEncodeCStr(pEncoder, pSchema->name) < 0) return -1;
|
||||||
|
@ -2039,6 +2043,7 @@ static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSch
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tDecodeSSchema(SCoder* pDecoder, SSchema* pSchema) {
|
static FORCE_INLINE int32_t tDecodeSSchema(SCoder* pDecoder, SSchema* pSchema) {
|
||||||
if (tDecodeI8(pDecoder, &pSchema->type) < 0) return -1;
|
if (tDecodeI8(pDecoder, &pSchema->type) < 0) return -1;
|
||||||
|
if (tDecodeI8(pDecoder, &pSchema->index) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pSchema->bytes) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pSchema->bytes) < 0) return -1;
|
||||||
if (tDecodeI16(pDecoder, &pSchema->colId) < 0) return -1;
|
if (tDecodeI16(pDecoder, &pSchema->colId) < 0) return -1;
|
||||||
if (tDecodeCStrTo(pDecoder, pSchema->name) < 0) return -1;
|
if (tDecodeCStrTo(pDecoder, pSchema->name) < 0) return -1;
|
||||||
|
|
|
@ -64,6 +64,7 @@ char getPrecisionUnit(int32_t precision);
|
||||||
|
|
||||||
int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision);
|
int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision);
|
||||||
int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit);
|
int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit);
|
||||||
|
int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec, int64_t *timeVal);
|
||||||
|
|
||||||
void taosFormatUtcTime(char *buf, int32_t bufLen, int64_t time, int32_t precision);
|
void taosFormatUtcTime(char *buf, int32_t bufLen, int64_t time, int32_t precision);
|
||||||
|
|
||||||
|
|
|
@ -140,88 +140,89 @@
|
||||||
#define TK_APPS 122
|
#define TK_APPS 122
|
||||||
#define TK_CONNECTIONS 123
|
#define TK_CONNECTIONS 123
|
||||||
#define TK_LICENCE 124
|
#define TK_LICENCE 124
|
||||||
#define TK_QUERIES 125
|
#define TK_GRANTS 125
|
||||||
#define TK_SCORES 126
|
#define TK_QUERIES 126
|
||||||
#define TK_TOPICS 127
|
#define TK_SCORES 127
|
||||||
#define TK_VARIABLES 128
|
#define TK_TOPICS 128
|
||||||
#define TK_BNODES 129
|
#define TK_VARIABLES 129
|
||||||
#define TK_SNODES 130
|
#define TK_BNODES 130
|
||||||
#define TK_LIKE 131
|
#define TK_SNODES 131
|
||||||
#define TK_INDEX 132
|
#define TK_LIKE 132
|
||||||
#define TK_FULLTEXT 133
|
#define TK_INDEX 133
|
||||||
#define TK_FUNCTION 134
|
#define TK_FULLTEXT 134
|
||||||
#define TK_INTERVAL 135
|
#define TK_FUNCTION 135
|
||||||
#define TK_TOPIC 136
|
#define TK_INTERVAL 136
|
||||||
#define TK_AS 137
|
#define TK_TOPIC 137
|
||||||
#define TK_DESC 138
|
#define TK_AS 138
|
||||||
#define TK_DESCRIBE 139
|
#define TK_DESC 139
|
||||||
#define TK_RESET 140
|
#define TK_DESCRIBE 140
|
||||||
#define TK_QUERY 141
|
#define TK_RESET 141
|
||||||
#define TK_EXPLAIN 142
|
#define TK_QUERY 142
|
||||||
#define TK_ANALYZE 143
|
#define TK_EXPLAIN 143
|
||||||
#define TK_VERBOSE 144
|
#define TK_ANALYZE 144
|
||||||
#define TK_NK_BOOL 145
|
#define TK_VERBOSE 145
|
||||||
#define TK_RATIO 146
|
#define TK_NK_BOOL 146
|
||||||
#define TK_COMPACT 147
|
#define TK_RATIO 147
|
||||||
#define TK_VNODES 148
|
#define TK_COMPACT 148
|
||||||
#define TK_IN 149
|
#define TK_VNODES 149
|
||||||
#define TK_OUTPUTTYPE 150
|
#define TK_IN 150
|
||||||
#define TK_AGGREGATE 151
|
#define TK_OUTPUTTYPE 151
|
||||||
#define TK_BUFSIZE 152
|
#define TK_AGGREGATE 152
|
||||||
#define TK_STREAM 153
|
#define TK_BUFSIZE 153
|
||||||
#define TK_INTO 154
|
#define TK_STREAM 154
|
||||||
#define TK_KILL 155
|
#define TK_INTO 155
|
||||||
#define TK_CONNECTION 156
|
#define TK_KILL 156
|
||||||
#define TK_MERGE 157
|
#define TK_CONNECTION 157
|
||||||
#define TK_VGROUP 158
|
#define TK_MERGE 158
|
||||||
#define TK_REDISTRIBUTE 159
|
#define TK_VGROUP 159
|
||||||
#define TK_SPLIT 160
|
#define TK_REDISTRIBUTE 160
|
||||||
#define TK_SYNCDB 161
|
#define TK_SPLIT 161
|
||||||
#define TK_NULL 162
|
#define TK_SYNCDB 162
|
||||||
#define TK_FIRST 163
|
#define TK_NULL 163
|
||||||
#define TK_LAST 164
|
#define TK_FIRST 164
|
||||||
#define TK_NOW 165
|
#define TK_LAST 165
|
||||||
#define TK_ROWTS 166
|
#define TK_NOW 166
|
||||||
#define TK_TBNAME 167
|
#define TK_ROWTS 167
|
||||||
#define TK_QSTARTTS 168
|
#define TK_TBNAME 168
|
||||||
#define TK_QENDTS 169
|
#define TK_QSTARTTS 169
|
||||||
#define TK_WSTARTTS 170
|
#define TK_QENDTS 170
|
||||||
#define TK_WENDTS 171
|
#define TK_WSTARTTS 171
|
||||||
#define TK_WDURATION 172
|
#define TK_WENDTS 172
|
||||||
#define TK_BETWEEN 173
|
#define TK_WDURATION 173
|
||||||
#define TK_IS 174
|
#define TK_BETWEEN 174
|
||||||
#define TK_NK_LT 175
|
#define TK_IS 175
|
||||||
#define TK_NK_GT 176
|
#define TK_NK_LT 176
|
||||||
#define TK_NK_LE 177
|
#define TK_NK_GT 177
|
||||||
#define TK_NK_GE 178
|
#define TK_NK_LE 178
|
||||||
#define TK_NK_NE 179
|
#define TK_NK_GE 179
|
||||||
#define TK_MATCH 180
|
#define TK_NK_NE 180
|
||||||
#define TK_NMATCH 181
|
#define TK_MATCH 181
|
||||||
#define TK_JOIN 182
|
#define TK_NMATCH 182
|
||||||
#define TK_INNER 183
|
#define TK_JOIN 183
|
||||||
#define TK_SELECT 184
|
#define TK_INNER 184
|
||||||
#define TK_DISTINCT 185
|
#define TK_SELECT 185
|
||||||
#define TK_WHERE 186
|
#define TK_DISTINCT 186
|
||||||
#define TK_PARTITION 187
|
#define TK_WHERE 187
|
||||||
#define TK_BY 188
|
#define TK_PARTITION 188
|
||||||
#define TK_SESSION 189
|
#define TK_BY 189
|
||||||
#define TK_STATE_WINDOW 190
|
#define TK_SESSION 190
|
||||||
#define TK_SLIDING 191
|
#define TK_STATE_WINDOW 191
|
||||||
#define TK_FILL 192
|
#define TK_SLIDING 192
|
||||||
#define TK_VALUE 193
|
#define TK_FILL 193
|
||||||
#define TK_NONE 194
|
#define TK_VALUE 194
|
||||||
#define TK_PREV 195
|
#define TK_NONE 195
|
||||||
#define TK_LINEAR 196
|
#define TK_PREV 196
|
||||||
#define TK_NEXT 197
|
#define TK_LINEAR 197
|
||||||
#define TK_GROUP 198
|
#define TK_NEXT 198
|
||||||
#define TK_HAVING 199
|
#define TK_GROUP 199
|
||||||
#define TK_ORDER 200
|
#define TK_HAVING 200
|
||||||
#define TK_SLIMIT 201
|
#define TK_ORDER 201
|
||||||
#define TK_SOFFSET 202
|
#define TK_SLIMIT 202
|
||||||
#define TK_LIMIT 203
|
#define TK_SOFFSET 203
|
||||||
#define TK_OFFSET 204
|
#define TK_LIMIT 204
|
||||||
#define TK_ASC 205
|
#define TK_OFFSET 205
|
||||||
#define TK_NULLS 206
|
#define TK_ASC 206
|
||||||
|
#define TK_NULLS 207
|
||||||
|
|
||||||
#define TK_NK_SPACE 300
|
#define TK_NK_SPACE 300
|
||||||
#define TK_NK_COMMENT 301
|
#define TK_NK_COMMENT 301
|
||||||
|
|
|
@ -142,6 +142,43 @@ typedef struct {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define NUM_TO_STRING(_inputType, _input, _outputBytes, _output) \
|
||||||
|
do { \
|
||||||
|
switch (_inputType) { \
|
||||||
|
case TSDB_DATA_TYPE_TINYINT: \
|
||||||
|
snprintf(_output, (int32_t)(_outputBytes), "%d", *(int8_t *)(_input)); \
|
||||||
|
break; \
|
||||||
|
case TSDB_DATA_TYPE_UTINYINT: \
|
||||||
|
snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint8_t *)(_input)); \
|
||||||
|
break; \
|
||||||
|
case TSDB_DATA_TYPE_SMALLINT: \
|
||||||
|
snprintf(_output, (int32_t)(_outputBytes), "%d", *(int16_t *)(_input)); \
|
||||||
|
break; \
|
||||||
|
case TSDB_DATA_TYPE_USMALLINT: \
|
||||||
|
snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint16_t *)(_input)); \
|
||||||
|
break; \
|
||||||
|
case TSDB_DATA_TYPE_TIMESTAMP: \
|
||||||
|
case TSDB_DATA_TYPE_BIGINT: \
|
||||||
|
snprintf(_output, (int32_t)(_outputBytes), "%" PRId64, *(int64_t *)(_input)); \
|
||||||
|
break; \
|
||||||
|
case TSDB_DATA_TYPE_UBIGINT: \
|
||||||
|
snprintf(_output, (int32_t)(_outputBytes), "%" PRIu64, *(uint64_t *)(_input)); \
|
||||||
|
break; \
|
||||||
|
case TSDB_DATA_TYPE_FLOAT: \
|
||||||
|
snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \
|
||||||
|
break; \
|
||||||
|
case TSDB_DATA_TYPE_DOUBLE: \
|
||||||
|
snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \
|
||||||
|
break; \
|
||||||
|
case TSDB_DATA_TYPE_UINT: \
|
||||||
|
snprintf(_output, (int32_t)(_outputBytes), "%u", *(uint32_t *)(_input)); \
|
||||||
|
break; \
|
||||||
|
default: \
|
||||||
|
snprintf(_output, (int32_t)(_outputBytes), "%d", *(int32_t *)(_input)); \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
|
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
|
||||||
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
|
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
|
||||||
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
|
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
|
||||||
|
|
|
@ -85,8 +85,8 @@ typedef enum EFunctionType {
|
||||||
// conversion function
|
// conversion function
|
||||||
FUNCTION_TYPE_CAST = 2000,
|
FUNCTION_TYPE_CAST = 2000,
|
||||||
FUNCTION_TYPE_TO_ISO8601,
|
FUNCTION_TYPE_TO_ISO8601,
|
||||||
|
FUNCTION_TYPE_TO_UNIXTIMESTAMP,
|
||||||
FUNCTION_TYPE_TO_JSON,
|
FUNCTION_TYPE_TO_JSON,
|
||||||
FUNCTION_TYPE_UNIXTIMESTAMP,
|
|
||||||
|
|
||||||
// date and time function
|
// date and time function
|
||||||
FUNCTION_TYPE_NOW = 2500,
|
FUNCTION_TYPE_NOW = 2500,
|
||||||
|
@ -135,8 +135,17 @@ bool fmIsTimeorderFunc(int32_t funcId);
|
||||||
bool fmIsPseudoColumnFunc(int32_t funcId);
|
bool fmIsPseudoColumnFunc(int32_t funcId);
|
||||||
bool fmIsWindowPseudoColumnFunc(int32_t funcId);
|
bool fmIsWindowPseudoColumnFunc(int32_t funcId);
|
||||||
bool fmIsWindowClauseFunc(int32_t funcId);
|
bool fmIsWindowClauseFunc(int32_t funcId);
|
||||||
|
bool fmIsSpecialDataRequiredFunc(int32_t funcId);
|
||||||
|
bool fmIsDynamicScanOptimizedFunc(int32_t funcId);
|
||||||
|
|
||||||
int32_t fmFuncScanType(int32_t funcId);
|
typedef enum EFuncDataRequired {
|
||||||
|
FUNC_DATA_REQUIRED_ALL_NEEDED = 1,
|
||||||
|
FUNC_DATA_REQUIRED_STATIS_NEEDED,
|
||||||
|
FUNC_DATA_REQUIRED_NO_NEEDED,
|
||||||
|
FUNC_DATA_REQUIRED_DISCARD
|
||||||
|
} EFuncDataRequired;
|
||||||
|
|
||||||
|
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||||
|
|
||||||
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||||
int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet);
|
int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet);
|
||||||
|
|
|
@ -78,6 +78,9 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float uptime; // day
|
float uptime; // day
|
||||||
int8_t has_mnode;
|
int8_t has_mnode;
|
||||||
|
int8_t has_qnode;
|
||||||
|
int8_t has_snode;
|
||||||
|
int8_t has_bnode;
|
||||||
SMonDiskDesc logdir;
|
SMonDiskDesc logdir;
|
||||||
SMonDiskDesc tempdir;
|
SMonDiskDesc tempdir;
|
||||||
} SMonDnodeInfo;
|
} SMonDnodeInfo;
|
||||||
|
@ -134,8 +137,8 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t expire_time;
|
int32_t expire_time;
|
||||||
int32_t timeseries_used;
|
int64_t timeseries_used;
|
||||||
int32_t timeseries_total;
|
int64_t timeseries_total;
|
||||||
} SMonGrantInfo;
|
} SMonGrantInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -216,6 +216,7 @@ SNodeList* nodesMakeList();
|
||||||
int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode);
|
int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode);
|
||||||
int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
|
int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
|
||||||
int32_t nodesListMakeAppend(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 nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||||
int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc);
|
||||||
int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode);
|
int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode);
|
||||||
|
|
|
@ -30,6 +30,7 @@ typedef struct SLogicNode {
|
||||||
SNode* pConditions;
|
SNode* pConditions;
|
||||||
SNodeList* pChildren;
|
SNodeList* pChildren;
|
||||||
struct SLogicNode* pParent;
|
struct SLogicNode* pParent;
|
||||||
|
int32_t optimizedFlag;
|
||||||
} SLogicNode;
|
} SLogicNode;
|
||||||
|
|
||||||
typedef enum EScanType {
|
typedef enum EScanType {
|
||||||
|
@ -50,6 +51,8 @@ typedef struct SScanLogicNode {
|
||||||
SName tableName;
|
SName tableName;
|
||||||
bool showRewrite;
|
bool showRewrite;
|
||||||
double ratio;
|
double ratio;
|
||||||
|
SNodeList* pDynamicScanFuncs;
|
||||||
|
int32_t dataRequired;
|
||||||
} SScanLogicNode;
|
} SScanLogicNode;
|
||||||
|
|
||||||
typedef struct SJoinLogicNode {
|
typedef struct SJoinLogicNode {
|
||||||
|
@ -196,20 +199,13 @@ typedef struct SSystemTableScanPhysiNode {
|
||||||
int32_t accountId;
|
int32_t accountId;
|
||||||
} SSystemTableScanPhysiNode;
|
} SSystemTableScanPhysiNode;
|
||||||
|
|
||||||
typedef enum EScanRequired {
|
|
||||||
SCAN_REQUIRED_DATA_NO_NEEDED = 1,
|
|
||||||
SCAN_REQUIRED_DATA_STATIS_NEEDED,
|
|
||||||
SCAN_REQUIRED_DATA_ALL_NEEDED,
|
|
||||||
SCAN_REQUIRED_DATA_DISCARD,
|
|
||||||
} EScanRequired;
|
|
||||||
|
|
||||||
typedef struct STableScanPhysiNode {
|
typedef struct STableScanPhysiNode {
|
||||||
SScanPhysiNode scan;
|
SScanPhysiNode scan;
|
||||||
uint8_t scanFlag; // denotes reversed scan of data or not
|
uint8_t scanFlag; // denotes reversed scan of data or not
|
||||||
STimeWindow scanRange;
|
STimeWindow scanRange;
|
||||||
double ratio;
|
double ratio;
|
||||||
EScanRequired scanRequired;
|
int32_t dataRequired;
|
||||||
SNodeList* pScanReferFuncs;
|
SNodeList* pDynamicScanFuncs;
|
||||||
} STableScanPhysiNode;
|
} STableScanPhysiNode;
|
||||||
|
|
||||||
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "tcommon.h"
|
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
|
#include "tcommon.h"
|
||||||
|
|
||||||
typedef struct SFilterInfo SFilterInfo;
|
typedef struct SFilterInfo SFilterInfo;
|
||||||
typedef int32_t (*filer_get_col_from_id)(void *, int32_t, void **);
|
typedef int32_t (*filer_get_col_from_id)(void *, int32_t, void **);
|
||||||
|
@ -31,20 +31,20 @@ enum {
|
||||||
FLT_OPTION_NEED_UNIQE = 4,
|
FLT_OPTION_NEED_UNIQE = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct SFilterColumnParam{
|
typedef struct SFilterColumnParam {
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
SArray* pDataBlock;
|
SArray *pDataBlock;
|
||||||
} SFilterColumnParam;
|
} SFilterColumnParam;
|
||||||
|
|
||||||
extern int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pinfo, uint32_t options);
|
extern int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pinfo, uint32_t options);
|
||||||
extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t** p, SColumnDataAgg *statis, int16_t numOfCols);
|
extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, int8_t **p, SColumnDataAgg *statis, int16_t numOfCols);
|
||||||
extern int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param);
|
extern int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param);
|
||||||
extern int32_t filterSetDataFromColId(SFilterInfo *info, void *param);
|
extern int32_t filterSetDataFromColId(SFilterInfo *info, void *param);
|
||||||
extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict);
|
extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict);
|
||||||
extern int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows, bool *gotNchar);
|
extern int32_t filterConverNcharColumns(SFilterInfo *pFilterInfo, int32_t rows, bool *gotNchar);
|
||||||
extern int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo);
|
extern int32_t filterFreeNcharColumns(SFilterInfo *pFilterInfo);
|
||||||
extern void filterFreeInfo(SFilterInfo *info);
|
extern void filterFreeInfo(SFilterInfo *info);
|
||||||
extern bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows);
|
extern bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,14 @@ int32_t ltrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut
|
||||||
int32_t rtrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t rtrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
||||||
|
/* Conversion functions */
|
||||||
|
int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
||||||
|
/* Time related functions */
|
||||||
|
int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
||||||
bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
|
|
||||||
int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
|
@ -38,6 +38,7 @@ typedef struct TdDirEntry *TdDirEntryPtr;
|
||||||
void taosRemoveDir(const char *dirname);
|
void taosRemoveDir(const char *dirname);
|
||||||
bool taosDirExist(char *dirname);
|
bool taosDirExist(char *dirname);
|
||||||
int32_t taosMkDir(const char *dirname);
|
int32_t taosMkDir(const char *dirname);
|
||||||
|
int32_t taosMulMkDir(const char *dirname);
|
||||||
void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
|
void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
|
||||||
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
|
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
|
||||||
int32_t taosRealPath(char *dirname, int32_t maxlen);
|
int32_t taosRealPath(char *dirname, int32_t maxlen);
|
||||||
|
|
|
@ -39,7 +39,7 @@ int32_t taosGetEmail(char *email, int32_t maxLen);
|
||||||
int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen);
|
int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen);
|
||||||
int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores);
|
int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores);
|
||||||
int32_t taosGetCpuCores(float *numOfCores);
|
int32_t taosGetCpuCores(float *numOfCores);
|
||||||
int32_t taosGetCpuUsage(double *cpu_system, double *cpu_engine);
|
void taosGetCpuUsage(double *cpu_system, double *cpu_engine);
|
||||||
int32_t taosGetTotalMemory(int64_t *totalKB);
|
int32_t taosGetTotalMemory(int64_t *totalKB);
|
||||||
int32_t taosGetProcMemory(int64_t *usedKB);
|
int32_t taosGetProcMemory(int64_t *usedKB);
|
||||||
int32_t taosGetSysMemory(int64_t *usedKB);
|
int32_t taosGetSysMemory(int64_t *usedKB);
|
||||||
|
|
|
@ -597,6 +597,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_INVALID_ROLLUP_OPTION TAOS_DEF_ERROR_CODE(0, 0x2622)
|
#define TSDB_CODE_PAR_INVALID_ROLLUP_OPTION TAOS_DEF_ERROR_CODE(0, 0x2622)
|
||||||
#define TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION TAOS_DEF_ERROR_CODE(0, 0x2623)
|
#define TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION TAOS_DEF_ERROR_CODE(0, 0x2623)
|
||||||
#define TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST TAOS_DEF_ERROR_CODE(0, 0x2624)
|
#define TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST TAOS_DEF_ERROR_CODE(0, 0x2624)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_OPTION_UNIT TAOS_DEF_ERROR_CODE(0, 0x2625)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626)
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||||
|
|
|
@ -94,6 +94,11 @@ extern const int32_t TYPE_BYTES[15];
|
||||||
#define TSDB_TIME_PRECISION_MICRO_STR "us"
|
#define TSDB_TIME_PRECISION_MICRO_STR "us"
|
||||||
#define TSDB_TIME_PRECISION_NANO_STR "ns"
|
#define TSDB_TIME_PRECISION_NANO_STR "ns"
|
||||||
|
|
||||||
|
#define TSDB_TIME_PRECISION_SEC_DIGITS 10
|
||||||
|
#define TSDB_TIME_PRECISION_MILLI_DIGITS 13
|
||||||
|
#define TSDB_TIME_PRECISION_MICRO_DIGITS 16
|
||||||
|
#define TSDB_TIME_PRECISION_NANO_DIGITS 19
|
||||||
|
|
||||||
#define TSDB_INFORMATION_SCHEMA_DB "information_schema"
|
#define TSDB_INFORMATION_SCHEMA_DB "information_schema"
|
||||||
#define TSDB_INS_TABLE_DNODES "dnodes"
|
#define TSDB_INS_TABLE_DNODES "dnodes"
|
||||||
#define TSDB_INS_TABLE_MNODES "mnodes"
|
#define TSDB_INS_TABLE_MNODES "mnodes"
|
||||||
|
|
|
@ -157,7 +157,7 @@ function install_main_path() {
|
||||||
${csudo} mkdir -p ${install_main_dir}/cfg
|
${csudo} mkdir -p ${install_main_dir}/cfg
|
||||||
${csudo} mkdir -p ${install_main_dir}/bin
|
${csudo} mkdir -p ${install_main_dir}/bin
|
||||||
${csudo} mkdir -p ${install_main_dir}/connector
|
${csudo} mkdir -p ${install_main_dir}/connector
|
||||||
${csudo} mkdir -p ${install_main_dir}/driver
|
${csudo} mkdir -p ${install_main_dir}/lib
|
||||||
${csudo} mkdir -p ${install_main_dir}/examples
|
${csudo} mkdir -p ${install_main_dir}/examples
|
||||||
${csudo} mkdir -p ${install_main_dir}/include
|
${csudo} mkdir -p ${install_main_dir}/include
|
||||||
${csudo} mkdir -p ${install_main_dir}/init.d
|
${csudo} mkdir -p ${install_main_dir}/init.d
|
||||||
|
@ -198,6 +198,10 @@ function install_lib() {
|
||||||
# Remove links
|
# Remove links
|
||||||
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
|
${csudo} rm -f ${lib_link_dir}/libtaos.* || :
|
||||||
${csudo} rm -f ${lib64_link_dir}/libtaos.* || :
|
${csudo} rm -f ${lib64_link_dir}/libtaos.* || :
|
||||||
|
${csudo} rm -f ${lib_link_dir}/libtdb.* || :
|
||||||
|
${csudo} rm -f ${lib64_link_dir}/libtdb.* || :
|
||||||
|
|
||||||
|
${csudo} cp -rf ${script_dir}/lib/* ${install_main_dir}/lib && ${csudo} chmod 777 ${install_main_dir}/lib/*
|
||||||
|
|
||||||
${csudo} ln -s ${install_main_dir}/lib/libtaos.* ${lib_link_dir}/libtaos.so.1
|
${csudo} ln -s ${install_main_dir}/lib/libtaos.* ${lib_link_dir}/libtaos.so.1
|
||||||
${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
${csudo} ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||||
|
|
|
@ -737,7 +737,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
||||||
int32_t type = pResultInfo->fields[i].type;
|
int32_t type = pResultInfo->fields[i].type;
|
||||||
int32_t bytes = pResultInfo->fields[i].bytes;
|
int32_t bytes = pResultInfo->fields[i].bytes;
|
||||||
|
|
||||||
if (type == TSDB_DATA_TYPE_NCHAR) {
|
if (type == TSDB_DATA_TYPE_NCHAR && colLength[i] > 0) {
|
||||||
char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]);
|
char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -256,7 +256,7 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t taosAddClientLogCfg(SConfig *pCfg) {
|
int32_t taosAddClientLogCfg(SConfig *pCfg) {
|
||||||
if (cfgAddDir(pCfg, "configDir", configDir, 1) != 0) return -1;
|
if (cfgAddDir(pCfg, "configDir", configDir, 1) != 0) return -1;
|
||||||
if (cfgAddDir(pCfg, "scriptDir", configDir, 1) != 0) return -1;
|
if (cfgAddDir(pCfg, "scriptDir", configDir, 1) != 0) return -1;
|
||||||
if (cfgAddDir(pCfg, "logDir", tsLogDir, 1) != 0) return -1;
|
if (cfgAddDir(pCfg, "logDir", tsLogDir, 1) != 0) return -1;
|
||||||
|
@ -616,7 +616,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
|
||||||
|
|
||||||
taosSetAllDebugFlag(cfgGetItem(pCfg, "debugFlag")->i32);
|
taosSetAllDebugFlag(cfgGetItem(pCfg, "debugFlag")->i32);
|
||||||
|
|
||||||
if (taosMkDir(tsLogDir) != 0) {
|
if (taosMulMkDir(tsLogDir) != 0) {
|
||||||
uError("failed to create dir:%s since %s", tsLogDir, terrstr());
|
uError("failed to create dir:%s since %s", tsLogDir, terrstr());
|
||||||
cfgCleanup(pCfg);
|
cfgCleanup(pCfg);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -308,6 +308,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
|
||||||
tlen += taosEncodeFixedI16(buf, pReq->stbCfg.nTagCols);
|
tlen += taosEncodeFixedI16(buf, pReq->stbCfg.nTagCols);
|
||||||
for (col_id_t i = 0; i < pReq->stbCfg.nTagCols; ++i) {
|
for (col_id_t i = 0; i < pReq->stbCfg.nTagCols; ++i) {
|
||||||
tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pTagSchema[i].type);
|
tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pTagSchema[i].type);
|
||||||
|
tlen += taosEncodeFixedI8(buf, pReq->stbCfg.pTagSchema[i].index);
|
||||||
tlen += taosEncodeFixedI16(buf, pReq->stbCfg.pTagSchema[i].colId);
|
tlen += taosEncodeFixedI16(buf, pReq->stbCfg.pTagSchema[i].colId);
|
||||||
tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pTagSchema[i].bytes);
|
tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pTagSchema[i].bytes);
|
||||||
tlen += taosEncodeString(buf, pReq->stbCfg.pTagSchema[i].name);
|
tlen += taosEncodeString(buf, pReq->stbCfg.pTagSchema[i].name);
|
||||||
|
@ -378,6 +379,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
|
||||||
pReq->stbCfg.pTagSchema = (SSchema *)taosMemoryMalloc(pReq->stbCfg.nTagCols * sizeof(SSchema));
|
pReq->stbCfg.pTagSchema = (SSchema *)taosMemoryMalloc(pReq->stbCfg.nTagCols * sizeof(SSchema));
|
||||||
for (col_id_t i = 0; i < pReq->stbCfg.nTagCols; ++i) {
|
for (col_id_t i = 0; i < pReq->stbCfg.nTagCols; ++i) {
|
||||||
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].type));
|
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].type));
|
||||||
|
buf = taosDecodeFixedI8(buf, &(pReq->stbCfg.pTagSchema[i].index));
|
||||||
buf = taosDecodeFixedI16(buf, &pReq->stbCfg.pTagSchema[i].colId);
|
buf = taosDecodeFixedI16(buf, &pReq->stbCfg.pTagSchema[i].colId);
|
||||||
buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].bytes);
|
buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].bytes);
|
||||||
buf = taosDecodeStringTo(buf, pReq->stbCfg.pTagSchema[i].name);
|
buf = taosDecodeStringTo(buf, pReq->stbCfg.pTagSchema[i].name);
|
||||||
|
@ -1989,7 +1991,7 @@ void tFreeSUseDbBatchRsp(SUseDbBatchRsp *pRsp) {
|
||||||
taosArrayDestroy(pRsp->pArray);
|
taosArrayDestroy(pRsp->pArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq) {
|
int32_t tSerializeSDbCfgReq(void *buf, int32_t bufLen, SDbCfgReq *pReq) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
@ -2002,7 +2004,7 @@ int32_t tSerializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq) {
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq) {
|
int32_t tDeserializeSDbCfgReq(void *buf, int32_t bufLen, SDbCfgReq *pReq) {
|
||||||
SCoder decoder = {0};
|
SCoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
@ -2014,7 +2016,7 @@ int32_t tDeserializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSDbCfgRsp(void* buf, int32_t bufLen, const SDbCfgRsp* pRsp) {
|
int32_t tSerializeSDbCfgRsp(void *buf, int32_t bufLen, const SDbCfgRsp *pRsp) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
@ -2045,7 +2047,7 @@ int32_t tSerializeSDbCfgRsp(void* buf, int32_t bufLen, const SDbCfgRsp* pRsp) {
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSDbCfgRsp(void* buf, int32_t bufLen, SDbCfgRsp* pRsp) {
|
int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
|
||||||
SCoder decoder = {0};
|
SCoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
@ -2076,7 +2078,7 @@ int32_t tDeserializeSDbCfgRsp(void* buf, int32_t bufLen, SDbCfgRsp* pRsp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq) {
|
int32_t tSerializeSUserIndexReq(void *buf, int32_t bufLen, SUserIndexReq *pReq) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
@ -2089,7 +2091,7 @@ int32_t tSerializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq)
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq) {
|
int32_t tDeserializeSUserIndexReq(void *buf, int32_t bufLen, SUserIndexReq *pReq) {
|
||||||
SCoder decoder = {0};
|
SCoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
@ -2101,7 +2103,7 @@ int32_t tDeserializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSUserIndexRsp(void* buf, int32_t bufLen, const SUserIndexRsp* pRsp) {
|
int32_t tSerializeSUserIndexRsp(void *buf, int32_t bufLen, const SUserIndexRsp *pRsp) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
||||||
|
@ -2118,7 +2120,7 @@ int32_t tSerializeSUserIndexRsp(void* buf, int32_t bufLen, const SUserIndexRsp*
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSUserIndexRsp(void* buf, int32_t bufLen, SUserIndexRsp* pRsp) {
|
int32_t tDeserializeSUserIndexRsp(void *buf, int32_t bufLen, SUserIndexRsp *pRsp) {
|
||||||
SCoder decoder = {0};
|
SCoder decoder = {0};
|
||||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||||
|
|
||||||
|
@ -2134,7 +2136,6 @@ int32_t tDeserializeSUserIndexRsp(void* buf, int32_t bufLen, SUserIndexRsp* pRsp
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t tSerializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) {
|
int32_t tSerializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
|
@ -406,7 +406,31 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
|
||||||
default: {
|
default: {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec, int64_t *timeVal) {
|
||||||
|
int32_t charLen = varDataLen(inputData);
|
||||||
|
char *newColData;
|
||||||
|
if (type == TSDB_DATA_TYPE_BINARY) {
|
||||||
|
newColData = taosMemoryCalloc(1, charLen + 1);
|
||||||
|
memcpy(newColData, varDataVal(inputData), charLen);
|
||||||
|
taosParseTime(newColData, timeVal, charLen, (int32_t)timePrec, 0);
|
||||||
|
taosMemoryFree(newColData);
|
||||||
|
} else if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
newColData = taosMemoryCalloc(1, charLen / TSDB_NCHAR_SIZE + 1);
|
||||||
|
int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(inputData), charLen, newColData);
|
||||||
|
if (len < 0){
|
||||||
|
taosMemoryFree(newColData);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
newColData[len] = 0;
|
||||||
|
taosParseTime(newColData, timeVal, len + 1, (int32_t)timePrec, 0);
|
||||||
|
taosMemoryFree(newColData);
|
||||||
|
} else {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
|
static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
|
||||||
|
|
|
@ -1028,13 +1028,18 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) {
|
||||||
|
|
||||||
char * taosVariantGet(SVariant *pVar, int32_t type) {
|
char * taosVariantGet(SVariant *pVar, int32_t type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
case TSDB_DATA_TYPE_TINYINT:
|
case TSDB_DATA_TYPE_TINYINT:
|
||||||
case TSDB_DATA_TYPE_SMALLINT:
|
case TSDB_DATA_TYPE_SMALLINT:
|
||||||
|
case TSDB_DATA_TYPE_INT:
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
case TSDB_DATA_TYPE_INT:
|
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
return (char *)&pVar->i;
|
return (char *)&pVar->i;
|
||||||
|
case TSDB_DATA_TYPE_UTINYINT:
|
||||||
|
case TSDB_DATA_TYPE_USMALLINT:
|
||||||
|
case TSDB_DATA_TYPE_UINT:
|
||||||
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
|
return (char *)&pVar->u;
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
return (char *)&pVar->d;
|
return (char *)&pVar->d;
|
||||||
|
@ -1042,7 +1047,7 @@ char * taosVariantGet(SVariant *pVar, int32_t type) {
|
||||||
return (char *)pVar->pz;
|
return (char *)pVar->pz;
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
case TSDB_DATA_TYPE_NCHAR:
|
||||||
return (char *)pVar->ucs4;
|
return (char *)pVar->ucs4;
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,14 @@ target_include_directories(
|
||||||
)
|
)
|
||||||
target_link_libraries(taosd dnode)
|
target_link_libraries(taosd dnode)
|
||||||
|
|
||||||
|
IF (TD_GRANT)
|
||||||
|
TARGET_LINK_LIBRARIES(taosd grant)
|
||||||
|
ENDIF ()
|
||||||
|
IF (TD_USB_DONGLE)
|
||||||
|
TARGET_LINK_LIBRARIES(taosd usb_dongle)
|
||||||
|
else()
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
||||||
|
|
|
@ -58,7 +58,7 @@ int32_t bmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to create bnode since %s, input:%d cur:%d", terrstr(), createReq.dnodeId, pDnode->dnodeId);
|
dError("failed to create bnode since %s, input:%d cur:%d", terrstr(), createReq.dnodeId, pDnode->dnodeId);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return bmOpen(pWrapper);
|
return dndOpenNode(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ int32_t bmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to drop bnode since %s", terrstr());
|
dError("failed to drop bnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
// dndCloseNode(pWrapper);
|
||||||
return bmDrop(pWrapper);
|
return bmDrop(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,10 @@ static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
|
||||||
|
|
||||||
static void dmGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
|
static void dmGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
|
||||||
pInfo->uptime = (taosGetTimestampMs() - pDnode->rebootTime) / (86400000.0f);
|
pInfo->uptime = (taosGetTimestampMs() - pDnode->rebootTime) / (86400000.0f);
|
||||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, MNODE);
|
pInfo->has_mnode = pDnode->wrappers[MNODE].required;
|
||||||
if (pWrapper != NULL) {
|
pInfo->has_qnode = pDnode->wrappers[QNODE].required;
|
||||||
pInfo->has_mnode = pWrapper->required;
|
pInfo->has_snode = pDnode->wrappers[SNODE].required;
|
||||||
dndReleaseWrapper(pWrapper);
|
pInfo->has_bnode = pDnode->wrappers[BNODE].required;
|
||||||
}
|
|
||||||
tstrncpy(pInfo->logdir.name, tsLogDir, sizeof(pInfo->logdir.name));
|
tstrncpy(pInfo->logdir.name, tsLogDir, sizeof(pInfo->logdir.name));
|
||||||
pInfo->logdir.size = tsLogSpace.size;
|
pInfo->logdir.size = tsLogSpace.size;
|
||||||
tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name));
|
tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name));
|
||||||
|
@ -65,7 +64,7 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
bool getFromAPI = !tsMultiProcess;
|
bool getFromAPI = !tsMultiProcess;
|
||||||
pWrapper = &pDnode->wrappers[MNODE];
|
pWrapper = &pDnode->wrappers[MNODE];
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
if (dndMarkWrapper(pWrapper) != 0) {
|
if (dndMarkWrapper(pWrapper) == 0) {
|
||||||
mmGetMonitorInfo(pWrapper, &mmInfo);
|
mmGetMonitorInfo(pWrapper, &mmInfo);
|
||||||
dndReleaseWrapper(pWrapper);
|
dndReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +81,7 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
|
|
||||||
pWrapper = &pDnode->wrappers[VNODES];
|
pWrapper = &pDnode->wrappers[VNODES];
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
if (dndMarkWrapper(pWrapper) != 0) {
|
if (dndMarkWrapper(pWrapper) == 0) {
|
||||||
vmGetMonitorInfo(pWrapper, &vmInfo);
|
vmGetMonitorInfo(pWrapper, &vmInfo);
|
||||||
dndReleaseWrapper(pWrapper);
|
dndReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +98,7 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
|
|
||||||
pWrapper = &pDnode->wrappers[QNODE];
|
pWrapper = &pDnode->wrappers[QNODE];
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
if (dndMarkWrapper(pWrapper) != 0) {
|
if (dndMarkWrapper(pWrapper) == 0) {
|
||||||
qmGetMonitorInfo(pWrapper, &qmInfo);
|
qmGetMonitorInfo(pWrapper, &qmInfo);
|
||||||
dndReleaseWrapper(pWrapper);
|
dndReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +115,7 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
|
|
||||||
pWrapper = &pDnode->wrappers[SNODE];
|
pWrapper = &pDnode->wrappers[SNODE];
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
if (dndMarkWrapper(pWrapper) != 0) {
|
if (dndMarkWrapper(pWrapper) == 0) {
|
||||||
smGetMonitorInfo(pWrapper, &smInfo);
|
smGetMonitorInfo(pWrapper, &smInfo);
|
||||||
dndReleaseWrapper(pWrapper);
|
dndReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +132,7 @@ void dmSendMonitorReport(SDnode *pDnode) {
|
||||||
|
|
||||||
pWrapper = &pDnode->wrappers[BNODE];
|
pWrapper = &pDnode->wrappers[BNODE];
|
||||||
if (getFromAPI) {
|
if (getFromAPI) {
|
||||||
if (dndMarkWrapper(pWrapper) != 0) {
|
if (dndMarkWrapper(pWrapper) == 0) {
|
||||||
bmGetMonitorInfo(pWrapper, &bmInfo);
|
bmGetMonitorInfo(pWrapper, &bmInfo);
|
||||||
dndReleaseWrapper(pWrapper);
|
dndReleaseWrapper(pWrapper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dndInt.h"
|
#include "dndInt.h"
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
|
#include "tgrant.h"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
bool dumpConfig;
|
bool dumpConfig;
|
||||||
|
@ -90,8 +91,7 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndGenerateGrant() {
|
static void dndGenerateGrant() {
|
||||||
// grantParseParameter();
|
grantParseParameter();
|
||||||
printf("this feature is not implemented yet\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndPrintVersion() {
|
static void dndPrintVersion() {
|
||||||
|
|
|
@ -27,7 +27,7 @@ extern "C" {
|
||||||
typedef struct SBnodeMgmt {
|
typedef struct SBnodeMgmt {
|
||||||
SBnode *pBnode;
|
SBnode *pBnode;
|
||||||
SDnode *pDnode;
|
SDnode *pDnode;
|
||||||
SMgmtWrapper *pWrapper;
|
SMgmtWrapper *pWrapper;
|
||||||
const char *path;
|
const char *path;
|
||||||
SMultiWorker writeWorker;
|
SMultiWorker writeWorker;
|
||||||
SSingleWorker monitorWorker;
|
SSingleWorker monitorWorker;
|
||||||
|
|
|
@ -126,6 +126,7 @@ typedef struct SDnode {
|
||||||
int32_t numOfDisks;
|
int32_t numOfDisks;
|
||||||
uint16_t serverPort;
|
uint16_t serverPort;
|
||||||
bool dropped;
|
bool dropped;
|
||||||
|
EProcType procType;
|
||||||
EDndType ntype;
|
EDndType ntype;
|
||||||
EDndStatus status;
|
EDndStatus status;
|
||||||
EDndEvent event;
|
EDndEvent event;
|
||||||
|
|
|
@ -27,46 +27,42 @@ static bool dndRequireNode(SMgmtWrapper *pWrapper) {
|
||||||
return required;
|
return required;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndOpenNode(SMgmtWrapper *pWrapper) {
|
static int32_t dndInitNodeProc(SMgmtWrapper *pWrapper) {
|
||||||
if (taosMkDir(pWrapper->path) != 0) {
|
int32_t shmsize = tsMnodeShmSize;
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
if (pWrapper->ntype == VNODES) {
|
||||||
dError("node:%s, failed to create dir:%s since %s", pWrapper->name, pWrapper->path, terrstr());
|
shmsize = tsVnodeShmSize;
|
||||||
|
} else if (pWrapper->ntype == QNODE) {
|
||||||
|
shmsize = tsQnodeShmSize;
|
||||||
|
} else if (pWrapper->ntype == SNODE) {
|
||||||
|
shmsize = tsSnodeShmSize;
|
||||||
|
} else if (pWrapper->ntype == MNODE) {
|
||||||
|
shmsize = tsMnodeShmSize;
|
||||||
|
} else if (pWrapper->ntype == BNODE) {
|
||||||
|
shmsize = tsBnodeShmSize;
|
||||||
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*pWrapper->fp.openFp)(pWrapper) != 0) {
|
if (taosCreateShm(&pWrapper->shm, pWrapper->ntype, shmsize) != 0) {
|
||||||
dError("node:%s, failed to open since %s", pWrapper->name, terrstr());
|
terrno = TAOS_SYSTEM_ERROR(terrno);
|
||||||
|
dError("node:%s, failed to create shm size:%d since %s", pWrapper->name, shmsize, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
dInfo("node:%s, shm:%d is created, size:%d", pWrapper->name, pWrapper->shm.id, shmsize);
|
||||||
|
|
||||||
|
SProcCfg cfg = dndGenProcCfg(pWrapper);
|
||||||
|
cfg.isChild = false;
|
||||||
|
pWrapper->procType = PROC_PARENT;
|
||||||
|
pWrapper->pProc = taosProcInit(&cfg);
|
||||||
|
if (pWrapper->pProc == NULL) {
|
||||||
|
dError("node:%s, failed to create proc since %s", pWrapper->name, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("node:%s, has been opened", pWrapper->name);
|
|
||||||
pWrapper->deployed = true;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dndCloseNode(SMgmtWrapper *pWrapper) {
|
static int32_t dndNewNodeProc(SMgmtWrapper *pWrapper, EDndType n) {
|
||||||
dDebug("node:%s, mgmt start to close", pWrapper->name);
|
|
||||||
pWrapper->required = false;
|
|
||||||
taosWLockLatch(&pWrapper->latch);
|
|
||||||
if (pWrapper->deployed) {
|
|
||||||
(*pWrapper->fp.closeFp)(pWrapper);
|
|
||||||
pWrapper->deployed = false;
|
|
||||||
}
|
|
||||||
taosWUnLockLatch(&pWrapper->latch);
|
|
||||||
|
|
||||||
while (pWrapper->refCount > 0) {
|
|
||||||
taosMsleep(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pWrapper->pProc) {
|
|
||||||
taosProcCleanup(pWrapper->pProc);
|
|
||||||
pWrapper->pProc = NULL;
|
|
||||||
}
|
|
||||||
dDebug("node:%s, mgmt has been closed", pWrapper->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int32_t dndNewProc(SMgmtWrapper *pWrapper, EDndType n) {
|
|
||||||
char tstr[8] = {0};
|
char tstr[8] = {0};
|
||||||
char *args[6] = {0};
|
char *args[6] = {0};
|
||||||
snprintf(tstr, sizeof(tstr), "%d", n);
|
snprintf(tstr, sizeof(tstr), "%d", n);
|
||||||
|
@ -88,6 +84,86 @@ static int32_t dndNewProc(SMgmtWrapper *pWrapper, EDndType n) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t dndRunNodeProc(SMgmtWrapper *pWrapper) {
|
||||||
|
if (pWrapper->pDnode->ntype == NODE_MAX) {
|
||||||
|
dInfo("node:%s, should be started manually", pWrapper->name);
|
||||||
|
} else {
|
||||||
|
if (dndNewNodeProc(pWrapper, pWrapper->ntype) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosProcRun(pWrapper->pProc) != 0) {
|
||||||
|
dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t dndOpenNodeImp(SMgmtWrapper *pWrapper) {
|
||||||
|
if (taosMkDir(pWrapper->path) != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
dError("node:%s, failed to create dir:%s since %s", pWrapper->name, pWrapper->path, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*pWrapper->fp.openFp)(pWrapper) != 0) {
|
||||||
|
dError("node:%s, failed to open since %s", pWrapper->name, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dDebug("node:%s, has been opened", pWrapper->name);
|
||||||
|
pWrapper->deployed = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t dndOpenNode(SMgmtWrapper *pWrapper) {
|
||||||
|
SDnode *pDnode = pWrapper->pDnode;
|
||||||
|
if (pDnode->procType == PROC_SINGLE) {
|
||||||
|
return dndOpenNodeImp(pWrapper);
|
||||||
|
} else if (pDnode->procType == PROC_PARENT) {
|
||||||
|
if (dndInitNodeProc(pWrapper) != 0) return -1;
|
||||||
|
if (dndWriteShmFile(pDnode) != 0) return -1;
|
||||||
|
if (dndRunNodeProc(pWrapper) != 0) return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dndCloseNodeImp(SMgmtWrapper *pWrapper) {
|
||||||
|
dDebug("node:%s, mgmt start to close", pWrapper->name);
|
||||||
|
pWrapper->required = false;
|
||||||
|
taosWLockLatch(&pWrapper->latch);
|
||||||
|
if (pWrapper->deployed) {
|
||||||
|
(*pWrapper->fp.closeFp)(pWrapper);
|
||||||
|
pWrapper->deployed = false;
|
||||||
|
}
|
||||||
|
taosWUnLockLatch(&pWrapper->latch);
|
||||||
|
|
||||||
|
while (pWrapper->refCount > 0) {
|
||||||
|
taosMsleep(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pWrapper->pProc) {
|
||||||
|
taosProcCleanup(pWrapper->pProc);
|
||||||
|
pWrapper->pProc = NULL;
|
||||||
|
}
|
||||||
|
dDebug("node:%s, mgmt has been closed", pWrapper->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dndCloseNode(SMgmtWrapper *pWrapper) {
|
||||||
|
if (pWrapper->pDnode->procType == PROC_PARENT) {
|
||||||
|
if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) {
|
||||||
|
dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId);
|
||||||
|
taosKillProc(pWrapper->procId);
|
||||||
|
dInfo("node:%s, wait for child process:%d to stop", pWrapper->name, pWrapper->procId);
|
||||||
|
taosWaitProc(pWrapper->procId);
|
||||||
|
dInfo("node:%s, child process:%d is stopped", pWrapper->name, pWrapper->procId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dndCloseNodeImp(pWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
static void dndProcessProcHandle(void *handle) {
|
static void dndProcessProcHandle(void *handle) {
|
||||||
dWarn("handle:%p, the child process dies and send an offline rsp", handle);
|
dWarn("handle:%p, the child process dies and send an offline rsp", handle);
|
||||||
SRpcMsg rpcMsg = {.handle = handle, .code = TSDB_CODE_NODE_OFFLINE};
|
SRpcMsg rpcMsg = {.handle = handle, .code = TSDB_CODE_NODE_OFFLINE};
|
||||||
|
@ -96,13 +172,14 @@ static void dndProcessProcHandle(void *handle) {
|
||||||
|
|
||||||
static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
||||||
dInfo("dnode run in single process");
|
dInfo("dnode run in single process");
|
||||||
|
pDnode->procType = PROC_SINGLE;
|
||||||
|
|
||||||
for (EDndType n = DNODE; n < NODE_MAX; ++n) {
|
for (EDndType n = DNODE; n < NODE_MAX; ++n) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
pWrapper->required = dndRequireNode(pWrapper);
|
pWrapper->required = dndRequireNode(pWrapper);
|
||||||
if (!pWrapper->required) continue;
|
if (!pWrapper->required) continue;
|
||||||
|
|
||||||
if (dndOpenNode(pWrapper) != 0) {
|
if (dndOpenNodeImp(pWrapper) != 0) {
|
||||||
dError("node:%s, failed to start since %s", pWrapper->name, terrstr());
|
dError("node:%s, failed to start since %s", pWrapper->name, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -136,8 +213,10 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
||||||
|
|
||||||
static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
dInfo("dnode run in parent process");
|
dInfo("dnode run in parent process");
|
||||||
|
pDnode->procType = PROC_PARENT;
|
||||||
|
|
||||||
SMgmtWrapper *pDWrapper = &pDnode->wrappers[DNODE];
|
SMgmtWrapper *pDWrapper = &pDnode->wrappers[DNODE];
|
||||||
if (dndOpenNode(pDWrapper) != 0) {
|
if (dndOpenNodeImp(pDWrapper) != 0) {
|
||||||
dError("node:%s, failed to start since %s", pDWrapper->name, terrstr());
|
dError("node:%s, failed to start since %s", pDWrapper->name, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -146,36 +225,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
pWrapper->required = dndRequireNode(pWrapper);
|
pWrapper->required = dndRequireNode(pWrapper);
|
||||||
if (!pWrapper->required) continue;
|
if (!pWrapper->required) continue;
|
||||||
|
if (dndInitNodeProc(pWrapper) != 0) return -1;
|
||||||
int32_t shmsize = tsMnodeShmSize;
|
|
||||||
if (n == VNODES) {
|
|
||||||
shmsize = tsVnodeShmSize;
|
|
||||||
} else if (n == QNODE) {
|
|
||||||
shmsize = tsQnodeShmSize;
|
|
||||||
} else if (n == SNODE) {
|
|
||||||
shmsize = tsSnodeShmSize;
|
|
||||||
} else if (n == MNODE) {
|
|
||||||
shmsize = tsMnodeShmSize;
|
|
||||||
} else if (n == BNODE) {
|
|
||||||
shmsize = tsBnodeShmSize;
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosCreateShm(&pWrapper->shm, n, shmsize) != 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(terrno);
|
|
||||||
dError("node:%s, failed to create shm size:%d since %s", pWrapper->name, shmsize, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
dInfo("node:%s, shm:%d is created, size:%d", pWrapper->name, pWrapper->shm.id, shmsize);
|
|
||||||
|
|
||||||
SProcCfg cfg = dndGenProcCfg(pWrapper);
|
|
||||||
cfg.isChild = false;
|
|
||||||
pWrapper->procType = PROC_PARENT;
|
|
||||||
pWrapper->pProc = taosProcInit(&cfg);
|
|
||||||
if (pWrapper->pProc == NULL) {
|
|
||||||
dError("node:%s, failed to create proc since %s", pWrapper->name, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dndWriteShmFile(pDnode) != 0) {
|
if (dndWriteShmFile(pDnode) != 0) {
|
||||||
|
@ -186,19 +236,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
for (EDndType n = DNODE + 1; n < NODE_MAX; ++n) {
|
for (EDndType n = DNODE + 1; n < NODE_MAX; ++n) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
if (!pWrapper->required) continue;
|
if (!pWrapper->required) continue;
|
||||||
|
if (dndRunNodeProc(pWrapper) != 0) return -1;
|
||||||
if (pDnode->ntype == NODE_MAX) {
|
|
||||||
dInfo("node:%s, should be started manually", pWrapper->name);
|
|
||||||
} else {
|
|
||||||
if (dndNewProc(pWrapper, n) != 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosProcRun(pWrapper->pProc) != 0) {
|
|
||||||
dError("node:%s, failed to run proc since %s", pWrapper->name, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dndSetStatus(pDnode, DND_STAT_RUNNING);
|
dndSetStatus(pDnode, DND_STAT_RUNNING);
|
||||||
|
@ -239,7 +277,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
if (pWrapper->procId <= 0 || !taosProcExist(pWrapper->procId)) {
|
if (pWrapper->procId <= 0 || !taosProcExist(pWrapper->procId)) {
|
||||||
dWarn("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId);
|
dWarn("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId);
|
||||||
taosProcCloseHandles(pWrapper->pProc, dndProcessProcHandle);
|
taosProcCloseHandles(pWrapper->pProc, dndProcessProcHandle);
|
||||||
dndNewProc(pWrapper, n);
|
dndNewNodeProc(pWrapper, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,6 +291,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
static int32_t dndRunInChildProcess(SDnode *pDnode) {
|
static int32_t dndRunInChildProcess(SDnode *pDnode) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype];
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype];
|
||||||
dInfo("%s run in child process", pWrapper->name);
|
dInfo("%s run in child process", pWrapper->name);
|
||||||
|
pDnode->procType = PROC_CHILD;
|
||||||
|
|
||||||
pWrapper->required = dndRequireNode(pWrapper);
|
pWrapper->required = dndRequireNode(pWrapper);
|
||||||
if (!pWrapper->required) {
|
if (!pWrapper->required) {
|
||||||
|
@ -264,7 +303,7 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) {
|
||||||
tmsgSetDefaultMsgCb(&msgCb);
|
tmsgSetDefaultMsgCb(&msgCb);
|
||||||
pWrapper->procType = PROC_CHILD;
|
pWrapper->procType = PROC_CHILD;
|
||||||
|
|
||||||
if (dndOpenNode(pWrapper) != 0) {
|
if (dndOpenNodeImp(pWrapper) != 0) {
|
||||||
dError("node:%s, failed to start since %s", pWrapper->name, terrstr());
|
dError("node:%s, failed to start since %s", pWrapper->name, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ int32_t mmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to drop mnode since %s", terrstr());
|
dError("failed to drop mnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
// dndCloseNode(pWrapper);
|
||||||
return mmDrop(pWrapper);
|
return mmDrop(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ int32_t qmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to create qnode since %s", terrstr());
|
dError("failed to create qnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return qmOpen(pWrapper);
|
return dndOpenNode(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to drop qnode since %s", terrstr());
|
dError("failed to drop qnode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
// dndCloseNode(pWrapper);
|
||||||
return qmDrop(pWrapper);
|
return qmDrop(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ static void qmProcessMonitorQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
|
||||||
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
||||||
if (pMsg->rpcMsg.msgType == TDMT_MON_SM_INFO) {
|
if (pMsg->rpcMsg.msgType == TDMT_MON_QM_INFO) {
|
||||||
code = qmProcessGetMonQmInfoReq(pMgmt->pWrapper, pMsg);
|
code = qmProcessGetMonQmInfoReq(pMgmt->pWrapper, pMsg);
|
||||||
} else {
|
} else {
|
||||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
|
|
|
@ -58,7 +58,7 @@ int32_t smProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
dError("failed to create snode since %s", terrstr());
|
dError("failed to create snode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return smOpen(pWrapper);
|
return dndOpenNode(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return smDrop(pWrapper);
|
return smDrop(pWrapper);
|
||||||
|
// return dndCloseNode(pWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#ifndef _GRANT
|
||||||
|
#include "os.h"
|
||||||
|
#include "taoserror.h"
|
||||||
|
#include "tgrant.h"
|
||||||
|
#include "mndInt.h"
|
||||||
|
|
||||||
|
int32_t grantInit() { return TSDB_CODE_SUCCESS; }
|
||||||
|
void grantCleanUp() {}
|
||||||
|
void grantParseParameter() { mError("can't parsed parameter k"); }
|
||||||
|
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||||
|
void grantReset(EGrantType grant, uint64_t value) {}
|
||||||
|
void grantAdd(EGrantType grant, uint64_t value) {}
|
||||||
|
void grantRestore(EGrantType grant, uint64_t value) {}
|
||||||
|
|
||||||
|
#endif
|
|
@ -55,6 +55,8 @@ target_include_directories(
|
||||||
vnode
|
vnode
|
||||||
PUBLIC "inc"
|
PUBLIC "inc"
|
||||||
PRIVATE "src/inc"
|
PRIVATE "src/inc"
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar"
|
||||||
|
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
vnode
|
vnode
|
||||||
|
@ -69,6 +71,7 @@ target_link_libraries(
|
||||||
PUBLIC scheduler
|
PUBLIC scheduler
|
||||||
PUBLIC tdb
|
PUBLIC tdb
|
||||||
#PUBLIC bdb
|
#PUBLIC bdb
|
||||||
|
#PUBLIC scalar
|
||||||
PUBLIC transport
|
PUBLIC transport
|
||||||
PUBLIC stream
|
PUBLIC stream
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,18 +25,18 @@ typedef struct SPoolMem {
|
||||||
static SPoolMem *openPool();
|
static SPoolMem *openPool();
|
||||||
static void clearPool(SPoolMem *pPool);
|
static void clearPool(SPoolMem *pPool);
|
||||||
static void closePool(SPoolMem *pPool);
|
static void closePool(SPoolMem *pPool);
|
||||||
static void *poolMalloc(void *arg, size_t size);
|
static void * poolMalloc(void *arg, size_t size);
|
||||||
static void poolFree(void *arg, void *ptr);
|
static void poolFree(void *arg, void *ptr);
|
||||||
|
|
||||||
struct SMetaDB {
|
struct SMetaDB {
|
||||||
TXN txn;
|
TXN txn;
|
||||||
TENV *pEnv;
|
TENV * pEnv;
|
||||||
TDB *pTbDB;
|
TDB * pTbDB;
|
||||||
TDB *pSchemaDB;
|
TDB * pSchemaDB;
|
||||||
TDB *pNameIdx;
|
TDB * pNameIdx;
|
||||||
TDB *pStbIdx;
|
TDB * pStbIdx;
|
||||||
TDB *pNtbIdx;
|
TDB * pNtbIdx;
|
||||||
TDB *pCtbIdx;
|
TDB * pCtbIdx;
|
||||||
SPoolMem *pPool;
|
SPoolMem *pPool;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ typedef struct __attribute__((__packed__)) {
|
||||||
} SSchemaDbKey;
|
} SSchemaDbKey;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char * name;
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
} SNameIdxKey;
|
} SNameIdxKey;
|
||||||
|
|
||||||
|
@ -205,14 +205,14 @@ void metaCloseDB(SMeta *pMeta) {
|
||||||
|
|
||||||
int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
|
int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
SMetaDB *pMetaDb;
|
SMetaDB * pMetaDb;
|
||||||
void *pKey;
|
void * pKey;
|
||||||
void *pVal;
|
void * pVal;
|
||||||
int kLen;
|
int kLen;
|
||||||
int vLen;
|
int vLen;
|
||||||
int ret;
|
int ret;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
void *pBuf;
|
void * pBuf;
|
||||||
SCtbIdxKey ctbIdxKey;
|
SCtbIdxKey ctbIdxKey;
|
||||||
SSchemaDbKey schemaDbKey;
|
SSchemaDbKey schemaDbKey;
|
||||||
SSchemaWrapper schemaWrapper;
|
SSchemaWrapper schemaWrapper;
|
||||||
|
@ -329,11 +329,11 @@ int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) {
|
||||||
STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) {
|
STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) {
|
||||||
int ret;
|
int ret;
|
||||||
SMetaDB *pMetaDb = pMeta->pDB;
|
SMetaDB *pMetaDb = pMeta->pDB;
|
||||||
void *pKey;
|
void * pKey;
|
||||||
void *pVal;
|
void * pVal;
|
||||||
int kLen;
|
int kLen;
|
||||||
int vLen;
|
int vLen;
|
||||||
STbCfg *pTbCfg;
|
STbCfg * pTbCfg;
|
||||||
|
|
||||||
// Fetch
|
// Fetch
|
||||||
pKey = &uid;
|
pKey = &uid;
|
||||||
|
@ -385,14 +385,14 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSchemaWrapper *metaGetTableSchemaImpl(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline, bool isGetEx) {
|
static SSchemaWrapper *metaGetTableSchemaImpl(SMeta *pMeta, tb_uid_t uid, int32_t sver, bool isinline, bool isGetEx) {
|
||||||
void *pKey;
|
void * pKey;
|
||||||
void *pVal;
|
void * pVal;
|
||||||
int kLen;
|
int kLen;
|
||||||
int vLen;
|
int vLen;
|
||||||
int ret;
|
int ret;
|
||||||
SSchemaDbKey schemaDbKey;
|
SSchemaDbKey schemaDbKey;
|
||||||
SSchemaWrapper *pSchemaWrapper;
|
SSchemaWrapper *pSchemaWrapper;
|
||||||
void *pBuf;
|
void * pBuf;
|
||||||
|
|
||||||
// fetch
|
// fetch
|
||||||
schemaDbKey.uid = uid;
|
schemaDbKey.uid = uid;
|
||||||
|
@ -419,9 +419,9 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
|
||||||
tb_uid_t quid;
|
tb_uid_t quid;
|
||||||
SSchemaWrapper *pSW;
|
SSchemaWrapper *pSW;
|
||||||
STSchemaBuilder sb;
|
STSchemaBuilder sb;
|
||||||
SSchemaEx *pSchema;
|
SSchemaEx * pSchema;
|
||||||
STSchema *pTSchema;
|
STSchema * pTSchema;
|
||||||
STbCfg *pTbCfg;
|
STbCfg * pTbCfg;
|
||||||
|
|
||||||
pTbCfg = metaGetTbInfoByUid(pMeta, uid);
|
pTbCfg = metaGetTbInfoByUid(pMeta, uid);
|
||||||
if (pTbCfg->type == META_CHILD_TABLE) {
|
if (pTbCfg->type == META_CHILD_TABLE) {
|
||||||
|
@ -452,7 +452,7 @@ struct SMTbCursor {
|
||||||
|
|
||||||
SMTbCursor *metaOpenTbCursor(SMeta *pMeta) {
|
SMTbCursor *metaOpenTbCursor(SMeta *pMeta) {
|
||||||
SMTbCursor *pTbCur = NULL;
|
SMTbCursor *pTbCur = NULL;
|
||||||
SMetaDB *pDB = pMeta->pDB;
|
SMetaDB * pDB = pMeta->pDB;
|
||||||
|
|
||||||
pTbCur = (SMTbCursor *)taosMemoryCalloc(1, sizeof(*pTbCur));
|
pTbCur = (SMTbCursor *)taosMemoryCalloc(1, sizeof(*pTbCur));
|
||||||
if (pTbCur == NULL) {
|
if (pTbCur == NULL) {
|
||||||
|
@ -474,12 +474,12 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *metaTbCursorNext(SMTbCursor *pTbCur) {
|
char *metaTbCursorNext(SMTbCursor *pTbCur) {
|
||||||
void *pKey = NULL;
|
void * pKey = NULL;
|
||||||
void *pVal = NULL;
|
void * pVal = NULL;
|
||||||
int kLen;
|
int kLen;
|
||||||
int vLen;
|
int vLen;
|
||||||
int ret;
|
int ret;
|
||||||
void *pBuf;
|
void * pBuf;
|
||||||
STbCfg tbCfg;
|
STbCfg tbCfg;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -503,17 +503,17 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SMCtbCursor {
|
struct SMCtbCursor {
|
||||||
TDBC *pCur;
|
TDBC * pCur;
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
void *pKey;
|
void * pKey;
|
||||||
void *pVal;
|
void * pVal;
|
||||||
int kLen;
|
int kLen;
|
||||||
int vLen;
|
int vLen;
|
||||||
};
|
};
|
||||||
|
|
||||||
SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) {
|
SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) {
|
||||||
SMCtbCursor *pCtbCur = NULL;
|
SMCtbCursor *pCtbCur = NULL;
|
||||||
SMetaDB *pDB = pMeta->pDB;
|
SMetaDB * pDB = pMeta->pDB;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pCtbCur = (SMCtbCursor *)taosMemoryCalloc(1, sizeof(*pCtbCur));
|
pCtbCur = (SMCtbCursor *)taosMemoryCalloc(1, sizeof(*pCtbCur));
|
||||||
|
@ -621,6 +621,7 @@ static int metaEncodeSchema(void **buf, SSchemaWrapper *pSW) {
|
||||||
for (int i = 0; i < pSW->nCols; i++) {
|
for (int i = 0; i < pSW->nCols; i++) {
|
||||||
pSchema = pSW->pSchema + i;
|
pSchema = pSW->pSchema + i;
|
||||||
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
||||||
|
tlen += taosEncodeFixedI8(buf, pSchema->index);
|
||||||
tlen += taosEncodeFixedI16(buf, pSchema->colId);
|
tlen += taosEncodeFixedI16(buf, pSchema->colId);
|
||||||
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
|
tlen += taosEncodeFixedI32(buf, pSchema->bytes);
|
||||||
tlen += taosEncodeString(buf, pSchema->name);
|
tlen += taosEncodeString(buf, pSchema->name);
|
||||||
|
@ -637,6 +638,7 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) {
|
||||||
for (int i = 0; i < pSW->nCols; i++) {
|
for (int i = 0; i < pSW->nCols; i++) {
|
||||||
pSchema = pSW->pSchema + i;
|
pSchema = pSW->pSchema + i;
|
||||||
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
buf = taosDecodeFixedI8(buf, &pSchema->type);
|
||||||
|
buf = taosSkipFixedLen(buf, sizeof(int8_t));
|
||||||
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
buf = taosDecodeFixedI16(buf, &pSchema->colId);
|
||||||
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
buf = taosDecodeFixedI32(buf, &pSchema->bytes);
|
||||||
buf = taosDecodeStringTo(buf, pSchema->name);
|
buf = taosDecodeStringTo(buf, pSchema->name);
|
||||||
|
@ -781,7 +783,7 @@ static void closePool(SPoolMem *pPool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *poolMalloc(void *arg, size_t size) {
|
static void *poolMalloc(void *arg, size_t size) {
|
||||||
void *ptr = NULL;
|
void * ptr = NULL;
|
||||||
SPoolMem *pPool = (SPoolMem *)arg;
|
SPoolMem *pPool = (SPoolMem *)arg;
|
||||||
SPoolMem *pMem;
|
SPoolMem *pMem;
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -411,7 +411,7 @@ typedef struct STableScanInfo {
|
||||||
SResultRowInfo* pResultRowInfo;
|
SResultRowInfo* pResultRowInfo;
|
||||||
int32_t* rowCellInfoOffset;
|
int32_t* rowCellInfoOffset;
|
||||||
SExprInfo* pExpr;
|
SExprInfo* pExpr;
|
||||||
SSDataBlock block;
|
SSDataBlock* pResBlock;
|
||||||
SArray* pColMatchInfo;
|
SArray* pColMatchInfo;
|
||||||
int32_t numOfOutput;
|
int32_t numOfOutput;
|
||||||
int64_t elapsedTime;
|
int64_t elapsedTime;
|
||||||
|
@ -569,6 +569,9 @@ typedef struct SGroupbyOperatorInfo {
|
||||||
int32_t groupKeyLen; // total group by column width
|
int32_t groupKeyLen; // total group by column width
|
||||||
SGroupResInfo groupResInfo;
|
SGroupResInfo groupResInfo;
|
||||||
SAggSupporter aggSup;
|
SAggSupporter aggSup;
|
||||||
|
SExprInfo* pScalarExprInfo;
|
||||||
|
int32_t numOfScalarExpr;// the number of scalar expression in group operator
|
||||||
|
SqlFunctionCtx*pScalarFuncCtx;
|
||||||
} SGroupbyOperatorInfo;
|
} SGroupbyOperatorInfo;
|
||||||
|
|
||||||
typedef struct SDataGroupInfo {
|
typedef struct SDataGroupInfo {
|
||||||
|
@ -674,7 +677,7 @@ void operatorDummyCloseFn(void* param, int32_t numOfCols);
|
||||||
int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num);
|
int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num);
|
||||||
int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols,
|
int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
int32_t numOfRows, SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey);
|
int32_t numOfRows, SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey);
|
||||||
void toSDatablock(SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf, SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset);
|
void toSDatablock(SSDataBlock* pBlock, int32_t rowCapacity, SGroupResInfo* pGroupResInfo, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, int32_t* rowCellOffset);
|
||||||
void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset);
|
void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset);
|
||||||
void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order);
|
void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order);
|
||||||
int32_t setGroupResultOutputBuf_rv(SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t type,
|
int32_t setGroupResultOutputBuf_rv(SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t type,
|
||||||
|
@ -685,12 +688,11 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
|
||||||
uint64_t* total, SArray* pColList);
|
uint64_t* total, SArray* pColList);
|
||||||
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
||||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
||||||
SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t capacity);
|
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset);
|
||||||
SSDataBlock* loadNextDataBlock(void* param);
|
|
||||||
|
|
||||||
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t repeatTime,
|
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t repeatTime,
|
||||||
int32_t reverseTime, SArray* pColMatchInfo, SNode* pCondition, SExecTaskInfo* pTaskInfo);
|
int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock,
|
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock,
|
||||||
SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||||
SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||||
|
@ -704,8 +706,8 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataB
|
||||||
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlot,
|
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlot,
|
||||||
const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, int64_t gap, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, int64_t gap, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock,
|
SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList,
|
||||||
SArray* pGroupColList, SNode* pCondition, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
SNode* pCondition, SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||||
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* pResBlock, SArray* pColList, SArray* pTableIdList, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* pResBlock, SArray* pColList, SArray* pTableIdList, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
|
@ -729,6 +731,8 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOf
|
||||||
int32_t numOfOutput);
|
int32_t numOfOutput);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void 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);
|
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order);
|
||||||
|
|
||||||
void finalizeQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
void finalizeQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||||
|
|
|
@ -234,9 +234,8 @@ int32_t operatorDummyOpenFn(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
void operatorDummyCloseFn(void* param, int32_t numOfCols) {}
|
void operatorDummyCloseFn(void* param, int32_t numOfCols) {}
|
||||||
|
|
||||||
static int32_t doCopyToSDataBlock(SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType,
|
static int32_t doCopyToSDataBlock(SSDataBlock* pBlock, int32_t rowCapacity, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo,
|
||||||
SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset);
|
int32_t orderType, int32_t* rowCellOffset);
|
||||||
|
|
||||||
static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
|
static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
|
||||||
static void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, int64_t keyFirst,
|
static void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, int64_t keyFirst,
|
||||||
int64_t keyLast, STimeWindow* win);
|
int64_t keyLast, STimeWindow* win);
|
||||||
|
@ -1068,9 +1067,9 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx,
|
||||||
pCtx[i].size = pBlock->info.rows;
|
pCtx[i].size = pBlock->info.rows;
|
||||||
pCtx[i].currentStage = MAIN_SCAN;
|
pCtx[i].currentStage = MAIN_SCAN;
|
||||||
|
|
||||||
SExprInfo expr = pOperator->pExpr[i];
|
SExprInfo* pOneExpr = &pOperator->pExpr[i];
|
||||||
for (int32_t j = 0; j < expr.base.numOfParams; ++j) {
|
for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) {
|
||||||
SFunctParam *pFuncParam = &expr.base.pParam[j];
|
SFunctParam *pFuncParam = &pOneExpr->base.pParam[j];
|
||||||
if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
|
if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
|
||||||
int32_t slotId = pFuncParam->pCol->slotId;
|
int32_t slotId = pFuncParam->pCol->slotId;
|
||||||
pCtx[i].input.pData[j] = taosArrayGet(pBlock->pDataBlock, slotId);
|
pCtx[i].input.pData[j] = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
|
@ -1145,19 +1144,21 @@ static void setPseudoOutputColInfo(SSDataBlock* pResult, SqlFunctionCtx* pCtx, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
|
void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx, int32_t numOfOutput, SArray* pPseudoList) {
|
||||||
int32_t numOfOutput, SArray* pPseudoList) {
|
|
||||||
setPseudoOutputColInfo(pResult, pCtx, pPseudoList);
|
setPseudoOutputColInfo(pResult, pCtx, pPseudoList);
|
||||||
pResult->info.groupId = pSrcBlock->info.groupId;
|
pResult->info.groupId = pSrcBlock->info.groupId;
|
||||||
|
|
||||||
for (int32_t k = 0; k < numOfOutput; ++k) {
|
for (int32_t k = 0; k < numOfOutput; ++k) {
|
||||||
|
int32_t outputSlotId = pExpr[k].base.resSchema.slotId;
|
||||||
|
SqlFunctionCtx* pfCtx = &pCtx[k];
|
||||||
|
|
||||||
if (pExpr[k].pExpr->nodeType == QUERY_NODE_COLUMN) { // it is a project query
|
if (pExpr[k].pExpr->nodeType == QUERY_NODE_COLUMN) { // it is a project query
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, k);
|
SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||||
colDataAssign(pColInfoData, pCtx[k].input.pData[0], pCtx[k].input.numOfRows);
|
colDataAssign(pColInfoData, pfCtx->input.pData[0], pfCtx->input.numOfRows);
|
||||||
|
|
||||||
pResult->info.rows = pSrcBlock->info.rows;
|
pResult->info.rows = pSrcBlock->info.rows;
|
||||||
} else if (pExpr[k].pExpr->nodeType == QUERY_NODE_VALUE) {
|
} else if (pExpr[k].pExpr->nodeType == QUERY_NODE_VALUE) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, k);
|
SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||||
for (int32_t i = 0; i < pSrcBlock->info.rows; ++i) {
|
for (int32_t i = 0; i < pSrcBlock->info.rows; ++i) {
|
||||||
colDataAppend(pColInfoData, i, taosVariantGet(&pExpr[k].base.pParam[0].param, pExpr[k].base.pParam[0].param.nType), TSDB_DATA_TYPE_NULL == pExpr[k].base.pParam[0].param.nType);
|
colDataAppend(pColInfoData, i, taosVariantGet(&pExpr[k].base.pParam[0].param, pExpr[k].base.pParam[0].param.nType), TSDB_DATA_TYPE_NULL == pExpr[k].base.pParam[0].param.nType);
|
||||||
}
|
}
|
||||||
|
@ -1167,40 +1168,40 @@ static void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSData
|
||||||
taosArrayPush(pBlockList, &pSrcBlock);
|
taosArrayPush(pBlockList, &pSrcBlock);
|
||||||
|
|
||||||
SScalarParam dest = {0};
|
SScalarParam dest = {0};
|
||||||
dest.columnData = taosArrayGet(pResult->pDataBlock, k);
|
dest.columnData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||||
|
|
||||||
scalarCalculate(pExpr[k].pExpr->_optrRoot.pRootNode, pBlockList, &dest);
|
scalarCalculate(pExpr[k].pExpr->_optrRoot.pRootNode, pBlockList, &dest);
|
||||||
pResult->info.rows = dest.numOfRows;
|
pResult->info.rows = dest.numOfRows;
|
||||||
|
|
||||||
taosArrayDestroy(pBlockList);
|
taosArrayDestroy(pBlockList);
|
||||||
} else if (pExpr[k].pExpr->nodeType == QUERY_NODE_FUNCTION) {
|
} else if (pExpr[k].pExpr->nodeType == QUERY_NODE_FUNCTION) {
|
||||||
ASSERT(!fmIsAggFunc(pCtx[k].functionId));
|
ASSERT(!fmIsAggFunc(pfCtx->functionId));
|
||||||
|
|
||||||
if (fmIsPseudoColumnFunc(pCtx[k].functionId)) {
|
if (fmIsPseudoColumnFunc(pfCtx->functionId)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if (fmIsNonstandardSQLFunc(pCtx[k].functionId)) {
|
} else if (fmIsNonstandardSQLFunc(pfCtx->functionId)) {
|
||||||
// todo set the correct timestamp column
|
// todo set the correct timestamp column
|
||||||
pCtx[k].input.pPTS = taosArrayGet(pSrcBlock->pDataBlock, 1);
|
pfCtx->input.pPTS = taosArrayGet(pSrcBlock->pDataBlock, 1);
|
||||||
|
|
||||||
SResultRowEntryInfo *pResInfo = GET_RES_INFO(&pCtx[k]);
|
SResultRowEntryInfo *pResInfo = GET_RES_INFO(&pCtx[k]);
|
||||||
pCtx[k].fpSet.init(&pCtx[k], pResInfo);
|
pfCtx->fpSet.init(&pCtx[k], pResInfo);
|
||||||
|
|
||||||
pCtx[k].pOutput = taosArrayGet(pResult->pDataBlock, k);
|
pfCtx->pOutput = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||||
pCtx[k].offset = pResult->info.rows; // set the start offset
|
pfCtx->offset = pResult->info.rows; // set the start offset
|
||||||
|
|
||||||
if (taosArrayGetSize(pPseudoList) > 0) {
|
if (taosArrayGetSize(pPseudoList) > 0) {
|
||||||
int32_t* outputColIndex = taosArrayGet(pPseudoList, 0);
|
int32_t* outputColIndex = taosArrayGet(pPseudoList, 0);
|
||||||
pCtx[k].pTsOutput = (SColumnInfoData*)pCtx[*outputColIndex].pOutput;
|
pfCtx->pTsOutput = (SColumnInfoData*)pCtx[*outputColIndex].pOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfRows = pCtx[k].fpSet.process(&pCtx[k]);
|
int32_t numOfRows = pfCtx->fpSet.process(pfCtx);
|
||||||
pResult->info.rows += numOfRows;
|
pResult->info.rows += numOfRows;
|
||||||
} else {
|
} else {
|
||||||
SArray* pBlockList = taosArrayInit(4, POINTER_BYTES);
|
SArray* pBlockList = taosArrayInit(4, POINTER_BYTES);
|
||||||
taosArrayPush(pBlockList, &pSrcBlock);
|
taosArrayPush(pBlockList, &pSrcBlock);
|
||||||
|
|
||||||
SScalarParam dest = {0};
|
SScalarParam dest = {0};
|
||||||
dest.columnData = taosArrayGet(pResult->pDataBlock, k);
|
dest.columnData = taosArrayGet(pResult->pDataBlock, outputSlotId);
|
||||||
|
|
||||||
scalarCalculate((SNode*)pExpr[k].pExpr->_function.pFunctNode, pBlockList, &dest);
|
scalarCalculate((SNode*)pExpr[k].pExpr->_function.pFunctNode, pBlockList, &dest);
|
||||||
pResult->info.rows = dest.numOfRows;
|
pResult->info.rows = dest.numOfRows;
|
||||||
|
@ -1810,7 +1811,7 @@ static int32_t setCtxTagColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset) {
|
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset) {
|
||||||
SqlFunctionCtx* pFuncCtx = (SqlFunctionCtx*)taosMemoryCalloc(numOfOutput, sizeof(SqlFunctionCtx));
|
SqlFunctionCtx* pFuncCtx = (SqlFunctionCtx*)taosMemoryCalloc(numOfOutput, sizeof(SqlFunctionCtx));
|
||||||
if (pFuncCtx == NULL) {
|
if (pFuncCtx == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1851,12 +1852,12 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t num
|
||||||
pCtx->input.pData = taosMemoryCalloc(pFunct->numOfParams, POINTER_BYTES);
|
pCtx->input.pData = taosMemoryCalloc(pFunct->numOfParams, POINTER_BYTES);
|
||||||
pCtx->input.pColumnDataAgg = taosMemoryCalloc(pFunct->numOfParams, POINTER_BYTES);
|
pCtx->input.pColumnDataAgg = taosMemoryCalloc(pFunct->numOfParams, POINTER_BYTES);
|
||||||
|
|
||||||
pCtx->pTsOutput = NULL;//taosArrayInit(4, POINTER_BYTES);
|
pCtx->pTsOutput = NULL;
|
||||||
pCtx->resDataInfo.bytes = pFunct->resSchema.bytes;
|
pCtx->resDataInfo.bytes = pFunct->resSchema.bytes;
|
||||||
pCtx->resDataInfo.type = pFunct->resSchema.type;
|
pCtx->resDataInfo.type = pFunct->resSchema.type;
|
||||||
pCtx->order = TSDB_ORDER_ASC;
|
pCtx->order = TSDB_ORDER_ASC;
|
||||||
pCtx->start.key = INT64_MIN;
|
pCtx->start.key = INT64_MIN;
|
||||||
pCtx->end.key = INT64_MIN;
|
pCtx->end.key = INT64_MIN;
|
||||||
#if 0
|
#if 0
|
||||||
for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
|
for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
|
||||||
// int16_t type = pFunct->param[j].nType;
|
// int16_t type = pFunct->param[j].nType;
|
||||||
|
@ -3330,8 +3331,7 @@ void setIntervalQueryRange(STaskRuntimeEnv* pRuntimeEnv, TSKEY key) {
|
||||||
* @param pQInfo
|
* @param pQInfo
|
||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
static int32_t doCopyToSDataBlock(SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType,
|
int32_t doCopyToSDataBlock(SSDataBlock* pBlock, int32_t rowCapacity, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, int32_t* rowCellOffset) {
|
||||||
SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset) {
|
|
||||||
int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
|
int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
|
||||||
int32_t numOfResult = pBlock->info.rows; // there are already exists result rows
|
int32_t numOfResult = pBlock->info.rows; // there are already exists result rows
|
||||||
|
|
||||||
|
@ -3370,7 +3370,9 @@ static int32_t doCopyToSDataBlock(SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResI
|
||||||
pGroupResInfo->index += 1;
|
pGroupResInfo->index += 1;
|
||||||
|
|
||||||
for (int32_t j = 0; j < pBlock->info.numOfCols; ++j) {
|
for (int32_t j = 0; j < pBlock->info.numOfCols; ++j) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, j);
|
int32_t slotId = pExprInfo[j].base.resSchema.slotId;
|
||||||
|
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
SResultRowEntryInfo* pEntryInfo = getResultCell(pRow, j, rowCellOffset);
|
SResultRowEntryInfo* pEntryInfo = getResultCell(pRow, j, rowCellOffset);
|
||||||
|
|
||||||
char* in = GET_ROWCELL_INTERBUF(pEntryInfo);
|
char* in = GET_ROWCELL_INTERBUF(pEntryInfo);
|
||||||
|
@ -3391,8 +3393,8 @@ static int32_t doCopyToSDataBlock(SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResI
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void toSDatablock(SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf, SSDataBlock* pBlock, int32_t rowCapacity,
|
void toSDatablock(SSDataBlock* pBlock, int32_t rowCapacity, SGroupResInfo* pGroupResInfo, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf,
|
||||||
int32_t* rowCellOffset) {
|
int32_t* rowCellOffset) {
|
||||||
assert(pGroupResInfo->currentGroup <= pGroupResInfo->totalGroup);
|
assert(pGroupResInfo->currentGroup <= pGroupResInfo->totalGroup);
|
||||||
|
|
||||||
blockDataCleanup(pBlock);
|
blockDataCleanup(pBlock);
|
||||||
|
@ -3401,7 +3403,7 @@ void toSDatablock(SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf, SSDataBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t orderType = TSDB_ORDER_ASC;
|
int32_t orderType = TSDB_ORDER_ASC;
|
||||||
doCopyToSDataBlock(pBuf, pGroupResInfo, orderType, pBlock, rowCapacity, rowCellOffset);
|
doCopyToSDataBlock(pBlock, rowCapacity, pExprInfo, pBuf, pGroupResInfo, orderType, rowCellOffset);
|
||||||
|
|
||||||
// add condition (pBlock->info.rows >= 1) just to runtime happy
|
// add condition (pBlock->info.rows >= 1) just to runtime happy
|
||||||
blockDataUpdateTsWindow(pBlock);
|
blockDataUpdateTsWindow(pBlock);
|
||||||
|
@ -4438,32 +4440,6 @@ _error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock* createResultDataBlock(const SArray* pExprInfo) {
|
|
||||||
SSDataBlock* pResBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
|
||||||
if (pResBlock == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t numOfCols = taosArrayGetSize(pExprInfo);
|
|
||||||
pResBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
|
||||||
|
|
||||||
SArray* pResult = pResBlock->pDataBlock;
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
SColumnInfoData colInfoData = {0};
|
|
||||||
SExprInfo* p = taosArrayGetP(pExprInfo, i);
|
|
||||||
|
|
||||||
SResSchema* pSchema = &p->base.resSchema;
|
|
||||||
colInfoData.info.type = pSchema->type;
|
|
||||||
colInfoData.info.colId = pSchema->colId;
|
|
||||||
colInfoData.info.bytes = pSchema->bytes;
|
|
||||||
colInfoData.info.scale = pSchema->scale;
|
|
||||||
colInfoData.info.precision = pSchema->precision;
|
|
||||||
taosArrayPush(pResult, &colInfoData);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pResBlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, const char* pKey);
|
static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, const char* pKey);
|
||||||
static void cleanupAggSup(SAggSupporter* pAggSup);
|
static void cleanupAggSup(SAggSupporter* pAggSup);
|
||||||
|
|
||||||
|
@ -4777,7 +4753,7 @@ static int32_t initGroupCol(SExprInfo* pExprInfo, int32_t numOfCols, SArray* pGr
|
||||||
SColumn* pCol = taosArrayGet(pGroupInfo, i);
|
SColumn* pCol = taosArrayGet(pGroupInfo, i);
|
||||||
for (int32_t j = 0; j < numOfCols; ++j) {
|
for (int32_t j = 0; j < numOfCols; ++j) {
|
||||||
SExprInfo* pe = &pExprInfo[j];
|
SExprInfo* pe = &pExprInfo[j];
|
||||||
if (pe->base.resSchema.colId == pCol->colId) {
|
if (pe->base.resSchema.slotId == pCol->colId) {
|
||||||
taosArrayPush(plist, pCol);
|
taosArrayPush(plist, pCol);
|
||||||
taosArrayPush(pInfo->groupInfo, &j);
|
taosArrayPush(pInfo->groupInfo, &j);
|
||||||
len += pCol->bytes;
|
len += pCol->bytes;
|
||||||
|
@ -4816,7 +4792,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, num, &pInfo->binfo.rowCellInfoOffset);
|
pInfo->binfo.pCtx = createSqlFunctionCtx(pExprInfo, num, &pInfo->binfo.rowCellInfoOffset);
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1);
|
initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1);
|
||||||
|
|
||||||
if (pInfo->binfo.pCtx == NULL || pInfo->binfo.pRes == NULL) {
|
if (pInfo->binfo.pCtx == NULL || pInfo->binfo.pRes == NULL) {
|
||||||
|
@ -5137,9 +5113,7 @@ static SSDataBlock* doMultiTableAggregate(SOperatorInfo* pOperator, bool* newgro
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
toSDatablock(&pAggInfo->groupResInfo, pAggInfo->pResultBuf, pInfo->pRes, pAggInfo->binfo.capacity,
|
toSDatablock(pInfo->pRes, pAggInfo->binfo.capacity, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->pResultBuf, pAggInfo->binfo.rowCellInfoOffset);
|
||||||
pAggInfo->binfo.rowCellInfoOffset);
|
|
||||||
|
|
||||||
if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) {
|
if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
}
|
}
|
||||||
|
@ -5188,8 +5162,7 @@ static SSDataBlock* doMultiTableAggregate(SOperatorInfo* pOperator, bool* newgro
|
||||||
updateNumOfRowsInResultRows(pInfo->pCtx, pOperator->numOfOutput, &pInfo->resultRowInfo, pInfo->rowCellInfoOffset);
|
updateNumOfRowsInResultRows(pInfo->pCtx, pOperator->numOfOutput, &pInfo->resultRowInfo, pInfo->rowCellInfoOffset);
|
||||||
|
|
||||||
initGroupResInfo(&pAggInfo->groupResInfo, &pInfo->resultRowInfo);
|
initGroupResInfo(&pAggInfo->groupResInfo, &pInfo->resultRowInfo);
|
||||||
toSDatablock(&pAggInfo->groupResInfo, pAggInfo->pResultBuf, pInfo->pRes, pAggInfo->binfo.capacity,
|
toSDatablock(pInfo->pRes, pAggInfo->binfo.capacity, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->pResultBuf, pAggInfo->binfo.rowCellInfoOffset);
|
||||||
pAggInfo->binfo.rowCellInfoOffset);
|
|
||||||
|
|
||||||
if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) {
|
if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
|
@ -5204,6 +5177,7 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup)
|
||||||
|
|
||||||
SSDataBlock* pRes = pInfo->pRes;
|
SSDataBlock* pRes = pInfo->pRes;
|
||||||
blockDataCleanup(pRes);
|
blockDataCleanup(pRes);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (pProjectInfo->existDataBlock) { // TODO refactor
|
if (pProjectInfo->existDataBlock) { // TODO refactor
|
||||||
SSDataBlock* pBlock = pProjectInfo->existDataBlock;
|
SSDataBlock* pBlock = pProjectInfo->existDataBlock;
|
||||||
|
@ -5392,8 +5366,7 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator, bool* newgro
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity);
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity);
|
||||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity,
|
toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset);
|
||||||
pInfo->binfo.rowCellInfoOffset);
|
|
||||||
|
|
||||||
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
|
@ -5411,8 +5384,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity,
|
toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset);
|
||||||
pInfo->binfo.rowCellInfoOffset);
|
|
||||||
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
}
|
}
|
||||||
|
@ -5447,8 +5419,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup
|
||||||
|
|
||||||
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
|
initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity);
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity);
|
||||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity,
|
toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset);
|
||||||
pInfo->binfo.rowCellInfoOffset);
|
|
||||||
|
|
||||||
ASSERT(pInfo->binfo.pRes->info.rows > 0);
|
ASSERT(pInfo->binfo.pRes->info.rows > 0);
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
|
@ -5693,7 +5664,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pBInfo->pRes, pBInfo->capacity, pBInfo->rowCellInfoOffset);
|
toSDatablock(pBInfo->pRes, pBInfo->capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pBInfo->rowCellInfoOffset);
|
||||||
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -5725,7 +5696,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
|
|
||||||
initGroupResInfo(&pInfo->groupResInfo, &pBInfo->resultRowInfo);
|
initGroupResInfo(&pInfo->groupResInfo, &pBInfo->resultRowInfo);
|
||||||
blockDataEnsureCapacity(pBInfo->pRes, pBInfo->capacity);
|
blockDataEnsureCapacity(pBInfo->pRes, pBInfo->capacity);
|
||||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pBInfo->pRes, pBInfo->capacity, pBInfo->rowCellInfoOffset);
|
toSDatablock(pBInfo->pRes, pBInfo->capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pBInfo->rowCellInfoOffset);
|
||||||
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
|
@ -5742,7 +5713,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator, bool* newgroup)
|
||||||
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
SOptrBasicInfo* pBInfo = &pInfo->binfo;
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pBInfo->pRes, pBInfo->capacity, pBInfo->rowCellInfoOffset);
|
toSDatablock(pBInfo->pRes, pBInfo->capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pBInfo->rowCellInfoOffset);
|
||||||
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -5774,7 +5745,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator, bool* newgroup)
|
||||||
|
|
||||||
initGroupResInfo(&pInfo->groupResInfo, &pBInfo->resultRowInfo);
|
initGroupResInfo(&pInfo->groupResInfo, &pBInfo->resultRowInfo);
|
||||||
blockDataEnsureCapacity(pBInfo->pRes, pBInfo->capacity);
|
blockDataEnsureCapacity(pBInfo->pRes, pBInfo->capacity);
|
||||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pBInfo->pRes, pBInfo->capacity, pBInfo->rowCellInfoOffset);
|
toSDatablock(pBInfo->pRes, pBInfo->capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pBInfo->rowCellInfoOffset);
|
||||||
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
|
@ -5953,7 +5924,7 @@ static void cleanupAggSup(SAggSupporter* pAggSup) {
|
||||||
|
|
||||||
int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols,
|
int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
int32_t numOfRows, SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey) {
|
int32_t numOfRows, SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey) {
|
||||||
pBasicInfo->pCtx = createSqlFunctionCtx_rv(pExprInfo, numOfCols, &pBasicInfo->rowCellInfoOffset);
|
pBasicInfo->pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pBasicInfo->rowCellInfoOffset);
|
||||||
pBasicInfo->pRes = pResultBlock;
|
pBasicInfo->pRes = pResultBlock;
|
||||||
pBasicInfo->capacity = numOfRows;
|
pBasicInfo->capacity = numOfRows;
|
||||||
|
|
||||||
|
@ -6382,8 +6353,6 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
|
||||||
SExprInfo* pExpr, int32_t numOfOutput) {
|
SExprInfo* pExpr, int32_t numOfOutput) {
|
||||||
STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo));
|
STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo));
|
||||||
|
|
||||||
// pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset);
|
|
||||||
// pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity);
|
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
||||||
|
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
|
@ -6406,8 +6375,6 @@ SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRun
|
||||||
SExprInfo* pExpr, int32_t numOfOutput) {
|
SExprInfo* pExpr, int32_t numOfOutput) {
|
||||||
STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo));
|
STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo));
|
||||||
|
|
||||||
// pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset);
|
|
||||||
// pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity);
|
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
||||||
|
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
|
@ -6682,45 +6649,13 @@ bool validateExprColumnInfo(SQueriedTableInfo* pTableInfo, SExprBasicInfo* pExpr
|
||||||
return j != INT32_MIN;
|
return j != INT32_MIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t deserializeColFilterInfo(SColumnFilterInfo* pColFilters, int16_t numOfFilters, char** pMsg) {
|
|
||||||
for (int32_t f = 0; f < numOfFilters; ++f) {
|
|
||||||
SColumnFilterInfo* pFilterMsg = (SColumnFilterInfo*)(*pMsg);
|
|
||||||
|
|
||||||
SColumnFilterInfo* pColFilter = &pColFilters[f];
|
|
||||||
pColFilter->filterstr = htons(pFilterMsg->filterstr);
|
|
||||||
|
|
||||||
(*pMsg) += sizeof(SColumnFilterInfo);
|
|
||||||
|
|
||||||
if (pColFilter->filterstr) {
|
|
||||||
pColFilter->len = htobe64(pFilterMsg->len);
|
|
||||||
|
|
||||||
pColFilter->pz =
|
|
||||||
(int64_t)taosMemoryCalloc(1, (size_t)(pColFilter->len + 1 * TSDB_NCHAR_SIZE)); // note: null-terminator
|
|
||||||
if (pColFilter->pz == 0) {
|
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy((void*)pColFilter->pz, (*pMsg), (size_t)pColFilter->len);
|
|
||||||
(*pMsg) += (pColFilter->len + 1);
|
|
||||||
} else {
|
|
||||||
pColFilter->lowerBndi = htobe64(pFilterMsg->lowerBndi);
|
|
||||||
pColFilter->upperBndi = htobe64(pFilterMsg->upperBndi);
|
|
||||||
}
|
|
||||||
|
|
||||||
pColFilter->lowerRelOptr = htons(pFilterMsg->lowerRelOptr);
|
|
||||||
pColFilter->upperRelOptr = htons(pFilterMsg->upperRelOptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, int32_t scale, int32_t precision,
|
static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, int32_t scale, int32_t precision,
|
||||||
const char* name) {
|
const char* name) {
|
||||||
SResSchema s = {0};
|
SResSchema s = {0};
|
||||||
s.scale = scale;
|
s.scale = scale;
|
||||||
s.type = type;
|
s.type = type;
|
||||||
s.bytes = bytes;
|
s.bytes = bytes;
|
||||||
s.colId = slotId;
|
s.slotId = slotId;
|
||||||
s.precision = precision;
|
s.precision = precision;
|
||||||
strncpy(s.name, name, tListLen(s.name));
|
strncpy(s.name, name, tListLen(s.name));
|
||||||
|
|
||||||
|
@ -6762,7 +6697,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
|
||||||
pTargetNode = (STargetNode*)nodesListGetNode(pGroupKeys, i - numOfFuncs);
|
pTargetNode = (STargetNode*)nodesListGetNode(pGroupKeys, i - numOfFuncs);
|
||||||
}
|
}
|
||||||
|
|
||||||
SExprInfo* pExp = &pExprs[pTargetNode->slotId];
|
SExprInfo* pExp = &pExprs[i];
|
||||||
|
|
||||||
pExp->pExpr = taosMemoryCalloc(1, sizeof(tExprNode));
|
pExp->pExpr = taosMemoryCalloc(1, sizeof(tExprNode));
|
||||||
pExp->pExpr->_function.num = 1;
|
pExp->pExpr->_function.num = 1;
|
||||||
|
@ -6882,8 +6817,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId);
|
tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId);
|
||||||
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
||||||
|
SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc);
|
||||||
|
|
||||||
return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pScanPhyNode->count,
|
return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pScanPhyNode->count,
|
||||||
pScanPhyNode->reverse, pColList, pScanPhyNode->node.pConditions, pTaskInfo);
|
pScanPhyNode->reverse, pColList, pResBlock, pScanPhyNode->node.pConditions, pTaskInfo);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
||||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode;
|
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode;
|
||||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pExchange->node.pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createOutputBuf_rv1(pExchange->node.pOutputDataBlockDesc);
|
||||||
|
@ -6938,9 +6875,15 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num);
|
SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num);
|
||||||
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc);
|
||||||
|
|
||||||
|
SExprInfo* pScalarExprInfo = NULL;
|
||||||
|
int32_t numOfScalarExpr = 0;
|
||||||
if (pAggNode->pGroupKeys != NULL) {
|
if (pAggNode->pGroupKeys != NULL) {
|
||||||
SArray* pColList = extractColumnInfo(pAggNode->pGroupKeys);
|
SArray* pColList = extractColumnInfo(pAggNode->pGroupKeys);
|
||||||
return createGroupOperatorInfo(op, pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pTaskInfo, NULL);
|
if (pAggNode->pExprs != NULL) {
|
||||||
|
pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return createGroupOperatorInfo(op, pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL);
|
||||||
} else {
|
} else {
|
||||||
return createAggregateOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo);
|
return createAggregateOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo);
|
||||||
}
|
}
|
||||||
|
@ -7187,10 +7130,15 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
|
||||||
}
|
}
|
||||||
|
|
||||||
*numOfOutputCols = 0;
|
*numOfOutputCols = 0;
|
||||||
|
|
||||||
int32_t num = LIST_LENGTH(pOutputNodeList->pSlots);
|
int32_t num = LIST_LENGTH(pOutputNodeList->pSlots);
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SSlotDescNode* pNode = (SSlotDescNode*)nodesListGetNode(pOutputNodeList->pSlots, i);
|
SSlotDescNode* pNode = (SSlotDescNode*)nodesListGetNode(pOutputNodeList->pSlots, i);
|
||||||
|
// todo: add reserve flag check
|
||||||
|
if (pNode->slotId >= numOfCols) { // it is a column reserved for the arithmetic expression calculation
|
||||||
|
(*numOfOutputCols) += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
SColMatchInfo* info = taosArrayGet(pList, pNode->slotId);
|
SColMatchInfo* info = taosArrayGet(pList, pNode->slotId);
|
||||||
if (pNode->output) {
|
if (pNode->output) {
|
||||||
(*numOfOutputCols) += 1;
|
(*numOfOutputCols) += 1;
|
||||||
|
|
|
@ -265,7 +265,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
|
||||||
SSDataBlock* pRes = pInfo->binfo.pRes;
|
SSDataBlock* pRes = pInfo->binfo.pRes;
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pRes, pInfo->binfo.capacity, pInfo->binfo.rowCellInfoOffset);
|
toSDatablock(pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset);
|
||||||
if (pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
}
|
}
|
||||||
|
@ -285,6 +285,12 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order);
|
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order);
|
||||||
|
|
||||||
|
// there is an scalar expression that needs to be calculated before apply the group aggregation.
|
||||||
|
if (pInfo->pScalarExprInfo != NULL) {
|
||||||
|
projectApplyFunctions(pInfo->pScalarExprInfo, pBlock, pBlock, pInfo->pScalarFuncCtx, pInfo->numOfScalarExpr, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->binfo.pCtx, pOperator->numOfOutput);
|
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->binfo.pCtx, pOperator->numOfOutput);
|
||||||
doHashGroupbyAgg(pOperator, pBlock);
|
doHashGroupbyAgg(pOperator, pBlock);
|
||||||
}
|
}
|
||||||
|
@ -305,7 +311,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
|
||||||
initGroupResInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo);
|
initGroupResInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pRes, pInfo->binfo.capacity, pInfo->binfo.rowCellInfoOffset);
|
toSDatablock(pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset);
|
||||||
doFilter(pInfo->pCondition, pRes);
|
doFilter(pInfo->pCondition, pRes);
|
||||||
|
|
||||||
bool hasRemain = hasRemainDataInCurrentGroup(&pInfo->groupResInfo);
|
bool hasRemain = hasRemainDataInCurrentGroup(&pInfo->groupResInfo);
|
||||||
|
@ -322,16 +328,21 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
|
||||||
return (pRes->info.rows == 0)? NULL:pRes;
|
return (pRes->info.rows == 0)? NULL:pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList, SNode* pCondition, SExecTaskInfo* pTaskInfo,
|
SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList,
|
||||||
const STableGroupInfo* pTableGroupInfo) {
|
SNode* pCondition, SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) {
|
||||||
SGroupbyOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SGroupbyOperatorInfo));
|
SGroupbyOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SGroupbyOperatorInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pGroupCols = pGroupColList;
|
pInfo->pGroupCols = pGroupColList;
|
||||||
pInfo->pCondition = pCondition;
|
pInfo->pCondition = pCondition;
|
||||||
|
|
||||||
|
pInfo->pScalarExprInfo = pScalarExprInfo;
|
||||||
|
pInfo->numOfScalarExpr = numOfScalarExpr;
|
||||||
|
pInfo->pScalarFuncCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pInfo->binfo.rowCellInfoOffset);
|
||||||
|
|
||||||
|
|
||||||
int32_t code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pGroupColList);
|
int32_t code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pGroupColList);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -113,7 +113,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
STableScanInfo* pTableScanInfo = pOperator->info;
|
STableScanInfo* pTableScanInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
SSDataBlock* pBlock = &pTableScanInfo->block;
|
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||||
STableGroupInfo* pTableGroupInfo = &pOperator->pTaskInfo->tableqinfoGroupInfo;
|
STableGroupInfo* pTableGroupInfo = &pOperator->pTaskInfo->tableqinfoGroupInfo;
|
||||||
|
|
||||||
*newgroup = false;
|
*newgroup = false;
|
||||||
|
@ -218,7 +218,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput,
|
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput,
|
||||||
int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo,
|
int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock,
|
||||||
SNode* pCondition, SExecTaskInfo* pTaskInfo) {
|
SNode* pCondition, SExecTaskInfo* pTaskInfo) {
|
||||||
assert(repeatTime > 0);
|
assert(repeatTime > 0);
|
||||||
|
|
||||||
|
@ -232,12 +232,7 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->block.pDataBlock = taosArrayInit(numOfOutput, sizeof(SColumnInfoData));
|
pInfo->pResBlock = pResBlock;
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
|
||||||
SColumnInfoData idata = {0};
|
|
||||||
taosArrayPush(pInfo->block.pDataBlock, &idata);
|
|
||||||
}
|
|
||||||
|
|
||||||
pInfo->pFilterNode = pCondition;
|
pInfo->pFilterNode = pCondition;
|
||||||
pInfo->dataReader = pTsdbReadHandle;
|
pInfo->dataReader = pTsdbReadHandle;
|
||||||
pInfo->times = repeatTime;
|
pInfo->times = repeatTime;
|
||||||
|
@ -312,7 +307,7 @@ static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
tsdbGetFileBlocksDistInfo(pTableScanInfo->dataReader, &tableBlockDist);
|
tsdbGetFileBlocksDistInfo(pTableScanInfo->dataReader, &tableBlockDist);
|
||||||
tableBlockDist.numOfRowsInMemTable = (int32_t) tsdbGetNumOfRowsInMemTable(pTableScanInfo->dataReader);
|
tableBlockDist.numOfRowsInMemTable = (int32_t) tsdbGetNumOfRowsInMemTable(pTableScanInfo->dataReader);
|
||||||
|
|
||||||
SSDataBlock* pBlock = &pTableScanInfo->block;
|
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||||
pBlock->info.rows = 1;
|
pBlock->info.rows = 1;
|
||||||
pBlock->info.numOfCols = 1;
|
pBlock->info.numOfCols = 1;
|
||||||
|
|
||||||
|
@ -343,13 +338,13 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo*
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->dataReader = dataReader;
|
pInfo->dataReader = dataReader;
|
||||||
pInfo->block.pDataBlock = taosArrayInit(1, sizeof(SColumnInfoData));
|
// pInfo->block.pDataBlock = taosArrayInit(1, sizeof(SColumnInfoData));
|
||||||
|
|
||||||
SColumnInfoData infoData = {0};
|
SColumnInfoData infoData = {0};
|
||||||
infoData.info.type = TSDB_DATA_TYPE_BINARY;
|
infoData.info.type = TSDB_DATA_TYPE_BINARY;
|
||||||
infoData.info.bytes = 1024;
|
infoData.info.bytes = 1024;
|
||||||
infoData.info.colId = 0;
|
infoData.info.colId = 0;
|
||||||
taosArrayPush(pInfo->block.pDataBlock, &infoData);
|
// taosArrayPush(pInfo->block.pDataBlock, &infoData);
|
||||||
|
|
||||||
pOperator->name = "DataBlockInfoScanOperator";
|
pOperator->name = "DataBlockInfoScanOperator";
|
||||||
// pOperator->operatorType = OP_TableBlockInfoScan;
|
// pOperator->operatorType = OP_TableBlockInfoScan;
|
||||||
|
|
|
@ -22,7 +22,7 @@ extern "C" {
|
||||||
|
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
|
||||||
#define FUNCTION_NAME_MAX_LENGTH 16
|
#define FUNCTION_NAME_MAX_LENGTH 32
|
||||||
|
|
||||||
#define FUNC_MGT_FUNC_CLASSIFICATION_MASK(n) (1 << n)
|
#define FUNC_MGT_FUNC_CLASSIFICATION_MASK(n) (1 << n)
|
||||||
|
|
||||||
|
@ -41,12 +41,14 @@ extern "C" {
|
||||||
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
||||||
|
|
||||||
typedef int32_t (*FCheckAndGetResultType)(SFunctionNode* pFunc);
|
typedef int32_t (*FCheckAndGetResultType)(SFunctionNode* pFunc);
|
||||||
|
typedef EFuncDataRequired (*FFuncDataRequired)(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||||
|
|
||||||
typedef struct SBuiltinFuncDefinition {
|
typedef struct SBuiltinFuncDefinition {
|
||||||
char name[FUNCTION_NAME_MAX_LENGTH];
|
char name[FUNCTION_NAME_MAX_LENGTH];
|
||||||
EFunctionType type;
|
EFunctionType type;
|
||||||
uint64_t classification;
|
uint64_t classification;
|
||||||
FCheckAndGetResultType checkFunc;
|
FCheckAndGetResultType checkFunc;
|
||||||
|
FFuncDataRequired dataRequiredFunc;
|
||||||
FExecGetEnv getEnvFunc;
|
FExecGetEnv getEnvFunc;
|
||||||
FExecInit initFunc;
|
FExecInit initFunc;
|
||||||
FExecProcess processFunc;
|
FExecProcess processFunc;
|
||||||
|
|
|
@ -21,10 +21,12 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
|
#include "functionMgt.h"
|
||||||
|
|
||||||
bool functionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
bool functionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo);
|
||||||
void functionFinalize(SqlFunctionCtx *pCtx);
|
void functionFinalize(SqlFunctionCtx *pCtx);
|
||||||
|
|
||||||
|
EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||||
bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
int32_t countFunction(SqlFunctionCtx *pCtx);
|
int32_t countFunction(SqlFunctionCtx *pCtx);
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "count",
|
.name = "count",
|
||||||
.type = FUNCTION_TYPE_COUNT,
|
.type = FUNCTION_TYPE_COUNT,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.checkFunc = checkAndGetResultType,
|
.checkFunc = checkAndGetResultType,
|
||||||
|
.dataRequiredFunc = countDataRequired,
|
||||||
.getEnvFunc = getCountFuncEnv,
|
.getEnvFunc = getCountFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = countFunction,
|
.processFunc = countFunction,
|
||||||
|
@ -389,7 +390,37 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.checkFunc = checkAndGetResultType,
|
.checkFunc = checkAndGetResultType,
|
||||||
.getEnvFunc = NULL,
|
.getEnvFunc = NULL,
|
||||||
.initFunc = NULL,
|
.initFunc = NULL,
|
||||||
.sprocessFunc = NULL,
|
.sprocessFunc = castFunction,
|
||||||
|
.finalizeFunc = NULL
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "to_iso8601",
|
||||||
|
.type = FUNCTION_TYPE_TO_ISO8601,
|
||||||
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
|
.checkFunc = checkAndGetResultType,
|
||||||
|
.getEnvFunc = NULL,
|
||||||
|
.initFunc = NULL,
|
||||||
|
.sprocessFunc = toISO8601Function,
|
||||||
|
.finalizeFunc = NULL
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "to_unixtimestamp",
|
||||||
|
.type = FUNCTION_TYPE_TO_UNIXTIMESTAMP,
|
||||||
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
|
.checkFunc = checkAndGetResultType,
|
||||||
|
.getEnvFunc = NULL,
|
||||||
|
.initFunc = NULL,
|
||||||
|
.sprocessFunc = toUnixtimestampFunction,
|
||||||
|
.finalizeFunc = NULL
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "timetruncate",
|
||||||
|
.type = FUNCTION_TYPE_TIMETRUNCATE,
|
||||||
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
|
.checkFunc = checkAndGetResultType,
|
||||||
|
.getEnvFunc = NULL,
|
||||||
|
.initFunc = NULL,
|
||||||
|
.sprocessFunc = timeTruncateFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -599,7 +630,25 @@ int32_t checkAndGetResultType(SFunctionNode* pFunc) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FUNCTION_TYPE_CAST: {
|
case FUNCTION_TYPE_CAST: {
|
||||||
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT };
|
//type
|
||||||
|
SValueNode* pParam = nodesListGetNode(pFunc->pParameterList, 1);
|
||||||
|
int32_t paraType = pParam->datum.i;
|
||||||
|
//bytes
|
||||||
|
pParam = nodesListGetNode(pFunc->pParameterList, 2);
|
||||||
|
int32_t paraBytes = pParam->datum.i;
|
||||||
|
pFunc->node.resType = (SDataType) { .bytes = paraBytes, .type = paraType};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FUNCTION_TYPE_TO_ISO8601: {
|
||||||
|
pFunc->node.resType = (SDataType) { .bytes = 64, .type = TSDB_DATA_TYPE_BINARY};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FUNCTION_TYPE_TO_UNIXTIMESTAMP: {
|
||||||
|
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FUNCTION_TYPE_TIMETRUNCATE: {
|
||||||
|
pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,14 @@ void functionFinalize(SqlFunctionCtx *pCtx) {
|
||||||
pResInfo->isNullRes = (pResInfo->numOfRes == 0)? 1:0;
|
pResInfo->isNullRes = (pResInfo->numOfRes == 0)? 1:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) {
|
||||||
|
SNode* pParam = nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(pParam) && PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pParam)->colId) {
|
||||||
|
return FUNC_DATA_REQUIRED_NO_NEEDED;
|
||||||
|
}
|
||||||
|
return FUNC_DATA_REQUIRED_STATIS_NEEDED;
|
||||||
|
}
|
||||||
|
|
||||||
bool getCountFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
bool getCountFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
||||||
pEnv->calcMemSize = sizeof(int64_t);
|
pEnv->calcMemSize = sizeof(int64_t);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -76,6 +76,16 @@ int32_t fmGetFuncResultType(SFunctionNode* pFunc) {
|
||||||
return funcMgtBuiltins[pFunc->funcId].checkFunc(pFunc);
|
return funcMgtBuiltins[pFunc->funcId].checkFunc(pFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) {
|
||||||
|
if (pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) {
|
||||||
|
return FUNC_DATA_REQUIRED_ALL_NEEDED;
|
||||||
|
}
|
||||||
|
if (NULL == funcMgtBuiltins[pFunc->funcId].dataRequiredFunc) {
|
||||||
|
return FUNC_DATA_REQUIRED_ALL_NEEDED;
|
||||||
|
}
|
||||||
|
return funcMgtBuiltins[pFunc->funcId].dataRequiredFunc(pFunc, pTimeWindow);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet) {
|
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet) {
|
||||||
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
|
@ -120,6 +130,13 @@ bool fmIsNonstandardSQLFunc(int32_t funcId) {
|
||||||
return isSpecificClassifyFunc(funcId, FUNC_MGT_NONSTANDARD_SQL_FUNC);
|
return isSpecificClassifyFunc(funcId, FUNC_MGT_NONSTANDARD_SQL_FUNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fmIsSpecialDataRequiredFunc(int32_t funcId) {
|
||||||
|
return isSpecificClassifyFunc(funcId, FUNC_MGT_SPECIAL_DATA_REQUIRED);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool fmIsDynamicScanOptimizedFunc(int32_t funcId) {
|
||||||
|
return isSpecificClassifyFunc(funcId, FUNC_MGT_DYNAMIC_SCAN_OPTIMIZED);
|
||||||
|
}
|
||||||
|
|
||||||
void fmFuncMgtDestroy() {
|
void fmFuncMgtDestroy() {
|
||||||
void* m = gFunMgtService.pFuncNameHashTable;
|
void* m = gFunMgtService.pFuncNameHashTable;
|
||||||
|
|
|
@ -541,7 +541,7 @@ struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, co
|
||||||
pFillCol[i].col.bytes = pExprInfo->base.resSchema.bytes;
|
pFillCol[i].col.bytes = pExprInfo->base.resSchema.bytes;
|
||||||
pFillCol[i].col.type = (int8_t)pExprInfo->base.resSchema.type;
|
pFillCol[i].col.type = (int8_t)pExprInfo->base.resSchema.type;
|
||||||
pFillCol[i].col.offset = offset;
|
pFillCol[i].col.offset = offset;
|
||||||
pFillCol[i].col.colId = pExprInfo->base.resSchema.colId;
|
pFillCol[i].col.colId = pExprInfo->base.resSchema.slotId;
|
||||||
pFillCol[i].tagIndex = -2;
|
pFillCol[i].tagIndex = -2;
|
||||||
pFillCol[i].flag = pExprInfo->base.pParam[0].pCol->flag; // always be the normal column for table query
|
pFillCol[i].flag = pExprInfo->base.pParam[0].pCol->flag; // always be the normal column for table query
|
||||||
// pFillCol[i].functionId = pExprInfo->pExpr->_function.functionId;
|
// pFillCol[i].functionId = pExprInfo->pExpr->_function.functionId;
|
||||||
|
|
|
@ -375,6 +375,9 @@ static void monGenDnodeJson(SMonInfo *pMonitor) {
|
||||||
tjsonAddDoubleToObject(pJson, "vnodes_num", pStat->totalVnodes);
|
tjsonAddDoubleToObject(pJson, "vnodes_num", pStat->totalVnodes);
|
||||||
tjsonAddDoubleToObject(pJson, "masters", pStat->masterNum);
|
tjsonAddDoubleToObject(pJson, "masters", pStat->masterNum);
|
||||||
tjsonAddDoubleToObject(pJson, "has_mnode", pInfo->has_mnode);
|
tjsonAddDoubleToObject(pJson, "has_mnode", pInfo->has_mnode);
|
||||||
|
tjsonAddDoubleToObject(pJson, "has_qnode", pInfo->has_qnode);
|
||||||
|
tjsonAddDoubleToObject(pJson, "has_snode", pInfo->has_snode);
|
||||||
|
tjsonAddDoubleToObject(pJson, "has_bnode", pInfo->has_bnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void monGenDiskJson(SMonInfo *pMonitor) {
|
static void monGenDiskJson(SMonInfo *pMonitor) {
|
||||||
|
@ -530,7 +533,7 @@ void monSendReport() {
|
||||||
if (pCont != NULL) {
|
if (pCont != NULL) {
|
||||||
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
||||||
if (taosSendHttpReport(tsMonitor.cfg.server, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
if (taosSendHttpReport(tsMonitor.cfg.server, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) {
|
||||||
uError("failed to send monitor msg since %s", terrstr());
|
uError("failed to send monitor msg");
|
||||||
}
|
}
|
||||||
taosMemoryFree(pCont);
|
taosMemoryFree(pCont);
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,9 +194,9 @@ int32_t tDecodeSMonVgroupInfo(SCoder *decoder, SMonVgroupInfo *pInfo) {
|
||||||
if (tDecodeCStrTo(decoder, desc.database_name) < 0) return -1;
|
if (tDecodeCStrTo(decoder, desc.database_name) < 0) return -1;
|
||||||
if (tDecodeCStrTo(decoder, desc.status) < 0) return -1;
|
if (tDecodeCStrTo(decoder, desc.status) < 0) return -1;
|
||||||
for (int32_t j = 0; j < TSDB_MAX_REPLICA; ++j) {
|
for (int32_t j = 0; j < TSDB_MAX_REPLICA; ++j) {
|
||||||
SMonVnodeDesc vdesc = {0};
|
SMonVnodeDesc *pVDesc = &desc.vnodes[j];
|
||||||
if (tDecodeI32(decoder, &vdesc.dnode_id) < 0) return -1;
|
if (tDecodeI32(decoder, &pVDesc->dnode_id) < 0) return -1;
|
||||||
if (tDecodeCStrTo(decoder, vdesc.vnode_role) < 0) return -1;
|
if (tDecodeCStrTo(decoder, pVDesc->vnode_role) < 0) return -1;
|
||||||
}
|
}
|
||||||
taosArrayPush(pInfo->vgroups, &desc);
|
taosArrayPush(pInfo->vgroups, &desc);
|
||||||
}
|
}
|
||||||
|
@ -205,15 +205,15 @@ int32_t tDecodeSMonVgroupInfo(SCoder *decoder, SMonVgroupInfo *pInfo) {
|
||||||
|
|
||||||
int32_t tEncodeSMonGrantInfo(SCoder *encoder, const SMonGrantInfo *pInfo) {
|
int32_t tEncodeSMonGrantInfo(SCoder *encoder, const SMonGrantInfo *pInfo) {
|
||||||
if (tEncodeI32(encoder, pInfo->expire_time) < 0) return -1;
|
if (tEncodeI32(encoder, pInfo->expire_time) < 0) return -1;
|
||||||
if (tEncodeI32(encoder, pInfo->timeseries_used) < 0) return -1;
|
if (tEncodeI64(encoder, pInfo->timeseries_used) < 0) return -1;
|
||||||
if (tEncodeI32(encoder, pInfo->timeseries_total) < 0) return -1;
|
if (tEncodeI64(encoder, pInfo->timeseries_total) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDecodeSMonGrantInfo(SCoder *decoder, SMonGrantInfo *pInfo) {
|
int32_t tDecodeSMonGrantInfo(SCoder *decoder, SMonGrantInfo *pInfo) {
|
||||||
if (tDecodeI32(decoder, &pInfo->expire_time) < 0) return -1;
|
if (tDecodeI32(decoder, &pInfo->expire_time) < 0) return -1;
|
||||||
if (tDecodeI32(decoder, &pInfo->timeseries_used) < 0) return -1;
|
if (tDecodeI64(decoder, &pInfo->timeseries_used) < 0) return -1;
|
||||||
if (tDecodeI32(decoder, &pInfo->timeseries_total) < 0) return -1;
|
if (tDecodeI64(decoder, &pInfo->timeseries_total) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,6 @@ static void dataTypeCopy(const SDataType* pSrc, SDataType* pDst) {
|
||||||
static void exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) {
|
static void exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) {
|
||||||
dataTypeCopy(&pSrc->resType, &pDst->resType);
|
dataTypeCopy(&pSrc->resType, &pDst->resType);
|
||||||
COPY_CHAR_ARRAY_FIELD(aliasName);
|
COPY_CHAR_ARRAY_FIELD(aliasName);
|
||||||
// CLONE_NODE_LIST_FIELD(pAssociationList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) {
|
||||||
|
@ -222,15 +221,19 @@ static SVgroupsInfo* vgroupsInfoClone(const SVgroupsInfo* pSrc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
||||||
|
COPY_ALL_SCALAR_FIELDS;
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pScanCols);
|
CLONE_NODE_LIST_FIELD(pScanCols);
|
||||||
CLONE_OBJECT_FIELD(pMeta, tableMetaClone);
|
CLONE_OBJECT_FIELD(pMeta, tableMetaClone);
|
||||||
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
||||||
COPY_SCALAR_FIELD(scanType);
|
CLONE_NODE_LIST_FIELD(pDynamicScanFuncs);
|
||||||
COPY_SCALAR_FIELD(scanFlag);
|
return (SNode*)pDst;
|
||||||
COPY_SCALAR_FIELD(scanRange);
|
}
|
||||||
COPY_SCALAR_FIELD(tableName);
|
|
||||||
COPY_SCALAR_FIELD(showRewrite);
|
static SNode* logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) {
|
||||||
|
COPY_ALL_SCALAR_FIELDS;
|
||||||
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
|
CLONE_NODE_FIELD(pOnConditions);
|
||||||
return (SNode*)pDst;
|
return (SNode*)pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,15 +266,8 @@ static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNo
|
||||||
static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) {
|
static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) {
|
||||||
COPY_ALL_SCALAR_FIELDS;
|
COPY_ALL_SCALAR_FIELDS;
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
// COPY_SCALAR_FIELD(winType);
|
|
||||||
CLONE_NODE_LIST_FIELD(pFuncs);
|
CLONE_NODE_LIST_FIELD(pFuncs);
|
||||||
// COPY_SCALAR_FIELD(interval);
|
|
||||||
// COPY_SCALAR_FIELD(offset);
|
|
||||||
// COPY_SCALAR_FIELD(sliding);
|
|
||||||
// COPY_SCALAR_FIELD(intervalUnit);
|
|
||||||
// COPY_SCALAR_FIELD(slidingUnit);
|
|
||||||
CLONE_NODE_FIELD(pFill);
|
CLONE_NODE_FIELD(pFill);
|
||||||
// COPY_SCALAR_FIELD(sessionGap);
|
|
||||||
CLONE_NODE_FIELD(pTspk);
|
CLONE_NODE_FIELD(pTspk);
|
||||||
return (SNode*)pDst;
|
return (SNode*)pDst;
|
||||||
}
|
}
|
||||||
|
@ -360,6 +356,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
|
||||||
return downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst);
|
return downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst);
|
||||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||||
return logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst);
|
return logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst);
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||||
|
return logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst);
|
||||||
case QUERY_NODE_LOGIC_PLAN_AGG:
|
case QUERY_NODE_LOGIC_PLAN_AGG:
|
||||||
return logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst);
|
return logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst);
|
||||||
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
||||||
|
|
|
@ -723,6 +723,9 @@ static int32_t jsonToPhysiTagScanNode(const SJson* pJson, void* pObj) {
|
||||||
static const char* jkTableScanPhysiPlanScanFlag = "ScanFlag";
|
static const char* jkTableScanPhysiPlanScanFlag = "ScanFlag";
|
||||||
static const char* jkTableScanPhysiPlanStartKey = "StartKey";
|
static const char* jkTableScanPhysiPlanStartKey = "StartKey";
|
||||||
static const char* jkTableScanPhysiPlanEndKey = "EndKey";
|
static const char* jkTableScanPhysiPlanEndKey = "EndKey";
|
||||||
|
static const char* jkTableScanPhysiPlanRatio = "Ratio";
|
||||||
|
static const char* jkTableScanPhysiPlanDataRequired = "DataRequired";
|
||||||
|
static const char* jkTableScanPhysiPlanDynamicScanFuncs = "DynamicScanFuncs";
|
||||||
|
|
||||||
static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
|
const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
|
||||||
|
@ -737,6 +740,15 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanEndKey, pNode->scanRange.ekey);
|
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanEndKey, pNode->scanRange.ekey);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddDoubleToObject(pJson, jkTableScanPhysiPlanRatio, pNode->ratio);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanDataRequired, pNode->dataRequired);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodeListToJson(pJson, jkTableScanPhysiPlanDynamicScanFuncs, pNode->pDynamicScanFuncs);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -754,6 +766,15 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBigIntValue(pJson, jkTableScanPhysiPlanEndKey, &pNode->scanRange.ekey);
|
code = tjsonGetBigIntValue(pJson, jkTableScanPhysiPlanEndKey, &pNode->scanRange.ekey);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetDoubleValue(pJson, jkTableScanPhysiPlanRatio, &pNode->ratio);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanDataRequired, pNode->dataRequired);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2767,6 +2788,7 @@ int32_t nodesStringToList(const char* pStr, SNodeList** pList) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
int32_t code = jsonToNodeListImpl(pJson, pList);
|
int32_t code = jsonToNodeListImpl(pJson, pList);
|
||||||
|
tjsonDelete(pJson);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
nodesDestroyList(*pList);
|
nodesDestroyList(*pList);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
|
|
@ -158,6 +158,16 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
||||||
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
case QUERY_NODE_SHOW_FUNCTIONS_STMT:
|
||||||
case QUERY_NODE_SHOW_INDEXES_STMT:
|
case QUERY_NODE_SHOW_INDEXES_STMT:
|
||||||
case QUERY_NODE_SHOW_STREAMS_STMT:
|
case QUERY_NODE_SHOW_STREAMS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_APPS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CONNECTIONS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_LICENCE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
|
||||||
|
case QUERY_NODE_SHOW_QUERIES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_SCORES_STMT:
|
||||||
|
case QUERY_NODE_SHOW_TOPICS_STMT:
|
||||||
|
case QUERY_NODE_SHOW_VARIABLE_STMT:
|
||||||
case QUERY_NODE_SHOW_BNODES_STMT:
|
case QUERY_NODE_SHOW_BNODES_STMT:
|
||||||
case QUERY_NODE_SHOW_SNODES_STMT:
|
case QUERY_NODE_SHOW_SNODES_STMT:
|
||||||
return makeNode(type, sizeof(SShowStmt));
|
return makeNode(type, sizeof(SShowStmt));
|
||||||
|
@ -694,6 +704,17 @@ int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode) {
|
||||||
return nodesListAppend(*pList, pNode);
|
return nodesListAppend(*pList, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode) {
|
||||||
|
if (NULL == *pList) {
|
||||||
|
*pList = nodesMakeList();
|
||||||
|
if (NULL == *pList) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodesListStrictAppend(*pList, pNode);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc) {
|
int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc) {
|
||||||
if (NULL == pTarget || NULL == pSrc) {
|
if (NULL == pTarget || NULL == pSrc) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
|
|
|
@ -79,13 +79,13 @@ alter_account_option ::= USERS literal.
|
||||||
alter_account_option ::= CONNS literal. { }
|
alter_account_option ::= CONNS literal. { }
|
||||||
alter_account_option ::= STATE literal. { }
|
alter_account_option ::= STATE literal. { }
|
||||||
|
|
||||||
/************************************************ create/alter/drop/show user *****************************************/
|
/************************************************ create/alter/drop user **********************************************/
|
||||||
cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B); }
|
cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B); }
|
||||||
cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B); }
|
cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B); }
|
||||||
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); }
|
cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); }
|
||||||
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
|
cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); }
|
||||||
|
|
||||||
/************************************************ create/drop/alter/show dnode ****************************************/
|
/************************************************ create/drop/alter dnode *********************************************/
|
||||||
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
|
||||||
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
|
||||||
cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); }
|
cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); }
|
||||||
|
@ -124,7 +124,7 @@ cmd ::= DROP SNODE ON DNODE NK_INTEGER(A).
|
||||||
cmd ::= CREATE MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &A); }
|
cmd ::= CREATE MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &A); }
|
||||||
cmd ::= DROP MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &A); }
|
cmd ::= DROP MNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &A); }
|
||||||
|
|
||||||
/************************************************ create/drop/show/use database ***************************************/
|
/************************************************ create/drop/use database ********************************************/
|
||||||
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C); }
|
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C); }
|
||||||
cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); }
|
cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); }
|
||||||
cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A); }
|
cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A); }
|
||||||
|
@ -332,6 +332,7 @@ cmd ::= SHOW ACCOUNTS.
|
||||||
cmd ::= SHOW APPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); }
|
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 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); }
|
cmd ::= SHOW LICENCE. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); }
|
||||||
|
cmd ::= SHOW GRANTS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); }
|
||||||
cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); }
|
cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); }
|
||||||
cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); }
|
cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); }
|
||||||
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, A); }
|
cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, A); }
|
||||||
|
|
|
@ -257,13 +257,20 @@ SNodeList* addValueNodeFromTypeToList(SAstCreateContext* pCxt, SDataType dataTyp
|
||||||
char buf[64] = {0};
|
char buf[64] = {0};
|
||||||
//add value node for type
|
//add value node for type
|
||||||
snprintf(buf, sizeof(buf), "%u", dataType.type);
|
snprintf(buf, sizeof(buf), "%u", dataType.type);
|
||||||
SToken token = {.type = TSDB_DATA_TYPE_TINYINT, .n = strlen(buf), .z = buf};
|
SToken token = {.type = TSDB_DATA_TYPE_SMALLINT, .n = strlen(buf), .z = buf};
|
||||||
SNode* pNode = createValueNode(pCxt, token.type, &token);
|
SNode* pNode = createValueNode(pCxt, token.type, &token);
|
||||||
addNodeToList(pCxt, pList, pNode);
|
addNodeToList(pCxt, pList, pNode);
|
||||||
|
|
||||||
//add value node for bytes
|
//add value node for bytes
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
snprintf(buf, sizeof(buf), "%u", dataType.bytes);
|
int32_t bytes;
|
||||||
|
if (IS_VAR_DATA_TYPE(dataType.type)) {
|
||||||
|
bytes = (dataType.type == TSDB_DATA_TYPE_NCHAR) ? dataType.bytes * TSDB_NCHAR_SIZE : dataType.bytes;
|
||||||
|
bytes += VARSTR_HEADER_SIZE;
|
||||||
|
} else {
|
||||||
|
bytes = dataType.bytes;
|
||||||
|
}
|
||||||
|
snprintf(buf, sizeof(buf), "%d", bytes);
|
||||||
token.type = TSDB_DATA_TYPE_BIGINT;
|
token.type = TSDB_DATA_TYPE_BIGINT;
|
||||||
token.n = strlen(buf);
|
token.n = strlen(buf);
|
||||||
token.z = buf;
|
token.z = buf;
|
||||||
|
|
|
@ -143,7 +143,7 @@ static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTab
|
||||||
if (TSDB_CODE_SUCCESS == pCxt->code) {
|
if (TSDB_CODE_SUCCESS == pCxt->code) {
|
||||||
pCxt->code = rewriteConditionForFromTable(pCxt, pJoin->pRight);
|
pCxt->code = rewriteConditionForFromTable(pCxt, pJoin->pRight);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == pCxt->code) {
|
if (TSDB_CODE_SUCCESS == pCxt->code && NULL != pJoin->pOnCond) {
|
||||||
pCxt->code = rewriteCondition(pCxt, &pJoin->pOnCond);
|
pCxt->code = rewriteCondition(pCxt, &pJoin->pOnCond);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"FSYNC", TK_FSYNC},
|
{"FSYNC", TK_FSYNC},
|
||||||
{"FUNCTION", TK_FUNCTION},
|
{"FUNCTION", TK_FUNCTION},
|
||||||
{"FUNCTIONS", TK_FUNCTIONS},
|
{"FUNCTIONS", TK_FUNCTIONS},
|
||||||
|
{"GRANTS", TK_GRANTS},
|
||||||
{"GROUP", TK_GROUP},
|
{"GROUP", TK_GROUP},
|
||||||
{"HAVING", TK_HAVING},
|
{"HAVING", TK_HAVING},
|
||||||
{"IF", TK_IF},
|
{"IF", TK_IF},
|
||||||
|
@ -131,10 +132,10 @@ static SKeyword keywordTable[] = {
|
||||||
{"PRECISION", TK_PRECISION},
|
{"PRECISION", TK_PRECISION},
|
||||||
{"PRIVILEGE", TK_PRIVILEGE},
|
{"PRIVILEGE", TK_PRIVILEGE},
|
||||||
{"PREV", TK_PREV},
|
{"PREV", TK_PREV},
|
||||||
{"_QENDTS", TK_QENDTS},
|
{"_QENDTS", TK_QENDTS},
|
||||||
{"QNODE", TK_QNODE},
|
{"QNODE", TK_QNODE},
|
||||||
{"QNODES", TK_QNODES},
|
{"QNODES", TK_QNODES},
|
||||||
{"_QSTARTTS", TK_QSTARTTS},
|
{"_QSTARTTS", TK_QSTARTTS},
|
||||||
{"QTIME", TK_QTIME},
|
{"QTIME", TK_QTIME},
|
||||||
{"QUERIES", TK_QUERIES},
|
{"QUERIES", TK_QUERIES},
|
||||||
{"QUERY", TK_QUERY},
|
{"QUERY", TK_QUERY},
|
||||||
|
@ -144,7 +145,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"RESET", TK_RESET},
|
{"RESET", TK_RESET},
|
||||||
{"RETENTIONS", TK_RETENTIONS},
|
{"RETENTIONS", TK_RETENTIONS},
|
||||||
{"ROLLUP", TK_ROLLUP},
|
{"ROLLUP", TK_ROLLUP},
|
||||||
{"_ROWTS", TK_ROWTS},
|
{"_ROWTS", TK_ROWTS},
|
||||||
{"SCORES", TK_SCORES},
|
{"SCORES", TK_SCORES},
|
||||||
{"SELECT", TK_SELECT},
|
{"SELECT", TK_SELECT},
|
||||||
{"SESSION", TK_SESSION},
|
{"SESSION", TK_SESSION},
|
||||||
|
@ -163,7 +164,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"STATE", TK_STATE},
|
{"STATE", TK_STATE},
|
||||||
{"STATE_WINDOW", TK_STATE_WINDOW},
|
{"STATE_WINDOW", TK_STATE_WINDOW},
|
||||||
{"STORAGE", TK_STORAGE},
|
{"STORAGE", TK_STORAGE},
|
||||||
{"STREAM", TK_STREAM},
|
{"STREAM", TK_STREAM},
|
||||||
{"STREAMS", TK_STREAMS},
|
{"STREAMS", TK_STREAMS},
|
||||||
{"STREAM_MODE", TK_STREAM_MODE},
|
{"STREAM_MODE", TK_STREAM_MODE},
|
||||||
{"SYNCDB", TK_SYNCDB},
|
{"SYNCDB", TK_SYNCDB},
|
||||||
|
@ -192,8 +193,8 @@ static SKeyword keywordTable[] = {
|
||||||
{"VGROUPS", TK_VGROUPS},
|
{"VGROUPS", TK_VGROUPS},
|
||||||
{"VNODES", TK_VNODES},
|
{"VNODES", TK_VNODES},
|
||||||
{"WAL", TK_WAL},
|
{"WAL", TK_WAL},
|
||||||
{"_WDURATION", TK_WDURATION},
|
{"_WDURATION", TK_WDURATION},
|
||||||
{"_WENDTS", TK_WENDTS},
|
{"_WENDTS", TK_WENDTS},
|
||||||
{"WHERE", TK_WHERE},
|
{"WHERE", TK_WHERE},
|
||||||
{"_WSTARTTS", TK_WSTARTTS},
|
{"_WSTARTTS", TK_WSTARTTS},
|
||||||
// {"ID", TK_ID},
|
// {"ID", TK_ID},
|
||||||
|
@ -221,7 +222,6 @@ static SKeyword keywordTable[] = {
|
||||||
// {"UMINUS", TK_UMINUS},
|
// {"UMINUS", TK_UMINUS},
|
||||||
// {"UPLUS", TK_UPLUS},
|
// {"UPLUS", TK_UPLUS},
|
||||||
// {"BITNOT", TK_BITNOT},
|
// {"BITNOT", TK_BITNOT},
|
||||||
// {"GRANTS", TK_GRANTS},
|
|
||||||
// {"DOT", TK_DOT},
|
// {"DOT", TK_DOT},
|
||||||
// {"CTIME", TK_CTIME},
|
// {"CTIME", TK_CTIME},
|
||||||
// {"LP", TK_LP},
|
// {"LP", TK_LP},
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "parUtil.h"
|
#include "parUtil.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
#define GET_OPTION_VAL(pVal, defaultVal) (NULL == (pVal) ? (defaultVal) : ((SValueNode*)(pVal))->datum.i)
|
#define GET_OPTION_VAL(pVal, defaultVal) (NULL == (pVal) ? (defaultVal) : getBigintFromValueNode((SValueNode*)(pVal)))
|
||||||
|
|
||||||
typedef struct STranslateContext {
|
typedef struct STranslateContext {
|
||||||
SParseContext* pParseCxt;
|
SParseContext* pParseCxt;
|
||||||
|
@ -380,6 +380,7 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
|
||||||
|
|
||||||
static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
||||||
uint8_t precision = (NULL != pCxt->pCurrStmt ? pCxt->pCurrStmt->precision : pVal->node.resType.precision);
|
uint8_t precision = (NULL != pCxt->pCurrStmt ? pCxt->pCurrStmt->precision : pVal->node.resType.precision);
|
||||||
|
pVal->node.resType.precision = precision;
|
||||||
if (pVal->isDuration) {
|
if (pVal->isDuration) {
|
||||||
if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, precision) !=
|
if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, precision) !=
|
||||||
TSDB_CODE_SUCCESS) {
|
TSDB_CODE_SUCCESS) {
|
||||||
|
@ -452,6 +453,9 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
||||||
}
|
}
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
||||||
|
} else {
|
||||||
|
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||||
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||||
}
|
}
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -758,7 +762,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
|
||||||
size_t nums = taosArrayGetSize(pTables);
|
size_t nums = taosArrayGetSize(pTables);
|
||||||
for (size_t i = 0; i < nums; ++i) {
|
for (size_t i = 0; i < nums; ++i) {
|
||||||
STableNode* pTable = taosArrayGetP(pTables, i);
|
STableNode* pTable = taosArrayGetP(pTables, i);
|
||||||
int32_t code = createColumnNodeByTable(pCxt, pTable, *pCols);
|
int32_t code = createColumnNodeByTable(pCxt, pTable, *pCols);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -825,11 +829,39 @@ static int32_t createFirstLastAllCols(STranslateContext* pCxt, SFunctionNode* pS
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isTableStar(SNode* pNode) {
|
||||||
|
return (QUERY_NODE_COLUMN == nodeType(pNode)) && (0 == strcmp(((SColumnNode*)pNode)->colName, "*"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SNodeList** pOutput) {
|
||||||
|
*pOutput = nodesMakeList();
|
||||||
|
if (NULL == *pOutput) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
bool foundTable = false;
|
||||||
|
SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel);
|
||||||
|
size_t nums = taosArrayGetSize(pTables);
|
||||||
|
for (size_t i = 0; i < nums; ++i) {
|
||||||
|
STableNode* pTable = taosArrayGetP(pTables, i);
|
||||||
|
if (0 == strcmp(pTable->tableAlias, pCol->tableAlias)) {
|
||||||
|
int32_t code = createColumnNodeByTable(pCxt, pTable, *pOutput);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
foundTable = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!foundTable) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_TABLE_NOT_EXIST, pCol->tableAlias);
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (NULL == pSelect->pProjectionList) { // select * ...
|
if (NULL == pSelect->pProjectionList) { // select * ...
|
||||||
return createAllColumns(pCxt, &pSelect->pProjectionList);
|
return createAllColumns(pCxt, &pSelect->pProjectionList);
|
||||||
} else {
|
} else {
|
||||||
// todo : t.*
|
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
WHERE_EACH(pNode, pSelect->pProjectionList) {
|
WHERE_EACH(pNode, pSelect->pProjectionList) {
|
||||||
if (isFirstLastStar(pNode)) {
|
if (isFirstLastStar(pNode)) {
|
||||||
|
@ -840,6 +872,14 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
INSERT_LIST(pSelect->pProjectionList, pFuncs);
|
INSERT_LIST(pSelect->pProjectionList, pFuncs);
|
||||||
ERASE_NODE(pSelect->pProjectionList);
|
ERASE_NODE(pSelect->pProjectionList);
|
||||||
continue;
|
continue;
|
||||||
|
} else if (isTableStar(pNode)) {
|
||||||
|
SNodeList* pCols = NULL;
|
||||||
|
if (TSDB_CODE_SUCCESS != createTableAllCols(pCxt, (SColumnNode*)pNode, &pCols)) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
INSERT_LIST(pSelect->pProjectionList, pCols);
|
||||||
|
ERASE_NODE(pSelect->pProjectionList);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
WHERE_NEXT;
|
WHERE_NEXT;
|
||||||
}
|
}
|
||||||
|
@ -1041,6 +1081,27 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int64_t getUnitPerMinute(uint8_t precision) {
|
||||||
|
switch (precision) {
|
||||||
|
case TSDB_TIME_PRECISION_MILLI:
|
||||||
|
return MILLISECOND_PER_MINUTE;
|
||||||
|
case TSDB_TIME_PRECISION_MICRO:
|
||||||
|
return MILLISECOND_PER_MINUTE * 1000L;
|
||||||
|
case TSDB_TIME_PRECISION_NANO:
|
||||||
|
return NANOSECOND_PER_MINUTE;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return MILLISECOND_PER_MINUTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64_t getBigintFromValueNode(SValueNode* pVal) {
|
||||||
|
if (pVal->isDuration) {
|
||||||
|
return pVal->datum.i / getUnitPerMinute(pVal->node.resType.precision);
|
||||||
|
}
|
||||||
|
return pVal->datum.i;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t buildCreateDbRetentions(const SNodeList* pRetentions, SCreateDbReq* pReq) {
|
static int32_t buildCreateDbRetentions(const SNodeList* pRetentions, SCreateDbReq* pReq) {
|
||||||
if (NULL != pRetentions) {
|
if (NULL != pRetentions) {
|
||||||
pReq->pRetensions = taosArrayInit(LIST_LENGTH(pRetentions), sizeof(SRetention));
|
pReq->pRetensions = taosArrayInit(LIST_LENGTH(pRetentions), sizeof(SRetention));
|
||||||
|
@ -1098,7 +1159,10 @@ static int32_t checkRangeOption(STranslateContext* pCxt, const char* pName, SVal
|
||||||
if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) {
|
if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) {
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
int64_t val = pVal->datum.i;
|
if (pVal->isDuration && (TIME_UNIT_MINUTE != pVal->unit && TIME_UNIT_HOUR != pVal->unit && TIME_UNIT_DAY != pVal->unit)) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_OPTION_UNIT, pName, pVal->unit);
|
||||||
|
}
|
||||||
|
int64_t val = getBigintFromValueNode(pVal);
|
||||||
if (val < minVal || val > maxVal) {
|
if (val < minVal || val > maxVal) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_RANGE_OPTION, pName, val, minVal, maxVal);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_RANGE_OPTION, pName, val, minVal, maxVal);
|
||||||
}
|
}
|
||||||
|
@ -1187,9 +1251,18 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t daysToKeep0 = ((SValueNode*)nodesListGetNode(pKeep, 0))->datum.i;
|
SValueNode* pKeep0 = (SValueNode*)nodesListGetNode(pKeep, 0);
|
||||||
int32_t daysToKeep1 = ((SValueNode*)nodesListGetNode(pKeep, 1))->datum.i;
|
SValueNode* pKeep1 = (SValueNode*)nodesListGetNode(pKeep, 1);
|
||||||
int32_t daysToKeep2 = ((SValueNode*)nodesListGetNode(pKeep, 2))->datum.i;
|
SValueNode* pKeep2 = (SValueNode*)nodesListGetNode(pKeep, 2);
|
||||||
|
if ((pKeep0->isDuration && (TIME_UNIT_MINUTE != pKeep0->unit && TIME_UNIT_HOUR != pKeep0->unit && TIME_UNIT_DAY != pKeep0->unit)) ||
|
||||||
|
(pKeep1->isDuration && (TIME_UNIT_MINUTE != pKeep1->unit && TIME_UNIT_HOUR != pKeep1->unit && TIME_UNIT_DAY != pKeep1->unit)) ||
|
||||||
|
(pKeep2->isDuration && (TIME_UNIT_MINUTE != pKeep2->unit && TIME_UNIT_HOUR != pKeep2->unit && TIME_UNIT_DAY != pKeep2->unit))) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_KEEP_UNIT, pKeep0->unit, pKeep1->unit, pKeep2->unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t daysToKeep0 = getBigintFromValueNode(pKeep0);
|
||||||
|
int32_t daysToKeep1 = getBigintFromValueNode(pKeep1);
|
||||||
|
int32_t daysToKeep2 = getBigintFromValueNode(pKeep2);
|
||||||
if (daysToKeep0 < TSDB_MIN_KEEP || daysToKeep1 < TSDB_MIN_KEEP || daysToKeep2 < TSDB_MIN_KEEP ||
|
if (daysToKeep0 < TSDB_MIN_KEEP || daysToKeep1 < TSDB_MIN_KEEP || daysToKeep2 < TSDB_MIN_KEEP ||
|
||||||
daysToKeep0 > TSDB_MAX_KEEP || daysToKeep1 > TSDB_MAX_KEEP || daysToKeep2 > TSDB_MAX_KEEP) {
|
daysToKeep0 > TSDB_MAX_KEEP || daysToKeep1 > TSDB_MAX_KEEP || daysToKeep2 > TSDB_MAX_KEEP) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_KEEP_VALUE, daysToKeep0, daysToKeep1, daysToKeep2,
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_KEEP_VALUE, daysToKeep0, daysToKeep1, daysToKeep2,
|
||||||
|
@ -1240,8 +1313,7 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
|
||||||
code = checkRangeOption(pCxt, "compression", pOptions->pCompressionLevel, TSDB_MIN_COMP_LEVEL, TSDB_MAX_COMP_LEVEL);
|
code = checkRangeOption(pCxt, "compression", pOptions->pCompressionLevel, TSDB_MIN_COMP_LEVEL, TSDB_MAX_COMP_LEVEL);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code =
|
code = checkRangeOption(pCxt, "daysPerFile", pOptions->pDaysPerFile, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE);
|
||||||
checkRangeOption(pCxt, "daysPerFile", pOptions->pDaysPerFile, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE);
|
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkRangeOption(pCxt, "fsyncPeriod", pOptions->pFsyncPeriod, TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD);
|
code = checkRangeOption(pCxt, "fsyncPeriod", pOptions->pFsyncPeriod, TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD);
|
||||||
|
|
|
@ -62,35 +62,39 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
case TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL:
|
case TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL:
|
||||||
return "This interval value is too small : %s";
|
return "This interval value is too small : %s";
|
||||||
case TSDB_CODE_PAR_DB_NOT_SPECIFIED:
|
case TSDB_CODE_PAR_DB_NOT_SPECIFIED:
|
||||||
return "db not specified";
|
return "Database not specified";
|
||||||
case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME:
|
case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME:
|
||||||
return "Invalid identifier name : %s";
|
return "Invalid identifier name : %s";
|
||||||
case TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR:
|
case TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR:
|
||||||
return "corresponding super table not in this db";
|
return "Corresponding super table not in this db";
|
||||||
case TSDB_CODE_PAR_INVALID_RANGE_OPTION:
|
case TSDB_CODE_PAR_INVALID_RANGE_OPTION:
|
||||||
return "invalid option %s: %"PRId64" valid range: [%d, %d]";
|
return "Invalid option %s: %"PRId64" valid range: [%d, %d]";
|
||||||
case TSDB_CODE_PAR_INVALID_STR_OPTION:
|
case TSDB_CODE_PAR_INVALID_STR_OPTION:
|
||||||
return "invalid option %s: %s";
|
return "Invalid option %s: %s";
|
||||||
case TSDB_CODE_PAR_INVALID_ENUM_OPTION:
|
case TSDB_CODE_PAR_INVALID_ENUM_OPTION:
|
||||||
return "invalid option %s: %"PRId64", only %d, %d allowed";
|
return "Invalid option %s: %"PRId64", only %d, %d allowed";
|
||||||
case TSDB_CODE_PAR_INVALID_TTL_OPTION:
|
case TSDB_CODE_PAR_INVALID_TTL_OPTION:
|
||||||
return "invalid option ttl: %"PRId64", should be greater than or equal to %d";
|
return "Invalid option ttl: %"PRId64", should be greater than or equal to %d";
|
||||||
case TSDB_CODE_PAR_INVALID_KEEP_NUM:
|
case TSDB_CODE_PAR_INVALID_KEEP_NUM:
|
||||||
return "invalid number of keep options";
|
return "Invalid number of keep options";
|
||||||
case TSDB_CODE_PAR_INVALID_KEEP_ORDER:
|
case TSDB_CODE_PAR_INVALID_KEEP_ORDER:
|
||||||
return "invalid keep value, should be keep0 <= keep1 <= keep2";
|
return "Invalid keep value, should be keep0 <= keep1 <= keep2";
|
||||||
case TSDB_CODE_PAR_INVALID_KEEP_VALUE:
|
case TSDB_CODE_PAR_INVALID_KEEP_VALUE:
|
||||||
return "invalid option keep: %d, %d, %d valid range: [%d, %d]";
|
return "Invalid option keep: %d, %d, %d valid range: [%d, %d]";
|
||||||
case TSDB_CODE_PAR_INVALID_COMMENT_OPTION:
|
case TSDB_CODE_PAR_INVALID_COMMENT_OPTION:
|
||||||
return "invalid option comment, length cannot exceed %d";
|
return "Invalid option comment, length cannot exceed %d";
|
||||||
case TSDB_CODE_PAR_INVALID_F_RANGE_OPTION:
|
case TSDB_CODE_PAR_INVALID_F_RANGE_OPTION:
|
||||||
return "invalid option %s: %f valid range: [%d, %d]";
|
return "Invalid option %s: %f valid range: [%d, %d]";
|
||||||
case TSDB_CODE_PAR_INVALID_ROLLUP_OPTION:
|
case TSDB_CODE_PAR_INVALID_ROLLUP_OPTION:
|
||||||
return "invalid option rollup: only one function is allowed";
|
return "Invalid option rollup: only one function is allowed";
|
||||||
case TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION:
|
case TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION:
|
||||||
return "invalid option retentions";
|
return "Invalid option retentions";
|
||||||
case TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST:
|
case TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST:
|
||||||
return "GROUP BY and WINDOW-clause can't be used together";
|
return "GROUP BY and WINDOW-clause can't be used together";
|
||||||
|
case TSDB_CODE_PAR_INVALID_OPTION_UNIT:
|
||||||
|
return "Invalid option %s unit: %c, only m, h, d allowed";
|
||||||
|
case TSDB_CODE_PAR_INVALID_KEEP_UNIT:
|
||||||
|
return "Invalid option keep unit: %c, %c, %c, only m, h, d allowed";
|
||||||
case TSDB_CODE_OUT_OF_MEMORY:
|
case TSDB_CODE_OUT_OF_MEMORY:
|
||||||
return "Out of memory";
|
return "Out of memory";
|
||||||
default:
|
default:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -226,6 +226,16 @@ TEST_F(ParserTest, selectExpression) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ParserTest, selectCondition) {
|
||||||
|
setDatabase("root", "test");
|
||||||
|
|
||||||
|
bind("SELECT c1 FROM t1 where ts in (true, false)");
|
||||||
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
|
bind("SELECT * FROM t1 where c1 > 10 and c1 is not null");
|
||||||
|
ASSERT_TRUE(run());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ParserTest, selectPseudoColumn) {
|
TEST_F(ParserTest, selectPseudoColumn) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
strcpy(pScan->tableName.tname, pRealTable->table.tableName);
|
strcpy(pScan->tableName.tname, pRealTable->table.tableName);
|
||||||
pScan->showRewrite = pCxt->pPlanCxt->showRewrite;
|
pScan->showRewrite = pCxt->pPlanCxt->showRewrite;
|
||||||
pScan->ratio = pRealTable->ratio;
|
pScan->ratio = pRealTable->ratio;
|
||||||
|
pScan->dataRequired = FUNC_DATA_REQUIRED_ALL_NEEDED;
|
||||||
|
|
||||||
// set columns to scan
|
// set columns to scan
|
||||||
SNodeList* pCols = NULL;
|
SNodeList* pCols = NULL;
|
||||||
|
|
|
@ -14,7 +14,231 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "planInt.h"
|
#include "planInt.h"
|
||||||
|
#include "functionMgt.h"
|
||||||
|
|
||||||
int32_t optimizeLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode) {
|
#define OPTIMIZE_FLAG_MASK(n) (1 << n)
|
||||||
|
|
||||||
|
#define OPTIMIZE_FLAG_OSD OPTIMIZE_FLAG_MASK(0)
|
||||||
|
|
||||||
|
#define OPTIMIZE_FLAG_SET_MASK(val, mask) (val) |= (mask)
|
||||||
|
#define OPTIMIZE_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
||||||
|
|
||||||
|
typedef struct SOptimizeContext {
|
||||||
|
bool optimized;
|
||||||
|
} SOptimizeContext;
|
||||||
|
|
||||||
|
typedef int32_t (*FMatch)(SOptimizeContext* pCxt, SLogicNode* pLogicNode);
|
||||||
|
typedef int32_t (*FOptimize)(SOptimizeContext* pCxt, SLogicNode* pLogicNode);
|
||||||
|
|
||||||
|
typedef struct SOptimizeRule {
|
||||||
|
char* pName;
|
||||||
|
FOptimize optimizeFunc;
|
||||||
|
} SOptimizeRule;
|
||||||
|
|
||||||
|
typedef struct SOsdInfo {
|
||||||
|
SScanLogicNode* pScan;
|
||||||
|
SNodeList* pSdrFuncs;
|
||||||
|
SNodeList* pDsoFuncs;
|
||||||
|
} SOsdInfo;
|
||||||
|
|
||||||
|
static bool osdMayBeOptimized(SLogicNode* pNode) {
|
||||||
|
if (OPTIMIZE_FLAG_TEST_MASK(pNode->optimizedFlag, OPTIMIZE_FLAG_OSD)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(pNode)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (NULL == pNode->pParent ||
|
||||||
|
(QUERY_NODE_LOGIC_PLAN_WINDOW != nodeType(pNode->pParent) && QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode->pParent))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SLogicNode* osdFindPossibleScanNode(SLogicNode* pNode) {
|
||||||
|
if (osdMayBeOptimized(pNode)) {
|
||||||
|
return pNode;
|
||||||
|
}
|
||||||
|
SNode* pChild;
|
||||||
|
FOREACH(pChild, pNode->pChildren) {
|
||||||
|
SLogicNode* pScanNode = osdFindPossibleScanNode((SLogicNode*)pChild);
|
||||||
|
if (NULL != pScanNode) {
|
||||||
|
return pScanNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SNodeList* osdGetAllFuncs(SLogicNode* pNode) {
|
||||||
|
switch (nodeType(pNode)) {
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_WINDOW:
|
||||||
|
return ((SWindowLogicNode*)pNode)->pFuncs;
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_AGG:
|
||||||
|
return ((SAggLogicNode*)pNode)->pAggFuncs;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t osdGetRelatedFuncs(SScanLogicNode* pScan, SNodeList** pSdrFuncs, SNodeList** pDsoFuncs) {
|
||||||
|
SNodeList* pAllFuncs = osdGetAllFuncs(pScan->node.pParent);
|
||||||
|
SNode* pFunc = NULL;
|
||||||
|
FOREACH(pFunc, pAllFuncs) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
if (fmIsSpecialDataRequiredFunc(((SFunctionNode*)pFunc)->funcId)) {
|
||||||
|
code = nodesListMakeStrictAppend(pSdrFuncs, nodesCloneNode(pFunc));
|
||||||
|
} else if (fmIsDynamicScanOptimizedFunc(((SFunctionNode*)pFunc)->funcId)) {
|
||||||
|
code = nodesListMakeStrictAppend(pDsoFuncs, nodesCloneNode(pFunc));
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
nodesDestroyList(*pSdrFuncs);
|
||||||
|
nodesDestroyList(*pDsoFuncs);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t osdMatch(SOptimizeContext* pCxt, SLogicNode* pLogicNode, SOsdInfo* pInfo) {
|
||||||
|
pInfo->pScan = (SScanLogicNode*)osdFindPossibleScanNode(pLogicNode);
|
||||||
|
if (NULL == pInfo->pScan) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
return osdGetRelatedFuncs(pInfo->pScan, &pInfo->pSdrFuncs, &pInfo->pDsoFuncs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l , EFuncDataRequired r) {
|
||||||
|
switch (l) {
|
||||||
|
case FUNC_DATA_REQUIRED_ALL_NEEDED:
|
||||||
|
return l;
|
||||||
|
case FUNC_DATA_REQUIRED_STATIS_NEEDED:
|
||||||
|
return FUNC_DATA_REQUIRED_ALL_NEEDED == r ? r : l;
|
||||||
|
case FUNC_DATA_REQUIRED_NO_NEEDED:
|
||||||
|
return FUNC_DATA_REQUIRED_DISCARD == r ? l : r;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t osdGetDataRequired(SNodeList* pFuncs) {
|
||||||
|
if (NULL == pFuncs) {
|
||||||
|
return FUNC_DATA_REQUIRED_ALL_NEEDED;
|
||||||
|
}
|
||||||
|
EFuncDataRequired dataRequired = FUNC_DATA_REQUIRED_DISCARD;
|
||||||
|
SNode* pFunc = NULL;
|
||||||
|
FOREACH(pFunc, pFuncs) {
|
||||||
|
dataRequired = osdPromoteDataRequired(dataRequired, fmFuncDataRequired((SFunctionNode*)pFunc, NULL));
|
||||||
|
}
|
||||||
|
return dataRequired;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
|
SOsdInfo info = {0};
|
||||||
|
int32_t code = osdMatch(pCxt, pLogicNode, &info);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && (NULL != info.pDsoFuncs || NULL != info.pSdrFuncs)) {
|
||||||
|
info.pScan->dataRequired = osdGetDataRequired(info.pSdrFuncs);
|
||||||
|
info.pScan->pDynamicScanFuncs = info.pDsoFuncs;
|
||||||
|
OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_OSD);
|
||||||
|
pCxt->optimized = true;
|
||||||
|
}
|
||||||
|
nodesDestroyList(info.pSdrFuncs);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode* pScan) {
|
||||||
|
// todo
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cpdPartitionCondition(SJoinLogicNode* pJoin, SNodeList** pMultiTableCond, SNodeList** pSingleTableCond) {
|
||||||
|
// todo
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cpdPushJoinCondToOnCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin, SNodeList* pMultiTableCond) {
|
||||||
|
// todo
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cpdPushJoinCondToChildren(SOptimizeContext* pCxt, SJoinLogicNode* pJoin, SNodeList* pSingleTableCond) {
|
||||||
|
// todo
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cpdPushJoinCondition(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) {
|
||||||
|
if (NULL != pJoin->node.pConditions) {
|
||||||
|
SNodeList* pMultiTableCond = NULL;
|
||||||
|
SNodeList* pSingleTableCond = NULL;
|
||||||
|
int32_t code = cpdPartitionCondition(pJoin, &pMultiTableCond, &pSingleTableCond);
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pMultiTableCond) {
|
||||||
|
code = cpdPushJoinCondToOnCond(pCxt, pJoin, pMultiTableCond);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pSingleTableCond) {
|
||||||
|
code = cpdPushJoinCondToChildren(pCxt, pJoin, pSingleTableCond);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cpdPushAggCondition(SOptimizeContext* pCxt, SAggLogicNode* pAgg) {
|
||||||
|
// todo
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cpdPushCondition(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
switch (nodeType(pLogicNode)) {
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||||
|
code = cpdOptimizeScanCondition(pCxt, (SScanLogicNode*)pLogicNode);
|
||||||
|
break;
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||||
|
code = cpdPushJoinCondition(pCxt, (SJoinLogicNode*)pLogicNode);
|
||||||
|
break;
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_AGG:
|
||||||
|
code = cpdPushAggCondition(pCxt, (SAggLogicNode*)pLogicNode);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
SNode* pChild = NULL;
|
||||||
|
FOREACH(pChild, pLogicNode->pChildren) {
|
||||||
|
code = cpdPushCondition(pCxt, (SLogicNode*)pChild);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t cpdOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
|
return cpdPushCondition(pCxt, pLogicNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const SOptimizeRule optimizeRuleSet[] = {
|
||||||
|
{ .pName = "OptimizeScanData", .optimizeFunc = osdOptimize },
|
||||||
|
{ .pName = "ConditionPushDown", .optimizeFunc = cpdOptimize }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int32_t optimizeRuleNum = (sizeof(optimizeRuleSet) / sizeof(SOptimizeRule));
|
||||||
|
|
||||||
|
static int32_t applyOptimizeRule(SLogicNode* pLogicNode) {
|
||||||
|
SOptimizeContext cxt = { .optimized = false };
|
||||||
|
do {
|
||||||
|
cxt.optimized = false;
|
||||||
|
for (int32_t i = 0; i < optimizeRuleNum; ++i) {
|
||||||
|
int32_t code = optimizeRuleSet[i].optimizeFunc(&cxt, pLogicNode);
|
||||||
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (cxt.optimized);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t optimizeLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
|
return applyOptimizeRule(pLogicNode);
|
||||||
|
}
|
||||||
|
|
|
@ -437,6 +437,12 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
|
||||||
taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode);
|
taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode);
|
||||||
pSubplan->execNodeStat.tableNum = pScanLogicNode->pVgroupList->vgroups[0].numOfTable;
|
pSubplan->execNodeStat.tableNum = pScanLogicNode->pVgroupList->vgroups[0].numOfTable;
|
||||||
tNameGetFullDbName(&pScanLogicNode->tableName, pSubplan->dbFName);
|
tNameGetFullDbName(&pScanLogicNode->tableName, pSubplan->dbFName);
|
||||||
|
pTableScan->dataRequired = pScanLogicNode->dataRequired;
|
||||||
|
pTableScan->pDynamicScanFuncs = nodesCloneList(pScanLogicNode->pDynamicScanFuncs);
|
||||||
|
if (NULL != pScanLogicNode->pDynamicScanFuncs && NULL == pTableScan->pDynamicScanFuncs) {
|
||||||
|
nodesDestroyNode(pTableScan);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode);
|
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode);
|
||||||
}
|
}
|
||||||
|
@ -486,58 +492,25 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createColFromDataBlockDesc(SDataBlockDescNode* pDesc, SNodeList* pCols) {
|
|
||||||
SNode* pNode;
|
|
||||||
FOREACH(pNode, pDesc->pSlots) {
|
|
||||||
SSlotDescNode* pSlot = (SSlotDescNode*)pNode;
|
|
||||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
|
||||||
if (NULL == pCol) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
pCol->node.resType = pSlot->dataType;
|
|
||||||
pCol->dataBlockId = pDesc->dataBlockId;
|
|
||||||
pCol->slotId = pSlot->slotId;
|
|
||||||
pCol->colId = -1;
|
|
||||||
int32_t code = nodesListStrictAppend(pCols, pCol);
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t createJoinOutputCols(SPhysiPlanContext* pCxt, SDataBlockDescNode* pLeftDesc, SDataBlockDescNode* pRightDesc, SNodeList** pList) {
|
|
||||||
SNodeList* pCols = nodesMakeList();
|
|
||||||
if (NULL == pCols) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = createColFromDataBlockDesc(pLeftDesc, pCols);
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = createColFromDataBlockDesc(pRightDesc, pCols);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
*pList = pCols;
|
|
||||||
} else {
|
|
||||||
nodesDestroyList(pCols);
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_JOIN);
|
SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_JOIN);
|
||||||
if (NULL == pJoin) {
|
if (NULL == pJoin) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc;
|
|
||||||
|
|
||||||
int32_t code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pOnConditions, &pJoin->pOnConditions);
|
pJoin->joinType = pJoinLogicNode->joinType;
|
||||||
|
if (NULL != pJoinLogicNode->pOnConditions) {
|
||||||
|
SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc;
|
||||||
|
SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc;
|
||||||
|
code = setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pOnConditions, &pJoin->pOnConditions);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = createJoinOutputCols(pCxt, pLeftDesc, pRightDesc, &pJoin->pTargets);
|
pJoin->pTargets = nodesCloneList(pJoinLogicNode->node.pTargets);
|
||||||
|
if (NULL == pJoin->pTargets) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addDataBlockSlots(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc);
|
code = addDataBlockSlots(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc);
|
||||||
|
|
|
@ -23,18 +23,14 @@
|
||||||
#define SPLIT_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
#define SPLIT_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0)
|
||||||
|
|
||||||
typedef struct SSplitContext {
|
typedef struct SSplitContext {
|
||||||
int32_t errCode;
|
|
||||||
int32_t groupId;
|
int32_t groupId;
|
||||||
bool match;
|
bool split;
|
||||||
void* pInfo;
|
|
||||||
} SSplitContext;
|
} SSplitContext;
|
||||||
|
|
||||||
typedef int32_t (*FMatch)(SSplitContext* pCxt, SLogicSubplan* pSubplan);
|
typedef int32_t (*FSplit)(SSplitContext* pCxt, SLogicSubplan* pSubplan);
|
||||||
typedef int32_t (*FSplit)(SSplitContext* pCxt);
|
|
||||||
|
|
||||||
typedef struct SSplitRule {
|
typedef struct SSplitRule {
|
||||||
char* pName;
|
char* pName;
|
||||||
FMatch matchFunc;
|
|
||||||
FSplit splitFunc;
|
FSplit splitFunc;
|
||||||
} SSplitRule;
|
} SSplitRule;
|
||||||
|
|
||||||
|
@ -58,30 +54,25 @@ static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t stsMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
static void stsFindSplitNode(SLogicSubplan* pSubplan, SStsInfo* pInfo) {
|
||||||
if (SPLIT_FLAG_TEST_MASK(pSubplan->splitFlag, SPLIT_FLAG_STS)) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
SLogicNode* pSplitNode = stsMatchByNode(pSubplan->pNode);
|
SLogicNode* pSplitNode = stsMatchByNode(pSubplan->pNode);
|
||||||
if (NULL != pSplitNode) {
|
if (NULL != pSplitNode) {
|
||||||
SStsInfo* pInfo = taosMemoryCalloc(1, sizeof(SStsInfo));
|
|
||||||
if (NULL == pInfo) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
pInfo->pScan = (SScanLogicNode*)pSplitNode;
|
pInfo->pScan = (SScanLogicNode*)pSplitNode;
|
||||||
pInfo->pSubplan = pSubplan;
|
pInfo->pSubplan = pSubplan;
|
||||||
pCxt->pInfo = pInfo;
|
}
|
||||||
pCxt->match = true;
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
static void stsMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan, SStsInfo* pInfo) {
|
||||||
|
if (!SPLIT_FLAG_TEST_MASK(pSubplan->splitFlag, SPLIT_FLAG_STS)) {
|
||||||
|
stsFindSplitNode(pSubplan, pInfo);
|
||||||
}
|
}
|
||||||
SNode* pChild;
|
SNode* pChild;
|
||||||
FOREACH(pChild, pSubplan->pChildren) {
|
FOREACH(pChild, pSubplan->pChildren) {
|
||||||
int32_t code = stsMatch(pCxt, (SLogicSubplan*)pChild);
|
stsMatch(pCxt, (SLogicSubplan*)pChild, pInfo);
|
||||||
if (TSDB_CODE_SUCCESS != code || pCxt->match) {
|
if (NULL != pInfo->pScan) {
|
||||||
return code;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SLogicSubplan* stsCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode* pScan) {
|
static SLogicSubplan* stsCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode* pScan) {
|
||||||
|
@ -128,46 +119,44 @@ static int32_t stsCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t stsSplit(SSplitContext* pCxt) {
|
static int32_t stsSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
||||||
SStsInfo* pInfo = pCxt->pInfo;
|
SStsInfo info = {0};
|
||||||
if (NULL == pInfo->pSubplan->pChildren) {
|
stsMatch(pCxt, pSubplan, &info);
|
||||||
pInfo->pSubplan->pChildren = nodesMakeList();
|
if (NULL == info.pScan) {
|
||||||
if (NULL == pInfo->pSubplan->pChildren) {
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
if (NULL == info.pSubplan->pChildren) {
|
||||||
|
info.pSubplan->pChildren = nodesMakeList();
|
||||||
|
if (NULL == info.pSubplan->pChildren) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int32_t code = nodesListStrictAppend(pInfo->pSubplan->pChildren, stsCreateScanSubplan(pCxt, pInfo->pScan));
|
int32_t code = nodesListStrictAppend(info.pSubplan->pChildren, stsCreateScanSubplan(pCxt, info.pScan));
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = stsCreateExchangeNode(pCxt, pInfo->pSubplan, pInfo->pScan);
|
code = stsCreateExchangeNode(pCxt, info.pSubplan, info.pScan);
|
||||||
}
|
}
|
||||||
++(pCxt->groupId);
|
++(pCxt->groupId);
|
||||||
taosMemoryFreeClear(pCxt->pInfo);
|
pCxt->split = true;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const SSplitRule splitRuleSet[] = {
|
static const SSplitRule splitRuleSet[] = {
|
||||||
{ .pName = "SuperTableScan", .matchFunc = stsMatch, .splitFunc = stsSplit }
|
{ .pName = "SuperTableScan", .splitFunc = stsSplit }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
|
static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
|
||||||
|
|
||||||
static int32_t applySplitRule(SLogicSubplan* pSubplan) {
|
static int32_t applySplitRule(SLogicSubplan* pSubplan) {
|
||||||
SSplitContext cxt = { .errCode = TSDB_CODE_SUCCESS, .groupId = pSubplan->id.groupId + 1, .match = false, .pInfo = NULL };
|
SSplitContext cxt = { .groupId = pSubplan->id.groupId + 1, .split = false };
|
||||||
bool split = false;
|
|
||||||
do {
|
do {
|
||||||
split = false;
|
cxt.split = false;
|
||||||
for (int32_t i = 0; i < splitRuleNum; ++i) {
|
for (int32_t i = 0; i < splitRuleNum; ++i) {
|
||||||
cxt.match = false;
|
int32_t code = splitRuleSet[i].splitFunc(&cxt, pSubplan);
|
||||||
int32_t code = splitRuleSet[i].matchFunc(&cxt, pSubplan);
|
|
||||||
if (TSDB_CODE_SUCCESS == code && cxt.match) {
|
|
||||||
code = splitRuleSet[i].splitFunc(&cxt);
|
|
||||||
split = true;
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (split);
|
} while (cxt.split);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,6 +190,7 @@ int32_t splitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan
|
||||||
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
||||||
}
|
}
|
||||||
pSubplan->id.queryId = pCxt->queryId;
|
pSubplan->id.queryId = pCxt->queryId;
|
||||||
|
pSubplan->id.groupId = 1;
|
||||||
setLogicNodeParent(pSubplan->pNode);
|
setLogicNodeParent(pSubplan->pNode);
|
||||||
|
|
||||||
int32_t code = applySplitRule(pSubplan);
|
int32_t code = applySplitRule(pSubplan);
|
||||||
|
|
|
@ -150,7 +150,7 @@ private:
|
||||||
SQuery* query_;
|
SQuery* query_;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(PlannerTest, simple) {
|
TEST_F(PlannerTest, selectBasic) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT * FROM t1");
|
bind("SELECT * FROM t1");
|
||||||
|
@ -164,37 +164,50 @@ TEST_F(PlannerTest, selectConstant) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, stSimple) {
|
TEST_F(PlannerTest, selectStableBasic) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT * FROM st1");
|
bind("SELECT * FROM st1");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, groupBy) {
|
TEST_F(PlannerTest, selectJoin) {
|
||||||
|
setDatabase("root", "test");
|
||||||
|
|
||||||
|
bind("SELECT * FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
|
||||||
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
|
bind("SELECT * FROM st1s1 t1 join st1s2 t2 on t1.ts = t2.ts where t1.c1 > t2.c1");
|
||||||
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
|
bind("SELECT t1.* FROM st1s1 t1 join st1s2 t2 on t1.ts = t2.ts where t1.c1 > t2.c1");
|
||||||
|
ASSERT_TRUE(run());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(PlannerTest, selectGroupBy) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT count(*) FROM t1");
|
bind("SELECT count(*) FROM t1");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("SELECT c1, max(c3), min(c2), count(*) FROM t1 GROUP BY c1");
|
// bind("SELECT c1, max(c3), min(c2), count(*) FROM t1 GROUP BY c1");
|
||||||
ASSERT_TRUE(run());
|
// ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("SELECT c1 + c3, c1 + count(*) FROM t1 where c2 = 'abc' GROUP BY c1, c3");
|
// bind("SELECT c1 + c3, c1 + count(*) FROM t1 where c2 = 'abc' GROUP BY c1, c3");
|
||||||
ASSERT_TRUE(run());
|
// ASSERT_TRUE(run());
|
||||||
|
|
||||||
bind("SELECT c1 + c3, sum(c4 * c5) FROM t1 where concat(c2, 'wwww') = 'abcwww' GROUP BY c1 + c3");
|
// bind("SELECT c1 + c3, sum(c4 * c5) FROM t1 where concat(c2, 'wwww') = 'abcwww' GROUP BY c1 + c3");
|
||||||
ASSERT_TRUE(run());
|
// ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, subquery) {
|
TEST_F(PlannerTest, selectSubquery) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT count(*) FROM (SELECT c1 + c3 a, c1 + count(*) b FROM t1 where c2 = 'abc' GROUP BY c1, c3) where a > 100 group by b");
|
bind("SELECT count(*) FROM (SELECT c1 + c3 a, c1 + count(*) b FROM t1 where c2 = 'abc' GROUP BY c1, c3) where a > 100 group by b");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, interval) {
|
TEST_F(PlannerTest, selectInterval) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT count(*) FROM t1 interval(10s)");
|
bind("SELECT count(*) FROM t1 interval(10s)");
|
||||||
|
@ -210,14 +223,14 @@ TEST_F(PlannerTest, interval) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, sessionWindow) {
|
TEST_F(PlannerTest, selectSessionWindow) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT count(*) FROM t1 session(ts, 10s)");
|
bind("SELECT count(*) FROM t1 session(ts, 10s)");
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, stateWindow) {
|
TEST_F(PlannerTest, selectStateWindow) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT count(*) FROM t1 state_window(c1)");
|
bind("SELECT count(*) FROM t1 state_window(c1)");
|
||||||
|
@ -227,7 +240,7 @@ TEST_F(PlannerTest, stateWindow) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, partitionBy) {
|
TEST_F(PlannerTest, selectPartitionBy) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT * FROM t1 partition by c1");
|
bind("SELECT * FROM t1 partition by c1");
|
||||||
|
@ -243,7 +256,7 @@ TEST_F(PlannerTest, partitionBy) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, orderBy) {
|
TEST_F(PlannerTest, selectOrderBy) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT c1 FROM t1 order by c1");
|
bind("SELECT c1 FROM t1 order by c1");
|
||||||
|
@ -259,7 +272,7 @@ TEST_F(PlannerTest, orderBy) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, groupByOrderBy) {
|
TEST_F(PlannerTest, selectGroupByOrderBy) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("select count(*), sum(c1) from t1 order by sum(c1)");
|
bind("select count(*), sum(c1) from t1 order by sum(c1)");
|
||||||
|
@ -269,7 +282,7 @@ TEST_F(PlannerTest, groupByOrderBy) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, distinct) {
|
TEST_F(PlannerTest, selectDistinct) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT distinct c1 FROM t1");
|
bind("SELECT distinct c1 FROM t1");
|
||||||
|
@ -282,7 +295,7 @@ TEST_F(PlannerTest, distinct) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, limit) {
|
TEST_F(PlannerTest, selectLimit) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT * FROM t1 limit 2");
|
bind("SELECT * FROM t1 limit 2");
|
||||||
|
@ -295,7 +308,7 @@ TEST_F(PlannerTest, limit) {
|
||||||
ASSERT_TRUE(run());
|
ASSERT_TRUE(run());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlannerTest, slimit) {
|
TEST_F(PlannerTest, selectSlimit) {
|
||||||
setDatabase("root", "test");
|
setDatabase("root", "test");
|
||||||
|
|
||||||
bind("SELECT * FROM t1 partition by c1 slimit 2");
|
bind("SELECT * FROM t1 partition by c1 slimit 2");
|
||||||
|
|
|
@ -46,8 +46,9 @@ typedef struct SScalarCtx {
|
||||||
int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out);
|
int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out);
|
||||||
SColumnInfoData* createColumnInfoData(SDataType* pType, int32_t numOfRows);
|
SColumnInfoData* createColumnInfoData(SDataType* pType, int32_t numOfRows);
|
||||||
|
|
||||||
#define GET_PARAM_TYPE(_c) ((_c)->columnData->info.type)
|
#define GET_PARAM_TYPE(_c) ((_c)->columnData->info.type)
|
||||||
#define GET_PARAM_BYTES(_c) ((_c)->columnData->info.bytes)
|
#define GET_PARAM_BYTES(_c) ((_c)->columnData->info.bytes)
|
||||||
|
#define GET_PARAM_PRECISON(_c) ((_c)->columnData->info.precision)
|
||||||
|
|
||||||
void sclFreeParam(SScalarParam *param);
|
void sclFreeParam(SScalarParam *param);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "scalar.h"
|
#include "scalar.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
|
#include "ttime.h"
|
||||||
#include "sclInt.h"
|
#include "sclInt.h"
|
||||||
#include "sclvector.h"
|
#include "sclvector.h"
|
||||||
|
|
||||||
|
@ -647,6 +648,461 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
|
if (inputNum!= 3) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t inputType = pInput[0].columnData->info.type;
|
||||||
|
int16_t outputType = *(int16_t *)pInput[1].columnData->pData;
|
||||||
|
if (outputType != TSDB_DATA_TYPE_BIGINT && outputType != TSDB_DATA_TYPE_UBIGINT &&
|
||||||
|
outputType != TSDB_DATA_TYPE_VARCHAR && outputType != TSDB_DATA_TYPE_NCHAR &&
|
||||||
|
outputType != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
int64_t outputLen = *(int64_t *)pInput[2].columnData->pData;
|
||||||
|
|
||||||
|
char *input = NULL;
|
||||||
|
char *outputBuf = taosMemoryCalloc(outputLen * pInput[0].numOfRows, 1);
|
||||||
|
char *output = outputBuf;
|
||||||
|
if (IS_VAR_DATA_TYPE(inputType)) {
|
||||||
|
input = pInput[0].columnData->pData + pInput[0].columnData->varmeta.offset[0];
|
||||||
|
} else {
|
||||||
|
input = pInput[0].columnData->pData;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pInput[0].numOfRows; ++i) {
|
||||||
|
if (colDataIsNull_s(pInput[0].columnData, i)) {
|
||||||
|
colDataAppendNULL(pOutput->columnData, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(outputType) {
|
||||||
|
case TSDB_DATA_TYPE_BIGINT: {
|
||||||
|
if (inputType == TSDB_DATA_TYPE_BINARY) {
|
||||||
|
memcpy(output, varDataVal(input), varDataLen(input));
|
||||||
|
*(int64_t *)output = strtoll(output, NULL, 10);
|
||||||
|
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
char *newBuf = taosMemoryCalloc(1, outputLen * TSDB_NCHAR_SIZE + 1);
|
||||||
|
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), newBuf);
|
||||||
|
if (len < 0) {
|
||||||
|
taosMemoryFree(newBuf);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
newBuf[len] = 0;
|
||||||
|
*(int64_t *)output = strtoll(newBuf, NULL, 10);
|
||||||
|
taosMemoryFree(newBuf);
|
||||||
|
} else {
|
||||||
|
GET_TYPED_DATA(*(int64_t *)output, int64_t, inputType, input);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_UBIGINT: {
|
||||||
|
if (inputType == TSDB_DATA_TYPE_BINARY) {
|
||||||
|
memcpy(output, varDataVal(input), varDataLen(input));
|
||||||
|
*(uint64_t *)output = strtoull(output, NULL, 10);
|
||||||
|
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
char *newBuf = taosMemoryCalloc(1, outputLen * TSDB_NCHAR_SIZE + 1);
|
||||||
|
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), newBuf);
|
||||||
|
if (len < 0) {
|
||||||
|
taosMemoryFree(newBuf);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
newBuf[len] = 0;
|
||||||
|
*(uint64_t *)output = strtoull(newBuf, NULL, 10);
|
||||||
|
taosMemoryFree(newBuf);
|
||||||
|
} else {
|
||||||
|
GET_TYPED_DATA(*(uint64_t *)output, uint64_t, inputType, input);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_TIMESTAMP: {
|
||||||
|
if (inputType == TSDB_DATA_TYPE_BINARY || inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
//not support
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
} else {
|
||||||
|
GET_TYPED_DATA(*(int64_t *)output, int64_t, inputType, input);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_BINARY: {
|
||||||
|
if (inputType == TSDB_DATA_TYPE_BOOL) {
|
||||||
|
int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputLen - VARSTR_HEADER_SIZE), *(int8_t *)input ? "true" : "false");
|
||||||
|
varDataSetLen(output, len);
|
||||||
|
} else if (inputType == TSDB_DATA_TYPE_BINARY) {
|
||||||
|
int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputLen - VARSTR_HEADER_SIZE), varDataVal(input));
|
||||||
|
varDataSetLen(output, len);
|
||||||
|
} else if (inputType == TSDB_DATA_TYPE_BINARY || inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
//not support
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
} else {
|
||||||
|
char tmp[400] = {0};
|
||||||
|
NUM_TO_STRING(inputType, input, sizeof(tmp), tmp);
|
||||||
|
int32_t len = (int32_t)strlen(tmp);
|
||||||
|
len = (outputLen - VARSTR_HEADER_SIZE) > len ? len : (outputLen - VARSTR_HEADER_SIZE);
|
||||||
|
memcpy(varDataVal(output), tmp, len);
|
||||||
|
varDataSetLen(output, len);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
|
int32_t outputCharLen = (outputLen - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE;
|
||||||
|
if (inputType == TSDB_DATA_TYPE_BOOL) {
|
||||||
|
char tmp[8] = {0};
|
||||||
|
int32_t len = sprintf(tmp, "%.*s", outputCharLen, *(int8_t *)input ? "true" : "false" );
|
||||||
|
bool ret = taosMbsToUcs4(tmp, len, (TdUcs4 *)varDataVal(output), outputLen - VARSTR_HEADER_SIZE, &len);
|
||||||
|
if (!ret) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
varDataSetLen(output, len);
|
||||||
|
} else if (inputType == TSDB_DATA_TYPE_BINARY) {
|
||||||
|
int32_t len = outputCharLen > varDataLen(input) ? varDataLen(input) : outputCharLen;
|
||||||
|
bool ret = taosMbsToUcs4(input + VARSTR_HEADER_SIZE, len, (TdUcs4 *)varDataVal(output), outputLen - VARSTR_HEADER_SIZE, &len);
|
||||||
|
if (!ret) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
varDataSetLen(output, len);
|
||||||
|
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
int32_t len = MIN(outputLen, varDataLen(input) + VARSTR_HEADER_SIZE);
|
||||||
|
memcpy(output, input, len);
|
||||||
|
varDataSetLen(output, len - VARSTR_HEADER_SIZE);
|
||||||
|
} else {
|
||||||
|
char tmp[400] = {0};
|
||||||
|
NUM_TO_STRING(inputType, input, sizeof(tmp), tmp);
|
||||||
|
int32_t len = (int32_t)strlen(tmp);
|
||||||
|
len = outputCharLen > len ? len : outputCharLen;
|
||||||
|
bool ret = taosMbsToUcs4(tmp, len, (TdUcs4 *)varDataVal(output), outputLen - VARSTR_HEADER_SIZE, &len);
|
||||||
|
if (!ret) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
varDataSetLen(output, len);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
colDataAppend(pOutput->columnData, i, output, false);
|
||||||
|
if (IS_VAR_DATA_TYPE(inputType)) {
|
||||||
|
input += varDataTLen(input);
|
||||||
|
} else {
|
||||||
|
input += tDataTypes[inputType].bytes;
|
||||||
|
}
|
||||||
|
if (IS_VAR_DATA_TYPE(outputType)) {
|
||||||
|
output += varDataTLen(output);
|
||||||
|
} else {
|
||||||
|
output += tDataTypes[outputType].bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pOutput->numOfRows = pInput->numOfRows;
|
||||||
|
taosMemoryFree(outputBuf);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
|
int32_t type = GET_PARAM_TYPE(pInput);
|
||||||
|
if (type != TSDB_DATA_TYPE_BIGINT && type != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputNum != 1) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *input = pInput[0].columnData->pData;
|
||||||
|
for (int32_t i = 0; i < pInput[0].numOfRows; ++i) {
|
||||||
|
if (colDataIsNull_s(pInput[0].columnData, i)) {
|
||||||
|
colDataAppendNULL(pOutput->columnData, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char fraction[20] = {0};
|
||||||
|
bool hasFraction = false;
|
||||||
|
NUM_TO_STRING(type, input, sizeof(fraction), fraction);
|
||||||
|
int32_t tsDigits = (int32_t)strlen(fraction);
|
||||||
|
|
||||||
|
char buf[64] = {0};
|
||||||
|
int64_t timeVal;
|
||||||
|
GET_TYPED_DATA(timeVal, int64_t, type, input);
|
||||||
|
if (tsDigits > TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
|
timeVal = timeVal / (1000 * 1000);
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
timeVal = timeVal / (1000 * 1000 * 1000);
|
||||||
|
} else {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
hasFraction = true;
|
||||||
|
memmove(fraction, fraction + TSDB_TIME_PRECISION_SEC_DIGITS, TSDB_TIME_PRECISION_SEC_DIGITS);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm *tmInfo = localtime((const time_t *)&timeVal);
|
||||||
|
strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", tmInfo);
|
||||||
|
int32_t len = (int32_t)strlen(buf);
|
||||||
|
|
||||||
|
if (hasFraction) {
|
||||||
|
int32_t fracLen = (int32_t)strlen(fraction) + 1;
|
||||||
|
char *tzInfo = strchr(buf, '+');
|
||||||
|
if (tzInfo) {
|
||||||
|
memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo));
|
||||||
|
} else {
|
||||||
|
tzInfo = strchr(buf, '-');
|
||||||
|
memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
char tmp[32];
|
||||||
|
sprintf(tmp, ".%s", fraction);
|
||||||
|
memcpy(tzInfo, tmp, fracLen);
|
||||||
|
len += fracLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove(buf + VARSTR_HEADER_SIZE, buf, len);
|
||||||
|
varDataSetLen(buf, len);
|
||||||
|
|
||||||
|
colDataAppend(pOutput->columnData, i, buf, false);
|
||||||
|
input += tDataTypes[type].bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
pOutput->numOfRows = pInput->numOfRows;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
|
int32_t type = GET_PARAM_TYPE(pInput);
|
||||||
|
int32_t timePrec = GET_PARAM_PRECISON(pInput);
|
||||||
|
if (type != TSDB_DATA_TYPE_BINARY && type != TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputNum != 1) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *input = pInput[0].columnData->pData + pInput[0].columnData->varmeta.offset[0];
|
||||||
|
for (int32_t i = 0; i < pInput[0].numOfRows; ++i) {
|
||||||
|
if (colDataIsNull_s(pInput[0].columnData, i)) {
|
||||||
|
colDataAppendNULL(pOutput->columnData, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t timeVal = 0;
|
||||||
|
convertStringToTimestamp(type, input, timePrec, &timeVal);
|
||||||
|
|
||||||
|
colDataAppend(pOutput->columnData, i, (char *)&timeVal, false);
|
||||||
|
input += varDataTLen(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
pOutput->numOfRows = pInput->numOfRows;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
|
int32_t type = GET_PARAM_TYPE(&pInput[0]);
|
||||||
|
int32_t timePrec = GET_PARAM_PRECISON(&pInput[0]);
|
||||||
|
if (inputNum != 2) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type != TSDB_DATA_TYPE_BIGINT && type != TSDB_DATA_TYPE_TIMESTAMP &&
|
||||||
|
type != TSDB_DATA_TYPE_BINARY && type != TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GET_PARAM_TYPE(&pInput[1]) != TSDB_DATA_TYPE_BIGINT) { //time_unit
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t timeUnit, timeVal = 0;
|
||||||
|
GET_TYPED_DATA(timeUnit, int64_t, GET_PARAM_TYPE(&pInput[1]), pInput[1].columnData->pData);
|
||||||
|
|
||||||
|
int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 :
|
||||||
|
(timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000);
|
||||||
|
|
||||||
|
char *input = NULL;
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
input = pInput[0].columnData->pData + pInput[0].columnData->varmeta.offset[0];
|
||||||
|
} else {
|
||||||
|
input = pInput[0].columnData->pData;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pInput[0].numOfRows; ++i) {
|
||||||
|
if (colDataIsNull_s(pInput[0].columnData, i)) {
|
||||||
|
colDataAppendNULL(pOutput->columnData, i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) { /* datetime format strings */
|
||||||
|
convertStringToTimestamp(type, input, TSDB_TIME_PRECISION_NANO, &timeVal);
|
||||||
|
//If converted value is less than 10digits in second, use value in second instead
|
||||||
|
int64_t timeValSec = timeVal / 1000000000;
|
||||||
|
if (timeValSec < 1000000000) {
|
||||||
|
timeVal = timeValSec;
|
||||||
|
}
|
||||||
|
} else if (type == TSDB_DATA_TYPE_BIGINT) { /* unix timestamp */
|
||||||
|
GET_TYPED_DATA(timeVal, int64_t, type, input);
|
||||||
|
} else if (type == TSDB_DATA_TYPE_TIMESTAMP) { /* timestamp column*/
|
||||||
|
GET_TYPED_DATA(timeVal, int64_t, type, input);
|
||||||
|
int64_t timeValSec = timeVal / factor;
|
||||||
|
if (timeValSec < 1000000000) {
|
||||||
|
timeVal = timeValSec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char buf[20] = {0};
|
||||||
|
NUM_TO_STRING(TSDB_DATA_TYPE_BIGINT, &timeVal, sizeof(buf), buf);
|
||||||
|
int32_t tsDigits = (int32_t)strlen(buf);
|
||||||
|
timeUnit = timeUnit * 1000 / factor;
|
||||||
|
|
||||||
|
switch (timeUnit) {
|
||||||
|
case 0: { /* 1u */
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000 * 1000;
|
||||||
|
//} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
|
// //timeVal = timeVal / 1000;
|
||||||
|
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
|
timeVal = timeVal * factor;
|
||||||
|
} else {
|
||||||
|
timeVal = timeVal * 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: { /* 1a */
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
|
timeVal = timeVal * 1;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000 * 1000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000 * 1000000;
|
||||||
|
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS){
|
||||||
|
timeVal = timeVal * factor;
|
||||||
|
} else {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1000: { /* 1s */
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000 * 1000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000 * 1000000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000000 * 1000000000;
|
||||||
|
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
|
timeVal = timeVal * factor;
|
||||||
|
} else {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 60000: { /* 1m */
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000 / 60 * 60 * 1000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000 / 60 * 60 * 1000000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000000 / 60 * 60 * 1000000000;
|
||||||
|
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
|
timeVal = timeVal * factor / factor / 60 * 60 * factor;
|
||||||
|
} else {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3600000: { /* 1h */
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000 / 3600 * 3600 * 1000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000 / 3600 * 3600 * 1000000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000000 / 3600 * 3600 * 1000000000;
|
||||||
|
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
|
timeVal = timeVal * factor / factor / 3600 * 3600 * factor;
|
||||||
|
} else {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 86400000: { /* 1d */
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000 / 86400 * 86400 * 1000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000 / 86400 * 86400 * 1000000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000000 / 86400 * 86400 * 1000000000;
|
||||||
|
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
|
timeVal = timeVal * factor / factor / 86400* 86400 * factor;
|
||||||
|
} else {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 604800000: { /* 1w */
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000 / 604800 * 604800 * 1000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000 / 604800 * 604800 * 1000000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000000 / 604800 * 604800 * 1000000000;
|
||||||
|
} else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) {
|
||||||
|
timeVal = timeVal * factor / factor / 604800 * 604800* factor;
|
||||||
|
} else {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
timeVal = timeVal * 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//truncate the timestamp to db precision
|
||||||
|
switch (timePrec) {
|
||||||
|
case TSDB_TIME_PRECISION_MILLI: {
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000000;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_TIME_PRECISION_MICRO: {
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) {
|
||||||
|
timeVal = timeVal / 1000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
|
timeVal = timeVal * 1000;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_TIME_PRECISION_NANO: {
|
||||||
|
if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) {
|
||||||
|
timeVal = timeVal * 1000;
|
||||||
|
} else if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) {
|
||||||
|
timeVal = timeVal * 1000000;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
colDataAppend(pOutput->columnData, i, (char *)&timeVal, false);
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
input += varDataTLen(input);
|
||||||
|
} else {
|
||||||
|
input += tDataTypes[type].bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pOutput->numOfRows = pInput->numOfRows;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
return doScalarFunctionUnique(pInput, inputNum, pOutput, atan);
|
return doScalarFunctionUnique(pInput, inputNum, pOutput, atan);
|
||||||
|
|
|
@ -164,8 +164,8 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
|
||||||
wb[1] = uv_buf_init((char*)pCont, contLen);
|
wb[1] = uv_buf_init((char*)pCont, contLen);
|
||||||
|
|
||||||
connect->data = wb;
|
connect->data = wb;
|
||||||
uv_tcp_connect(connect, &socket_tcp, (const struct sockaddr*)&dest, clientConnCb);
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
uv_tcp_connect(connect, &socket_tcp, (const struct sockaddr*)&dest, clientConnCb);
|
||||||
uv_run(loop, UV_RUN_DEFAULT);
|
uv_run(loop, UV_RUN_DEFAULT);
|
||||||
uv_loop_close(loop);
|
uv_loop_close(loop);
|
||||||
taosMemoryFree(connect);
|
taosMemoryFree(connect);
|
||||||
|
|
|
@ -76,6 +76,47 @@ int32_t taosMkDir(const char *dirname) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t taosMulMkDir(const char *dirname) {
|
||||||
|
if (dirname == NULL) return -1;
|
||||||
|
char *temp = strdup(dirname);
|
||||||
|
char *pos = temp;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
if (strncmp(temp, "/", 1) == 0) {
|
||||||
|
pos += 1;
|
||||||
|
} else if (strncmp(temp, "./", 2) == 0) {
|
||||||
|
pos += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( ; *pos != '\0'; pos++) {
|
||||||
|
if (*pos == '/') {
|
||||||
|
*pos = '\0';
|
||||||
|
code = mkdir(temp, 0755);
|
||||||
|
if (code < 0 && errno != EEXIST) {
|
||||||
|
free(temp);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
*pos = '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*(pos - 1) != '/') {
|
||||||
|
code = mkdir(temp, 0755);
|
||||||
|
if (code < 0 && errno != EEXIST) {
|
||||||
|
free(temp);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(temp);
|
||||||
|
|
||||||
|
// int32_t code = mkdir(dirname, 0755);
|
||||||
|
if (code < 0 && errno == EEXIST) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
||||||
DIR *dir = opendir(dirname);
|
DIR *dir = opendir(dirname);
|
||||||
if (dir == NULL) return;
|
if (dir == NULL) return;
|
||||||
|
|
|
@ -24,7 +24,7 @@ int32_t taosNewProc(char **args) {
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
args[0] = tsProcPath;
|
args[0] = tsProcPath;
|
||||||
// close(STDIN_FILENO);
|
// close(STDIN_FILENO);
|
||||||
close(STDOUT_FILENO);
|
// close(STDOUT_FILENO);
|
||||||
// close(STDERR_FILENO);
|
// close(STDERR_FILENO);
|
||||||
return execvp(tsProcPath, args);
|
return execvp(tsProcPath, args);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -369,53 +369,33 @@ int32_t taosGetCpuCores(float *numOfCores) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosGetCpuUsage(double *cpu_system, double *cpu_engine) {
|
void taosGetCpuUsage(double *cpu_system, double *cpu_engine) {
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
static int64_t lastSysUsed = 0;
|
||||||
|
static int64_t lastSysTotal = 0;
|
||||||
|
static int64_t lastProcTotal = 0;
|
||||||
|
static int64_t curSysUsed = 0;
|
||||||
|
static int64_t curSysTotal = 0;
|
||||||
|
static int64_t curProcTotal = 0;
|
||||||
|
|
||||||
*cpu_system = 0;
|
*cpu_system = 0;
|
||||||
*cpu_engine = 0;
|
*cpu_engine = 0;
|
||||||
return 0;
|
|
||||||
#elif defined(_TD_DARWIN_64)
|
|
||||||
*cpu_system = 0;
|
|
||||||
*cpu_engine = 0;
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
static uint64_t lastSysUsed = 0;
|
|
||||||
static uint64_t lastSysTotal = 0;
|
|
||||||
static uint64_t lastProcTotal = 0;
|
|
||||||
|
|
||||||
SysCpuInfo sysCpu;
|
SysCpuInfo sysCpu = {0};
|
||||||
ProcCpuInfo procCpu;
|
ProcCpuInfo procCpu = {0};
|
||||||
if (taosGetSysCpuInfo(&sysCpu) != 0) {
|
if (taosGetSysCpuInfo(&sysCpu) == 0 && taosGetProcCpuInfo(&procCpu) == 0) {
|
||||||
return -1;
|
curSysUsed = sysCpu.user + sysCpu.nice + sysCpu.system;
|
||||||
|
curSysTotal = curSysUsed + sysCpu.idle;
|
||||||
|
curProcTotal = procCpu.utime + procCpu.stime + procCpu.cutime + procCpu.cstime;
|
||||||
|
|
||||||
|
if (curSysTotal > lastSysTotal && curSysUsed >= lastSysUsed && curProcTotal >= lastProcTotal) {
|
||||||
|
*cpu_engine = (curSysUsed - lastSysUsed) / (double)(curSysTotal - lastSysTotal) * 100;
|
||||||
|
*cpu_system = (curProcTotal - lastProcTotal) / (double)(curSysTotal - lastSysTotal) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastSysUsed = curSysUsed;
|
||||||
|
lastSysTotal = curSysTotal;
|
||||||
|
lastProcTotal = curProcTotal;
|
||||||
}
|
}
|
||||||
if (taosGetProcCpuInfo(&procCpu) != 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t curSysUsed = sysCpu.user + sysCpu.nice + sysCpu.system;
|
|
||||||
uint64_t curSysTotal = curSysUsed + sysCpu.idle;
|
|
||||||
uint64_t curProcTotal = procCpu.utime + procCpu.stime + procCpu.cutime + procCpu.cstime;
|
|
||||||
|
|
||||||
if (lastSysUsed == 0 || lastSysTotal == 0 || lastProcTotal == 0) {
|
|
||||||
lastSysUsed = curSysUsed > 1 ? curSysUsed : 1;
|
|
||||||
lastSysTotal = curSysTotal > 1 ? curSysTotal : 1;
|
|
||||||
lastProcTotal = curProcTotal > 1 ? curProcTotal : 1;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curSysTotal == lastSysTotal) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*cpu_engine = (curSysUsed - lastSysUsed) / (double)(curSysTotal - lastSysTotal) * 100;
|
|
||||||
*cpu_system = (curProcTotal - lastProcTotal) / (double)(curSysTotal - lastSysTotal) * 100;
|
|
||||||
|
|
||||||
lastSysUsed = curSysUsed;
|
|
||||||
lastSysTotal = curSysTotal;
|
|
||||||
lastProcTotal = curProcTotal;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosGetTotalMemory(int64_t *totalKB) {
|
int32_t taosGetTotalMemory(int64_t *totalKB) {
|
||||||
|
@ -618,7 +598,6 @@ void taosGetProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, i
|
||||||
static int64_t last_wchars = 0;
|
static int64_t last_wchars = 0;
|
||||||
static int64_t last_read_bytes = 0;
|
static int64_t last_read_bytes = 0;
|
||||||
static int64_t last_write_bytes = 0;
|
static int64_t last_write_bytes = 0;
|
||||||
|
|
||||||
static int64_t cur_rchars = 0;
|
static int64_t cur_rchars = 0;
|
||||||
static int64_t cur_wchars = 0;
|
static int64_t cur_wchars = 0;
|
||||||
static int64_t cur_read_bytes = 0;
|
static int64_t cur_read_bytes = 0;
|
||||||
|
@ -632,6 +611,11 @@ void taosGetProcIODelta(int64_t *rchars, int64_t *wchars, int64_t *read_bytes, i
|
||||||
last_wchars = cur_wchars;
|
last_wchars = cur_wchars;
|
||||||
last_read_bytes = cur_read_bytes;
|
last_read_bytes = cur_read_bytes;
|
||||||
last_write_bytes = cur_write_bytes;
|
last_write_bytes = cur_write_bytes;
|
||||||
|
} else {
|
||||||
|
*rchars = 0;
|
||||||
|
*wchars = 0;
|
||||||
|
*read_bytes = 0;
|
||||||
|
*write_bytes = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,7 +677,6 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
|
||||||
void taosGetCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes) {
|
void taosGetCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes) {
|
||||||
static int64_t last_receive_bytes = 0;
|
static int64_t last_receive_bytes = 0;
|
||||||
static int64_t last_transmit_bytes = 0;
|
static int64_t last_transmit_bytes = 0;
|
||||||
|
|
||||||
static int64_t cur_receive_bytes = 0;
|
static int64_t cur_receive_bytes = 0;
|
||||||
static int64_t cur_transmit_bytes = 0;
|
static int64_t cur_transmit_bytes = 0;
|
||||||
if (taosGetCardInfo(&cur_receive_bytes, &cur_transmit_bytes) == 0) {
|
if (taosGetCardInfo(&cur_receive_bytes, &cur_transmit_bytes) == 0) {
|
||||||
|
@ -701,6 +684,9 @@ void taosGetCardInfoDelta(int64_t *receive_bytes, int64_t *transmit_bytes) {
|
||||||
*transmit_bytes = cur_transmit_bytes - last_transmit_bytes;
|
*transmit_bytes = cur_transmit_bytes - last_transmit_bytes;
|
||||||
last_receive_bytes = cur_receive_bytes;
|
last_receive_bytes = cur_receive_bytes;
|
||||||
last_transmit_bytes = cur_transmit_bytes;
|
last_transmit_bytes = cur_transmit_bytes;
|
||||||
|
} else {
|
||||||
|
*receive_bytes = 0;
|
||||||
|
*transmit_bytes = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
sql connect
|
||||||
|
$x = 1
|
||||||
|
begin:
|
||||||
|
sql insert into db.tb values(now, $x ) -x begin
|
||||||
|
$x = $x + 1
|
||||||
|
goto begin
|
|
@ -0,0 +1,14 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
sql create database db
|
||||||
|
sql create table db.tb (ts timestamp, i int)
|
||||||
|
sql insert into db.tb values(now, 1)
|
||||||
|
|
||||||
|
print ======== start back
|
||||||
|
run_back tmp/back.sim
|
||||||
|
|
||||||
|
sleep 2000
|
||||||
|
return -1
|
|
@ -0,0 +1,35 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1 -c monitorfqdn -v localhost
|
||||||
|
system sh/cfg.sh -n dnode1 -c monitorport -v 80
|
||||||
|
system sh/cfg.sh -n dnode1 -c monitorInterval -v 1
|
||||||
|
system sh/cfg.sh -n dnode1 -c monitorComp -v 1
|
||||||
|
#system sh/cfg.sh -n dnode1 -c supportVnodes -v 128
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print =============== show dnodes
|
||||||
|
sleep 2000
|
||||||
|
sql create database db vgroups 2;
|
||||||
|
sleep 2000
|
||||||
|
|
||||||
|
print =============== create drop qnode 1
|
||||||
|
sql create qnode on dnode 1
|
||||||
|
sql create snode on dnode 1
|
||||||
|
sql create bnode on dnode 1
|
||||||
|
|
||||||
|
return
|
||||||
|
print =============== restart
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
system sh/deploy.sh -n dnode2 -i 2
|
||||||
|
system sh/exec.sh -n dnode2 -s start
|
||||||
|
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||||
|
system sh/exec.sh -n dnode2 -s start
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
|
@ -97,167 +97,167 @@ print ================ query 1 group by filter
|
||||||
sql select count(*) from ct3 group by c1
|
sql select count(*) from ct3 group by c1
|
||||||
print ====> sql : select count(*) from ct3 group by c1
|
print ====> sql : select count(*) from ct3 group by c1
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c2
|
sql select count(*) from ct3 group by c2
|
||||||
print ====> sql : select count(*) from ct3 group by c2
|
print ====> sql : select count(*) from ct3 group by c2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c3
|
sql select count(*) from ct3 group by c3
|
||||||
print ====> sql : select count(*) from ct3 group by c3
|
print ====> sql : select count(*) from ct3 group by c3
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c4
|
sql select count(*) from ct3 group by c4
|
||||||
print ====> sql : select count(*) from ct3 group by c4
|
print ====> sql : select count(*) from ct3 group by c4
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c5
|
sql select count(*) from ct3 group by c5
|
||||||
print ====> sql : select count(*) from ct3 group by c5
|
print ====> sql : select count(*) from ct3 group by c5
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c6
|
sql select count(*) from ct3 group by c6
|
||||||
print ====> sql : select count(*) from ct3 group by c6
|
print ====> sql : select count(*) from ct3 group by c6
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c7
|
sql select count(*) from ct3 group by c7
|
||||||
print ====> sql : select count(*) from ct3 group by c7
|
print ====> sql : select count(*) from ct3 group by c7
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 2 then
|
if $rows != 3 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c8
|
sql select count(*) from ct3 group by c8
|
||||||
print ====> sql : select count(*) from ct3 group by c8
|
print ====> sql : select count(*) from ct3 group by c8
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c9
|
sql select count(*) from ct3 group by c9
|
||||||
print ====> sql : select count(*) from ct3 group by c9
|
print ====> sql : select count(*) from ct3 group by c9
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c10
|
sql select count(*) from ct3 group by c10
|
||||||
print ====> sql : select count(*) from ct3 group by c10
|
print ====> sql : select count(*) from ct3 group by c10
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print ================ query 2 complex with group by
|
print ================ query 2 complex with group by
|
||||||
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
||||||
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select abs(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select acos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select asin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select atan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select ceil(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select cos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select floor(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select log(c1,10) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select pow(c1,3) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select round(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select sqrt(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select sin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select tan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
|
@ -307,170 +307,170 @@ print ================ query 1 group by filter
|
||||||
sql select count(*) from ct3 group by c1
|
sql select count(*) from ct3 group by c1
|
||||||
print ====> sql : select count(*) from ct3 group by c1
|
print ====> sql : select count(*) from ct3 group by c1
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c2
|
sql select count(*) from ct3 group by c2
|
||||||
print ====> sql : select count(*) from ct3 group by c2
|
print ====> sql : select count(*) from ct3 group by c2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c3
|
sql select count(*) from ct3 group by c3
|
||||||
print ====> sql : select count(*) from ct3 group by c3
|
print ====> sql : select count(*) from ct3 group by c3
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c4
|
sql select count(*) from ct3 group by c4
|
||||||
print ====> sql : select count(*) from ct3 group by c4
|
print ====> sql : select count(*) from ct3 group by c4
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c5
|
sql select count(*) from ct3 group by c5
|
||||||
print ====> sql : select count(*) from ct3 group by c5
|
print ====> sql : select count(*) from ct3 group by c5
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c6
|
sql select count(*) from ct3 group by c6
|
||||||
print ====> sql : select count(*) from ct3 group by c6
|
print ====> sql : select count(*) from ct3 group by c6
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c7
|
sql select count(*) from ct3 group by c7
|
||||||
print ====> sql : select count(*) from ct3 group by c7
|
print ====> sql : select count(*) from ct3 group by c7
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 2 then
|
if $rows != 3 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c8
|
sql select count(*) from ct3 group by c8
|
||||||
print ====> sql : select count(*) from ct3 group by c8
|
print ====> sql : select count(*) from ct3 group by c8
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c9
|
sql select count(*) from ct3 group by c9
|
||||||
print ====> sql : select count(*) from ct3 group by c9
|
print ====> sql : select count(*) from ct3 group by c9
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(*) from ct3 group by c10
|
sql select count(*) from ct3 group by c10
|
||||||
print ====> sql : select count(*) from ct3 group by c10
|
print ====> sql : select count(*) from ct3 group by c10
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 8 then
|
if $rows != 9 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print ================ query 2 complex with group by
|
print ================ query 2 complex with group by
|
||||||
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
||||||
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select abs(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select acos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select asin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select atan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select ceil(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select cos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select floor(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select log(c1,10) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select pow(c1,3) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select round(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select sqrt(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select sin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select tan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,386 @@
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
|
$loop_cnt = 0
|
||||||
|
check_dnode_ready:
|
||||||
|
$loop_cnt = $loop_cnt + 1
|
||||||
|
sleep 200
|
||||||
|
if $loop_cnt == 10 then
|
||||||
|
print ====> dnode not ready!
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql show dnodes
|
||||||
|
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data04 != ready then
|
||||||
|
goto check_dnode_ready
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print =============== create database
|
||||||
|
sql create database db
|
||||||
|
sql show databases
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql use db
|
||||||
|
|
||||||
|
print =============== create super table and child table
|
||||||
|
sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int)
|
||||||
|
sql show stables
|
||||||
|
print $rows $data00 $data01 $data02
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql create table ct1 using stb1 tags ( 1 )
|
||||||
|
sql create table ct2 using stb1 tags ( 2 )
|
||||||
|
sql create table ct3 using stb1 tags ( 3 )
|
||||||
|
sql create table ct4 using stb1 tags ( 4 )
|
||||||
|
sql show tables
|
||||||
|
print $rows $data00 $data10 $data20
|
||||||
|
if $rows != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== insert data into child table ct1 (s)
|
||||||
|
sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
|
||||||
|
sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
|
||||||
|
sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
|
||||||
|
sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
|
||||||
|
sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
|
||||||
|
sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
|
||||||
|
sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a )
|
||||||
|
sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a )
|
||||||
|
|
||||||
|
print =============== insert data into child table ct4 (y)
|
||||||
|
sql insert into ct4 values ( '2019-01-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
sql insert into ct4 values ( '2019-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
|
||||||
|
sql insert into ct4 values ( '2019-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
|
||||||
|
sql insert into ct4 values ( '2020-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
|
||||||
|
sql insert into ct4 values ( '2020-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
|
||||||
|
sql insert into ct4 values ( '2020-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
|
||||||
|
sql insert into ct4 values ( '2020-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
sql insert into ct4 values ( '2021-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
|
||||||
|
sql insert into ct4 values ( '2021-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
|
||||||
|
sql insert into ct4 values ( '2021-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
|
||||||
|
sql insert into ct4 values ( '2022-02-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
|
||||||
|
sql insert into ct4 values ( '2022-05-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
|
||||||
|
|
||||||
|
print ================ start query ======================
|
||||||
|
|
||||||
|
print ================ query 1 having condition
|
||||||
|
sql select c1 from ct1 group by c1 having count(c1)
|
||||||
|
sql select c1 from ct4 group by c1 having count(c1)
|
||||||
|
sql select count(c1) from ct1 group by c1 having count(c1)
|
||||||
|
|
||||||
|
sql select sum(c1) ,count(c7) from ct4 group by c7 having count(c7) > 1 ;
|
||||||
|
print ====> sql : select sum(c1) ,count(c7) from ct4 group by c7 having count(c7) > 1 ;
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sum(c1) ,count(c7) from ct4 group by c7 having count(c1) < sum(c1) ;
|
||||||
|
print ====> sql : select sum(c1) ,count(c7) from ct4 group by c7 having count(c7) > 1 ;
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 2 and sum(c1) > 2 ;
|
||||||
|
print ====> sql : select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 2 and sum(c1) > 2 ;
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 7 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 1 or sum(c1) > 2 ;
|
||||||
|
print ====> sql : select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 1 or sum(c1) > 2 ;
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 7 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
|
print ================ query 1 complex with having condition
|
||||||
|
|
||||||
|
sql select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) > 1 limit 1 offset 0
|
||||||
|
print ====> sql : select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) > 1 limit 1 offset 0
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select abs(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select abs(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select acos(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select acos(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select asin(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select asin(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select atan(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select atan(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select ceil(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select ceil(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select cos(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select cos(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select floor(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select floor(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select log(c1,10) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select log(c1,10) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select pow(c1,3) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select pow(c1,3) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select round(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select round(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sqrt(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select sqrt(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sin(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select sin(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select tan(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select tan(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =================== count all rows
|
||||||
|
sql select count(c1) from stb1
|
||||||
|
print ====> sql : select count(c1) from stb1
|
||||||
|
print ====> rows: $data00
|
||||||
|
if $data00 != 20 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
print =============== stop and restart taosd
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
|
$loop_cnt = 0
|
||||||
|
check_dnode_ready_0:
|
||||||
|
$loop_cnt = $loop_cnt + 1
|
||||||
|
sleep 200
|
||||||
|
if $loop_cnt == 10 then
|
||||||
|
print ====> dnode not ready!
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql show dnodes
|
||||||
|
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data04 != ready then
|
||||||
|
goto check_dnode_ready_0
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =================== count all rows
|
||||||
|
sql select count(c1) from stb1
|
||||||
|
print ====> sql : select count(c1) from stb1
|
||||||
|
print ====> rows: $data00
|
||||||
|
if $data00 != 20 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print ================ query 1 having condition
|
||||||
|
sql select c1 from ct1 group by c1 having count(c1)
|
||||||
|
sql select c1 from ct4 group by c1 having count(c1)
|
||||||
|
sql select count(c1) from ct1 group by c1 having count(c1)
|
||||||
|
|
||||||
|
sql select sum(c1) ,count(c7) from ct4 group by c7 having count(c7) > 1 ;
|
||||||
|
print ====> sql : select sum(c1) ,count(c7) from ct4 group by c7 having count(c7) > 1 ;
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sum(c1) ,count(c7) from ct4 group by c7 having count(c1) < sum(c1) ;
|
||||||
|
print ====> sql : select sum(c1) ,count(c7) from ct4 group by c7 having count(c7) > 1 ;
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 2 and sum(c1) > 2 ;
|
||||||
|
print ====> sql : select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 2 and sum(c1) > 2 ;
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 7 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 1 or sum(c1) > 2 ;
|
||||||
|
print ====> sql : select sum(c1) ,count(c1) from ct4 group by c1 having count(c7) < 1 or sum(c1) > 2 ;
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 7 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
|
print ================ query 1 complex with having condition
|
||||||
|
|
||||||
|
sql select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) > 1 limit 1 offset 0
|
||||||
|
print ====> sql : select count(c1) from ct4 where c1 > 2 group by c7 having count(c1) > 1 limit 1 offset 0
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select abs(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select abs(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select acos(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select acos(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select asin(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select asin(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select atan(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select atan(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select ceil(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select ceil(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select cos(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select cos(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select floor(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select floor(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select log(c1,10) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select log(c1,10) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select pow(c1,3) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select pow(c1,3) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select round(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select round(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sqrt(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select sqrt(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select sin(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select sin(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select tan(c1) from ct4 where c1 > 2 group by c1 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> sql : select tan(c1) from ct4 where c1 > 2 group by c7 having abs(c1) > 1 limit 1 offset 1
|
||||||
|
print ====> rows: $rows
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -192,14 +192,14 @@ if $data01 != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select c1 from stb1 where stb1 > 5 and c1 <= 6
|
sql select c1 from stb1 where c1 > 5 and c1 <= 6
|
||||||
print ====> sql : select c1 from stb1 where c1 > 5 and c1 <= 6
|
print ====> sql : select c1 from stb1 where c1 > 5 and c1 <= 6
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
print ====> rows0: $data00
|
print ====> rows0: $data00
|
||||||
if $rows != 4 then
|
if $rows != 3 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data01 != 6 then
|
if $data00 != 6 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ print ====> rows0: $data00
|
||||||
if $rows != 32 then
|
if $rows != 32 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data01 != 1 then
|
if $data00 != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ print ====> rows0: $data00
|
||||||
if $rows != 17 then
|
if $rows != 17 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data01 != 5 then
|
if $data00 != 5 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ if $rows != 12 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql_error select c1 from stb1 where c7 between false and true
|
sql select c1 from stb1 where c7 between false and true
|
||||||
|
|
||||||
sql select c1 from stb1 where c1 in (1,2,3)
|
sql select c1 from stb1 where c1 in (1,2,3)
|
||||||
print ====> sql : select c1 from stb1 where c1 in (1,2,3)
|
print ====> sql : select c1 from stb1 where c1 in (1,2,3)
|
||||||
|
@ -272,98 +272,98 @@ endi
|
||||||
|
|
||||||
|
|
||||||
print ================ query 2 complex with where
|
print ================ query 2 complex with where
|
||||||
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select count(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select abs(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select acos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select asin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select atan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select ceil(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select cos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select floor(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select log(c1,10) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select pow(c1,3) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select round(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select sqrt(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select sin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select tan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
|
@ -510,14 +510,14 @@ if $data01 != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select c1 from stb1 where stb1 > 5 and c1 <= 6
|
sql select c1 from stb1 where c1 > 5 and c1 <= 6
|
||||||
print ====> sql : select c1 from stb1 where c1 > 5 and c1 <= 6
|
print ====> sql : select c1 from stb1 where c1 > 5 and c1 <= 6
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
print ====> rows0: $data00
|
print ====> rows0: $data00
|
||||||
if $rows != 4 then
|
if $rows != 3 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data01 != 6 then
|
if $data00 != 6 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ print ====> rows0: $data00
|
||||||
if $rows != 32 then
|
if $rows != 32 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data01 != 1 then
|
if $data00 != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ print ====> rows0: $data00
|
||||||
if $rows != 17 then
|
if $rows != 17 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data01 != 5 then
|
if $data00 != 5 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ if $rows != 12 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql_error select c1 from stb1 where c7 between false and true
|
sql select c1 from stb1 where c7 between false and true
|
||||||
|
|
||||||
sql select c1 from stb1 where c1 in (1,2,3)
|
sql select c1 from stb1 where c1 in (1,2,3)
|
||||||
print ====> sql : select c1 from stb1 where c1 in (1,2,3)
|
print ====> sql : select c1 from stb1 where c1 in (1,2,3)
|
||||||
|
@ -590,98 +590,98 @@ endi
|
||||||
|
|
||||||
|
|
||||||
print ================ query 2 complex with where
|
print ================ query 2 complex with where
|
||||||
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select count(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select abs(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select acos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select asin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select atan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select ceil(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select cos(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select floor(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select log(c1,10) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select pow(c1,3) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select round(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select sqrt(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select sin(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
|
sql select tan(c1) from ct3 where c1 > 2 group by c1 limit 1 offset 1
|
||||||
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
|
||||||
print ====> rows: $rows
|
print ====> rows: $rows
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
|
|
|
@ -63,20 +63,21 @@ print =============== step2
|
||||||
$i = 1
|
$i = 1
|
||||||
$tb = $tbPrefix . $i
|
$tb = $tbPrefix . $i
|
||||||
|
|
||||||
print ===> select diff(tbcol) from $tb
|
print ===> select _rowts, diff(tbcol) from $tb
|
||||||
sql select diff(tbcol) from $tb
|
sql select _rowts, diff(tbcol) from $tb
|
||||||
print ===> rows: $rows
|
print ===> rows: $rows
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
||||||
if $data11 != 1 then
|
if $data11 != 1 then
|
||||||
|
print expect 1, actual: $data11
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print =============== step3
|
print =============== step3
|
||||||
$cc = 4 * 60000
|
$cc = 4 * 60000
|
||||||
$ms = 1601481600000 + $cc
|
$ms = 1601481600000 + $cc
|
||||||
print ===> select diff(tbcol) from $tb where ts > $ms
|
print ===> select _rowts, diff(tbcol) from $tb where ts > $ms
|
||||||
sql select diff(tbcol) from $tb where ts > $ms
|
sql select _rowts, diff(tbcol) from $tb where ts > $ms
|
||||||
print ===> rows: $rows
|
print ===> rows: $rows
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
||||||
|
@ -86,8 +87,8 @@ endi
|
||||||
|
|
||||||
$cc = 4 * 60000
|
$cc = 4 * 60000
|
||||||
$ms = 1601481600000 + $cc
|
$ms = 1601481600000 + $cc
|
||||||
print ===> select diff(tbcol) from $tb where ts <= $ms
|
print ===> select _rowts, diff(tbcol) from $tb where ts <= $ms
|
||||||
sql select diff(tbcol) from $tb where ts <= $ms
|
sql select _rowts, diff(tbcol) from $tb where ts <= $ms
|
||||||
print ===> rows: $rows
|
print ===> rows: $rows
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
||||||
|
@ -96,8 +97,8 @@ if $data11 != 1 then
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print =============== step4
|
print =============== step4
|
||||||
print ===> select diff(tbcol) as b from $tb
|
print ===> select _rowts, diff(tbcol) as b from $tb
|
||||||
sql select diff(tbcol) as b from $tb
|
sql select _rowts, diff(tbcol) as b from $tb
|
||||||
print ===> rows: $rows
|
print ===> rows: $rows
|
||||||
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
print ===> $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
print ===> $data10 $data11 $data12 $data13 $data14 $data15
|
||||||
|
@ -105,24 +106,24 @@ if $data11 != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print =============== step5
|
#print =============== step5
|
||||||
print ===> select diff(tbcol) as b from $tb interval(1m)
|
#print ===> select diff(tbcol) as b from $tb interval(1m)
|
||||||
sql select diff(tbcol) as b from $tb interval(1m) -x step5
|
#sql select diff(tbcol) as b from $tb interval(1m) -x step5
|
||||||
return -1
|
# return -1
|
||||||
step5:
|
#step5:
|
||||||
|
#
|
||||||
print =============== step6
|
#print =============== step6
|
||||||
$cc = 4 * 60000
|
#$cc = 4 * 60000
|
||||||
$ms = 1601481600000 + $cc
|
#$ms = 1601481600000 + $cc
|
||||||
print ===> select diff(tbcol) as b from $tb where ts <= $ms interval(1m)
|
#print ===> select diff(tbcol) as b from $tb where ts <= $ms interval(1m)
|
||||||
sql select diff(tbcol) as b from $tb where ts <= $ms interval(1m) -x step6
|
#sql select diff(tbcol) as b from $tb where ts <= $ms interval(1m) -x step6
|
||||||
return -1
|
# return -1
|
||||||
step6:
|
step6:
|
||||||
|
|
||||||
print =============== clear
|
print =============== clear
|
||||||
sql drop database $db
|
sql drop database $db
|
||||||
sql show databases
|
sql show databases
|
||||||
if $rows != 0 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print ================ insert data
|
||||||
|
$dbNamme = d0
|
||||||
|
$tbPrefix = ct
|
||||||
|
$tbNum = 10
|
||||||
|
$rowNum = 100
|
||||||
|
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||||
|
|
||||||
|
sql use $dbNamme
|
||||||
|
|
||||||
|
$loop_cnt = 0
|
||||||
|
|
||||||
|
loop_insert:
|
||||||
|
print ====> loop $loop_cnt insert
|
||||||
|
$loop_cnt = $loop_cnt + 1
|
||||||
|
|
||||||
|
$i = 0
|
||||||
|
while $i < $tbNum
|
||||||
|
$tb = $tbPrefix . $i
|
||||||
|
|
||||||
|
$x = 0
|
||||||
|
while $x < $rowNum
|
||||||
|
$c = $x / 10
|
||||||
|
$c = $c * 10
|
||||||
|
$c = $x - $c
|
||||||
|
|
||||||
|
$binary = ' . binary
|
||||||
|
$binary = $binary . $c
|
||||||
|
$binary = $binary . '
|
||||||
|
|
||||||
|
#print ====> insert into $tb values ($tstart , $c , $x , $binary )
|
||||||
|
#print ====> insert into ntb values ($tstart , $c , $x , $binary )
|
||||||
|
sql insert into $tb values ($tstart , $c , $x , $binary )
|
||||||
|
sql insert into ntb values ($tstart , $c , $x , $binary )
|
||||||
|
$tstart = $tstart + 1
|
||||||
|
$x = $x + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
#print ====> insert rows: $rowNum into $tb and ntb
|
||||||
|
|
||||||
|
$i = $i + 1
|
||||||
|
# $tstart = 1640966400000
|
||||||
|
endw
|
||||||
|
goto loop_insert
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print ================ insert data
|
||||||
|
$dbNamme = d1
|
||||||
|
$tbPrefix = ct
|
||||||
|
$tbNum = 10
|
||||||
|
$rowNum = 100
|
||||||
|
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||||
|
|
||||||
|
sql use $dbNamme
|
||||||
|
|
||||||
|
$loop_cnt = 0
|
||||||
|
|
||||||
|
loop_insert:
|
||||||
|
print ====> loop $loop_cnt insert
|
||||||
|
$loop_cnt = $loop_cnt + 1
|
||||||
|
|
||||||
|
$i = 0
|
||||||
|
while $i < $tbNum
|
||||||
|
$tb = $tbPrefix . $i
|
||||||
|
|
||||||
|
$x = 0
|
||||||
|
while $x < $rowNum
|
||||||
|
$c = $x / 10
|
||||||
|
$c = $c * 10
|
||||||
|
$c = $x - $c
|
||||||
|
|
||||||
|
$binary = ' . binary
|
||||||
|
$binary = $binary . $c
|
||||||
|
$binary = $binary . '
|
||||||
|
|
||||||
|
#print ====> insert into $tb values ($tstart , $c , $x , $binary )
|
||||||
|
#print ====> insert into ntb values ($tstart , $c , $x , $binary )
|
||||||
|
sql insert into $tb values ($tstart , $c , $x , $binary )
|
||||||
|
sql insert into ntb values ($tstart , $c , $x , $binary )
|
||||||
|
$tstart = $tstart + 1
|
||||||
|
$x = $x + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
#print ====> insert rows: $rowNum into $tb and ntb
|
||||||
|
|
||||||
|
$i = $i + 1
|
||||||
|
# $tstart = 1640966400000
|
||||||
|
endw
|
||||||
|
goto loop_insert
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,234 @@
|
||||||
|
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
|
||||||
|
# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||||
|
# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||||
|
# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||||
|
# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||||
|
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
|
||||||
|
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
|
||||||
|
#
|
||||||
|
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
|
||||||
|
#
|
||||||
|
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||||
|
######## This test case include scene2 and scene4
|
||||||
|
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||||
|
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
|
$loop_cnt = 0
|
||||||
|
check_dnode_ready:
|
||||||
|
$loop_cnt = $loop_cnt + 1
|
||||||
|
sleep 200
|
||||||
|
if $loop_cnt == 10 then
|
||||||
|
print ====> dnode not ready!
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql show dnodes
|
||||||
|
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data04 != ready then
|
||||||
|
goto check_dnode_ready
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
$loop_cnt = 0
|
||||||
|
$vgroups = 1
|
||||||
|
$dbNamme = d0
|
||||||
|
loop_vgroups:
|
||||||
|
print =============== create database $dbNamme vgroups $vgroups
|
||||||
|
sql create database $dbNamme vgroups $vgroups
|
||||||
|
sql show databases
|
||||||
|
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
|
||||||
|
print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
|
||||||
|
|
||||||
|
if $loop_cnt == 0 then
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data02 != 1 then # vgroups
|
||||||
|
print vgroups: $data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
else
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 == d1 then
|
||||||
|
if $data02 != 4 then # vgroups
|
||||||
|
print vgroups: $data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
else
|
||||||
|
if $data12 != 4 then # vgroups
|
||||||
|
print vgroups: $data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
endi
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql use $dbNamme
|
||||||
|
|
||||||
|
print =============== create super table
|
||||||
|
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
|
||||||
|
|
||||||
|
sql show stables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== create child table
|
||||||
|
$tbPrefix = ct
|
||||||
|
$tbNum = 100
|
||||||
|
|
||||||
|
$i = 0
|
||||||
|
while $i < $tbNum
|
||||||
|
$tb = $tbPrefix . $i
|
||||||
|
sql create table $tb using stb tags( $i )
|
||||||
|
$i = $i + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
print =============== create normal table
|
||||||
|
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
|
||||||
|
|
||||||
|
print =============== create multi topics. notes: now only support:
|
||||||
|
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
|
||||||
|
print =============== will support: * from stb
|
||||||
|
|
||||||
|
sql create topic topic_stb_column as select ts, c1, c3 from stb
|
||||||
|
#sql create topic topic_stb_all as select * from stb
|
||||||
|
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
|
||||||
|
|
||||||
|
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
|
||||||
|
sql create topic topic_ctb_all as select * from ct0
|
||||||
|
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
|
||||||
|
|
||||||
|
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
|
||||||
|
sql create topic topic_ntb_all as select * from ntb
|
||||||
|
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
|
||||||
|
|
||||||
|
sql show tables
|
||||||
|
if $rows != 101 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== run_back insert data
|
||||||
|
|
||||||
|
if $loop_cnt == 0 then
|
||||||
|
run_back tsim/tmq/insertDataV1.sim
|
||||||
|
else
|
||||||
|
run_back tsim/tmq/insertDataV4.sim
|
||||||
|
endi
|
||||||
|
|
||||||
|
#sleep 1000
|
||||||
|
|
||||||
|
#$rowNum = 1000
|
||||||
|
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||||
|
#
|
||||||
|
#$i = 0
|
||||||
|
#while $i < $tbNum
|
||||||
|
# $tb = $tbPrefix . $i
|
||||||
|
#
|
||||||
|
# $x = 0
|
||||||
|
# while $x < $rowNum
|
||||||
|
# $c = $x / 10
|
||||||
|
# $c = $c * 10
|
||||||
|
# $c = $x - $c
|
||||||
|
#
|
||||||
|
# $binary = ' . binary
|
||||||
|
# $binary = $binary . $c
|
||||||
|
# $binary = $binary . '
|
||||||
|
#
|
||||||
|
# sql insert into $tb values ($tstart , $c , $x , $binary )
|
||||||
|
# sql insert into ntb values ($tstart , $c , $x , $binary )
|
||||||
|
# $tstart = $tstart + 1
|
||||||
|
# $x = $x + 1
|
||||||
|
# endw
|
||||||
|
#
|
||||||
|
# $i = $i + 1
|
||||||
|
# $tstart = 1640966400000
|
||||||
|
#endw
|
||||||
|
|
||||||
|
#root@trd02 /home $ tmq_sim --help
|
||||||
|
# -c Configuration directory, default is
|
||||||
|
# -d The name of the database for cosumer, no default
|
||||||
|
# -t The topic string for cosumer, no default
|
||||||
|
# -k The key-value string for cosumer, no default
|
||||||
|
# -g showMsgFlag, default is 0
|
||||||
|
#
|
||||||
|
|
||||||
|
$consumeDelay = 50
|
||||||
|
$consumeMsgCntFromTopic = 1000
|
||||||
|
print consumeMsgCntFromTopic: $consumeMsgCntFromTopic , consumeDelay: $consumeDelay
|
||||||
|
|
||||||
|
# supported key:
|
||||||
|
# group.id:<xxx>
|
||||||
|
# enable.auto.commit:<true | false>
|
||||||
|
# auto.offset.reset:<earliest | latest | none>
|
||||||
|
# td.connect.ip:<fqdn | ipaddress>
|
||||||
|
# td.connect.user:root
|
||||||
|
# td.connect.pass:taosdata
|
||||||
|
# td.connect.port:6030
|
||||||
|
# td.connect.db:db
|
||||||
|
|
||||||
|
$numOfTopics = 2
|
||||||
|
$expectConsumeMsgCnt = $consumeMsgCntFromTopic * $numOfTopics
|
||||||
|
$expect_result = @{consume success: @
|
||||||
|
$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||||
|
$expect_result = $expect_result . @, @
|
||||||
|
$expect_result = $expect_result . 0}
|
||||||
|
print expect_result----> $expect_result
|
||||||
|
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
#if $system_content != @{consume success: 20000, 0}@ then
|
||||||
|
if $system_content < $expect_result then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
$numOfTopics = 3
|
||||||
|
$expectConsumeMsgCnt = $consumeMsgCntFromTopic * $numOfTopics
|
||||||
|
$expect_result = @{consume success: @
|
||||||
|
$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||||
|
$expect_result = $expect_result . @, @
|
||||||
|
$expect_result = $expect_result . 0}
|
||||||
|
print expect_result----> $expect_result
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
#if $system_content != @{consume success: 300, 0}@ then
|
||||||
|
if $system_content < $expectConsumeMsgCnt then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
$numOfTopics = 3
|
||||||
|
$expectConsumeMsgCnt = $consumeMsgCntFromTopic * $numOfTopics
|
||||||
|
$expect_result = @{consume success: @
|
||||||
|
$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||||
|
$expect_result = $expect_result . @, @
|
||||||
|
$expect_result = $expect_result . 0}
|
||||||
|
print expect_result----> $expect_result
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
#if $system_content != @{consume success: 30000, 0}@ then
|
||||||
|
if $system_content < $expectConsumeMsgCnt then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $loop_cnt == 0 then
|
||||||
|
$loop_cnt = 1
|
||||||
|
$vgroups = 4
|
||||||
|
$dbNamme = d1
|
||||||
|
goto loop_vgroups
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
|
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -0,0 +1,266 @@
|
||||||
|
#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406
|
||||||
|
# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||||
|
# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||||
|
# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||||
|
# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb
|
||||||
|
# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN
|
||||||
|
# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5;
|
||||||
|
#
|
||||||
|
# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval).
|
||||||
|
#
|
||||||
|
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||||
|
######## This test case include scene1 and scene3
|
||||||
|
######## ######## ######## ######## ######## ######## ######## ######## ######## ########
|
||||||
|
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/cfg.sh -n dnode1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
|
$loop_cnt = 0
|
||||||
|
check_dnode_ready:
|
||||||
|
$loop_cnt = $loop_cnt + 1
|
||||||
|
sleep 200
|
||||||
|
if $loop_cnt == 10 then
|
||||||
|
print ====> dnode not ready!
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql show dnodes
|
||||||
|
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
|
||||||
|
if $data00 != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data04 != ready then
|
||||||
|
goto check_dnode_ready
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
$loop_cnt = 0
|
||||||
|
$vgroups = 1
|
||||||
|
$dbNamme = d0
|
||||||
|
loop_vgroups:
|
||||||
|
print =============== create database $dbNamme vgroups $vgroups
|
||||||
|
sql create database $dbNamme vgroups $vgroups
|
||||||
|
sql show databases
|
||||||
|
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
|
||||||
|
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
|
||||||
|
print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29
|
||||||
|
|
||||||
|
if $loop_cnt == 0 then
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data02 != 1 then # vgroups
|
||||||
|
print vgroups: $data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
else
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 == d1 then
|
||||||
|
if $data02 != 4 then # vgroups
|
||||||
|
print vgroups: $data02
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
else
|
||||||
|
if $data12 != 4 then # vgroups
|
||||||
|
print vgroups: $data12
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
endi
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql use $dbNamme
|
||||||
|
|
||||||
|
print =============== create super table
|
||||||
|
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int)
|
||||||
|
|
||||||
|
sql show stables
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== create child table
|
||||||
|
$tbPrefix = ct
|
||||||
|
$tbNum = 100
|
||||||
|
|
||||||
|
$i = 0
|
||||||
|
while $i < $tbNum
|
||||||
|
$tb = $tbPrefix . $i
|
||||||
|
sql create table $tb using stb tags( $i )
|
||||||
|
$i = $i + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
print =============== create normal table
|
||||||
|
sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10))
|
||||||
|
|
||||||
|
print =============== create multi topics. notes: now only support:
|
||||||
|
print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb
|
||||||
|
print =============== will support: * from stb
|
||||||
|
|
||||||
|
sql create topic topic_stb_column as select ts, c1, c3 from stb
|
||||||
|
#sql create topic topic_stb_all as select * from stb
|
||||||
|
sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb
|
||||||
|
|
||||||
|
sql create topic topic_ctb_column as select ts, c1, c3 from ct0
|
||||||
|
sql create topic topic_ctb_all as select * from ct0
|
||||||
|
sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0
|
||||||
|
|
||||||
|
sql create topic topic_ntb_column as select ts, c1, c3 from ntb
|
||||||
|
sql create topic topic_ntb_all as select * from ntb
|
||||||
|
sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb
|
||||||
|
|
||||||
|
sql show tables
|
||||||
|
if $rows != 101 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== run_back insert data
|
||||||
|
|
||||||
|
if $loop_cnt == 0 then
|
||||||
|
run_back tsim/tmq/insertDataV1.sim
|
||||||
|
else
|
||||||
|
run_back tsim/tmq/insertDataV4.sim
|
||||||
|
endi
|
||||||
|
|
||||||
|
#sleep 1000
|
||||||
|
|
||||||
|
#$rowNum = 1000
|
||||||
|
#$tstart = 1640966400000 # 2022-01-01 00:00:00.000
|
||||||
|
#
|
||||||
|
#$i = 0
|
||||||
|
#while $i < $tbNum
|
||||||
|
# $tb = $tbPrefix . $i
|
||||||
|
#
|
||||||
|
# $x = 0
|
||||||
|
# while $x < $rowNum
|
||||||
|
# $c = $x / 10
|
||||||
|
# $c = $c * 10
|
||||||
|
# $c = $x - $c
|
||||||
|
#
|
||||||
|
# $binary = ' . binary
|
||||||
|
# $binary = $binary . $c
|
||||||
|
# $binary = $binary . '
|
||||||
|
#
|
||||||
|
# sql insert into $tb values ($tstart , $c , $x , $binary )
|
||||||
|
# sql insert into ntb values ($tstart , $c , $x , $binary )
|
||||||
|
# $tstart = $tstart + 1
|
||||||
|
# $x = $x + 1
|
||||||
|
# endw
|
||||||
|
#
|
||||||
|
# $i = $i + 1
|
||||||
|
# $tstart = 1640966400000
|
||||||
|
#endw
|
||||||
|
|
||||||
|
#root@trd02 /home $ tmq_sim --help
|
||||||
|
# -c Configuration directory, default is
|
||||||
|
# -d The name of the database for cosumer, no default
|
||||||
|
# -t The topic string for cosumer, no default
|
||||||
|
# -k The key-value string for cosumer, no default
|
||||||
|
# -g showMsgFlag, default is 0
|
||||||
|
#
|
||||||
|
|
||||||
|
$consumeDelay = 50
|
||||||
|
$expectConsumeMsgCnt = 1000
|
||||||
|
print expectConsumeMsgCnt: $expectConsumeMsgCnt , consumeDelay: $consumeDelay
|
||||||
|
|
||||||
|
# supported key:
|
||||||
|
# group.id:<xxx>
|
||||||
|
# enable.auto.commit:<true | false>
|
||||||
|
# auto.offset.reset:<earliest | latest | none>
|
||||||
|
# td.connect.ip:<fqdn | ipaddress>
|
||||||
|
# td.connect.user:root
|
||||||
|
# td.connect.pass:taosdata
|
||||||
|
# td.connect.port:6030
|
||||||
|
# td.connect.db:db
|
||||||
|
|
||||||
|
$expect_result = @{consume success: @
|
||||||
|
$expect_result = $expect_result . $expectConsumeMsgCnt
|
||||||
|
$expect_result = $expect_result . @, @
|
||||||
|
$expect_result = $expect_result . 0}
|
||||||
|
print expect_result----> $expect_result
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
if $system_content < $expectConsumeMsgCnt then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
#print cmd result----> $system_content
|
||||||
|
##if $system_content != @{consume success: 10000, 0}@ then
|
||||||
|
#if $system_content < $expectConsumeMsgCnt then
|
||||||
|
# return -1
|
||||||
|
#endi
|
||||||
|
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
#if $system_content != @{consume success: 10000, 0}@ then
|
||||||
|
if $system_content < $expectConsumeMsgCnt then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
$expect_result = @{consume success: @
|
||||||
|
$expect_result = $expect_result . $rowNum
|
||||||
|
$expect_result = $expect_result . @, @
|
||||||
|
$expect_result = $expect_result . 0}
|
||||||
|
print expect_result----> $expect_result
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
if $system_content < $expectConsumeMsgCnt then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
if $system_content < $expectConsumeMsgCnt then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
if $system_content < $expectConsumeMsgCnt then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
$expect_result = @{consume success: @
|
||||||
|
$expect_result = $expect_result . $totalMsgCnt
|
||||||
|
$expect_result = $expect_result . @, @
|
||||||
|
$expect_result = $expect_result . 0}
|
||||||
|
print expect_result----> $expect_result
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
if $system_content < $expectConsumeMsgCnt then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
if $system_content < $expectConsumeMsgCnt then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" -y $consumeDelay -m $expectConsumeMsgCnt
|
||||||
|
print cmd result----> $system_content
|
||||||
|
if $system_content < $expectConsumeMsgCnt then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $loop_cnt == 0 then
|
||||||
|
$loop_cnt = 1
|
||||||
|
$vgroups = 4
|
||||||
|
$dbNamme = d1
|
||||||
|
goto loop_vgroups
|
||||||
|
endi
|
||||||
|
|
||||||
|
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -42,6 +42,8 @@ typedef struct {
|
||||||
char topicString[256];
|
char topicString[256];
|
||||||
char keyString[1024];
|
char keyString[1024];
|
||||||
int32_t showMsgFlag;
|
int32_t showMsgFlag;
|
||||||
|
int32_t consumeDelay; // unit s
|
||||||
|
int32_t consumeMsgCnt;
|
||||||
|
|
||||||
// save result after parse agrvs
|
// save result after parse agrvs
|
||||||
int32_t numOfTopic;
|
int32_t numOfTopic;
|
||||||
|
@ -71,12 +73,19 @@ static void printHelp() {
|
||||||
printf("%s%s%s\n", indent, indent, "The key-value string for cosumer, no default ");
|
printf("%s%s%s\n", indent, indent, "The key-value string for cosumer, no default ");
|
||||||
printf("%s%s\n", indent, "-g");
|
printf("%s%s\n", indent, "-g");
|
||||||
printf("%s%s%s%d\n", indent, indent, "showMsgFlag, default is ", g_stConfInfo.showMsgFlag);
|
printf("%s%s%s%d\n", indent, indent, "showMsgFlag, default is ", g_stConfInfo.showMsgFlag);
|
||||||
|
printf("%s%s\n", indent, "-y");
|
||||||
|
printf("%s%s%s%d\n", indent, indent, "consume delay, default is s", g_stConfInfo.consumeDelay);
|
||||||
|
printf("%s%s\n", indent, "-m");
|
||||||
|
printf("%s%s%s%d\n", indent, indent, "consume msg count, default is s", g_stConfInfo.consumeMsgCnt);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseArgument(int32_t argc, char *argv[]) {
|
void parseArgument(int32_t argc, char *argv[]) {
|
||||||
|
|
||||||
memset(&g_stConfInfo, 0, sizeof(SConfInfo));
|
memset(&g_stConfInfo, 0, sizeof(SConfInfo));
|
||||||
|
g_stConfInfo.showMsgFlag = 0;
|
||||||
|
g_stConfInfo.consumeDelay = 8000;
|
||||||
|
g_stConfInfo.consumeMsgCnt = 0;
|
||||||
|
|
||||||
for (int32_t i = 1; i < argc; i++) {
|
for (int32_t i = 1; i < argc; i++) {
|
||||||
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
||||||
|
@ -92,6 +101,10 @@ void parseArgument(int32_t argc, char *argv[]) {
|
||||||
strcpy(g_stConfInfo.keyString, argv[++i]);
|
strcpy(g_stConfInfo.keyString, argv[++i]);
|
||||||
} else if (strcmp(argv[i], "-g") == 0) {
|
} else if (strcmp(argv[i], "-g") == 0) {
|
||||||
g_stConfInfo.showMsgFlag = atol(argv[++i]);
|
g_stConfInfo.showMsgFlag = atol(argv[++i]);
|
||||||
|
} else if (strcmp(argv[i], "-y") == 0) {
|
||||||
|
g_stConfInfo.consumeDelay = atol(argv[++i]);
|
||||||
|
} else if (strcmp(argv[i], "-m") == 0) {
|
||||||
|
g_stConfInfo.consumeMsgCnt = atol(argv[++i]);
|
||||||
} else {
|
} else {
|
||||||
printf("%s unknow para: %s %s", GREEN, argv[++i], NC);
|
printf("%s unknow para: %s %s", GREEN, argv[++i], NC);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -256,6 +269,48 @@ void loop_consume(tmq_t* tmq) {
|
||||||
printf("{consume success: %d, %d}", totalMsgs, totalRows);
|
printf("{consume success: %d, %d}", totalMsgs, totalRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void parallel_consume(tmq_t* tmq) {
|
||||||
|
tmq_resp_err_t err;
|
||||||
|
|
||||||
|
int32_t totalMsgs = 0;
|
||||||
|
int32_t totalRows = 0;
|
||||||
|
int32_t skipLogNum = 0;
|
||||||
|
while (running) {
|
||||||
|
tmq_message_t* tmqMsg = tmq_consumer_poll(tmq, g_stConfInfo.consumeDelay * 1000);
|
||||||
|
if (tmqMsg) {
|
||||||
|
totalMsgs++;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
TAOS_ROW row;
|
||||||
|
while (NULL != (row = tmq_get_row(tmqMsg))) {
|
||||||
|
totalRows++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
skipLogNum += tmqGetSkipLogNum(tmqMsg);
|
||||||
|
if (0 != g_stConfInfo.showMsgFlag) {
|
||||||
|
msg_process(tmqMsg);
|
||||||
|
}
|
||||||
|
tmq_message_destroy(tmqMsg);
|
||||||
|
|
||||||
|
if (totalMsgs >= g_stConfInfo.consumeMsgCnt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = tmq_consumer_close(tmq);
|
||||||
|
if (err) {
|
||||||
|
printf("tmq_consumer_close() fail, reason: %s\n", tmq_err2str(err));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d", totalMsgs); // output to sim for check result
|
||||||
|
}
|
||||||
|
|
||||||
int main(int32_t argc, char *argv[]) {
|
int main(int32_t argc, char *argv[]) {
|
||||||
parseArgument(argc, argv);
|
parseArgument(argc, argv);
|
||||||
parseInputString();
|
parseInputString();
|
||||||
|
@ -271,8 +326,12 @@ int main(int32_t argc, char *argv[]) {
|
||||||
printf("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err));
|
printf("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
loop_consume(tmq);
|
if (0 == g_stConfInfo.consumeMsgCnt) {
|
||||||
|
loop_consume(tmq);
|
||||||
|
} else {
|
||||||
|
parallel_consume(tmq);
|
||||||
|
}
|
||||||
|
|
||||||
err = tmq_unsubscribe(tmq);
|
err = tmq_unsubscribe(tmq);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -80,24 +80,24 @@ SScript *simProcessCallOver(SScript *script) {
|
||||||
simExecSuccess = false;
|
simExecSuccess = false;
|
||||||
simInfo("script:" FAILED_PREFIX "%s" FAILED_POSTFIX ", " FAILED_PREFIX "failed" FAILED_POSTFIX ", error:%s",
|
simInfo("script:" FAILED_PREFIX "%s" FAILED_POSTFIX ", " FAILED_PREFIX "failed" FAILED_POSTFIX ", error:%s",
|
||||||
script->fileName, script->error);
|
script->fileName, script->error);
|
||||||
return NULL;
|
|
||||||
} else {
|
} else {
|
||||||
simExecSuccess = true;
|
simExecSuccess = true;
|
||||||
simInfo("script:" SUCCESS_PREFIX "%s" SUCCESS_POSTFIX ", " SUCCESS_PREFIX "success" SUCCESS_POSTFIX,
|
simInfo("script:" SUCCESS_PREFIX "%s" SUCCESS_POSTFIX ", " SUCCESS_PREFIX "success" SUCCESS_POSTFIX,
|
||||||
script->fileName);
|
script->fileName);
|
||||||
simCloseTaosdConnect(script);
|
|
||||||
simScriptSucced++;
|
|
||||||
simScriptPos--;
|
|
||||||
|
|
||||||
simFreeScript(script);
|
|
||||||
if (simScriptPos == -1) {
|
|
||||||
simInfo("----------------------------------------------------------------------");
|
|
||||||
simInfo("Simulation Test Done, " SUCCESS_PREFIX "%d" SUCCESS_POSTFIX " Passed:\n", simScriptSucced);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return simScriptList[simScriptPos];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
simCloseTaosdConnect(script);
|
||||||
|
simScriptSucced++;
|
||||||
|
simScriptPos--;
|
||||||
|
simFreeScript(script);
|
||||||
|
|
||||||
|
if (simScriptPos == -1 && simExecSuccess) {
|
||||||
|
simInfo("----------------------------------------------------------------------");
|
||||||
|
simInfo("Simulation Test Done, " SUCCESS_PREFIX "%d" SUCCESS_POSTFIX " Passed:\n", simScriptSucced);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return simScriptList[simScriptPos];
|
||||||
} else {
|
} else {
|
||||||
simDebug("script:%s, is stopped", script->fileName);
|
simDebug("script:%s, is stopped", script->fileName);
|
||||||
simFreeScript(script);
|
simFreeScript(script);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
#include "tconfig.h"
|
||||||
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <wordexp.h>
|
#include <wordexp.h>
|
||||||
|
@ -90,6 +91,11 @@ TAOS *shellInit(SShellArguments *_args) {
|
||||||
_args->user = TSDB_DEFAULT_USER;
|
_args->user = TSDB_DEFAULT_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SConfig *pCfg = cfgInit();
|
||||||
|
if (NULL == pCfg) return NULL;
|
||||||
|
|
||||||
|
if (0 != taosAddClientLogCfg(pCfg)) return NULL;
|
||||||
|
|
||||||
// Connect to the database.
|
// Connect to the database.
|
||||||
TAOS *con = NULL;
|
TAOS *con = NULL;
|
||||||
if (_args->auth == NULL) {
|
if (_args->auth == NULL) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 33cdfe4f90a209f105c1b6091439798a9cde1e93
|
Subproject commit bf6c766986c61ff4fc80421fdea682a8fd4b5b32
|
Loading…
Reference in New Issue