diff --git a/cmake/cmake.define b/cmake/cmake.define index 639ae9ca3fd780a98d18969400f7c214dca01485..b89860e29f7251c47cd343d2e012d375b582b703 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -1,5 +1,15 @@ 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 (TD_LINUX) IF (TD_ARM_32) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index acb99caffc5b6ab48fb9fdffc237bf1749d5a869..54bb83d244a3a2398db36985176dcc17ce9729ba 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,5 +1,6 @@ add_executable(tmq "") add_executable(tstream "") +add_executable(demoapi "") target_sources(tmq PRIVATE @@ -10,6 +11,12 @@ target_sources(tstream PRIVATE "src/tstream.c" ) + +target_sources(demoapi + PRIVATE + "src/demoapi.c" +) + target_link_libraries(tmq taos ) @@ -18,6 +25,10 @@ target_link_libraries(tstream taos ) +target_link_libraries(demoapi + taos +) + target_include_directories(tmq PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) @@ -26,5 +37,11 @@ target_include_directories(tstream 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(tstream PROPERTIES OUTPUT_NAME tstream) +SET_TARGET_PROPERTIES(demoapi PROPERTIES OUTPUT_NAME demoapi) diff --git a/example/src/demoapi.c b/example/src/demoapi.c new file mode 100644 index 0000000000000000000000000000000000000000..ede13b4bb8bcfbe90810d5bad252219ba0c251a4 --- /dev/null +++ b/example/src/demoapi.c @@ -0,0 +1,197 @@ +// C api call sequence demo +// to compile: gcc -o apidemo apidemo.c -ltaos + +#include +#include +#include +#include +#include +#include + +#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; +} + diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 1040130f769bd0d852663f0e19f85b32b4c26a06..7c308f9354ff38f7e4bd699de3aa61e0bbc786a8 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -222,7 +222,7 @@ typedef struct SFunctParam { // the structure for sql function in select clause typedef struct SResSchame { int8_t type; - int32_t colId; + int32_t slotId; int32_t bytes; int32_t precision; int32_t scale; diff --git a/include/common/tglobal.h b/include/common/tglobal.h index f03943e1053dd1cc8834afa6fa0823ce62443c7e..5022cb7be80773460f42844af10cc17290de658b 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -18,6 +18,7 @@ #include "tarray.h" #include "tdef.h" +#include "tconfig.h" #ifdef __cplusplus 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); struct SConfig *taosGetCfg(); +int32_t taosAddClientLogCfg(SConfig *pCfg); #ifdef __cplusplus } diff --git a/include/common/tmsg.h b/include/common/tmsg.h index cb38c694ce67b6852680bc712040661061136ddc..5d5889e30828da52db198e19afa8ded6ce4d6f07 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -260,6 +260,7 @@ typedef struct { typedef struct SSchema { int8_t type; + int8_t index; // default is 0, not index created col_id_t colId; int32_t bytes; char name[TSDB_COL_NAME_LEN]; @@ -2015,6 +2016,7 @@ typedef struct { static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) { int32_t tlen = 0; tlen += taosEncodeFixedI8(buf, pSchema->type); + tlen += taosEncodeFixedI8(buf, pSchema->index); tlen += taosEncodeFixedI32(buf, pSchema->bytes); tlen += taosEncodeFixedI16(buf, pSchema->colId); 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) { buf = taosDecodeFixedI8(buf, &pSchema->type); + buf = taosDecodeFixedI8(buf, &pSchema->index); buf = taosDecodeFixedI32(buf, &pSchema->bytes); buf = taosDecodeFixedI16(buf, &pSchema->colId); 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) { 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 (tEncodeI16(pEncoder, pSchema->colId) < 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) { 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 (tDecodeI16(pDecoder, &pSchema->colId) < 0) return -1; if (tDecodeCStrTo(pDecoder, pSchema->name) < 0) return -1; diff --git a/include/common/ttime.h b/include/common/ttime.h index 306f54bedb2f5609dc2f1e48d47f483e2d9f0d0f..15450c31ca09998cc7ce22853872eff718917a25 100644 --- a/include/common/ttime.h +++ b/include/common/ttime.h @@ -64,6 +64,7 @@ char getPrecisionUnit(int32_t precision); int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision); 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); diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 3eb43c35e15a739ea4a33a634b52ee9490ea4cb9..f5b9c23ee67cb63f45c6afea0c33a1be1ae82280 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -140,88 +140,89 @@ #define TK_APPS 122 #define TK_CONNECTIONS 123 #define TK_LICENCE 124 -#define TK_QUERIES 125 -#define TK_SCORES 126 -#define TK_TOPICS 127 -#define TK_VARIABLES 128 -#define TK_BNODES 129 -#define TK_SNODES 130 -#define TK_LIKE 131 -#define TK_INDEX 132 -#define TK_FULLTEXT 133 -#define TK_FUNCTION 134 -#define TK_INTERVAL 135 -#define TK_TOPIC 136 -#define TK_AS 137 -#define TK_DESC 138 -#define TK_DESCRIBE 139 -#define TK_RESET 140 -#define TK_QUERY 141 -#define TK_EXPLAIN 142 -#define TK_ANALYZE 143 -#define TK_VERBOSE 144 -#define TK_NK_BOOL 145 -#define TK_RATIO 146 -#define TK_COMPACT 147 -#define TK_VNODES 148 -#define TK_IN 149 -#define TK_OUTPUTTYPE 150 -#define TK_AGGREGATE 151 -#define TK_BUFSIZE 152 -#define TK_STREAM 153 -#define TK_INTO 154 -#define TK_KILL 155 -#define TK_CONNECTION 156 -#define TK_MERGE 157 -#define TK_VGROUP 158 -#define TK_REDISTRIBUTE 159 -#define TK_SPLIT 160 -#define TK_SYNCDB 161 -#define TK_NULL 162 -#define TK_FIRST 163 -#define TK_LAST 164 -#define TK_NOW 165 -#define TK_ROWTS 166 -#define TK_TBNAME 167 -#define TK_QSTARTTS 168 -#define TK_QENDTS 169 -#define TK_WSTARTTS 170 -#define TK_WENDTS 171 -#define TK_WDURATION 172 -#define TK_BETWEEN 173 -#define TK_IS 174 -#define TK_NK_LT 175 -#define TK_NK_GT 176 -#define TK_NK_LE 177 -#define TK_NK_GE 178 -#define TK_NK_NE 179 -#define TK_MATCH 180 -#define TK_NMATCH 181 -#define TK_JOIN 182 -#define TK_INNER 183 -#define TK_SELECT 184 -#define TK_DISTINCT 185 -#define TK_WHERE 186 -#define TK_PARTITION 187 -#define TK_BY 188 -#define TK_SESSION 189 -#define TK_STATE_WINDOW 190 -#define TK_SLIDING 191 -#define TK_FILL 192 -#define TK_VALUE 193 -#define TK_NONE 194 -#define TK_PREV 195 -#define TK_LINEAR 196 -#define TK_NEXT 197 -#define TK_GROUP 198 -#define TK_HAVING 199 -#define TK_ORDER 200 -#define TK_SLIMIT 201 -#define TK_SOFFSET 202 -#define TK_LIMIT 203 -#define TK_OFFSET 204 -#define TK_ASC 205 -#define TK_NULLS 206 +#define TK_GRANTS 125 +#define TK_QUERIES 126 +#define TK_SCORES 127 +#define TK_TOPICS 128 +#define TK_VARIABLES 129 +#define TK_BNODES 130 +#define TK_SNODES 131 +#define TK_LIKE 132 +#define TK_INDEX 133 +#define TK_FULLTEXT 134 +#define TK_FUNCTION 135 +#define TK_INTERVAL 136 +#define TK_TOPIC 137 +#define TK_AS 138 +#define TK_DESC 139 +#define TK_DESCRIBE 140 +#define TK_RESET 141 +#define TK_QUERY 142 +#define TK_EXPLAIN 143 +#define TK_ANALYZE 144 +#define TK_VERBOSE 145 +#define TK_NK_BOOL 146 +#define TK_RATIO 147 +#define TK_COMPACT 148 +#define TK_VNODES 149 +#define TK_IN 150 +#define TK_OUTPUTTYPE 151 +#define TK_AGGREGATE 152 +#define TK_BUFSIZE 153 +#define TK_STREAM 154 +#define TK_INTO 155 +#define TK_KILL 156 +#define TK_CONNECTION 157 +#define TK_MERGE 158 +#define TK_VGROUP 159 +#define TK_REDISTRIBUTE 160 +#define TK_SPLIT 161 +#define TK_SYNCDB 162 +#define TK_NULL 163 +#define TK_FIRST 164 +#define TK_LAST 165 +#define TK_NOW 166 +#define TK_ROWTS 167 +#define TK_TBNAME 168 +#define TK_QSTARTTS 169 +#define TK_QENDTS 170 +#define TK_WSTARTTS 171 +#define TK_WENDTS 172 +#define TK_WDURATION 173 +#define TK_BETWEEN 174 +#define TK_IS 175 +#define TK_NK_LT 176 +#define TK_NK_GT 177 +#define TK_NK_LE 178 +#define TK_NK_GE 179 +#define TK_NK_NE 180 +#define TK_MATCH 181 +#define TK_NMATCH 182 +#define TK_JOIN 183 +#define TK_INNER 184 +#define TK_SELECT 185 +#define TK_DISTINCT 186 +#define TK_WHERE 187 +#define TK_PARTITION 188 +#define TK_BY 189 +#define TK_SESSION 190 +#define TK_STATE_WINDOW 191 +#define TK_SLIDING 192 +#define TK_FILL 193 +#define TK_VALUE 194 +#define TK_NONE 195 +#define TK_PREV 196 +#define TK_LINEAR 197 +#define TK_NEXT 198 +#define TK_GROUP 199 +#define TK_HAVING 200 +#define TK_ORDER 201 +#define TK_SLIMIT 202 +#define TK_SOFFSET 203 +#define TK_LIMIT 204 +#define TK_OFFSET 205 +#define TK_ASC 206 +#define TK_NULLS 207 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 5f1cfc030a2e35649d89e33771ca8a4c89825c70..032cb441224c9e4f114b1f71b74ed4208f887286 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -142,6 +142,43 @@ typedef struct { } \ } 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_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) diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 57a3862a9a811b09c1bdf89583850306e025df94..148a9f77d6081596332ac1dc4244e86317d69427 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -85,8 +85,8 @@ typedef enum EFunctionType { // conversion function FUNCTION_TYPE_CAST = 2000, FUNCTION_TYPE_TO_ISO8601, + FUNCTION_TYPE_TO_UNIXTIMESTAMP, FUNCTION_TYPE_TO_JSON, - FUNCTION_TYPE_UNIXTIMESTAMP, // date and time function FUNCTION_TYPE_NOW = 2500, @@ -135,8 +135,17 @@ bool fmIsTimeorderFunc(int32_t funcId); bool fmIsPseudoColumnFunc(int32_t funcId); bool fmIsWindowPseudoColumnFunc(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 fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet); diff --git a/include/libs/monitor/monitor.h b/include/libs/monitor/monitor.h index f5080fbe7b518733a55c38d2b93b489691e76906..af0580674d950077f60c37f98e66c3451e91a479 100644 --- a/include/libs/monitor/monitor.h +++ b/include/libs/monitor/monitor.h @@ -78,6 +78,9 @@ typedef struct { typedef struct { float uptime; // day int8_t has_mnode; + int8_t has_qnode; + int8_t has_snode; + int8_t has_bnode; SMonDiskDesc logdir; SMonDiskDesc tempdir; } SMonDnodeInfo; @@ -134,8 +137,8 @@ typedef struct { typedef struct { int32_t expire_time; - int32_t timeseries_used; - int32_t timeseries_total; + int64_t timeseries_used; + int64_t timeseries_total; } SMonGrantInfo; typedef struct { diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index c91779ba8b4c74187fbb4cba6bd5a9a4d4b16b48..3a1d7954a719761f9e70097c849dafd9f2638765 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -216,6 +216,7 @@ SNodeList* nodesMakeList(); int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode); int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode); int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode); +int32_t nodesListMakeStrictAppend(SNodeList** pList, SNodeptr pNode); int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc); int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc); int32_t nodesListPushFront(SNodeList* pList, SNodeptr pNode); diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 3931be7da5b5a90a93991d8a9db25c9c8771c973..3b5f9abe817c7432ef87ce589ac4d73c7ff7d8d3 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -30,6 +30,7 @@ typedef struct SLogicNode { SNode* pConditions; SNodeList* pChildren; struct SLogicNode* pParent; + int32_t optimizedFlag; } SLogicNode; typedef enum EScanType { @@ -50,6 +51,8 @@ typedef struct SScanLogicNode { SName tableName; bool showRewrite; double ratio; + SNodeList* pDynamicScanFuncs; + int32_t dataRequired; } SScanLogicNode; typedef struct SJoinLogicNode { @@ -196,20 +199,13 @@ typedef struct SSystemTableScanPhysiNode { int32_t accountId; } 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 { SScanPhysiNode scan; uint8_t scanFlag; // denotes reversed scan of data or not STimeWindow scanRange; double ratio; - EScanRequired scanRequired; - SNodeList* pScanReferFuncs; + int32_t dataRequired; + SNodeList* pDynamicScanFuncs; } STableScanPhysiNode; typedef STableScanPhysiNode STableSeqScanPhysiNode; diff --git a/include/libs/scalar/filter.h b/include/libs/scalar/filter.h index c81cb49b642cd116cba24ca319f3b60414e0dc29..f1cd99f04a17a8b316319d96c4e49309406866e1 100644 --- a/include/libs/scalar/filter.h +++ b/include/libs/scalar/filter.h @@ -19,8 +19,8 @@ extern "C" { #endif -#include "tcommon.h" #include "nodes.h" +#include "tcommon.h" typedef struct SFilterInfo SFilterInfo; typedef int32_t (*filer_get_col_from_id)(void *, int32_t, void **); @@ -31,20 +31,20 @@ enum { FLT_OPTION_NEED_UNIQE = 4, }; -typedef struct SFilterColumnParam{ +typedef struct SFilterColumnParam { int32_t numOfCols; - SArray* pDataBlock; + SArray *pDataBlock; } SFilterColumnParam; 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 filterSetDataFromColId(SFilterInfo *info, void *param); extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict); -extern int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows, bool *gotNchar); -extern int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo); -extern void filterFreeInfo(SFilterInfo *info); -extern bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows); +extern int32_t filterConverNcharColumns(SFilterInfo *pFilterInfo, int32_t rows, bool *gotNchar); +extern int32_t filterFreeNcharColumns(SFilterInfo *pFilterInfo); +extern void filterFreeInfo(SFilterInfo *info); +extern bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows); #ifdef __cplusplus } diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index b5acc64f0b7040070cc6e85481c7f41adea5e298..caea52a5ef9831bba2132ab522b0e80c979f4ac5 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -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 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); int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); diff --git a/include/os/osDir.h b/include/os/osDir.h index d3597cab36aa27e19360f290ec841c54a3e96ccd..e7da54bf548ff4da95e800e0beccdda9e13c4df7 100644 --- a/include/os/osDir.h +++ b/include/os/osDir.h @@ -38,6 +38,7 @@ typedef struct TdDirEntry *TdDirEntryPtr; void taosRemoveDir(const char *dirname); bool taosDirExist(char *dirname); int32_t taosMkDir(const char *dirname); +int32_t taosMulMkDir(const char *dirname); void taosRemoveOldFiles(const char *dirname, int32_t keepDays); int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen); int32_t taosRealPath(char *dirname, int32_t maxlen); diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index 022f11bb0e646125a73d9a962fabb252a003b11a..c009bcf350858b934d14e48e3424a8611046ddb0 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -39,7 +39,7 @@ int32_t taosGetEmail(char *email, int32_t maxLen); int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen); int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, 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 taosGetProcMemory(int64_t *usedKB); int32_t taosGetSysMemory(int64_t *usedKB); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 04baa3c09d2048d033b877bdda71557367229d20..60535e2f493a3bcb1769f067fb7e13a6fb715452 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -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_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_INVALID_OPTION_UNIT TAOS_DEF_ERROR_CODE(0, 0x2625) +#define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626) //planner #define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700) diff --git a/include/util/tdef.h b/include/util/tdef.h index 263c90c0f8cea5772d2bb18843dec899f02d72de..f276a1a8123cca46ea8f3252ee4550650866590f 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -94,6 +94,11 @@ extern const int32_t TYPE_BYTES[15]; #define TSDB_TIME_PRECISION_MICRO_STR "us" #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_INS_TABLE_DNODES "dnodes" #define TSDB_INS_TABLE_MNODES "mnodes" diff --git a/packaging/install.sh b/packaging/install.sh index 3aae074af55ada32ecee1a8033b71217c706d301..c9748d223b9a36057397e07dbf4c6fd27a90693c 100755 --- a/packaging/install.sh +++ b/packaging/install.sh @@ -157,7 +157,7 @@ function install_main_path() { ${csudo} mkdir -p ${install_main_dir}/cfg ${csudo} mkdir -p ${install_main_dir}/bin ${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}/include ${csudo} mkdir -p ${install_main_dir}/init.d @@ -198,6 +198,10 @@ function install_lib() { # Remove links ${csudo} rm -f ${lib_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 ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 71c5df6a0962c7f8b2a43d3fc542e17d3e7b3512..63bb3637cf2fc1dac7b7379afefc72b2f1b9f5a4 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -737,7 +737,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int int32_t type = pResultInfo->fields[i].type; 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]); if (p == NULL) { return TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 0bc1fa09f519ea49af319a8ab4a80afe5966766c..58bc7235a1a14f1be58ca88d0d08f500f4c78092 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -256,7 +256,7 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e 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, "scriptDir", configDir, 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); - if (taosMkDir(tsLogDir) != 0) { + if (taosMulMkDir(tsLogDir) != 0) { uError("failed to create dir:%s since %s", tsLogDir, terrstr()); cfgCleanup(pCfg); return -1; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 0edfcb3314c37c0b0b21223137fa29347f3cb81f..08010db1d8ec27fc6fc0231da306f6a0fe640cab 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -308,6 +308,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) { tlen += taosEncodeFixedI16(buf, pReq->stbCfg.nTagCols); 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].index); tlen += taosEncodeFixedI16(buf, pReq->stbCfg.pTagSchema[i].colId); tlen += taosEncodeFixedI32(buf, pReq->stbCfg.pTagSchema[i].bytes); 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)); 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].index)); buf = taosDecodeFixedI16(buf, &pReq->stbCfg.pTagSchema[i].colId); buf = taosDecodeFixedI32(buf, &pReq->stbCfg.pTagSchema[i].bytes); buf = taosDecodeStringTo(buf, pReq->stbCfg.pTagSchema[i].name); @@ -1989,7 +1991,7 @@ void tFreeSUseDbBatchRsp(SUseDbBatchRsp *pRsp) { 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}; 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; } -int32_t tDeserializeSDbCfgReq(void* buf, int32_t bufLen, SDbCfgReq* pReq) { +int32_t tDeserializeSDbCfgReq(void *buf, int32_t bufLen, SDbCfgReq *pReq) { SCoder decoder = {0}; 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; } -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}; 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; } -int32_t tDeserializeSDbCfgRsp(void* buf, int32_t bufLen, SDbCfgRsp* pRsp) { +int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) { SCoder decoder = {0}; 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; } -int32_t tSerializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq) { +int32_t tSerializeSUserIndexReq(void *buf, int32_t bufLen, SUserIndexReq *pReq) { SCoder encoder = {0}; 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; } -int32_t tDeserializeSUserIndexReq(void* buf, int32_t bufLen, SUserIndexReq* pReq) { +int32_t tDeserializeSUserIndexReq(void *buf, int32_t bufLen, SUserIndexReq *pReq) { SCoder decoder = {0}; 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; } -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}; 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; } -int32_t tDeserializeSUserIndexRsp(void* buf, int32_t bufLen, SUserIndexRsp* pRsp) { +int32_t tDeserializeSUserIndexRsp(void *buf, int32_t bufLen, SUserIndexRsp *pRsp) { SCoder decoder = {0}; 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; } - int32_t tSerializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index a65352f2b919f85894996193796f4d2efde15b16..1baf393e9a215c9e18cd2208c28a6163a501564b 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -406,7 +406,31 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char default: { 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) { diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index 8c5010e577a0de784f70733830432df90446dc6d..a0503e43a187d8b136b7e8ab7673be6a15ebe230 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -1028,13 +1028,18 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) { char * taosVariantGet(SVariant *pVar, int32_t type) { switch (type) { - case TSDB_DATA_TYPE_BOOL: + case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_BIGINT: - case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_TIMESTAMP: 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_FLOAT: return (char *)&pVar->d; @@ -1042,7 +1047,7 @@ char * taosVariantGet(SVariant *pVar, int32_t type) { return (char *)pVar->pz; case TSDB_DATA_TYPE_NCHAR: return (char *)pVar->ucs4; - default: + default: return NULL; } diff --git a/source/dnode/mgmt/CMakeLists.txt b/source/dnode/mgmt/CMakeLists.txt index f4987734628d7947724d67bdd0746927dc80c8bf..297e3a08d7277d6e75eb0bcc612b27cb22d6be64 100644 --- a/source/dnode/mgmt/CMakeLists.txt +++ b/source/dnode/mgmt/CMakeLists.txt @@ -23,6 +23,14 @@ target_include_directories( ) 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}) add_subdirectory(test) endif(${BUILD_TEST}) diff --git a/source/dnode/mgmt/bm/bmHandle.c b/source/dnode/mgmt/bm/bmHandle.c index 645a1d09c2a918f6e2705bba2696ee242b55cf55..d11059260317d287398320902e5889a72c71a463 100644 --- a/source/dnode/mgmt/bm/bmHandle.c +++ b/source/dnode/mgmt/bm/bmHandle.c @@ -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); return -1; } 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()); return -1; } else { + // dndCloseNode(pWrapper); return bmDrop(pWrapper); } } diff --git a/source/dnode/mgmt/dm/dmMonitor.c b/source/dnode/mgmt/dm/dmMonitor.c index fb5855070ca420685cd1a74f9e41089de8d2bd7f..6edf85106bcbfcc5f8d0cc6e2449ea50da2b56c4 100644 --- a/source/dnode/mgmt/dm/dmMonitor.c +++ b/source/dnode/mgmt/dm/dmMonitor.c @@ -25,11 +25,10 @@ static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) { static void dmGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) { pInfo->uptime = (taosGetTimestampMs() - pDnode->rebootTime) / (86400000.0f); - SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, MNODE); - if (pWrapper != NULL) { - pInfo->has_mnode = pWrapper->required; - dndReleaseWrapper(pWrapper); - } + pInfo->has_mnode = pDnode->wrappers[MNODE].required; + pInfo->has_qnode = pDnode->wrappers[QNODE].required; + pInfo->has_snode = pDnode->wrappers[SNODE].required; + pInfo->has_bnode = pDnode->wrappers[BNODE].required; tstrncpy(pInfo->logdir.name, tsLogDir, sizeof(pInfo->logdir.name)); pInfo->logdir.size = tsLogSpace.size; tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name)); @@ -65,7 +64,7 @@ void dmSendMonitorReport(SDnode *pDnode) { bool getFromAPI = !tsMultiProcess; pWrapper = &pDnode->wrappers[MNODE]; if (getFromAPI) { - if (dndMarkWrapper(pWrapper) != 0) { + if (dndMarkWrapper(pWrapper) == 0) { mmGetMonitorInfo(pWrapper, &mmInfo); dndReleaseWrapper(pWrapper); } @@ -82,7 +81,7 @@ void dmSendMonitorReport(SDnode *pDnode) { pWrapper = &pDnode->wrappers[VNODES]; if (getFromAPI) { - if (dndMarkWrapper(pWrapper) != 0) { + if (dndMarkWrapper(pWrapper) == 0) { vmGetMonitorInfo(pWrapper, &vmInfo); dndReleaseWrapper(pWrapper); } @@ -99,7 +98,7 @@ void dmSendMonitorReport(SDnode *pDnode) { pWrapper = &pDnode->wrappers[QNODE]; if (getFromAPI) { - if (dndMarkWrapper(pWrapper) != 0) { + if (dndMarkWrapper(pWrapper) == 0) { qmGetMonitorInfo(pWrapper, &qmInfo); dndReleaseWrapper(pWrapper); } @@ -116,7 +115,7 @@ void dmSendMonitorReport(SDnode *pDnode) { pWrapper = &pDnode->wrappers[SNODE]; if (getFromAPI) { - if (dndMarkWrapper(pWrapper) != 0) { + if (dndMarkWrapper(pWrapper) == 0) { smGetMonitorInfo(pWrapper, &smInfo); dndReleaseWrapper(pWrapper); } @@ -133,7 +132,7 @@ void dmSendMonitorReport(SDnode *pDnode) { pWrapper = &pDnode->wrappers[BNODE]; if (getFromAPI) { - if (dndMarkWrapper(pWrapper) != 0) { + if (dndMarkWrapper(pWrapper) == 0) { bmGetMonitorInfo(pWrapper, &bmInfo); dndReleaseWrapper(pWrapper); } diff --git a/source/dnode/mgmt/exe/dndMain.c b/source/dnode/mgmt/exe/dndMain.c index 997c56f9fb10f63b67bf858de4b76a1efedaaa4c..66ab2a6dcd1964a19fee3a133785e005bce24322 100644 --- a/source/dnode/mgmt/exe/dndMain.c +++ b/source/dnode/mgmt/exe/dndMain.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "dndInt.h" #include "tconfig.h" +#include "tgrant.h" static struct { bool dumpConfig; @@ -90,8 +91,7 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) { } static void dndGenerateGrant() { - // grantParseParameter(); - printf("this feature is not implemented yet\n"); + grantParseParameter(); } static void dndPrintVersion() { diff --git a/source/dnode/mgmt/inc/bmInt.h b/source/dnode/mgmt/inc/bmInt.h index 84a6a53e99c3c8785f982c0ffbcf83180fa69430..3158fe7d34f37616745927925354dfdde18453ba 100644 --- a/source/dnode/mgmt/inc/bmInt.h +++ b/source/dnode/mgmt/inc/bmInt.h @@ -27,7 +27,7 @@ extern "C" { typedef struct SBnodeMgmt { SBnode *pBnode; SDnode *pDnode; - SMgmtWrapper *pWrapper; + SMgmtWrapper *pWrapper; const char *path; SMultiWorker writeWorker; SSingleWorker monitorWorker; diff --git a/source/dnode/mgmt/inc/dndInt.h b/source/dnode/mgmt/inc/dndInt.h index 7faf1e4276ea879da4b20003d088fccb5f5c688c..a38fe87b59ea93015eb78acb40159072efb3e1e0 100644 --- a/source/dnode/mgmt/inc/dndInt.h +++ b/source/dnode/mgmt/inc/dndInt.h @@ -126,6 +126,7 @@ typedef struct SDnode { int32_t numOfDisks; uint16_t serverPort; bool dropped; + EProcType procType; EDndType ntype; EDndStatus status; EDndEvent event; diff --git a/source/dnode/mgmt/main/dndExec.c b/source/dnode/mgmt/main/dndExec.c index 6c0d0456c9225547a0d4dfcd59d1a6ddc6fa67ff..51569d2ed4640e995f7c33e5e38bf69cec11be97 100644 --- a/source/dnode/mgmt/main/dndExec.c +++ b/source/dnode/mgmt/main/dndExec.c @@ -27,7 +27,81 @@ static bool dndRequireNode(SMgmtWrapper *pWrapper) { return required; } -int32_t dndOpenNode(SMgmtWrapper *pWrapper) { +static int32_t dndInitNodeProc(SMgmtWrapper *pWrapper) { + int32_t shmsize = tsMnodeShmSize; + if (pWrapper->ntype == VNODES) { + 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; + } + + if (taosCreateShm(&pWrapper->shm, pWrapper->ntype, 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; + } + + return 0; +} + +static int32_t dndNewNodeProc(SMgmtWrapper *pWrapper, EDndType n) { + char tstr[8] = {0}; + char *args[6] = {0}; + snprintf(tstr, sizeof(tstr), "%d", n); + args[1] = "-c"; + args[2] = configDir; + args[3] = "-n"; + args[4] = tstr; + args[5] = NULL; + + int32_t pid = taosNewProc(args); + if (pid <= 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + dError("node:%s, failed to exec in new process since %s", pWrapper->name, terrstr()); + return -1; + } + + pWrapper->procId = pid; + dInfo("node:%s, continue running in new process:%d", pWrapper->name, pid); + 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()); @@ -44,7 +118,19 @@ int32_t dndOpenNode(SMgmtWrapper *pWrapper) { return 0; } -void dndCloseNode(SMgmtWrapper *pWrapper) { +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); @@ -65,27 +151,17 @@ void dndCloseNode(SMgmtWrapper *pWrapper) { dDebug("node:%s, mgmt has been closed", pWrapper->name); } - -static int32_t dndNewProc(SMgmtWrapper *pWrapper, EDndType n) { - char tstr[8] = {0}; - char *args[6] = {0}; - snprintf(tstr, sizeof(tstr), "%d", n); - args[1] = "-c"; - args[2] = configDir; - args[3] = "-n"; - args[4] = tstr; - args[5] = NULL; - - int32_t pid = taosNewProc(args); - if (pid <= 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - dError("node:%s, failed to exec in new process since %s", pWrapper->name, terrstr()); - return -1; +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); + } } - - pWrapper->procId = pid; - dInfo("node:%s, continue running in new process:%d", pWrapper->name, pid); - return 0; + dndCloseNodeImp(pWrapper); } static void dndProcessProcHandle(void *handle) { @@ -96,13 +172,14 @@ static void dndProcessProcHandle(void *handle) { static int32_t dndRunInSingleProcess(SDnode *pDnode) { dInfo("dnode run in single process"); + pDnode->procType = PROC_SINGLE; for (EDndType n = DNODE; n < NODE_MAX; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; pWrapper->required = dndRequireNode(pWrapper); if (!pWrapper->required) continue; - if (dndOpenNode(pWrapper) != 0) { + if (dndOpenNodeImp(pWrapper) != 0) { dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); return -1; } @@ -136,8 +213,10 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) { static int32_t dndRunInParentProcess(SDnode *pDnode) { dInfo("dnode run in parent process"); + pDnode->procType = PROC_PARENT; + SMgmtWrapper *pDWrapper = &pDnode->wrappers[DNODE]; - if (dndOpenNode(pDWrapper) != 0) { + if (dndOpenNodeImp(pDWrapper) != 0) { dError("node:%s, failed to start since %s", pDWrapper->name, terrstr()); return -1; } @@ -146,36 +225,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; pWrapper->required = dndRequireNode(pWrapper); if (!pWrapper->required) continue; - - 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 (dndInitNodeProc(pWrapper) != 0) return -1; } if (dndWriteShmFile(pDnode) != 0) { @@ -186,19 +236,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { for (EDndType n = DNODE + 1; n < NODE_MAX; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; if (!pWrapper->required) continue; - - 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; - } + if (dndRunNodeProc(pWrapper) != 0) return -1; } dndSetStatus(pDnode, DND_STAT_RUNNING); @@ -239,7 +277,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { if (pWrapper->procId <= 0 || !taosProcExist(pWrapper->procId)) { dWarn("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId); 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) { SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype]; dInfo("%s run in child process", pWrapper->name); + pDnode->procType = PROC_CHILD; pWrapper->required = dndRequireNode(pWrapper); if (!pWrapper->required) { @@ -264,7 +303,7 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) { tmsgSetDefaultMsgCb(&msgCb); pWrapper->procType = PROC_CHILD; - if (dndOpenNode(pWrapper) != 0) { + if (dndOpenNodeImp(pWrapper) != 0) { dError("node:%s, failed to start since %s", pWrapper->name, terrstr()); return -1; } diff --git a/source/dnode/mgmt/mm/mmHandle.c b/source/dnode/mgmt/mm/mmHandle.c index 6ad0b8c0ed5e62d0d84b49727bc5ad2145c35c22..63240c32249033ba254617ee4f09a92035b52697 100644 --- a/source/dnode/mgmt/mm/mmHandle.c +++ b/source/dnode/mgmt/mm/mmHandle.c @@ -80,6 +80,7 @@ int32_t mmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { dError("failed to drop mnode since %s", terrstr()); return -1; } else { + // dndCloseNode(pWrapper); return mmDrop(pWrapper); } } diff --git a/source/dnode/mgmt/qm/qmHandle.c b/source/dnode/mgmt/qm/qmHandle.c index 96fc33852962cce1b4c74bffdd0ad0ee1ee2b371..4fda72759ae94d881226433acc7c73478b7190a4 100644 --- a/source/dnode/mgmt/qm/qmHandle.c +++ b/source/dnode/mgmt/qm/qmHandle.c @@ -58,7 +58,7 @@ int32_t qmProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { dError("failed to create qnode since %s", terrstr()); return -1; } 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()); return -1; } else { + // dndCloseNode(pWrapper); return qmDrop(pWrapper); } } diff --git a/source/dnode/mgmt/qm/qmWorker.c b/source/dnode/mgmt/qm/qmWorker.c index 974052cdf64683f990269bf6aad34725a56229f8..6b27af4fbd343d6b8bc616ddcb09b671c29bbfe0 100644 --- a/source/dnode/mgmt/qm/qmWorker.c +++ b/source/dnode/mgmt/qm/qmWorker.c @@ -32,7 +32,7 @@ static void qmProcessMonitorQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { SRpcMsg *pRpc = &pMsg->rpcMsg; 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); } else { terrno = TSDB_CODE_MSG_NOT_PROCESSED; diff --git a/source/dnode/mgmt/sm/smHandle.c b/source/dnode/mgmt/sm/smHandle.c index 36345cf49032f6be6b951704aafbe39dae1886c2..5b30dc04bc8d979168b9b008d922d40d44cb3471 100644 --- a/source/dnode/mgmt/sm/smHandle.c +++ b/source/dnode/mgmt/sm/smHandle.c @@ -58,7 +58,7 @@ int32_t smProcessCreateReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { dError("failed to create snode since %s", terrstr()); return -1; } else { - return smOpen(pWrapper); + return dndOpenNode(pWrapper); } } @@ -78,6 +78,7 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { return -1; } else { return smDrop(pWrapper); + // return dndCloseNode(pWrapper); } } diff --git a/source/dnode/mnode/impl/src/mndGrant.c b/source/dnode/mnode/impl/src/mndGrant.c new file mode 100644 index 0000000000000000000000000000000000000000..cdf3271789041dd427cbc88955ad62fe17d7d6e7 --- /dev/null +++ b/source/dnode/mnode/impl/src/mndGrant.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#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 \ No newline at end of file diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index b5fe7d460f6dc2ea8406dc4de2e2cc69badaaffb..bd2e4213d574ec3d4086038b0e8776d266f91071 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -55,6 +55,8 @@ target_include_directories( vnode PUBLIC "inc" PRIVATE "src/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar" + ) target_link_libraries( vnode @@ -69,6 +71,7 @@ target_link_libraries( PUBLIC scheduler PUBLIC tdb #PUBLIC bdb + #PUBLIC scalar PUBLIC transport PUBLIC stream ) diff --git a/source/dnode/vnode/src/meta/metaTDBImpl.c b/source/dnode/vnode/src/meta/metaTDBImpl.c index c78691e7c25099d3e96bac5f7412aba9ac7da230..e3acba7eb6017449e5664d124578699ebd97a078 100644 --- a/source/dnode/vnode/src/meta/metaTDBImpl.c +++ b/source/dnode/vnode/src/meta/metaTDBImpl.c @@ -25,18 +25,18 @@ typedef struct SPoolMem { static SPoolMem *openPool(); static void clearPool(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); struct SMetaDB { TXN txn; - TENV *pEnv; - TDB *pTbDB; - TDB *pSchemaDB; - TDB *pNameIdx; - TDB *pStbIdx; - TDB *pNtbIdx; - TDB *pCtbIdx; + TENV * pEnv; + TDB * pTbDB; + TDB * pSchemaDB; + TDB * pNameIdx; + TDB * pStbIdx; + TDB * pNtbIdx; + TDB * pCtbIdx; SPoolMem *pPool; }; @@ -46,7 +46,7 @@ typedef struct __attribute__((__packed__)) { } SSchemaDbKey; typedef struct { - char *name; + char * name; tb_uid_t uid; } SNameIdxKey; @@ -205,14 +205,14 @@ void metaCloseDB(SMeta *pMeta) { int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) { tb_uid_t uid; - SMetaDB *pMetaDb; - void *pKey; - void *pVal; + SMetaDB * pMetaDb; + void * pKey; + void * pVal; int kLen; int vLen; int ret; char buf[512]; - void *pBuf; + void * pBuf; SCtbIdxKey ctbIdxKey; SSchemaDbKey schemaDbKey; SSchemaWrapper schemaWrapper; @@ -329,11 +329,11 @@ int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid) { STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) { int ret; SMetaDB *pMetaDb = pMeta->pDB; - void *pKey; - void *pVal; + void * pKey; + void * pVal; int kLen; int vLen; - STbCfg *pTbCfg; + STbCfg * pTbCfg; // Fetch 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) { - void *pKey; - void *pVal; + void * pKey; + void * pVal; int kLen; int vLen; int ret; SSchemaDbKey schemaDbKey; SSchemaWrapper *pSchemaWrapper; - void *pBuf; + void * pBuf; // fetch schemaDbKey.uid = uid; @@ -419,9 +419,9 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) { tb_uid_t quid; SSchemaWrapper *pSW; STSchemaBuilder sb; - SSchemaEx *pSchema; - STSchema *pTSchema; - STbCfg *pTbCfg; + SSchemaEx * pSchema; + STSchema * pTSchema; + STbCfg * pTbCfg; pTbCfg = metaGetTbInfoByUid(pMeta, uid); if (pTbCfg->type == META_CHILD_TABLE) { @@ -452,7 +452,7 @@ struct SMTbCursor { SMTbCursor *metaOpenTbCursor(SMeta *pMeta) { SMTbCursor *pTbCur = NULL; - SMetaDB *pDB = pMeta->pDB; + SMetaDB * pDB = pMeta->pDB; pTbCur = (SMTbCursor *)taosMemoryCalloc(1, sizeof(*pTbCur)); if (pTbCur == NULL) { @@ -474,12 +474,12 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) { } char *metaTbCursorNext(SMTbCursor *pTbCur) { - void *pKey = NULL; - void *pVal = NULL; + void * pKey = NULL; + void * pVal = NULL; int kLen; int vLen; int ret; - void *pBuf; + void * pBuf; STbCfg tbCfg; for (;;) { @@ -503,17 +503,17 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) { } struct SMCtbCursor { - TDBC *pCur; + TDBC * pCur; tb_uid_t suid; - void *pKey; - void *pVal; + void * pKey; + void * pVal; int kLen; int vLen; }; SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) { SMCtbCursor *pCtbCur = NULL; - SMetaDB *pDB = pMeta->pDB; + SMetaDB * pDB = pMeta->pDB; int ret; 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++) { pSchema = pSW->pSchema + i; tlen += taosEncodeFixedI8(buf, pSchema->type); + tlen += taosEncodeFixedI8(buf, pSchema->index); tlen += taosEncodeFixedI16(buf, pSchema->colId); tlen += taosEncodeFixedI32(buf, pSchema->bytes); tlen += taosEncodeString(buf, pSchema->name); @@ -637,6 +638,7 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) { for (int i = 0; i < pSW->nCols; i++) { pSchema = pSW->pSchema + i; buf = taosDecodeFixedI8(buf, &pSchema->type); + buf = taosSkipFixedLen(buf, sizeof(int8_t)); buf = taosDecodeFixedI16(buf, &pSchema->colId); buf = taosDecodeFixedI32(buf, &pSchema->bytes); buf = taosDecodeStringTo(buf, pSchema->name); @@ -781,7 +783,7 @@ static void closePool(SPoolMem *pPool) { } static void *poolMalloc(void *arg, size_t size) { - void *ptr = NULL; + void * ptr = NULL; SPoolMem *pPool = (SPoolMem *)arg; SPoolMem *pMem; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index e308c9c2b9713a0562d561713286db3faf545ef7..550e7cd183934681889b8c1e38d6ed5c81617596 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -13,21 +13,22 @@ * along with this program. If not, see . */ -#include "vnodeInt.h" -#include "tdatablock.h" #include "os.h" #include "talgo.h" #include "tcompare.h" +#include "tdatablock.h" #include "tdataformat.h" #include "texception.h" +#include "vnodeInt.h" +#include "filter.h" #include "taosdef.h" #include "tlosertree.h" -#include "vnodeInt.h" #include "tmsg.h" +#include "vnodeInt.h" -#define EXTRA_BYTES 2 -#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) +#define EXTRA_BYTES 2 +#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) #define QH_GET_NUM_OF_COLS(handle) ((size_t)(taosArrayGetSize((handle)->pColumns))) #define GET_FILE_DATA_BLOCK_INFO(_checkInfo, _block) \ @@ -37,32 +38,32 @@ .uid = (_checkInfo)->tableId}) enum { - TSDB_QUERY_TYPE_ALL = 1, - TSDB_QUERY_TYPE_LAST = 2, + TSDB_QUERY_TYPE_ALL = 1, + TSDB_QUERY_TYPE_LAST = 2, }; enum { - TSDB_CACHED_TYPE_NONE = 0, + TSDB_CACHED_TYPE_NONE = 0, TSDB_CACHED_TYPE_LASTROW = 1, - TSDB_CACHED_TYPE_LAST = 2, + TSDB_CACHED_TYPE_LAST = 2, }; typedef struct SQueryFilePos { - int32_t fid; - int32_t slot; - int32_t pos; - int64_t lastKey; - int32_t rows; - bool mixBlock; - bool blockCompleted; + int32_t fid; + int32_t slot; + int32_t pos; + int64_t lastKey; + int32_t rows; + bool mixBlock; + bool blockCompleted; STimeWindow win; } SQueryFilePos; typedef struct SDataBlockLoadInfo { - SDFileSet* fileGroup; - int32_t slot; - uint64_t uid; - SArray* pLoadedCols; + SDFileSet* fileGroup; + int32_t slot; + uint64_t uid; + SArray* pLoadedCols; } SDataBlockLoadInfo; typedef struct SLoadCompBlockInfo { @@ -71,33 +72,33 @@ typedef struct SLoadCompBlockInfo { } SLoadCompBlockInfo; enum { - CHECKINFO_CHOSEN_MEM = 0, + CHECKINFO_CHOSEN_MEM = 0, CHECKINFO_CHOSEN_IMEM = 1, - CHECKINFO_CHOSEN_BOTH = 2 //for update=2(merge case) + CHECKINFO_CHOSEN_BOTH = 2 // for update=2(merge case) }; typedef struct STableCheckInfo { - uint64_t tableId; - TSKEY lastKey; - SBlockInfo* pCompInfo; - int32_t compSize; - int32_t numOfBlocks:29; // number of qualified data blocks not the original blocks - uint8_t chosen:2; // indicate which iterator should move forward - bool initBuf:1; // whether to initialize the in-memory skip list iterator or not - SSkipListIterator* iter; // mem buffer skip list iterator - SSkipListIterator* iiter; // imem buffer skip list iterator + uint64_t tableId; + TSKEY lastKey; + SBlockInfo* pCompInfo; + int32_t compSize; + int32_t numOfBlocks : 29; // number of qualified data blocks not the original blocks + uint8_t chosen : 2; // indicate which iterator should move forward + bool initBuf : 1; // whether to initialize the in-memory skip list iterator or not + SSkipListIterator* iter; // mem buffer skip list iterator + SSkipListIterator* iiter; // imem buffer skip list iterator } STableCheckInfo; typedef struct STableBlockInfo { - SBlock *compBlock; - STableCheckInfo *pTableCheckInfo; + SBlock* compBlock; + STableCheckInfo* pTableCheckInfo; } STableBlockInfo; typedef struct SBlockOrderSupporter { - int32_t numOfTables; - STableBlockInfo** pDataBlockInfo; - int32_t* blockIndexArray; - int32_t* numOfBlocksPerTable; + int32_t numOfTables; + STableBlockInfo** pDataBlockInfo; + int32_t* blockIndexArray; + int32_t* numOfBlocksPerTable; } SBlockOrderSupporter; typedef struct SIOCostSummary { @@ -109,37 +110,37 @@ typedef struct SIOCostSummary { } SIOCostSummary; typedef struct STsdbReadHandle { - STsdb* pTsdb; - SQueryFilePos cur; // current position - int16_t order; - STimeWindow window; // the primary query time window that applies to all queries - SDataStatis* statis; // query level statistics, only one table block statistics info exists at any time - int32_t numOfBlocks; - SArray* pColumns; // column list, SColumnInfoData array list - bool locateStart; - int32_t outputCapacity; - int32_t realNumOfRows; - SArray* pTableCheckInfo; // SArray - int32_t activeIndex; - bool checkFiles; // check file stage - int8_t cachelastrow; // check if last row cached - bool loadExternalRow; // load time window external data rows - bool currentLoadExternalRows; // current load external rows - int32_t loadType; // block load type - char *idStr; // query info handle, for debug purpose - int32_t type; // query type: retrieve all data blocks, 2. retrieve only last row, 3. retrieve direct prev|next rows - SDFileSet* pFileGroup; - SFSIter fileIter; - SReadH rhelper; - STableBlockInfo* pDataBlockInfo; - SDataCols *pDataCols; // in order to hold current file data block - int32_t allocSize; // allocated data block size - SArray *defaultLoadColumn;// default load column - SDataBlockLoadInfo dataBlockLoadInfo; /* record current block load information */ - SLoadCompBlockInfo compBlockLoadInfo; /* record current compblock information in SQueryAttr */ - - SArray *prev; // previous row which is before than time window - SArray *next; // next row which is after the query time window + STsdb* pTsdb; + SQueryFilePos cur; // current position + int16_t order; + STimeWindow window; // the primary query time window that applies to all queries + SDataStatis* statis; // query level statistics, only one table block statistics info exists at any time + int32_t numOfBlocks; + SArray* pColumns; // column list, SColumnInfoData array list + bool locateStart; + int32_t outputCapacity; + int32_t realNumOfRows; + SArray* pTableCheckInfo; // SArray + int32_t activeIndex; + bool checkFiles; // check file stage + int8_t cachelastrow; // check if last row cached + bool loadExternalRow; // load time window external data rows + bool currentLoadExternalRows; // current load external rows + int32_t loadType; // block load type + char* idStr; // query info handle, for debug purpose + int32_t type; // query type: retrieve all data blocks, 2. retrieve only last row, 3. retrieve direct prev|next rows + SDFileSet* pFileGroup; + SFSIter fileIter; + SReadH rhelper; + STableBlockInfo* pDataBlockInfo; + SDataCols* pDataCols; // in order to hold current file data block + int32_t allocSize; // allocated data block size + SArray* defaultLoadColumn; // default load column + SDataBlockLoadInfo dataBlockLoadInfo; /* record current block load information */ + SLoadCompBlockInfo compBlockLoadInfo; /* record current compblock information in SQueryAttr */ + + SArray* prev; // previous row which is before than time window + SArray* next; // next row which is after the query time window SIOCostSummary cost; } STsdbReadHandle; @@ -149,24 +150,27 @@ typedef struct STableGroupSupporter { SSchema* pTagSchema; } STableGroupSupporter; -static STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList); -static int32_t checkForCachedLastRow(STsdbReadHandle* pTsdbReadHandle, STableGroupInfo *groupList); -static int32_t checkForCachedLast(STsdbReadHandle* pTsdbReadHandle); +int32_t tsdbQueryTableList(void* pMeta, SArray* pRes, void* filterInfo); + +static STimeWindow updateLastrowForEachGroup(STableGroupInfo* groupList); +static int32_t checkForCachedLastRow(STsdbReadHandle* pTsdbReadHandle, STableGroupInfo* groupList); +static int32_t checkForCachedLast(STsdbReadHandle* pTsdbReadHandle); // static int32_t tsdbGetCachedLastRow(STable* pTable, STSRow** pRes, TSKEY* lastKey); static void changeQueryHandleForInterpQuery(tsdbReaderT pHandle); static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, SBlock* pBlock); static int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order); -static int32_t tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int maxRowsToRead, STimeWindow* win, STsdbReadHandle* pTsdbReadHandle); +static int32_t tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int maxRowsToRead, STimeWindow* win, + STsdbReadHandle* pTsdbReadHandle); static int32_t tsdbCheckInfoCompar(const void* key1, const void* key2); -//static int32_t doGetExternalRow(STsdbReadHandle* pTsdbReadHandle, int16_t type, void* pMemRef); -//static void* doFreeColumnInfoData(SArray* pColumnInfoData); -//static void* destroyTableCheckInfo(SArray* pTableCheckInfo); -static bool tsdbGetExternalRow(tsdbReaderT pHandle); +// static int32_t doGetExternalRow(STsdbReadHandle* pTsdbReadHandle, int16_t type, void* pMemRef); +// static void* doFreeColumnInfoData(SArray* pColumnInfoData); +// static void* destroyTableCheckInfo(SArray* pTableCheckInfo); +static bool tsdbGetExternalRow(tsdbReaderT pHandle); static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) { pBlockLoadInfo->slot = -1; - pBlockLoadInfo->uid = 0; + pBlockLoadInfo->uid = 0; pBlockLoadInfo->fileGroup = NULL; } @@ -204,30 +208,32 @@ static SArray* getDefaultLoadColumns(STsdbReadHandle* pTsdbReadHandle, bool load } int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT* pHandle) { - STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*) pHandle; + STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)pHandle; - int64_t rows = 0; - STsdbMemTable* pMemTable = NULL;//pTsdbReadHandle->pMemTable; - if (pMemTable == NULL) { return rows; } + int64_t rows = 0; + STsdbMemTable* pMemTable = NULL; // pTsdbReadHandle->pMemTable; + if (pMemTable == NULL) { + return rows; + } -// STableData* pMem = NULL; -// STableData* pIMem = NULL; + // STableData* pMem = NULL; + // STableData* pIMem = NULL; -// SMemTable* pMemT = pMemRef->snapshot.mem; -// SMemTable* pIMemT = pMemRef->snapshot.imem; + // SMemTable* pMemT = pMemRef->snapshot.mem; + // SMemTable* pIMemT = pMemRef->snapshot.imem; size_t size = taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo); for (int32_t i = 0; i < size; ++i) { STableCheckInfo* pCheckInfo = taosArrayGet(pTsdbReadHandle->pTableCheckInfo, i); -// if (pMemT && pCheckInfo->tableId < pMemT->maxTables) { -// pMem = pMemT->tData[pCheckInfo->tableId]; -// rows += (pMem && pMem->uid == pCheckInfo->tableId) ? pMem->numOfRows : 0; -// } -// if (pIMemT && pCheckInfo->tableId < pIMemT->maxTables) { -// pIMem = pIMemT->tData[pCheckInfo->tableId]; -// rows += (pIMem && pIMem->uid == pCheckInfo->tableId) ? pIMem->numOfRows : 0; -// } + // if (pMemT && pCheckInfo->tableId < pMemT->maxTables) { + // pMem = pMemT->tData[pCheckInfo->tableId]; + // rows += (pMem && pMem->uid == pCheckInfo->tableId) ? pMem->numOfRows : 0; + // } + // if (pIMemT && pCheckInfo->tableId < pIMemT->maxTables) { + // pIMem = pIMemT->tData[pCheckInfo->tableId]; + // rows += (pIMem && pIMem->uid == pCheckInfo->tableId) ? pIMem->numOfRows : 0; + // } } return rows; } @@ -244,15 +250,15 @@ static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, S // todo apply the lastkey of table check to avoid to load header file for (int32_t i = 0; i < numOfGroup; ++i) { - SArray* group = *(SArray**) taosArrayGet(pGroupList->pGroupList, i); + SArray* group = *(SArray**)taosArrayGet(pGroupList->pGroupList, i); size_t gsize = taosArrayGetSize(group); assert(gsize > 0); for (int32_t j = 0; j < gsize; ++j) { - STableKeyInfo* pKeyInfo = (STableKeyInfo*) taosArrayGet(group, j); + STableKeyInfo* pKeyInfo = (STableKeyInfo*)taosArrayGet(group, j); - STableCheckInfo info = { .lastKey = pKeyInfo->lastKey, .tableId = pKeyInfo->uid}; + STableCheckInfo info = {.lastKey = pKeyInfo->lastKey, .tableId = pKeyInfo->uid}; if (ASCENDING_TRAVERSE(pTsdbReadHandle->order)) { if (info.lastKey == INT64_MIN || info.lastKey < pTsdbReadHandle->window.skey) { info.lastKey = pTsdbReadHandle->window.skey; @@ -264,7 +270,8 @@ static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, S } taosArrayPush(pTableCheckInfo, &info); - tsdbDebug("%p check table uid:%"PRId64" from lastKey:%"PRId64" %s", pTsdbReadHandle, info.tableId, info.lastKey, pTsdbReadHandle->idStr); + tsdbDebug("%p check table uid:%" PRId64 " from lastKey:%" PRId64 " %s", pTsdbReadHandle, info.tableId, + info.lastKey, pTsdbReadHandle->idStr); } } @@ -279,10 +286,10 @@ static void resetCheckInfo(STsdbReadHandle* pTsdbReadHandle) { // todo apply the lastkey of table check to avoid to load header file for (int32_t i = 0; i < numOfTables; ++i) { - STableCheckInfo* pCheckInfo = (STableCheckInfo*) taosArrayGet(pTsdbReadHandle->pTableCheckInfo, i); + STableCheckInfo* pCheckInfo = (STableCheckInfo*)taosArrayGet(pTsdbReadHandle->pTableCheckInfo, i); pCheckInfo->lastKey = pTsdbReadHandle->window.skey; - pCheckInfo->iter = tSkipListDestroyIter(pCheckInfo->iter); - pCheckInfo->iiter = tSkipListDestroyIter(pCheckInfo->iiter); + pCheckInfo->iter = tSkipListDestroyIter(pCheckInfo->iter); + pCheckInfo->iiter = tSkipListDestroyIter(pCheckInfo->iiter); pCheckInfo->initBuf = false; if (ASCENDING_TRAVERSE(pTsdbReadHandle->order)) { @@ -297,7 +304,7 @@ static void resetCheckInfo(STsdbReadHandle* pTsdbReadHandle) { static SArray* createCheckInfoFromCheckInfo(STableCheckInfo* pCheckInfo, TSKEY skey, SArray** psTable) { SArray* pNew = taosArrayInit(1, sizeof(STableCheckInfo)); - STableCheckInfo info = { .lastKey = skey}; + STableCheckInfo info = {.lastKey = skey}; info.tableId = pCheckInfo->tableId; taosArrayPush(pNew, &info); @@ -308,7 +315,7 @@ static bool emptyQueryTimewindow(STsdbReadHandle* pTsdbReadHandle) { assert(pTsdbReadHandle != NULL); STimeWindow* w = &pTsdbReadHandle->window; - bool asc = ASCENDING_TRAVERSE(pTsdbReadHandle->order); + bool asc = ASCENDING_TRAVERSE(pTsdbReadHandle->order); return ((asc && w->skey > w->ekey) || (!asc && w->ekey > w->skey)); } @@ -354,23 +361,23 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond, goto _end; } - pReadHandle->order = pCond->order; - pReadHandle->pTsdb = tsdb; - pReadHandle->type = TSDB_QUERY_TYPE_ALL; - pReadHandle->cur.fid = INT32_MIN; - pReadHandle->cur.win = TSWINDOW_INITIALIZER; - pReadHandle->checkFiles = true; - pReadHandle->activeIndex = 0; // current active table index - pReadHandle->allocSize = 0; + pReadHandle->order = pCond->order; + pReadHandle->pTsdb = tsdb; + pReadHandle->type = TSDB_QUERY_TYPE_ALL; + pReadHandle->cur.fid = INT32_MIN; + pReadHandle->cur.win = TSWINDOW_INITIALIZER; + pReadHandle->checkFiles = true; + pReadHandle->activeIndex = 0; // current active table index + pReadHandle->allocSize = 0; pReadHandle->locateStart = false; - pReadHandle->loadType = pCond->type; + pReadHandle->loadType = pCond->type; - pReadHandle->outputCapacity = 4096;//((STsdb*)tsdb)->config.maxRowsPerFileBlock; + pReadHandle->outputCapacity = 4096; //((STsdb*)tsdb)->config.maxRowsPerFileBlock; pReadHandle->loadExternalRow = pCond->loadExternalRows; pReadHandle->currentLoadExternalRows = pCond->loadExternalRows; char buf[128] = {0}; - snprintf(buf, tListLen(buf), "TID:0x%"PRIx64" QID:0x%"PRIx64, taskId, qId); + snprintf(buf, tListLen(buf), "TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, qId); pReadHandle->idStr = strdup(buf); if (tsdbInitReadH(&pReadHandle->rhelper, (STsdb*)tsdb) != 0) { @@ -421,37 +428,39 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond, return (tsdbReaderT)pReadHandle; - _end: +_end: tsdbCleanupReadHandle(pReadHandle); terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; return NULL; } -tsdbReaderT* tsdbQueryTables(STsdb* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList, uint64_t qId, uint64_t taskId) { +tsdbReaderT* tsdbQueryTables(STsdb* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList, uint64_t qId, + uint64_t taskId) { STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(tsdb, pCond, qId, taskId); if (pTsdbReadHandle == NULL) { return NULL; } if (emptyQueryTimewindow(pTsdbReadHandle)) { - return (tsdbReaderT*) pTsdbReadHandle; + return (tsdbReaderT*)pTsdbReadHandle; } // todo apply the lastkey of table check to avoid to load header file pTsdbReadHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pTsdbReadHandle, groupList); if (pTsdbReadHandle->pTableCheckInfo == NULL) { -// tsdbCleanupReadHandle(pTsdbReadHandle); + // tsdbCleanupReadHandle(pTsdbReadHandle); terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; return NULL; } - tsdbDebug("%p total numOfTable:%" PRIzu " in this query, group %"PRIzu" %s", pTsdbReadHandle, taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), - taosArrayGetSize(groupList->pGroupList), pTsdbReadHandle->idStr); + tsdbDebug("%p total numOfTable:%" PRIzu " in this query, group %" PRIzu " %s", pTsdbReadHandle, + taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(groupList->pGroupList), + pTsdbReadHandle->idStr); - return (tsdbReaderT) pTsdbReadHandle; + return (tsdbReaderT)pTsdbReadHandle; } -void tsdbResetQueryHandle(tsdbReaderT queryHandle, STsdbQueryCond *pCond) { +void tsdbResetQueryHandle(tsdbReaderT queryHandle, STsdbQueryCond* pCond) { STsdbReadHandle* pTsdbReadHandle = queryHandle; if (emptyQueryTimewindow(pTsdbReadHandle)) { @@ -463,13 +472,13 @@ void tsdbResetQueryHandle(tsdbReaderT queryHandle, STsdbQueryCond *pCond) { return; } - pTsdbReadHandle->order = pCond->order; - pTsdbReadHandle->window = pCond->twindow; - pTsdbReadHandle->type = TSDB_QUERY_TYPE_ALL; - pTsdbReadHandle->cur.fid = -1; - pTsdbReadHandle->cur.win = TSWINDOW_INITIALIZER; - pTsdbReadHandle->checkFiles = true; - pTsdbReadHandle->activeIndex = 0; // current active table index + pTsdbReadHandle->order = pCond->order; + pTsdbReadHandle->window = pCond->twindow; + pTsdbReadHandle->type = TSDB_QUERY_TYPE_ALL; + pTsdbReadHandle->cur.fid = -1; + pTsdbReadHandle->cur.win = TSWINDOW_INITIALIZER; + pTsdbReadHandle->checkFiles = true; + pTsdbReadHandle->activeIndex = 0; // current active table index pTsdbReadHandle->locateStart = false; pTsdbReadHandle->loadExternalRow = pCond->loadExternalRows; @@ -488,16 +497,16 @@ void tsdbResetQueryHandle(tsdbReaderT queryHandle, STsdbQueryCond *pCond) { resetCheckInfo(pTsdbReadHandle); } -void tsdbResetQueryHandleForNewTable(tsdbReaderT queryHandle, STsdbQueryCond *pCond, STableGroupInfo* groupList) { +void tsdbResetQueryHandleForNewTable(tsdbReaderT queryHandle, STsdbQueryCond* pCond, STableGroupInfo* groupList) { STsdbReadHandle* pTsdbReadHandle = queryHandle; - pTsdbReadHandle->order = pCond->order; - pTsdbReadHandle->window = pCond->twindow; - pTsdbReadHandle->type = TSDB_QUERY_TYPE_ALL; - pTsdbReadHandle->cur.fid = -1; - pTsdbReadHandle->cur.win = TSWINDOW_INITIALIZER; - pTsdbReadHandle->checkFiles = true; - pTsdbReadHandle->activeIndex = 0; // current active table index + pTsdbReadHandle->order = pCond->order; + pTsdbReadHandle->window = pCond->twindow; + pTsdbReadHandle->type = TSDB_QUERY_TYPE_ALL; + pTsdbReadHandle->cur.fid = -1; + pTsdbReadHandle->cur.win = TSWINDOW_INITIALIZER; + pTsdbReadHandle->checkFiles = true; + pTsdbReadHandle->activeIndex = 0; // current active table index pTsdbReadHandle->locateStart = false; pTsdbReadHandle->loadExternalRow = pCond->loadExternalRows; @@ -514,21 +523,23 @@ void tsdbResetQueryHandleForNewTable(tsdbReaderT queryHandle, STsdbQueryCond *pC tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo); SArray* pTable = NULL; -// STsdbMeta* pMeta = tsdbGetMeta(pTsdbReadHandle->pTsdb); + // STsdbMeta* pMeta = tsdbGetMeta(pTsdbReadHandle->pTsdb); -// pTsdbReadHandle->pTableCheckInfo = destroyTableCheckInfo(pTsdbReadHandle->pTableCheckInfo); + // pTsdbReadHandle->pTableCheckInfo = destroyTableCheckInfo(pTsdbReadHandle->pTableCheckInfo); - pTsdbReadHandle->pTableCheckInfo = NULL;//createCheckInfoFromTableGroup(pTsdbReadHandle, groupList, pMeta, &pTable); + pTsdbReadHandle->pTableCheckInfo = NULL; // createCheckInfoFromTableGroup(pTsdbReadHandle, groupList, pMeta, + // &pTable); if (pTsdbReadHandle->pTableCheckInfo == NULL) { -// tsdbCleanupReadHandle(pTsdbReadHandle); + // tsdbCleanupReadHandle(pTsdbReadHandle); terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; } -// pTsdbReadHandle->prev = doFreeColumnInfoData(pTsdbReadHandle->prev); -// pTsdbReadHandle->next = doFreeColumnInfoData(pTsdbReadHandle->next); + // pTsdbReadHandle->prev = doFreeColumnInfoData(pTsdbReadHandle->prev); + // pTsdbReadHandle->next = doFreeColumnInfoData(pTsdbReadHandle->next); } -tsdbReaderT tsdbQueryLastRow(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, uint64_t qId, uint64_t taskId) { +tsdbReaderT tsdbQueryLastRow(STsdb* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList, uint64_t qId, + uint64_t taskId) { pCond->twindow = updateLastrowForEachGroup(groupList); // no qualified table @@ -536,13 +547,13 @@ tsdbReaderT tsdbQueryLastRow(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo return NULL; } - STsdbReadHandle *pTsdbReadHandle = (STsdbReadHandle*) tsdbQueryTables(tsdb, pCond, groupList, qId, taskId); + STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbQueryTables(tsdb, pCond, groupList, qId, taskId); if (pTsdbReadHandle == NULL) { return NULL; } int32_t code = checkForCachedLastRow(pTsdbReadHandle, groupList); - if (code != TSDB_CODE_SUCCESS) { // set the numOfTables to be 0 + if (code != TSDB_CODE_SUCCESS) { // set the numOfTables to be 0 terrno = code; return NULL; } @@ -551,7 +562,7 @@ tsdbReaderT tsdbQueryLastRow(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupInfo if (pTsdbReadHandle->cachelastrow) { pTsdbReadHandle->type = TSDB_QUERY_TYPE_LAST; } - + return pTsdbReadHandle; } @@ -576,12 +587,12 @@ tsdbReaderT tsdbQueryCacheLast(STsdb *tsdb, STsdbQueryCond *pCond, STableGroupIn } #endif -SArray* tsdbGetQueriedTableList(tsdbReaderT *pHandle) { +SArray* tsdbGetQueriedTableList(tsdbReaderT* pHandle) { assert(pHandle != NULL); - STsdbReadHandle *pTsdbReadHandle = (STsdbReadHandle*) pHandle; + STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)pHandle; - size_t size = taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo); + size_t size = taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo); SArray* res = taosArrayInit(size, POINTER_BYTES); return res; } @@ -594,18 +605,18 @@ static STableGroupInfo* trimTableGroup(STimeWindow* window, STableGroupInfo* pGr STableGroupInfo* pNew = taosMemoryCalloc(1, sizeof(STableGroupInfo)); pNew->pGroupList = taosArrayInit(numOfGroup, POINTER_BYTES); - for(int32_t i = 0; i < numOfGroup; ++i) { + for (int32_t i = 0; i < numOfGroup; ++i) { SArray* oneGroup = taosArrayGetP(pGroupList->pGroupList, i); - size_t numOfTables = taosArrayGetSize(oneGroup); + size_t numOfTables = taosArrayGetSize(oneGroup); SArray* px = taosArrayInit(4, sizeof(STableKeyInfo)); for (int32_t j = 0; j < numOfTables; ++j) { STableKeyInfo* pInfo = (STableKeyInfo*)taosArrayGet(oneGroup, j); -// if (window->skey <= pInfo->lastKey && ((STable*)pInfo->pTable)->lastKey != TSKEY_INITIAL_VAL) { -// taosArrayPush(px, pInfo); -// pNew->numOfTables += 1; -// break; -// } + // if (window->skey <= pInfo->lastKey && ((STable*)pInfo->pTable)->lastKey != TSKEY_INITIAL_VAL) { + // taosArrayPush(px, pInfo); + // pNew->numOfTables += 1; + // break; + // } } // there are no data in this group @@ -619,7 +630,8 @@ static STableGroupInfo* trimTableGroup(STimeWindow* window, STableGroupInfo* pGr return pNew; } -tsdbReaderT tsdbQueryRowsInExternalWindow(STsdb *tsdb, STsdbQueryCond* pCond, STableGroupInfo *groupList, uint64_t qId, uint64_t taskId) { +tsdbReaderT tsdbQueryRowsInExternalWindow(STsdb* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList, uint64_t qId, + uint64_t taskId) { STableGroupInfo* pNew = trimTableGroup(&pCond->twindow, groupList); if (pNew->numOfTables == 0) { @@ -634,7 +646,7 @@ tsdbReaderT tsdbQueryRowsInExternalWindow(STsdb *tsdb, STsdbQueryCond* pCond, ST } } - STsdbReadHandle *pTsdbReadHandle = (STsdbReadHandle*) tsdbQueryTables(tsdb, pCond, pNew, qId, taskId); + STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbQueryTables(tsdb, pCond, pNew, qId, taskId); pTsdbReadHandle->loadExternalRow = true; pTsdbReadHandle->currentLoadExternalRows = true; @@ -674,9 +686,9 @@ static bool initTableMemIterator(STsdbReadHandle* pHandle, STableCheckInfo* pChe return false; } - bool memEmpty = (pCheckInfo->iter == NULL) || (pCheckInfo->iter != NULL && !tSkipListIterNext(pCheckInfo->iter)); + bool memEmpty = (pCheckInfo->iter == NULL) || (pCheckInfo->iter != NULL && !tSkipListIterNext(pCheckInfo->iter)); bool imemEmpty = (pCheckInfo->iiter == NULL) || (pCheckInfo->iiter != NULL && !tSkipListIterNext(pCheckInfo->iiter)); - if (memEmpty && imemEmpty) { // buffer is empty + if (memEmpty && imemEmpty) { // buffer is empty return false; } @@ -687,8 +699,9 @@ static bool initTableMemIterator(STsdbReadHandle* pHandle, STableCheckInfo* pChe STSRow* row = (STSRow*)SL_GET_NODE_DATA(node); TSKEY key = TD_ROW_KEY(row); // first timestamp in buffer tsdbDebug("%p uid:%" PRId64 ", check data in mem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64 - "-%" PRId64 ", lastKey:%" PRId64 ", numOfRows:%"PRId64", %s", - pHandle, pCheckInfo->tableId, key, order, (*pMem)->keyMin, (*pMem)->keyMax, pCheckInfo->lastKey, (*pMem)->nrows, pHandle->idStr); + "-%" PRId64 ", lastKey:%" PRId64 ", numOfRows:%" PRId64 ", %s", + pHandle, pCheckInfo->tableId, key, order, (*pMem)->keyMin, (*pMem)->keyMax, pCheckInfo->lastKey, + (*pMem)->nrows, pHandle->idStr); if (ASCENDING_TRAVERSE(order)) { assert(pCheckInfo->lastKey <= key); @@ -697,7 +710,7 @@ static bool initTableMemIterator(STsdbReadHandle* pHandle, STableCheckInfo* pChe } } else { - tsdbDebug("%p uid:%"PRId64", no data in mem, %s", pHandle, pCheckInfo->tableId, pHandle->idStr); + tsdbDebug("%p uid:%" PRId64 ", no data in mem, %s", pHandle, pCheckInfo->tableId, pHandle->idStr); } if (!imemEmpty) { @@ -707,8 +720,9 @@ static bool initTableMemIterator(STsdbReadHandle* pHandle, STableCheckInfo* pChe STSRow* row = (STSRow*)SL_GET_NODE_DATA(node); TSKEY key = TD_ROW_KEY(row); // first timestamp in buffer tsdbDebug("%p uid:%" PRId64 ", check data in imem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64 - "-%" PRId64 ", lastKey:%" PRId64 ", numOfRows:%"PRId64", %s", - pHandle, pCheckInfo->tableId, key, order, (*pIMem)->keyMin, (*pIMem)->keyMax, pCheckInfo->lastKey, (*pIMem)->nrows, pHandle->idStr); + "-%" PRId64 ", lastKey:%" PRId64 ", numOfRows:%" PRId64 ", %s", + pHandle, pCheckInfo->tableId, key, order, (*pIMem)->keyMin, (*pIMem)->keyMax, pCheckInfo->lastKey, + (*pIMem)->nrows, pHandle->idStr); if (ASCENDING_TRAVERSE(order)) { assert(pCheckInfo->lastKey <= key); @@ -716,7 +730,7 @@ static bool initTableMemIterator(STsdbReadHandle* pHandle, STableCheckInfo* pChe assert(pCheckInfo->lastKey >= key); } } else { - tsdbDebug("%p uid:%"PRId64", no data in imem, %s", pHandle, pCheckInfo->tableId, pHandle->idStr); + tsdbDebug("%p uid:%" PRId64 ", no data in imem, %s", pHandle, pCheckInfo->tableId, pHandle->idStr); } return true; @@ -761,30 +775,20 @@ static TSKEY extractFirstTraverseKey(STableCheckInfo* pCheckInfo, int32_t order, TSKEY r2 = TD_ROW_KEY(rimem); if (r1 == r2) { -#if 0 - if(update == TD_ROW_DISCARD_UPDATE){ + if (update == TD_ROW_DISCARD_UPDATE) { pCheckInfo->chosen = CHECKINFO_CHOSEN_IMEM; tSkipListIterNext(pCheckInfo->iter); - } - else if(update == TD_ROW_OVERWRITE_UPDATE) { + } else if (update == TD_ROW_OVERWRITE_UPDATE) { pCheckInfo->chosen = CHECKINFO_CHOSEN_MEM; tSkipListIterNext(pCheckInfo->iiter); } else { pCheckInfo->chosen = CHECKINFO_CHOSEN_BOTH; } -#endif - if (TD_SUPPORT_UPDATE(update)) { - pCheckInfo->chosen = CHECKINFO_CHOSEN_BOTH; - } else { - pCheckInfo->chosen = CHECKINFO_CHOSEN_IMEM; - tSkipListIterNext(pCheckInfo->iter); - } return r1; } else if (r1 < r2 && ASCENDING_TRAVERSE(order)) { pCheckInfo->chosen = CHECKINFO_CHOSEN_MEM; return r1; - } - else { + } else { pCheckInfo->chosen = CHECKINFO_CHOSEN_IMEM; return r2; } @@ -828,7 +832,7 @@ static STSRow* getSRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order, int tSkipListIterNext(pCheckInfo->iter); pCheckInfo->chosen = CHECKINFO_CHOSEN_IMEM; return rimem; - } else if(update == TD_ROW_OVERWRITE_UPDATE){ + } else if (update == TD_ROW_OVERWRITE_UPDATE) { tSkipListIterNext(pCheckInfo->iiter); pCheckInfo->chosen = CHECKINFO_CHOSEN_MEM; return rmem; @@ -872,7 +876,7 @@ static bool moveToNextRowInMem(STableCheckInfo* pCheckInfo) { if (pCheckInfo->iiter != NULL) { return tSkipListIterGet(pCheckInfo->iiter) != NULL; } - } else if (pCheckInfo->chosen == CHECKINFO_CHOSEN_IMEM){ + } else if (pCheckInfo->chosen == CHECKINFO_CHOSEN_IMEM) { if (pCheckInfo->iiter != NULL) { hasNext = tSkipListIterNext(pCheckInfo->iiter); } @@ -897,8 +901,8 @@ static bool moveToNextRowInMem(STableCheckInfo* pCheckInfo) { } static bool hasMoreDataInCache(STsdbReadHandle* pHandle) { - STsdbCfg *pCfg = &pHandle->pTsdb->config; - size_t size = taosArrayGetSize(pHandle->pTableCheckInfo); + STsdbCfg* pCfg = &pHandle->pTsdb->config; + size_t size = taosArrayGetSize(pHandle->pTableCheckInfo); assert(pHandle->activeIndex < size && pHandle->activeIndex >= 0 && size >= 1); pHandle->cur.fid = INT32_MIN; @@ -913,8 +917,8 @@ static bool hasMoreDataInCache(STsdbReadHandle* pHandle) { } pCheckInfo->lastKey = TD_ROW_KEY(row); // first timestamp in buffer - tsdbDebug("%p uid:%" PRId64", check data in buffer from skey:%" PRId64 ", order:%d, %s", pHandle, - pCheckInfo->tableId, pCheckInfo->lastKey, pHandle->order, pHandle->idStr); + tsdbDebug("%p uid:%" PRId64 ", check data in buffer from skey:%" PRId64 ", order:%d, %s", pHandle, + pCheckInfo->tableId, pCheckInfo->lastKey, pHandle->order, pHandle->idStr); // all data in mem are checked already. if ((pCheckInfo->lastKey > pHandle->window.ekey && ASCENDING_TRAVERSE(pHandle->order)) || @@ -922,7 +926,7 @@ static bool hasMoreDataInCache(STsdbReadHandle* pHandle) { return false; } - int32_t step = ASCENDING_TRAVERSE(pHandle->order)? 1:-1; + int32_t step = ASCENDING_TRAVERSE(pHandle->order) ? 1 : -1; STimeWindow* win = &pHandle->cur.win; pHandle->cur.rows = tsdbReadRowsFromCache(pCheckInfo, pHandle->window.ekey, pHandle->outputCapacity, win, pHandle); @@ -947,9 +951,9 @@ static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile, int32_t precisio if (key < 0) { key -= (daysPerFile * tsTickPerDay[precision]); } - + int64_t fid = (int64_t)(key / (daysPerFile * tsTickPerDay[precision])); // set the starting fileId - if (fid < 0L && llabs(fid) > INT32_MAX) { // data value overflow for INT32 + if (fid < 0L && llabs(fid) > INT32_MAX) { // data value overflow for INT32 fid = INT32_MIN; } @@ -987,7 +991,7 @@ static int32_t binarySearchForBlock(SBlock* pBlock, int32_t numOfBlocks, TSKEY s return midSlot; } -static int32_t loadBlockInfo(STsdbReadHandle * pTsdbReadHandle, int32_t index, int32_t* numOfBlocks) { +static int32_t loadBlockInfo(STsdbReadHandle* pTsdbReadHandle, int32_t index, int32_t* numOfBlocks) { int32_t code = 0; STableCheckInfo* pCheckInfo = taosArrayGet(pTsdbReadHandle->pTableCheckInfo, index); @@ -1030,9 +1034,11 @@ static int32_t loadBlockInfo(STsdbReadHandle * pTsdbReadHandle, int32_t index, i TSKEY s = TSKEY_INITIAL_VAL, e = TSKEY_INITIAL_VAL; if (ASCENDING_TRAVERSE(pTsdbReadHandle->order)) { - assert(pCheckInfo->lastKey <= pTsdbReadHandle->window.ekey && pTsdbReadHandle->window.skey <= pTsdbReadHandle->window.ekey); + assert(pCheckInfo->lastKey <= pTsdbReadHandle->window.ekey && + pTsdbReadHandle->window.skey <= pTsdbReadHandle->window.ekey); } else { - assert(pCheckInfo->lastKey >= pTsdbReadHandle->window.ekey && pTsdbReadHandle->window.skey >= pTsdbReadHandle->window.ekey); + assert(pCheckInfo->lastKey >= pTsdbReadHandle->window.ekey && + pTsdbReadHandle->window.skey >= pTsdbReadHandle->window.ekey); } s = TMIN(pCheckInfo->lastKey, pTsdbReadHandle->window.ekey); @@ -1093,10 +1099,11 @@ static int32_t getFileCompInfo(STsdbReadHandle* pTsdbReadHandle, int32_t* numOfB return code; } -static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBlock, STableCheckInfo* pCheckInfo, int32_t slotIndex) { +static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBlock, STableCheckInfo* pCheckInfo, + int32_t slotIndex) { int64_t st = taosGetTimestampUs(); - STSchema *pSchema = metaGetTbTSchema(pTsdbReadHandle->pTsdb->pMeta, pCheckInfo->tableId, 0); + STSchema* pSchema = metaGetTbTSchema(pTsdbReadHandle->pTsdb->pMeta, pCheckInfo->tableId, 0); int32_t code = tdInitDataCols(pTsdbReadHandle->pDataCols, pSchema); if (code != TSDB_CODE_SUCCESS) { tsdbError("%p failed to malloc buf for pDataCols, %s", pTsdbReadHandle, pTsdbReadHandle->idStr); @@ -1120,7 +1127,8 @@ static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBl int16_t* colIds = pTsdbReadHandle->defaultLoadColumn->pData; - int32_t ret = tsdbLoadBlockDataCols(&(pTsdbReadHandle->rhelper), pBlock, pCheckInfo->pCompInfo, colIds, (int)(QH_GET_NUM_OF_COLS(pTsdbReadHandle)), true); + int32_t ret = tsdbLoadBlockDataCols(&(pTsdbReadHandle->rhelper), pBlock, pCheckInfo->pCompInfo, colIds, + (int)(QH_GET_NUM_OF_COLS(pTsdbReadHandle)), true); if (ret != TSDB_CODE_SUCCESS) { int32_t c = terrno; assert(c != TSDB_CODE_SUCCESS); @@ -1139,9 +1147,9 @@ static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBl pBlock->numOfRows = pCols->numOfRows; // Convert from TKEY to TSKEY for primary timestamp column if current block has timestamp before 1970-01-01T00:00:00Z - if(pBlock->keyFirst < 0 && colIds[0] == PRIMARYKEY_TIMESTAMP_COL_ID) { + if (pBlock->keyFirst < 0 && colIds[0] == PRIMARYKEY_TIMESTAMP_COL_ID) { int64_t* src = pCols->cols[0].pData; - for(int32_t i = 0; i < pBlock->numOfRows; ++i) { + for (int32_t i = 0; i < pBlock->numOfRows; ++i) { src[i] = tdGetKey(src[i]); } } @@ -1149,30 +1157,34 @@ static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBl int64_t elapsedTime = (taosGetTimestampUs() - st); pTsdbReadHandle->cost.blockLoadTime += elapsedTime; - tsdbDebug("%p load file block into buffer, index:%d, brange:%"PRId64"-%"PRId64", rows:%d, elapsed time:%"PRId64 " us, %s", - pTsdbReadHandle, slotIndex, pBlock->keyFirst, pBlock->keyLast, pBlock->numOfRows, elapsedTime, pTsdbReadHandle->idStr); + tsdbDebug("%p load file block into buffer, index:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, elapsed time:%" PRId64 + " us, %s", + pTsdbReadHandle, slotIndex, pBlock->keyFirst, pBlock->keyLast, pBlock->numOfRows, elapsedTime, + pTsdbReadHandle->idStr); return TSDB_CODE_SUCCESS; _error: pBlock->numOfRows = 0; - tsdbError("%p error occurs in loading file block, index:%d, brange:%"PRId64"-%"PRId64", rows:%d, %s", + tsdbError("%p error occurs in loading file block, index:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, %s", pTsdbReadHandle, slotIndex, pBlock->keyFirst, pBlock->keyLast, pBlock->numOfRows, pTsdbReadHandle->idStr); return terrno; } static int32_t getEndPosInDataBlock(STsdbReadHandle* pTsdbReadHandle, SDataBlockInfo* pBlockInfo); -static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t capacity, int32_t numOfRows, int32_t start, int32_t end); -static void moveDataToFront(STsdbReadHandle* pTsdbReadHandle, int32_t numOfRows, int32_t numOfCols); -static void doCheckGeneratedBlockRange(STsdbReadHandle* pTsdbReadHandle); -static void copyAllRemainRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, SDataBlockInfo* pBlockInfo, int32_t endPos); - -static int32_t handleDataMergeIfNeeded(STsdbReadHandle* pTsdbReadHandle, SBlock* pBlock, STableCheckInfo* pCheckInfo){ +static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t capacity, int32_t numOfRows, + int32_t start, int32_t end); +static void moveDataToFront(STsdbReadHandle* pTsdbReadHandle, int32_t numOfRows, int32_t numOfCols); +static void doCheckGeneratedBlockRange(STsdbReadHandle* pTsdbReadHandle); +static void copyAllRemainRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, + SDataBlockInfo* pBlockInfo, int32_t endPos); + +static int32_t handleDataMergeIfNeeded(STsdbReadHandle* pTsdbReadHandle, SBlock* pBlock, STableCheckInfo* pCheckInfo) { SQueryFilePos* cur = &pTsdbReadHandle->cur; STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config; SDataBlockInfo binfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock); TSKEY key; - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; /*bool hasData = */ initTableMemIterator(pTsdbReadHandle, pCheckInfo); assert(cur->pos >= 0 && cur->pos <= binfo.rows); @@ -1180,22 +1192,22 @@ static int32_t handleDataMergeIfNeeded(STsdbReadHandle* pTsdbReadHandle, SBlock* key = extractFirstTraverseKey(pCheckInfo, pTsdbReadHandle->order, pCfg->update); if (key != TSKEY_INITIAL_VAL) { - tsdbDebug("%p key in mem:%"PRId64", %s", pTsdbReadHandle, key, pTsdbReadHandle->idStr); + tsdbDebug("%p key in mem:%" PRId64 ", %s", pTsdbReadHandle, key, pTsdbReadHandle->idStr); } else { tsdbDebug("%p no data in mem, %s", pTsdbReadHandle, pTsdbReadHandle->idStr); } if ((ASCENDING_TRAVERSE(pTsdbReadHandle->order) && (key != TSKEY_INITIAL_VAL && key <= binfo.window.ekey)) || (!ASCENDING_TRAVERSE(pTsdbReadHandle->order) && (key != TSKEY_INITIAL_VAL && key >= binfo.window.skey))) { - if ((ASCENDING_TRAVERSE(pTsdbReadHandle->order) && (key != TSKEY_INITIAL_VAL && key < binfo.window.skey)) || (!ASCENDING_TRAVERSE(pTsdbReadHandle->order) && (key != TSKEY_INITIAL_VAL && key > binfo.window.ekey))) { - // do not load file block into buffer int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? 1 : -1; - TSKEY maxKey = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? (binfo.window.skey - step):(binfo.window.ekey - step); - cur->rows = tsdbReadRowsFromCache(pCheckInfo, maxKey, pTsdbReadHandle->outputCapacity, &cur->win, pTsdbReadHandle); + TSKEY maxKey = + ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? (binfo.window.skey - step) : (binfo.window.ekey - step); + cur->rows = + tsdbReadRowsFromCache(pCheckInfo, maxKey, pTsdbReadHandle->outputCapacity, &cur->win, pTsdbReadHandle); pTsdbReadHandle->realNumOfRows = cur->rows; // update the last key value @@ -1209,7 +1221,6 @@ static int32_t handleDataMergeIfNeeded(STsdbReadHandle* pTsdbReadHandle, SBlock* return code; } - // return error, add test cases if ((code = doLoadFileDataBlock(pTsdbReadHandle, pBlock, pCheckInfo, cur->slot)) != TSDB_CODE_SUCCESS) { return code; @@ -1226,12 +1237,12 @@ static int32_t handleDataMergeIfNeeded(STsdbReadHandle* pTsdbReadHandle, SBlock* assert(pTsdbReadHandle->outputCapacity >= binfo.rows); int32_t endPos = getEndPosInDataBlock(pTsdbReadHandle, &binfo); - if ((cur->pos == 0 && endPos == binfo.rows -1 && ASCENDING_TRAVERSE(pTsdbReadHandle->order)) || + if ((cur->pos == 0 && endPos == binfo.rows - 1 && ASCENDING_TRAVERSE(pTsdbReadHandle->order)) || (cur->pos == (binfo.rows - 1) && endPos == 0 && (!ASCENDING_TRAVERSE(pTsdbReadHandle->order)))) { pTsdbReadHandle->realNumOfRows = binfo.rows; cur->rows = binfo.rows; - cur->win = binfo.window; + cur->win = binfo.window; cur->mixBlock = false; cur->blockCompleted = true; @@ -1242,29 +1253,31 @@ static int32_t handleDataMergeIfNeeded(STsdbReadHandle* pTsdbReadHandle, SBlock* cur->lastKey = binfo.window.skey - 1; cur->pos = -1; } - } else { // partially copy to dest buffer + } else { // partially copy to dest buffer copyAllRemainRowsFromFileBlock(pTsdbReadHandle, pCheckInfo, &binfo, endPos); cur->mixBlock = true; } assert(cur->blockCompleted); if (cur->rows == binfo.rows) { - tsdbDebug("%p whole file block qualified, brange:%"PRId64"-%"PRId64", rows:%d, lastKey:%"PRId64", %s", + tsdbDebug("%p whole file block qualified, brange:%" PRId64 "-%" PRId64 ", rows:%d, lastKey:%" PRId64 ", %s", pTsdbReadHandle, cur->win.skey, cur->win.ekey, cur->rows, cur->lastKey, pTsdbReadHandle->idStr); } else { - tsdbDebug("%p create data block from remain file block, brange:%"PRId64"-%"PRId64", rows:%d, total:%d, lastKey:%"PRId64", %s", - pTsdbReadHandle, cur->win.skey, cur->win.ekey, cur->rows, binfo.rows, cur->lastKey, pTsdbReadHandle->idStr); + tsdbDebug("%p create data block from remain file block, brange:%" PRId64 "-%" PRId64 + ", rows:%d, total:%d, lastKey:%" PRId64 ", %s", + pTsdbReadHandle, cur->win.skey, cur->win.ekey, cur->rows, binfo.rows, cur->lastKey, + pTsdbReadHandle->idStr); } - } return code; } -static int32_t loadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBlock, STableCheckInfo* pCheckInfo, bool* exists) { +static int32_t loadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBlock, STableCheckInfo* pCheckInfo, + bool* exists) { SQueryFilePos* cur = &pTsdbReadHandle->cur; - int32_t code = TSDB_CODE_SUCCESS; - bool asc = ASCENDING_TRAVERSE(pTsdbReadHandle->order); + int32_t code = TSDB_CODE_SUCCESS; + bool asc = ASCENDING_TRAVERSE(pTsdbReadHandle->order); if (asc) { // query ended in/started from current block @@ -1287,10 +1300,10 @@ static int32_t loadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBloc assert(pCheckInfo->lastKey <= pBlock->keyLast); doMergeTwoLevelData(pTsdbReadHandle, pCheckInfo, pBlock); } else { // the whole block is loaded in to buffer - cur->pos = asc? 0:(pBlock->numOfRows - 1); + cur->pos = asc ? 0 : (pBlock->numOfRows - 1); code = handleDataMergeIfNeeded(pTsdbReadHandle, pBlock, pCheckInfo); } - } else { //desc order, query ended in current block + } else { // desc order, query ended in current block if (pTsdbReadHandle->window.ekey > pBlock->keyFirst || pCheckInfo->lastKey < pBlock->keyLast) { if ((code = doLoadFileDataBlock(pTsdbReadHandle, pBlock, pCheckInfo, cur->slot)) != TSDB_CODE_SUCCESS) { *exists = false; @@ -1299,7 +1312,8 @@ static int32_t loadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBloc SDataCols* pTsCol = pTsdbReadHandle->rhelper.pDCols[0]; if (pCheckInfo->lastKey < pBlock->keyLast) { - cur->pos = binarySearchForKey(pTsCol->cols[0].pData, pBlock->numOfRows, pCheckInfo->lastKey, pTsdbReadHandle->order); + cur->pos = + binarySearchForKey(pTsCol->cols[0].pData, pBlock->numOfRows, pCheckInfo->lastKey, pTsdbReadHandle->order); } else { cur->pos = pBlock->numOfRows - 1; } @@ -1307,7 +1321,7 @@ static int32_t loadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBloc assert(pCheckInfo->lastKey >= pBlock->keyFirst); doMergeTwoLevelData(pTsdbReadHandle, pCheckInfo, pBlock); } else { - cur->pos = asc? 0:(pBlock->numOfRows-1); + cur->pos = asc ? 0 : (pBlock->numOfRows - 1); code = handleDataMergeIfNeeded(pTsdbReadHandle, pBlock, pCheckInfo); } } @@ -1378,11 +1392,12 @@ static int doBinarySearchKey(char* pValue, int num, TSKEY key, int order) { return midPos; } -static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t capacity, int32_t numOfRows, int32_t start, int32_t end) { - int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? 1 : -1; +static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t capacity, int32_t numOfRows, + int32_t start, int32_t end) { + int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? 1 : -1; SDataCols* pCols = pTsdbReadHandle->rhelper.pDCols[0]; - TSKEY* tsArray = pCols->cols[0].pData; + TSKEY* tsArray = pCols->cols[0].pData; int32_t num = end - start + 1; assert(num >= 0); @@ -1393,9 +1408,9 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t int32_t requiredNumOfCols = (int32_t)taosArrayGetSize(pTsdbReadHandle->pColumns); - //data in buffer has greater timestamp, copy data in file block + // data in buffer has greater timestamp, copy data in file block int32_t i = 0, j = 0; - while(i < requiredNumOfCols && j < pCols->numOfCols) { + while (i < requiredNumOfCols && j < pCols->numOfCols) { SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, i); SDataCol* src = &pCols->cols[j]; @@ -1406,15 +1421,15 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t if (!isAllRowsNull(src) && pColInfo->info.colId == src->colId) { if (!IS_VAR_DATA_TYPE(pColInfo->info.type)) { // todo opt performance -// memmove(pData, (char*)src->pData + bytes * start, bytes * num); - for(int32_t k = start; k < num + start; ++k) { + // memmove(pData, (char*)src->pData + bytes * start, bytes * num); + for (int32_t k = start; k < num + start; ++k) { SCellVal sVal = {0}; if (tdGetColDataOfRow(&sVal, src, k, pCols->bitmapMode) < 0) { TASSERT(0); } if (sVal.valType == TD_VTYPE_NULL) { - colDataAppend(pColInfo, k, NULL, true); + colDataAppendNULL(pColInfo, k); } else { colDataAppend(pColInfo, k, sVal.val, false); } @@ -1423,28 +1438,32 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t // todo refactor, only copy one-by-one for (int32_t k = start; k < num + start; ++k) { SCellVal sVal = {0}; - if(tdGetColDataOfRow(&sVal, src, k, pCols->bitmapMode) < 0){ + if (tdGetColDataOfRow(&sVal, src, k, pCols->bitmapMode) < 0) { TASSERT(0); } - colDataAppend(pColInfo, k, sVal.val, false); + if (sVal.valType == TD_VTYPE_NULL) { + colDataAppendNULL(pColInfo, k); + } else { + colDataAppend(pColInfo, k, sVal.val, false); + } } } j++; i++; - } else { // pColInfo->info.colId < src->colId, it is a NULL data - for(int32_t k = start; k < num + start; ++k) { // TODO opt performance + } else { // pColInfo->info.colId < src->colId, it is a NULL data + for (int32_t k = start; k < num + start; ++k) { // TODO opt performance colDataAppend(pColInfo, k, NULL, true); } i++; } } - while (i < requiredNumOfCols) { // the remain columns are all null data + while (i < requiredNumOfCols) { // the remain columns are all null data SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, i); - for(int32_t k = start; k < num + start; ++k) { - colDataAppend(pColInfo, k, NULL, true); // TODO add a fast version to set a number of consecutive NULL value. + for (int32_t k = start; k < num + start; ++k) { + colDataAppend(pColInfo, k, NULL, true); // TODO add a fast version to set a number of consecutive NULL value. } i++; } @@ -1461,15 +1480,15 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit STSRow* row2, int32_t numOfCols, uint64_t uid, STSchema* pSchema1, STSchema* pSchema2, bool forceSetNull) { #if 1 - STSchema* pSchema; - STSRow* row; - int16_t colId; - int16_t offset; - - bool isRow1DataRow = TD_IS_TP_ROW(row1); - bool isRow2DataRow; - bool isChosenRowDataRow; - int32_t chosen_itr; + STSchema* pSchema; + STSRow* row; + int16_t colId; + int16_t offset; + + bool isRow1DataRow = TD_IS_TP_ROW(row1); + bool isRow2DataRow; + bool isChosenRowDataRow; + int32_t chosen_itr; SCellVal sVal = {0}; // the schema version info is embeded in STSRow @@ -1479,19 +1498,19 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit pSchema1 = metaGetTbTSchema(pTsdbReadHandle->pTsdb->pMeta, uid, TD_ROW_SVER(row1)); } - if(isRow1DataRow) { + if (isRow1DataRow) { numOfColsOfRow1 = schemaNCols(pSchema1); } else { numOfColsOfRow1 = tdRowGetNCols(row1); } int32_t numOfColsOfRow2 = 0; - if(row2) { + if (row2) { isRow2DataRow = TD_IS_TP_ROW(row2); if (pSchema2 == NULL) { pSchema2 = metaGetTbTSchema(pTsdbReadHandle->pTsdb->pMeta, uid, TD_ROW_SVER(row2)); } - if(isRow2DataRow) { + if (isRow2DataRow) { numOfColsOfRow2 = schemaNCols(pSchema2); } else { numOfColsOfRow2 = tdRowGetNCols(row2); @@ -1499,31 +1518,31 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit } int32_t i = 0, j = 0, k = 0; - while(i < numOfCols && (j < numOfColsOfRow1 || k < numOfColsOfRow2)) { + while (i < numOfCols && (j < numOfColsOfRow1 || k < numOfColsOfRow2)) { SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, i); int32_t colIdOfRow1; - if(j >= numOfColsOfRow1) { + if (j >= numOfColsOfRow1) { colIdOfRow1 = INT32_MAX; - } else if(isRow1DataRow) { + } else if (isRow1DataRow) { colIdOfRow1 = pSchema1->columns[j].colId; } else { - SKvRowIdx *pColIdx = tdKvRowColIdxAt(row1, j); + SKvRowIdx* pColIdx = tdKvRowColIdxAt(row1, j); colIdOfRow1 = pColIdx->colId; } int32_t colIdOfRow2; - if(k >= numOfColsOfRow2) { + if (k >= numOfColsOfRow2) { colIdOfRow2 = INT32_MAX; - } else if(isRow2DataRow) { + } else if (isRow2DataRow) { colIdOfRow2 = pSchema2->columns[k].colId; } else { - SKvRowIdx *pColIdx = tdKvRowColIdxAt(row2, k); + SKvRowIdx* pColIdx = tdKvRowColIdxAt(row2, k); colIdOfRow2 = pColIdx->colId; } - if(colIdOfRow1 == colIdOfRow2) { - if(colIdOfRow1 < pColInfo->info.colId) { + if (colIdOfRow1 == colIdOfRow2) { + if (colIdOfRow1 < pColInfo->info.colId) { j++; k++; continue; @@ -1532,8 +1551,8 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit pSchema = pSchema1; isChosenRowDataRow = isRow1DataRow; chosen_itr = j; - } else if(colIdOfRow1 < colIdOfRow2) { - if(colIdOfRow1 < pColInfo->info.colId) { + } else if (colIdOfRow1 < colIdOfRow2) { + if (colIdOfRow1 < pColInfo->info.colId) { j++; continue; } @@ -1542,7 +1561,7 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit isChosenRowDataRow = isRow1DataRow; chosen_itr = j; } else { - if(colIdOfRow2 < pColInfo->info.colId) { + if (colIdOfRow2 < pColInfo->info.colId) { k++; continue; } @@ -1551,12 +1570,12 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit chosen_itr = k; isChosenRowDataRow = isRow2DataRow; } - if(isChosenRowDataRow) { + if (isChosenRowDataRow) { colId = pSchema->columns[chosen_itr].colId; offset = pSchema->columns[chosen_itr].offset; tdSTpRowGetVal(row, colId, pSchema->columns[chosen_itr].type, pSchema->flen, offset, chosen_itr, &sVal); } else { - SKvRowIdx *pColIdx = tdKvRowColIdxAt(row, chosen_itr); + SKvRowIdx* pColIdx = tdKvRowColIdxAt(row, chosen_itr); colId = pColIdx->colId; offset = pColIdx->offset; tdSKvRowGetVal(row, colId, offset, chosen_itr, &sVal); @@ -1571,21 +1590,21 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit i++; - if(row == row1) { + if (row == row1) { j++; } else { k++; } } else { - if(forceSetNull) { + if (forceSetNull) { colDataAppend(pColInfo, numOfRows, NULL, true); } i++; } } - if(forceSetNull) { - while (i < numOfCols) { // the remain columns are all null data + if (forceSetNull) { + while (i < numOfCols) { // the remain columns are all null data SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, i); colDataAppend(pColInfo, numOfRows, NULL, true); i++; @@ -1602,15 +1621,16 @@ static void moveDataToFront(STsdbReadHandle* pTsdbReadHandle, int32_t numOfRows, // if the buffer is not full in case of descending order query, move the data in the front of the buffer if (numOfRows < pTsdbReadHandle->outputCapacity) { int32_t emptySize = pTsdbReadHandle->outputCapacity - numOfRows; - for(int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, i); - memmove((char*)pColInfo->pData, (char*)pColInfo->pData + emptySize * pColInfo->info.bytes, numOfRows * pColInfo->info.bytes); + memmove((char*)pColInfo->pData, (char*)pColInfo->pData + emptySize * pColInfo->info.bytes, + numOfRows * pColInfo->info.bytes); } } } -static void getQualifiedRowsPos(STsdbReadHandle* pTsdbReadHandle, int32_t startPos, int32_t endPos, int32_t numOfExisted, - int32_t* start, int32_t* end) { +static void getQualifiedRowsPos(STsdbReadHandle* pTsdbReadHandle, int32_t startPos, int32_t endPos, + int32_t numOfExisted, int32_t* start, int32_t* end) { *start = -1; if (ASCENDING_TRAVERSE(pTsdbReadHandle->order)) { @@ -1635,7 +1655,8 @@ static void getQualifiedRowsPos(STsdbReadHandle* pTsdbReadHandle, int32_t startP } } -static void updateInfoAfterMerge(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, int32_t numOfRows, int32_t endPos) { +static void updateInfoAfterMerge(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, int32_t numOfRows, + int32_t endPos) { SQueryFilePos* cur = &pTsdbReadHandle->cur; pCheckInfo->lastKey = cur->lastKey; @@ -1655,22 +1676,24 @@ static void doCheckGeneratedBlockRange(STsdbReadHandle* pTsdbReadHandle) { } SColumnInfoData* pColInfoData = taosArrayGet(pTsdbReadHandle->pColumns, 0); - assert(cur->win.skey == ((TSKEY*)pColInfoData->pData)[0] && cur->win.ekey == ((TSKEY*)pColInfoData->pData)[cur->rows-1]); + assert(cur->win.skey == ((TSKEY*)pColInfoData->pData)[0] && + cur->win.ekey == ((TSKEY*)pColInfoData->pData)[cur->rows - 1]); } else { cur->win = pTsdbReadHandle->window; - int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? 1:-1; + int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? 1 : -1; cur->lastKey = pTsdbReadHandle->window.ekey + step; } } -static void copyAllRemainRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, SDataBlockInfo* pBlockInfo, int32_t endPos) { +static void copyAllRemainRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, + SDataBlockInfo* pBlockInfo, int32_t endPos) { SQueryFilePos* cur = &pTsdbReadHandle->cur; SDataCols* pCols = pTsdbReadHandle->rhelper.pDCols[0]; - TSKEY* tsArray = pCols->cols[0].pData; + TSKEY* tsArray = pCols->cols[0].pData; - int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? 1:-1; + int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? 1 : -1; int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pTsdbReadHandle)); int32_t pos = cur->pos; @@ -1686,7 +1709,7 @@ static void copyAllRemainRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, STa int32_t numOfRows = doCopyRowsFromFileBlock(pTsdbReadHandle, pTsdbReadHandle->outputCapacity, 0, start, end); // the time window should always be ascending order: skey <= ekey - cur->win = (STimeWindow) {.skey = tsArray[start], .ekey = tsArray[end]}; + cur->win = (STimeWindow){.skey = tsArray[start], .ekey = tsArray[end]}; cur->mixBlock = (numOfRows != pBlockInfo->rows); cur->lastKey = tsArray[endPos] + step; cur->blockCompleted = true; @@ -1699,17 +1722,18 @@ static void copyAllRemainRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, STa updateInfoAfterMerge(pTsdbReadHandle, pCheckInfo, numOfRows, pos); doCheckGeneratedBlockRange(pTsdbReadHandle); - tsdbDebug("%p uid:%" PRIu64", data block created, mixblock:%d, brange:%"PRIu64"-%"PRIu64" rows:%d, %s", - pTsdbReadHandle, pCheckInfo->tableId, cur->mixBlock, cur->win.skey, cur->win.ekey, cur->rows, pTsdbReadHandle->idStr); + tsdbDebug("%p uid:%" PRIu64 ", data block created, mixblock:%d, brange:%" PRIu64 "-%" PRIu64 " rows:%d, %s", + pTsdbReadHandle, pCheckInfo->tableId, cur->mixBlock, cur->win.skey, cur->win.ekey, cur->rows, + pTsdbReadHandle->idStr); } int32_t getEndPosInDataBlock(STsdbReadHandle* pTsdbReadHandle, SDataBlockInfo* pBlockInfo) { // NOTE: reverse the order to find the end position in data block int32_t endPos = -1; - int32_t order = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? TSDB_ORDER_DESC : TSDB_ORDER_ASC; + int32_t order = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC; SQueryFilePos* cur = &pTsdbReadHandle->cur; - SDataCols* pCols = pTsdbReadHandle->rhelper.pDCols[0]; + SDataCols* pCols = pTsdbReadHandle->rhelper.pDCols[0]; if (ASCENDING_TRAVERSE(pTsdbReadHandle->order) && pTsdbReadHandle->window.ekey >= pBlockInfo->window.ekey) { endPos = pBlockInfo->rows - 1; @@ -1730,37 +1754,39 @@ int32_t getEndPosInDataBlock(STsdbReadHandle* pTsdbReadHandle, SDataBlockInfo* p // be included in the query time window will be discarded static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, SBlock* pBlock) { SQueryFilePos* cur = &pTsdbReadHandle->cur; - SDataBlockInfo blockInfo = {0};//GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock); + SDataBlockInfo blockInfo = {0}; // GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock); STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config; initTableMemIterator(pTsdbReadHandle, pCheckInfo); SDataCols* pCols = pTsdbReadHandle->rhelper.pDCols[0]; assert(pCols->cols[0].type == TSDB_DATA_TYPE_TIMESTAMP && pCols->cols[0].colId == PRIMARYKEY_TIMESTAMP_COL_ID && - cur->pos >= 0 && cur->pos < pBlock->numOfRows); + cur->pos >= 0 && cur->pos < pBlock->numOfRows); TSKEY* tsArray = pCols->cols[0].pData; - assert(pCols->numOfRows == pBlock->numOfRows && tsArray[0] == pBlock->keyFirst && tsArray[pBlock->numOfRows-1] == pBlock->keyLast); + assert(pCols->numOfRows == pBlock->numOfRows && tsArray[0] == pBlock->keyFirst && + tsArray[pBlock->numOfRows - 1] == pBlock->keyLast); // for search the endPos, so the order needs to reverse - int32_t order = (pTsdbReadHandle->order == TSDB_ORDER_ASC)? TSDB_ORDER_DESC:TSDB_ORDER_ASC; + int32_t order = (pTsdbReadHandle->order == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC; - int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? 1:-1; + int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? 1 : -1; int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pTsdbReadHandle)); STable* pTable = NULL; int32_t endPos = getEndPosInDataBlock(pTsdbReadHandle, &blockInfo); - tsdbDebug("%p uid:%" PRIu64" start merge data block, file block range:%"PRIu64"-%"PRIu64" rows:%d, start:%d," + tsdbDebug("%p uid:%" PRIu64 " start merge data block, file block range:%" PRIu64 "-%" PRIu64 + " rows:%d, start:%d," "end:%d, %s", - pTsdbReadHandle, pCheckInfo->tableId, blockInfo.window.skey, blockInfo.window.ekey, - blockInfo.rows, cur->pos, endPos, pTsdbReadHandle->idStr); + pTsdbReadHandle, pCheckInfo->tableId, blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, + cur->pos, endPos, pTsdbReadHandle->idStr); // compared with the data from in-memory buffer, to generate the correct timestamp array list int32_t numOfRows = 0; - int16_t rv1 = -1; - int16_t rv2 = -1; + int16_t rv1 = -1; + int16_t rv2 = -1; STSchema* pSchema1 = NULL; STSchema* pSchema2 = NULL; @@ -1786,49 +1812,53 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf break; } - if (((pos > endPos || tsArray[pos] > pTsdbReadHandle->window.ekey) && ASCENDING_TRAVERSE(pTsdbReadHandle->order)) || - ((pos < endPos || tsArray[pos] < pTsdbReadHandle->window.ekey) && !ASCENDING_TRAVERSE(pTsdbReadHandle->order))) { + if (((pos > endPos || tsArray[pos] > pTsdbReadHandle->window.ekey) && + ASCENDING_TRAVERSE(pTsdbReadHandle->order)) || + ((pos < endPos || tsArray[pos] < pTsdbReadHandle->window.ekey) && + !ASCENDING_TRAVERSE(pTsdbReadHandle->order))) { break; } if ((key < tsArray[pos] && ASCENDING_TRAVERSE(pTsdbReadHandle->order)) || (key > tsArray[pos] && !ASCENDING_TRAVERSE(pTsdbReadHandle->order))) { if (rv1 != TD_ROW_SVER(row1)) { -// pSchema1 = tsdbGetTableSchemaByVersion(pTable, memRowVersion(row1)); + // pSchema1 = tsdbGetTableSchemaByVersion(pTable, memRowVersion(row1)); rv1 = TD_ROW_SVER(row1); } - if(row2 && rv2 != TD_ROW_SVER(row2)) { -// pSchema2 = tsdbGetTableSchemaByVersion(pTable, memRowVersion(row2)); + if (row2 && rv2 != TD_ROW_SVER(row2)) { + // pSchema2 = tsdbGetTableSchemaByVersion(pTable, memRowVersion(row2)); rv2 = TD_ROW_SVER(row2); } - - mergeTwoRowFromMem(pTsdbReadHandle, pTsdbReadHandle->outputCapacity, numOfRows, row1, row2, numOfCols, pCheckInfo->tableId, pSchema1, pSchema2, true); + + mergeTwoRowFromMem(pTsdbReadHandle, pTsdbReadHandle->outputCapacity, numOfRows, row1, row2, numOfCols, + pCheckInfo->tableId, pSchema1, pSchema2, true); numOfRows += 1; if (cur->win.skey == TSKEY_INITIAL_VAL) { cur->win.skey = key; } cur->win.ekey = key; - cur->lastKey = key + step; + cur->lastKey = key + step; cur->mixBlock = true; moveToNextRowInMem(pCheckInfo); } else if (key == tsArray[pos]) { // data in buffer has the same timestamp of data in file block, ignore it if (pCfg->update) { - if(pCfg->update == TD_ROW_PARTIAL_UPDATE) { + if (pCfg->update == TD_ROW_PARTIAL_UPDATE) { doCopyRowsFromFileBlock(pTsdbReadHandle, pTsdbReadHandle->outputCapacity, numOfRows, pos, pos); } if (rv1 != TD_ROW_SVER(row1)) { -// pSchema1 = tsdbGetTableSchemaByVersion(pTable, memRowVersion(row1)); + // pSchema1 = tsdbGetTableSchemaByVersion(pTable, memRowVersion(row1)); rv1 = TD_ROW_SVER(row1); } - if(row2 && rv2 != TD_ROW_SVER(row2)) { -// pSchema2 = tsdbGetTableSchemaByVersion(pTable, memRowVersion(row2)); + if (row2 && rv2 != TD_ROW_SVER(row2)) { + // pSchema2 = tsdbGetTableSchemaByVersion(pTable, memRowVersion(row2)); rv2 = TD_ROW_SVER(row2); } - + bool forceSetNull = pCfg->update != TD_ROW_PARTIAL_UPDATE; - mergeTwoRowFromMem(pTsdbReadHandle, pTsdbReadHandle->outputCapacity, numOfRows, row1, row2, numOfCols, pCheckInfo->tableId, pSchema1, pSchema2, forceSetNull); + mergeTwoRowFromMem(pTsdbReadHandle, pTsdbReadHandle->outputCapacity, numOfRows, row1, row2, numOfCols, + pCheckInfo->tableId, pSchema1, pSchema2, forceSetNull); numOfRows += 1; if (cur->win.skey == TSKEY_INITIAL_VAL) { cur->win.skey = key; @@ -1844,7 +1874,7 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf moveToNextRowInMem(pCheckInfo); } } else if ((key > tsArray[pos] && ASCENDING_TRAVERSE(pTsdbReadHandle->order)) || - (key < tsArray[pos] && !ASCENDING_TRAVERSE(pTsdbReadHandle->order))) { + (key < tsArray[pos] && !ASCENDING_TRAVERSE(pTsdbReadHandle->order))) { if (cur->win.skey == TSKEY_INITIAL_VAL) { cur->win.skey = tsArray[pos]; } @@ -1852,7 +1882,7 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf int32_t end = doBinarySearchKey(pCols->cols[0].pData, pCols->numOfRows, key, order); assert(end != -1); - if (tsArray[end] == key) { // the value of key in cache equals to the end timestamp value, ignore it + if (tsArray[end] == key) { // the value of key in cache equals to the end timestamp value, ignore it if (pCfg->update == TD_ROW_DISCARD_UPDATE) { moveToNextRowInMem(pCheckInfo); } else { @@ -1866,8 +1896,8 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf numOfRows = doCopyRowsFromFileBlock(pTsdbReadHandle, pTsdbReadHandle->outputCapacity, numOfRows, qstart, qend); pos += (qend - qstart + 1) * step; - cur->win.ekey = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? tsArray[qend]:tsArray[qstart]; - cur->lastKey = cur->win.ekey + step; + cur->win.ekey = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? tsArray[qend] : tsArray[qstart]; + cur->lastKey = cur->win.ekey + step; } } while (numOfRows < pTsdbReadHandle->outputCapacity); @@ -1892,8 +1922,8 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf numOfRows = doCopyRowsFromFileBlock(pTsdbReadHandle, pTsdbReadHandle->outputCapacity, numOfRows, start, end); pos += (end - start + 1) * step; - cur->win.ekey = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? tsArray[end]:tsArray[start]; - cur->lastKey = cur->win.ekey + step; + cur->win.ekey = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? tsArray[end] : tsArray[start]; + cur->lastKey = cur->win.ekey + step; cur->mixBlock = true; } } @@ -1911,8 +1941,9 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf updateInfoAfterMerge(pTsdbReadHandle, pCheckInfo, numOfRows, pos); doCheckGeneratedBlockRange(pTsdbReadHandle); - tsdbDebug("%p uid:%" PRIu64", data block created, mixblock:%d, brange:%"PRIu64"-%"PRIu64" rows:%d, %s", - pTsdbReadHandle, pCheckInfo->tableId, cur->mixBlock, cur->win.skey, cur->win.ekey, cur->rows, pTsdbReadHandle->idStr); + tsdbDebug("%p uid:%" PRIu64 ", data block created, mixblock:%d, brange:%" PRIu64 "-%" PRIu64 " rows:%d, %s", + pTsdbReadHandle, pCheckInfo->tableId, cur->mixBlock, cur->win.skey, cur->win.ekey, cur->rows, + pTsdbReadHandle->idStr); } int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order) { @@ -2008,7 +2039,7 @@ static int32_t dataBlockOrderCompar(const void* pLeft, const void* pRight, void* STableBlockInfo* pRightBlockInfoEx = &pSupporter->pDataBlockInfo[rightTableIndex][rightTableBlockIndex]; // assert(pLeftBlockInfoEx->compBlock->offset != pRightBlockInfoEx->compBlock->offset); -#if 0 // TODO: temporarily comment off requested by Dr. Liao +#if 0 // TODO: temporarily comment off requested by Dr. Liao if (pLeftBlockInfoEx->compBlock->offset == pRightBlockInfoEx->compBlock->offset && pLeftBlockInfoEx->compBlock->last == pRightBlockInfoEx->compBlock->last) { tsdbError("error in header file, two block with same offset:%" PRId64, (int64_t)pLeftBlockInfoEx->compBlock->offset); @@ -2028,7 +2059,7 @@ static int32_t createDataBlocksInfo(STsdbReadHandle* pTsdbReadHandle, int32_t nu return TSDB_CODE_TDB_OUT_OF_MEMORY; } - pTsdbReadHandle->pDataBlockInfo = (STableBlockInfo*) tmp; + pTsdbReadHandle->pDataBlockInfo = (STableBlockInfo*)tmp; } memset(pTsdbReadHandle->pDataBlockInfo, 0, size); @@ -2087,18 +2118,18 @@ static int32_t createDataBlocksInfo(STsdbReadHandle* pTsdbReadHandle, int32_t nu cleanBlockOrderSupporter(&sup, numOfQualTables); tsdbDebug("%p create data blocks info struct completed for 1 table, %d blocks not sorted %s", pTsdbReadHandle, cnt, - pTsdbReadHandle->idStr); + pTsdbReadHandle->idStr); return TSDB_CODE_SUCCESS; } tsdbDebug("%p create data blocks info struct completed, %d blocks in %d tables %s", pTsdbReadHandle, cnt, - numOfQualTables, pTsdbReadHandle->idStr); + numOfQualTables, pTsdbReadHandle->idStr); assert(cnt <= numOfBlocks && numOfQualTables <= numOfTables); // the pTableQueryInfo[j]->numOfBlocks may be 0 sup.numOfTables = numOfQualTables; SMultiwayMergeTreeInfo* pTree = NULL; - uint8_t ret = tMergeTreeCreate(&pTree, sup.numOfTables, &sup, dataBlockOrderCompar); + uint8_t ret = tMergeTreeCreate(&pTree, sup.numOfTables, &sup, dataBlockOrderCompar); if (ret != TSDB_CODE_SUCCESS) { cleanBlockOrderSupporter(&sup, numOfTables); return TSDB_CODE_TDB_OUT_OF_MEMORY; @@ -2137,11 +2168,11 @@ static int32_t createDataBlocksInfo(STsdbReadHandle* pTsdbReadHandle, int32_t nu static int32_t getFirstFileDataBlock(STsdbReadHandle* pTsdbReadHandle, bool* exists); -static int32_t getDataBlockRv(STsdbReadHandle* pTsdbReadHandle, STableBlockInfo* pNext, bool *exists) { - int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? 1 : -1; +static int32_t getDataBlockRv(STsdbReadHandle* pTsdbReadHandle, STableBlockInfo* pNext, bool* exists) { + int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? 1 : -1; SQueryFilePos* cur = &pTsdbReadHandle->cur; - while(1) { + while (1) { int32_t code = loadFileDataBlock(pTsdbReadHandle, pNext->compBlock, pNext->pTableCheckInfo, exists); if (code != TSDB_CODE_SUCCESS || *exists) { return code; @@ -2169,7 +2200,7 @@ static int32_t getFirstFileDataBlock(STsdbReadHandle* pTsdbReadHandle, bool* exi int32_t numOfBlocks = 0; int32_t numOfTables = (int32_t)taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo); - STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config; + STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config; STimeWindow win = TSWINDOW_INITIALIZER; while (true) { @@ -2219,7 +2250,8 @@ static int32_t getFirstFileDataBlock(STsdbReadHandle* pTsdbReadHandle, bool* exi } // todo return error code to query engine - if ((code = createDataBlocksInfo(pTsdbReadHandle, numOfBlocks, &pTsdbReadHandle->numOfBlocks)) != TSDB_CODE_SUCCESS) { + if ((code = createDataBlocksInfo(pTsdbReadHandle, numOfBlocks, &pTsdbReadHandle->numOfBlocks)) != + TSDB_CODE_SUCCESS) { break; } @@ -2241,7 +2273,7 @@ static int32_t getFirstFileDataBlock(STsdbReadHandle* pTsdbReadHandle, bool* exi } assert(pTsdbReadHandle->pFileGroup != NULL && pTsdbReadHandle->numOfBlocks > 0); - cur->slot = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? 0:pTsdbReadHandle->numOfBlocks-1; + cur->slot = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? 0 : pTsdbReadHandle->numOfBlocks - 1; cur->fid = pTsdbReadHandle->pFileGroup->fid; STableBlockInfo* pBlockInfo = &pTsdbReadHandle->pDataBlockInfo[cur->slot]; @@ -2254,18 +2286,18 @@ static bool isEndFileDataBlock(SQueryFilePos* cur, int32_t numOfBlocks, bool asc } static void moveToNextDataBlockInCurrentFile(STsdbReadHandle* pTsdbReadHandle) { - int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? 1 : -1; + int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? 1 : -1; SQueryFilePos* cur = &pTsdbReadHandle->cur; assert(cur->slot < pTsdbReadHandle->numOfBlocks && cur->slot >= 0); cur->slot += step; - cur->mixBlock = false; + cur->mixBlock = false; cur->blockCompleted = false; } int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo* pTableBlockInfo) { - STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*) queryHandle; + STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)queryHandle; pTableBlockInfo->totalSize = 0; pTableBlockInfo->totalRows = 0; @@ -2287,7 +2319,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo* int32_t code = TSDB_CODE_SUCCESS; int32_t numOfBlocks = 0; int32_t numOfTables = (int32_t)taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo); - int defaultRows = 4096;//TSDB_DEFAULT_BLOCK_ROWS(pCfg->maxRowsPerFileBlock); + int defaultRows = 4096; // TSDB_DEFAULT_BLOCK_ROWS(pCfg->maxRowsPerFileBlock); STimeWindow win = TSWINDOW_INITIALIZER; bool ascTraverse = ASCENDING_TRAVERSE(pTsdbReadHandle->order); @@ -2304,7 +2336,8 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo* tsdbGetFidKeyRange(pCfg->daysPerFile, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey); // current file are not overlapped with query time window, ignore remain files - if ((ascTraverse && win.skey > pTsdbReadHandle->window.ekey) || (!ascTraverse && win.ekey < pTsdbReadHandle->window.ekey)) { + if ((ascTraverse && win.skey > pTsdbReadHandle->window.ekey) || + (!ascTraverse && win.ekey < pTsdbReadHandle->window.ekey)) { tsdbUnLockFS(REPO_FS(pTsdbReadHandle->pTsdb)); tsdbDebug("%p remain files are not qualified for qrange:%" PRId64 "-%" PRId64 ", ignore, %s", pTsdbReadHandle, pTsdbReadHandle->window.skey, pTsdbReadHandle->window.ekey, pTsdbReadHandle->idStr); @@ -2357,9 +2390,9 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo* if (numOfRows < defaultRows) { pTableBlockInfo->numOfSmallBlocks += 1; } -// int32_t stepIndex = (numOfRows-1)/TSDB_BLOCK_DIST_STEP_ROWS; -// SFileBlockInfo *blockInfo = (SFileBlockInfo*)taosArrayGet(pTableBlockInfo->dataBlockInfos, stepIndex); -// blockInfo->numBlocksOfStep++; + // int32_t stepIndex = (numOfRows-1)/TSDB_BLOCK_DIST_STEP_ROWS; + // SFileBlockInfo *blockInfo = (SFileBlockInfo*)taosArrayGet(pTableBlockInfo->dataBlockInfos, stepIndex); + // blockInfo->numBlocksOfStep++; } } } @@ -2416,7 +2449,7 @@ static int32_t getDataBlocksInFiles(STsdbReadHandle* pTsdbReadHandle, bool* exis static bool doHasDataInBuffer(STsdbReadHandle* pTsdbReadHandle) { size_t numOfTables = taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo); - + while (pTsdbReadHandle->activeIndex < numOfTables) { if (hasMoreDataInCache(pTsdbReadHandle)) { return true; @@ -2428,23 +2461,23 @@ static bool doHasDataInBuffer(STsdbReadHandle* pTsdbReadHandle) { return false; } -//todo not unref yet, since it is not support multi-group interpolation query +// todo not unref yet, since it is not support multi-group interpolation query static UNUSED_FUNC void changeQueryHandleForInterpQuery(tsdbReaderT pHandle) { // filter the queried time stamp in the first place - STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*) pHandle; + STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)pHandle; // starts from the buffer in case of descending timestamp order check data blocks size_t numOfTables = taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo); int32_t i = 0; - while(i < numOfTables) { + while (i < numOfTables) { STableCheckInfo* pCheckInfo = taosArrayGet(pTsdbReadHandle->pTableCheckInfo, i); // the first qualified table for interpolation query -// if ((pTsdbReadHandle->window.skey <= pCheckInfo->pTableObj->lastKey) && -// (pCheckInfo->pTableObj->lastKey != TSKEY_INITIAL_VAL)) { -// break; -// } + // if ((pTsdbReadHandle->window.skey <= pCheckInfo->pTableObj->lastKey) && + // (pCheckInfo->pTableObj->lastKey != TSKEY_INITIAL_VAL)) { + // break; + // } i++; } @@ -2454,7 +2487,7 @@ static UNUSED_FUNC void changeQueryHandleForInterpQuery(tsdbReaderT pHandle) { return; } - STableCheckInfo info = *(STableCheckInfo*) taosArrayGet(pTsdbReadHandle->pTableCheckInfo, i); + STableCheckInfo info = *(STableCheckInfo*)taosArrayGet(pTsdbReadHandle->pTableCheckInfo, i); taosArrayClear(pTsdbReadHandle->pTableCheckInfo); info.lastKey = pTsdbReadHandle->window.skey; @@ -2463,13 +2496,13 @@ static UNUSED_FUNC void changeQueryHandleForInterpQuery(tsdbReaderT pHandle) { static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int maxRowsToRead, STimeWindow* win, STsdbReadHandle* pTsdbReadHandle) { - int numOfRows = 0; - int32_t numOfCols = (int32_t)taosArrayGetSize(pTsdbReadHandle->pColumns); + int numOfRows = 0; + int32_t numOfCols = (int32_t)taosArrayGetSize(pTsdbReadHandle->pColumns); STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config; win->skey = TSKEY_INITIAL_VAL; - int64_t st = taosGetTimestampUs(); - int16_t rv = -1; + int64_t st = taosGetTimestampUs(); + int16_t rv = -1; STSchema* pSchema = NULL; do { @@ -2479,9 +2512,10 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int } TSKEY key = TD_ROW_KEY(row); - if ((key > maxKey && ASCENDING_TRAVERSE(pTsdbReadHandle->order)) || (key < maxKey && !ASCENDING_TRAVERSE(pTsdbReadHandle->order))) { - tsdbDebug("%p key:%"PRIu64" beyond qrange:%"PRId64" - %"PRId64", no more data in buffer", pTsdbReadHandle, key, pTsdbReadHandle->window.skey, - pTsdbReadHandle->window.ekey); + if ((key > maxKey && ASCENDING_TRAVERSE(pTsdbReadHandle->order)) || + (key < maxKey && !ASCENDING_TRAVERSE(pTsdbReadHandle->order))) { + tsdbDebug("%p key:%" PRIu64 " beyond qrange:%" PRId64 " - %" PRId64 ", no more data in buffer", pTsdbReadHandle, + key, pTsdbReadHandle->window.skey, pTsdbReadHandle->window.ekey); break; } @@ -2495,14 +2529,15 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int pSchema = metaGetTbTSchema(pTsdbReadHandle->pTsdb->pMeta, pCheckInfo->tableId, 0); rv = TD_ROW_SVER(row); } - mergeTwoRowFromMem(pTsdbReadHandle, maxRowsToRead, numOfRows, row, NULL, numOfCols, pCheckInfo->tableId, pSchema, NULL, true); + mergeTwoRowFromMem(pTsdbReadHandle, maxRowsToRead, numOfRows, row, NULL, numOfCols, pCheckInfo->tableId, pSchema, + NULL, true); if (++numOfRows >= maxRowsToRead) { moveToNextRowInMem(pCheckInfo); break; } - } while(moveToNextRowInMem(pCheckInfo)); + } while (moveToNextRowInMem(pCheckInfo)); assert(numOfRows <= maxRowsToRead); @@ -2510,15 +2545,16 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int if (!ASCENDING_TRAVERSE(pTsdbReadHandle->order) && numOfRows < maxRowsToRead) { int32_t emptySize = maxRowsToRead - numOfRows; - for(int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, i); - memmove((char*)pColInfo->pData, (char*)pColInfo->pData + emptySize * pColInfo->info.bytes, numOfRows * pColInfo->info.bytes); + memmove((char*)pColInfo->pData, (char*)pColInfo->pData + emptySize * pColInfo->info.bytes, + numOfRows * pColInfo->info.bytes); } } int64_t elapsedTime = taosGetTimestampUs() - st; - tsdbDebug("%p build data block from cache completed, elapsed time:%"PRId64" us, numOfRows:%d, numOfCols:%d, %s", pTsdbReadHandle, - elapsedTime, numOfRows, numOfCols, pTsdbReadHandle->idStr); + tsdbDebug("%p build data block from cache completed, elapsed time:%" PRId64 " us, numOfRows:%d, numOfCols:%d, %s", + pTsdbReadHandle, elapsedTime, numOfRows, numOfCols, pTsdbReadHandle->idStr); return numOfRows; } @@ -2545,20 +2581,20 @@ static void destroyHelper(void* param) { return; } -// tQueryInfo* pInfo = (tQueryInfo*)param; -// if (pInfo->optr != TSDB_RELATION_IN) { -// taosMemoryFreeClear(pInfo->q); -// } else { -// taosHashCleanup((SHashObj *)(pInfo->q)); -// } + // tQueryInfo* pInfo = (tQueryInfo*)param; + // if (pInfo->optr != TSDB_RELATION_IN) { + // taosMemoryFreeClear(pInfo->q); + // } else { + // taosHashCleanup((SHashObj *)(pInfo->q)); + // } taosMemoryFree(param); } -#define TSDB_PREV_ROW 0x1 -#define TSDB_NEXT_ROW 0x2 +#define TSDB_PREV_ROW 0x1 +#define TSDB_NEXT_ROW 0x2 -static bool loadBlockOfActiveTable(STsdbReadHandle* pTsdbReadHandle) { +static bool loadBlockOfActiveTable(STsdbReadHandle* pTsdbReadHandle) { if (pTsdbReadHandle->checkFiles) { // check if the query range overlaps with the file data block bool exists = true; @@ -2570,13 +2606,13 @@ static bool loadBlockOfActiveTable(STsdbReadHandle* pTsdbReadHandle) { } if (exists) { - tsdbRetrieveDataBlock((tsdbReaderT*) pTsdbReadHandle, NULL); + tsdbRetrieveDataBlock((tsdbReaderT*)pTsdbReadHandle, NULL); if (pTsdbReadHandle->currentLoadExternalRows && pTsdbReadHandle->window.skey == pTsdbReadHandle->window.ekey) { SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, 0); assert(*(int64_t*)pColInfo->pData == pTsdbReadHandle->window.skey); } - pTsdbReadHandle->currentLoadExternalRows = false; // clear the flag, since the exact matched row is found. + pTsdbReadHandle->currentLoadExternalRows = false; // clear the flag, since the exact matched row is found. return exists; } @@ -2589,16 +2625,17 @@ static bool loadBlockOfActiveTable(STsdbReadHandle* pTsdbReadHandle) { } // current result is empty - if (pTsdbReadHandle->currentLoadExternalRows && pTsdbReadHandle->window.skey == pTsdbReadHandle->window.ekey && pTsdbReadHandle->cur.rows == 0) { -// STsdbMemTable* pMemRef = pTsdbReadHandle->pMemTable; + if (pTsdbReadHandle->currentLoadExternalRows && pTsdbReadHandle->window.skey == pTsdbReadHandle->window.ekey && + pTsdbReadHandle->cur.rows == 0) { + // STsdbMemTable* pMemRef = pTsdbReadHandle->pMemTable; -// doGetExternalRow(pTsdbReadHandle, TSDB_PREV_ROW, pMemRef); -// doGetExternalRow(pTsdbReadHandle, TSDB_NEXT_ROW, pMemRef); + // doGetExternalRow(pTsdbReadHandle, TSDB_PREV_ROW, pMemRef); + // doGetExternalRow(pTsdbReadHandle, TSDB_NEXT_ROW, pMemRef); bool result = tsdbGetExternalRow(pTsdbReadHandle); -// pTsdbReadHandle->prev = doFreeColumnInfoData(pTsdbReadHandle->prev); -// pTsdbReadHandle->next = doFreeColumnInfoData(pTsdbReadHandle->next); + // pTsdbReadHandle->prev = doFreeColumnInfoData(pTsdbReadHandle->prev); + // pTsdbReadHandle->next = doFreeColumnInfoData(pTsdbReadHandle->next); pTsdbReadHandle->currentLoadExternalRows = false; return result; @@ -2610,30 +2647,31 @@ static bool loadBlockOfActiveTable(STsdbReadHandle* pTsdbReadHandle) { static bool loadCachedLastRow(STsdbReadHandle* pTsdbReadHandle) { // the last row is cached in buffer, return it directly. // here note that the pTsdbReadHandle->window must be the TS_INITIALIZER - int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pTsdbReadHandle)); + int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pTsdbReadHandle)); size_t numOfTables = taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo); assert(numOfTables > 0 && numOfCols > 0); SQueryFilePos* cur = &pTsdbReadHandle->cur; - STSRow* pRow = NULL; - TSKEY key = TSKEY_INITIAL_VAL; - int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order)? 1:-1; + STSRow* pRow = NULL; + TSKEY key = TSKEY_INITIAL_VAL; + int32_t step = ASCENDING_TRAVERSE(pTsdbReadHandle->order) ? 1 : -1; if (++pTsdbReadHandle->activeIndex < numOfTables) { STableCheckInfo* pCheckInfo = taosArrayGet(pTsdbReadHandle->pTableCheckInfo, pTsdbReadHandle->activeIndex); -// int32_t ret = tsdbGetCachedLastRow(pCheckInfo->pTableObj, &pRow, &key); -// if (ret != TSDB_CODE_SUCCESS) { -// return false; -// } - mergeTwoRowFromMem(pTsdbReadHandle, pTsdbReadHandle->outputCapacity, 0, pRow, NULL, numOfCols, pCheckInfo->tableId, NULL, NULL, true); + // int32_t ret = tsdbGetCachedLastRow(pCheckInfo->pTableObj, &pRow, &key); + // if (ret != TSDB_CODE_SUCCESS) { + // return false; + // } + mergeTwoRowFromMem(pTsdbReadHandle, pTsdbReadHandle->outputCapacity, 0, pRow, NULL, numOfCols, pCheckInfo->tableId, + NULL, NULL, true); taosMemoryFreeClear(pRow); // update the last key value pCheckInfo->lastKey = key + step; - cur->rows = 1; // only one row - cur->lastKey = key + step; + cur->rows = 1; // only one row + cur->lastKey = key + step; cur->mixBlock = true; cur->win.skey = key; cur->win.ekey = key; @@ -2644,9 +2682,7 @@ static bool loadCachedLastRow(STsdbReadHandle* pTsdbReadHandle) { return false; } - - -//static bool loadCachedLast(STsdbReadHandle* pTsdbReadHandle) { +// static bool loadCachedLast(STsdbReadHandle* pTsdbReadHandle) { // // the last row is cached in buffer, return it directly. // // here note that the pTsdbReadHandle->window must be the TS_INITIALIZER // int32_t tgNumOfCols = (int32_t)QH_GET_NUM_OF_COLS(pTsdbReadHandle); @@ -2666,8 +2702,8 @@ static bool loadCachedLastRow(STsdbReadHandle* pTsdbReadHandle) { // int32_t numOfCols = pTable->maxColNum; // // if (pTable->lastCols == NULL || pTable->maxColNum <= 0) { -// tsdbWarn("no last cached for table %s, uid:%" PRIu64 ",tid:%d", pTable->name->data, pTable->uid, pTable->tableId); -// continue; +// tsdbWarn("no last cached for table %s, uid:%" PRIu64 ",tid:%d", pTable->name->data, pTable->uid, +// pTable->tableId); continue; // } // // int32_t i = 0, j = 0; @@ -2802,7 +2838,7 @@ static bool loadDataBlockFromTableSeq(STsdbReadHandle* pTsdbReadHandle) { int64_t stime = taosGetTimestampUs(); - while(pTsdbReadHandle->activeIndex < numOfTables) { + while (pTsdbReadHandle->activeIndex < numOfTables) { if (loadBlockOfActiveTable(pTsdbReadHandle)) { return true; } @@ -2812,8 +2848,8 @@ static bool loadDataBlockFromTableSeq(STsdbReadHandle* pTsdbReadHandle) { pTsdbReadHandle->activeIndex += 1; pTsdbReadHandle->locateStart = false; - pTsdbReadHandle->checkFiles = true; - pTsdbReadHandle->cur.rows = 0; + pTsdbReadHandle->checkFiles = true; + pTsdbReadHandle->cur.rows = 0; pTsdbReadHandle->currentLoadExternalRows = pTsdbReadHandle->loadExternalRow; terrno = TSDB_CODE_SUCCESS; @@ -2827,15 +2863,16 @@ static bool loadDataBlockFromTableSeq(STsdbReadHandle* pTsdbReadHandle) { // handle data in cache situation bool tsdbNextDataBlock(tsdbReaderT pHandle) { - STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*) pHandle; + STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)pHandle; - for(int32_t i = 0; i < taosArrayGetSize(pTsdbReadHandle->pColumns); ++i) { + for (int32_t i = 0; i < taosArrayGetSize(pTsdbReadHandle->pColumns); ++i) { SColumnInfoData* pColInfo = taosArrayGet(pTsdbReadHandle->pColumns, i); colInfoDataCleanup(pColInfo, pTsdbReadHandle->outputCapacity); } if (emptyQueryTimewindow(pTsdbReadHandle)) { - tsdbDebug("%p query window not overlaps with the data set, no result returned, %s", pTsdbReadHandle, pTsdbReadHandle->idStr); + tsdbDebug("%p query window not overlaps with the data set, no result returned, %s", pTsdbReadHandle, + pTsdbReadHandle->idStr); return false; } @@ -2845,15 +2882,15 @@ bool tsdbNextDataBlock(tsdbReaderT pHandle) { // TODO refactor: remove "type" if (pTsdbReadHandle->type == TSDB_QUERY_TYPE_LAST) { if (pTsdbReadHandle->cachelastrow == TSDB_CACHED_TYPE_LASTROW) { -// return loadCachedLastRow(pTsdbReadHandle); + // return loadCachedLastRow(pTsdbReadHandle); } else if (pTsdbReadHandle->cachelastrow == TSDB_CACHED_TYPE_LAST) { -// return loadCachedLast(pTsdbReadHandle); + // return loadCachedLast(pTsdbReadHandle); } } if (pTsdbReadHandle->loadType == BLOCK_LOAD_TABLE_SEQ_ORDER) { return loadDataBlockFromTableSeq(pTsdbReadHandle); - } else { // loadType == RR and Offset Order + } else { // loadType == RR and Offset Order if (pTsdbReadHandle->checkFiles) { // check if the query range overlaps with the file data block bool exists = true; @@ -2885,7 +2922,7 @@ bool tsdbNextDataBlock(tsdbReaderT pHandle) { } } -//static int32_t doGetExternalRow(STsdbReadHandle* pTsdbReadHandle, int16_t type, STsdbMemTable* pMemRef) { +// static int32_t doGetExternalRow(STsdbReadHandle* pTsdbReadHandle, int16_t type, STsdbMemTable* pMemRef) { // STsdbReadHandle* pSecQueryHandle = NULL; // // if (type == TSDB_PREV_ROW && pTsdbReadHandle->prev) { @@ -2990,14 +3027,14 @@ bool tsdbNextDataBlock(tsdbReaderT pHandle) { // memcpy((char*)pCol->pData, (char*)s->pData + s->info.bytes * pos, pCol->info.bytes); // } // -//out_of_memory: +// out_of_memory: // tsdbCleanupReadHandle(pSecQueryHandle); // return terrno; //} bool tsdbGetExternalRow(tsdbReaderT pHandle) { - STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*) pHandle; - SQueryFilePos* cur = &pTsdbReadHandle->cur; + STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)pHandle; + SQueryFilePos* cur = &pTsdbReadHandle->cur; cur->fid = INT32_MIN; cur->mixBlock = true; @@ -3006,7 +3043,7 @@ bool tsdbGetExternalRow(tsdbReaderT pHandle) { return false; } - int32_t numOfCols = (int32_t) QH_GET_NUM_OF_COLS(pTsdbReadHandle); + int32_t numOfCols = (int32_t)QH_GET_NUM_OF_COLS(pTsdbReadHandle); for (int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData* pColInfoData = taosArrayGet(pTsdbReadHandle->pColumns, i); SColumnInfoData* first = taosArrayGet(pTsdbReadHandle->prev, i); @@ -3053,36 +3090,36 @@ bool tsdbGetExternalRow(tsdbReaderT pHandle) { //} bool isTsdbCacheLastRow(tsdbReaderT* pReader) { - return ((STsdbReadHandle *)pReader)->cachelastrow > TSDB_CACHED_TYPE_NONE; + return ((STsdbReadHandle*)pReader)->cachelastrow > TSDB_CACHED_TYPE_NONE; } -int32_t checkForCachedLastRow(STsdbReadHandle* pTsdbReadHandle, STableGroupInfo *groupList) { +int32_t checkForCachedLastRow(STsdbReadHandle* pTsdbReadHandle, STableGroupInfo* groupList) { assert(pTsdbReadHandle != NULL && groupList != NULL); -// TSKEY key = TSKEY_INITIAL_VAL; -// -// SArray* group = taosArrayGetP(groupList->pGroupList, 0); -// assert(group != NULL); -// -// STableKeyInfo* pInfo = (STableKeyInfo*)taosArrayGet(group, 0); -// -// int32_t code = 0; -// -// if (((STable*)pInfo->pTable)->lastRow) { -// code = tsdbGetCachedLastRow(pInfo->pTable, NULL, &key); -// if (code != TSDB_CODE_SUCCESS) { -// pTsdbReadHandle->cachelastrow = TSDB_CACHED_TYPE_NONE; -// } else { -// pTsdbReadHandle->cachelastrow = TSDB_CACHED_TYPE_LASTROW; -// } -// } -// -// // update the tsdb query time range -// if (pTsdbReadHandle->cachelastrow != TSDB_CACHED_TYPE_NONE) { -// pTsdbReadHandle->window = TSWINDOW_INITIALIZER; -// pTsdbReadHandle->checkFiles = false; -// pTsdbReadHandle->activeIndex = -1; // start from -1 -// } + // TSKEY key = TSKEY_INITIAL_VAL; + // + // SArray* group = taosArrayGetP(groupList->pGroupList, 0); + // assert(group != NULL); + // + // STableKeyInfo* pInfo = (STableKeyInfo*)taosArrayGet(group, 0); + // + // int32_t code = 0; + // + // if (((STable*)pInfo->pTable)->lastRow) { + // code = tsdbGetCachedLastRow(pInfo->pTable, NULL, &key); + // if (code != TSDB_CODE_SUCCESS) { + // pTsdbReadHandle->cachelastrow = TSDB_CACHED_TYPE_NONE; + // } else { + // pTsdbReadHandle->cachelastrow = TSDB_CACHED_TYPE_LASTROW; + // } + // } + // + // // update the tsdb query time range + // if (pTsdbReadHandle->cachelastrow != TSDB_CACHED_TYPE_NONE) { + // pTsdbReadHandle->window = TSWINDOW_INITIALIZER; + // pTsdbReadHandle->checkFiles = false; + // pTsdbReadHandle->activeIndex = -1; // start from -1 + // } return TSDB_CODE_SUCCESS; } @@ -3091,21 +3128,20 @@ int32_t checkForCachedLast(STsdbReadHandle* pTsdbReadHandle) { assert(pTsdbReadHandle != NULL); int32_t code = 0; -// if (pTsdbReadHandle->pTsdb && atomic_load_8(&pTsdbReadHandle->pTsdb->hasCachedLastColumn)){ -// pTsdbReadHandle->cachelastrow = TSDB_CACHED_TYPE_LAST; -// } + // if (pTsdbReadHandle->pTsdb && atomic_load_8(&pTsdbReadHandle->pTsdb->hasCachedLastColumn)){ + // pTsdbReadHandle->cachelastrow = TSDB_CACHED_TYPE_LAST; + // } // update the tsdb query time range if (pTsdbReadHandle->cachelastrow) { - pTsdbReadHandle->checkFiles = false; + pTsdbReadHandle->checkFiles = false; pTsdbReadHandle->activeIndex = -1; // start from -1 } return code; } - -STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) { +STimeWindow updateLastrowForEachGroup(STableGroupInfo* groupList) { STimeWindow window = {INT64_MAX, INT64_MIN}; int32_t totalNumOfTable = 0; @@ -3113,24 +3149,24 @@ STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) { // NOTE: starts from the buffer in case of descending timestamp order check data blocks size_t numOfGroups = taosArrayGetSize(groupList->pGroupList); - for(int32_t j = 0; j < numOfGroups; ++j) { + for (int32_t j = 0; j < numOfGroups; ++j) { SArray* pGroup = taosArrayGetP(groupList->pGroupList, j); TSKEY key = TSKEY_INITIAL_VAL; STableKeyInfo keyInfo = {0}; size_t numOfTables = taosArrayGetSize(pGroup); - for(int32_t i = 0; i < numOfTables; ++i) { - STableKeyInfo* pInfo = (STableKeyInfo*) taosArrayGet(pGroup, i); + for (int32_t i = 0; i < numOfTables; ++i) { + STableKeyInfo* pInfo = (STableKeyInfo*)taosArrayGet(pGroup, i); // if the lastKey equals to INT64_MIN, there is no data in this table - TSKEY lastKey = 0;//((STable*)(pInfo->pTable))->lastKey; + TSKEY lastKey = 0; //((STable*)(pInfo->pTable))->lastKey; if (key < lastKey) { key = lastKey; -// keyInfo.pTable = pInfo->pTable; + // keyInfo.pTable = pInfo->pTable; keyInfo.lastKey = key; - pInfo->lastKey = key; + pInfo->lastKey = key; if (key < window.skey) { window.skey = key; @@ -3143,18 +3179,18 @@ STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) { } // more than one table in each group, only one table left for each group -// if (keyInfo.pTable != NULL) { -// totalNumOfTable++; -// if (taosArrayGetSize(pGroup) == 1) { -// // do nothing -// } else { -// taosArrayClear(pGroup); -// taosArrayPush(pGroup, &keyInfo); -// } -// } else { // mark all the empty groups, and remove it later -// taosArrayDestroy(pGroup); -// taosArrayPush(emptyGroup, &j); -// } + // if (keyInfo.pTable != NULL) { + // totalNumOfTable++; + // if (taosArrayGetSize(pGroup) == 1) { + // // do nothing + // } else { + // taosArrayClear(pGroup); + // taosArrayPush(pGroup, &keyInfo); + // } + // } else { // mark all the empty groups, and remove it later + // taosArrayDestroy(pGroup); + // taosArrayPush(emptyGroup, &j); + // } } // window does not being updated, so set the original @@ -3163,7 +3199,7 @@ STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) { assert(totalNumOfTable == 0 && taosArrayGetSize(groupList->pGroupList) == numOfGroups); } - taosArrayRemoveBatch(groupList->pGroupList, TARRAY_GET_START(emptyGroup), (int32_t) taosArrayGetSize(emptyGroup)); + taosArrayRemoveBatch(groupList->pGroupList, TARRAY_GET_START(emptyGroup), (int32_t)taosArrayGetSize(emptyGroup)); taosArrayDestroy(emptyGroup); groupList->numOfTables = totalNumOfTable; @@ -3172,7 +3208,7 @@ STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) { void tsdbRetrieveDataBlockInfo(tsdbReaderT* pTsdbReadHandle, SDataBlockInfo* pDataBlockInfo) { STsdbReadHandle* pHandle = (STsdbReadHandle*)pTsdbReadHandle; - SQueryFilePos* cur = &pHandle->cur; + SQueryFilePos* cur = &pHandle->cur; uint64_t uid = 0; @@ -3185,11 +3221,12 @@ void tsdbRetrieveDataBlockInfo(tsdbReaderT* pTsdbReadHandle, SDataBlockInfo* pDa uid = pCheckInfo->tableId; } - tsdbDebug("data block generated, uid:%"PRIu64" numOfRows:%d, tsrange:%"PRId64" - %"PRId64" %s", uid, cur->rows, cur->win.skey, - cur->win.ekey, pHandle->idStr); + tsdbDebug("data block generated, uid:%" PRIu64 " numOfRows:%d, tsrange:%" PRId64 " - %" PRId64 " %s", uid, cur->rows, + cur->win.skey, cur->win.ekey, pHandle->idStr); -// pDataBlockInfo->uid = uid; // block Id may be over write by assigning uid fro this data block. Do NOT assign the table uid - pDataBlockInfo->rows = cur->rows; + // pDataBlockInfo->uid = uid; // block Id may be over write by assigning uid fro this data block. Do NOT assign + // the table uid + pDataBlockInfo->rows = cur->rows; pDataBlockInfo->window = cur->win; pDataBlockInfo->numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pHandle)); } @@ -3198,7 +3235,7 @@ void tsdbRetrieveDataBlockInfo(tsdbReaderT* pTsdbReadHandle, SDataBlockInfo* pDa * return null for mixed data block, if not a complete file data block, the statistics value will always return NULL */ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SDataStatis** pBlockStatis) { - STsdbReadHandle* pHandle = (STsdbReadHandle*) pTsdbReadHandle; + STsdbReadHandle* pHandle = (STsdbReadHandle*)pTsdbReadHandle; SQueryFilePos* c = &pHandle->cur; if (c->mixBlock) { @@ -3228,7 +3265,7 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SDataStati size_t numOfCols = QH_GET_NUM_OF_COLS(pHandle); memset(pHandle->statis, 0, numOfCols * sizeof(SDataStatis)); - for(int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < numOfCols; ++i) { pHandle->statis[i].colId = colIds[i]; } @@ -3242,9 +3279,9 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SDataStati pPrimaryColStatis->min = pBlockInfo->compBlock->keyFirst; pPrimaryColStatis->max = pBlockInfo->compBlock->keyLast; - //update the number of NULL data rows - for(int32_t i = 1; i < numOfCols; ++i) { - if (pHandle->statis[i].numOfNull == -1) { // set the column data are all NULL + // update the number of NULL data rows + for (int32_t i = 1; i < numOfCols; ++i) { + if (pHandle->statis[i].numOfNull == -1) { // set the column data are all NULL pHandle->statis[i].numOfNull = pBlockInfo->compBlock->numOfRows; } } @@ -3294,9 +3331,10 @@ SArray* tsdbRetrieveDataBlock(tsdbReaderT* pTsdbReadHandle, SArray* pIdList) { int32_t emptySize = pHandle->outputCapacity - numOfRows; int32_t reqNumOfCols = (int32_t)taosArrayGetSize(pHandle->pColumns); - for(int32_t i = 0; i < reqNumOfCols; ++i) { + for (int32_t i = 0; i < reqNumOfCols; ++i) { SColumnInfoData* pColInfo = taosArrayGet(pHandle->pColumns, i); - memmove((char*)pColInfo->pData, (char*)pColInfo->pData + emptySize * pColInfo->info.bytes, numOfRows * pColInfo->info.bytes); + memmove((char*)pColInfo->pData, (char*)pColInfo->pData + emptySize * pColInfo->info.bytes, + numOfRows * pColInfo->info.bytes); } } @@ -3352,7 +3390,7 @@ void filterPrepare(void* expr, void* param) { #endif -static int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) { +static int32_t tableGroupComparFn(const void* p1, const void* p2, const void* param) { #if 0 STableGroupSupporter* pTableGroupSupp = (STableGroupSupporter*) param; STable* pTable1 = ((STableKeyInfo*) p1)->uid; @@ -3449,7 +3487,8 @@ void createTableGroupImpl(SArray* pGroups, SArray* pTableList, size_t numOfTable taosArrayPush(pGroups, &g); } -SArray* createTableGroup(SArray* pTableList, SSchemaWrapper* pTagSchema, SColIndex* pCols, int32_t numOfOrderCols, TSKEY skey) { +SArray* createTableGroup(SArray* pTableList, SSchemaWrapper* pTagSchema, SColIndex* pCols, int32_t numOfOrderCols, + TSKEY skey) { assert(pTableList != NULL); SArray* pTableGroup = taosArrayInit(1, POINTER_BYTES); @@ -3459,7 +3498,7 @@ SArray* createTableGroup(SArray* pTableList, SSchemaWrapper* pTagSchema, SColInd return pTableGroup; } - if (numOfOrderCols == 0 || size == 1) { // no group by tags clause or only one table + if (numOfOrderCols == 0 || size == 1) { // no group by tags clause or only one table SArray* sa = taosArrayDup(pTableList); if (sa == NULL) { taosArrayDestroy(pTableGroup); @@ -3481,7 +3520,7 @@ SArray* createTableGroup(SArray* pTableList, SSchemaWrapper* pTagSchema, SColInd return pTableGroup; } -//static bool tableFilterFp(const void* pNode, void* param) { +// static bool tableFilterFp(const void* pNode, void* param) { // tQueryInfo* pInfo = (tQueryInfo*) param; // // STable* pTable = (STable*)(SL_GET_NODE_DATA((SSkipListNode*)pNode)); @@ -3566,15 +3605,16 @@ SArray* createTableGroup(SArray* pTableList, SSchemaWrapper* pTagSchema, SColInd // return true; //} -//static void getTableListfromSkipList(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp *param); +// static void getTableListfromSkipList(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp +// *param); -//static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) { -// // query according to the expression tree +// static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) { +// // // query according to the expression tree // SExprTraverseSupp supp = { -// .nodeFilterFn = (__result_filter_fn_t) tableFilterFp, +// .nodeFilterFn = (__result_filter_fn_t)tableFilterFp, // .setupInfoFn = filterPrepare, // .pExtInfo = pSTable->tagSchema, -// }; +// }; // // getTableListfromSkipList(pExpr, pSTable->pIndex, pRes, &supp); // tExprTreeDestroy(pExpr, destroyHelper); @@ -3586,19 +3626,20 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch SColIndex* pColIndex, int32_t numOfCols, uint64_t reqId, uint64_t taskId) { STbCfg* pTbCfg = metaGetTbInfoByUid(pMeta, uid); if (pTbCfg == NULL) { - tsdbError("%p failed to get stable, uid:%"PRIu64", TID:0x%"PRIx64" QID:0x%"PRIx64, pMeta, uid, taskId, reqId); + tsdbError("%p failed to get stable, uid:%" PRIu64 ", TID:0x%" PRIx64 " QID:0x%" PRIx64, pMeta, uid, taskId, reqId); terrno = TSDB_CODE_TDB_INVALID_TABLE_ID; goto _error; } if (pTbCfg->type != META_SUPER_TABLE) { - tsdbError("%p query normal tag not allowed, uid:%" PRIu64 ", TID:0x%"PRIx64" QID:0x%"PRIx64, pMeta, uid, taskId, reqId); - terrno = TSDB_CODE_OPS_NOT_SUPPORT; //basically, this error is caused by invalid sql issued by client + tsdbError("%p query normal tag not allowed, uid:%" PRIu64 ", TID:0x%" PRIx64 " QID:0x%" PRIx64, pMeta, uid, taskId, + reqId); + terrno = TSDB_CODE_OPS_NOT_SUPPORT; // basically, this error is caused by invalid sql issued by client goto _error; } - //NOTE: not add ref count for super table - SArray* res = taosArrayInit(8, sizeof(STableKeyInfo)); + // NOTE: not add ref count for super table + SArray* res = taosArrayInit(8, sizeof(STableKeyInfo)); SSchemaWrapper* pTagSchema = metaGetTableSchema(pMeta, uid, 0, true); // no tags and tbname condition, all child tables of this stable are involved @@ -3608,66 +3649,44 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch goto _error; } - pGroupInfo->numOfTables = (uint32_t) taosArrayGetSize(res); - pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey); + pGroupInfo->numOfTables = (uint32_t)taosArrayGetSize(res); + pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey); - tsdbDebug("%p no table name/tag condition, all tables qualified, numOfTables:%u, group:%zu, TID:0x%"PRIx64" QID:0x%"PRIx64, pMeta, - pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList), taskId, reqId); + tsdbDebug("%p no table name/tag condition, all tables qualified, numOfTables:%u, group:%zu, TID:0x%" PRIx64 + " QID:0x%" PRIx64, + pMeta, pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList), taskId, reqId); taosArrayDestroy(res); return ret; } int32_t ret = TSDB_CODE_SUCCESS; -// tExprNode* expr = NULL; -// -// TRY(TSDB_MAX_TAG_CONDITIONS) { -// expr = exprTreeFromTableName(tbnameCond); -// if (expr == NULL) { -// expr = exprTreeFromBinary(pTagCond, len); -// } else { -// CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, expr, NULL); -// tExprNode* tagExpr = exprTreeFromBinary(pTagCond, len); -// if (tagExpr != NULL) { -// CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, tagExpr, NULL); -// tExprNode* tbnameExpr = expr; -// expr = taosMemoryCalloc(1, sizeof(tExprNode)); -// if (expr == NULL) { -// THROW( TSDB_CODE_TDB_OUT_OF_MEMORY ); -// } -// expr->nodeType = TSQL_NODE_EXPR; -// expr->_node.optr = (uint8_t)tagNameRelType; -// expr->_node.pLeft = tagExpr; -// expr->_node.pRight = tbnameExpr; -// } -// } -// CLEANUP_EXECUTE(); -// -// } CATCH( code ) { -// CLEANUP_EXECUTE(); -// terrno = code; -// tsdbUnlockRepoMeta(tsdb); // unlock tsdb in any cases -// -// goto _error; -// // TODO: more error handling -// } END_TRY -// -// doQueryTableList(pTable, res, expr); -// pGroupInfo->numOfTables = (uint32_t)taosArrayGetSize(res); -// pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey); -// -// tsdbDebug("%p stable tid:%d, uid:%"PRIu64" query, numOfTables:%u, belong to %" PRIzu " groups", tsdb, pTable->tableId, -// pTable->uid, pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList)); -// -// taosArrayDestroy(res); -// -// if (tsdbUnlockRepoMeta(tsdb) < 0) goto _error; -// return ret; - _error: + SFilterInfo* filterInfo = NULL; + ret = filterInitFromNode((SNode*)pTagCond, &filterInfo, 0); + if (ret != TSDB_CODE_SUCCESS) { + terrno = ret; + return ret; + } + ret = tsdbQueryTableList(pMeta, res, filterInfo); + pGroupInfo->numOfTables = (uint32_t)taosArrayGetSize(res); + pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey); + + // tsdbDebug("%p stable tid:%d, uid:%" PRIu64 " query, numOfTables:%u, belong to %" PRIzu " groups", tsdb, + // pTable->tableId, pTable->uid, pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList)); + + taosArrayDestroy(res); + return ret; + +_error: return terrno; } +int32_t tsdbQueryTableList(void* pMeta, SArray* pRes, void* filterInfo) { + // impl later + + return TSDB_CODE_SUCCESS; +} int32_t tsdbGetOneTableGroup(void* pMeta, uint64_t uid, TSKEY startKey, STableGroupInfo* pGroupInfo) { STbCfg* pTbCfg = metaGetTbInfoByUid(pMeta, uid); if (pTbCfg == NULL) { @@ -3686,7 +3705,7 @@ int32_t tsdbGetOneTableGroup(void* pMeta, uint64_t uid, TSKEY startKey, STableGr taosArrayPush(pGroupInfo->pGroupList, &group); return TSDB_CODE_SUCCESS; - _error: +_error: return terrno; } @@ -3765,7 +3784,6 @@ static void* destroyTableCheckInfo(SArray* pTableCheckInfo) { return NULL; } - void tsdbCleanupReadHandle(tsdbReaderT queryHandle) { STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)queryHandle; if (pTsdbReadHandle == NULL) { @@ -3779,7 +3797,7 @@ void tsdbCleanupReadHandle(tsdbReaderT queryHandle) { taosMemoryFreeClear(pTsdbReadHandle->statis); if (!emptyQueryTimewindow(pTsdbReadHandle)) { -// tsdbMayUnTakeMemSnapshot(pTsdbReadHandle); + // tsdbMayUnTakeMemSnapshot(pTsdbReadHandle); } else { assert(pTsdbReadHandle->pTableCheckInfo == NULL); } @@ -3798,8 +3816,10 @@ void tsdbCleanupReadHandle(tsdbReaderT queryHandle) { SIOCostSummary* pCost = &pTsdbReadHandle->cost; - tsdbDebug("%p :io-cost summary: head-file read cnt:%"PRIu64", head-file time:%"PRIu64" us, statis-info:%"PRId64" us, datablock:%" PRId64" us, check data:%"PRId64" us, %s", - pTsdbReadHandle, pCost->headFileLoad, pCost->headFileLoadTime, pCost->statisInfoLoadTime, pCost->blockLoadTime, pCost->checkForNextTime, pTsdbReadHandle->idStr); + tsdbDebug("%p :io-cost summary: head-file read cnt:%" PRIu64 ", head-file time:%" PRIu64 " us, statis-info:%" PRId64 + " us, datablock:%" PRId64 " us, check data:%" PRId64 " us, %s", + pTsdbReadHandle, pCost->headFileLoad, pCost->headFileLoadTime, pCost->statisInfoLoadTime, + pCost->blockLoadTime, pCost->checkForNextTime, pTsdbReadHandle->idStr); taosMemoryFreeClear(pTsdbReadHandle); } @@ -4053,37 +4073,37 @@ static void queryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, S } // Apply the filter expression to each node in the skiplist to acquire the qualified nodes in skip list -void getTableListfromSkipList(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp *param) { - if (pExpr == NULL) { - return; - } - - tExprNode *pLeft = pExpr->_node.pLeft; - tExprNode *pRight = pExpr->_node.pRight; - - // column project - if (pLeft->nodeType != TSQL_NODE_EXPR && pRight->nodeType != TSQL_NODE_EXPR) { - assert(pLeft->nodeType == TSQL_NODE_COL && (pRight->nodeType == TSQL_NODE_VALUE || pRight->nodeType == TSQL_NODE_DUMMY)); - - param->setupInfoFn(pExpr, param->pExtInfo); - - tQueryInfo *pQueryInfo = pExpr->_node.info; - if (pQueryInfo->indexed && (pQueryInfo->optr != TSDB_RELATION_LIKE - && pQueryInfo->optr != TSDB_RELATION_MATCH && pQueryInfo->optr != TSDB_RELATION_NMATCH - && pQueryInfo->optr != TSDB_RELATION_IN)) { - queryIndexedColumn(pSkipList, pQueryInfo, result); - } else { - queryIndexlessColumn(pSkipList, pQueryInfo, result, param->nodeFilterFn); - } - - return; - } - - // The value of hasPK is always 0. - uint8_t weight = pLeft->_node.hasPK + pRight->_node.hasPK; - assert(weight == 0 && pSkipList != NULL && taosArrayGetSize(result) == 0); - - //apply the hierarchical filter expression to every node in skiplist to find the qualified nodes - applyFilterToSkipListNode(pSkipList, pExpr, result, param); -} +//void getTableListfromSkipList(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp *param) { +// if (pExpr == NULL) { +// return; +// } +// +// tExprNode *pLeft = pExpr->_node.pLeft; +// tExprNode *pRight = pExpr->_node.pRight; +// +// // column project +// if (pLeft->nodeType != TSQL_NODE_EXPR && pRight->nodeType != TSQL_NODE_EXPR) { +// assert(pLeft->nodeType == TSQL_NODE_COL && (pRight->nodeType == TSQL_NODE_VALUE || pRight->nodeType == TSQL_NODE_DUMMY)); +// +// param->setupInfoFn(pExpr, param->pExtInfo); +// +// tQueryInfo *pQueryInfo = pExpr->_node.info; +// if (pQueryInfo->indexed && (pQueryInfo->optr != TSDB_RELATION_LIKE +// && pQueryInfo->optr != TSDB_RELATION_MATCH && pQueryInfo->optr != TSDB_RELATION_NMATCH +// && pQueryInfo->optr != TSDB_RELATION_IN)) { +// queryIndexedColumn(pSkipList, pQueryInfo, result); +// } else { +// queryIndexlessColumn(pSkipList, pQueryInfo, result, param->nodeFilterFn); +// } +// +// return; +// } +// +// // The value of hasPK is always 0. +// uint8_t weight = pLeft->_node.hasPK + pRight->_node.hasPK; +// assert(weight == 0 && pSkipList != NULL && taosArrayGetSize(result) == 0); +// +// //apply the hierarchical filter expression to every node in skiplist to find the qualified nodes +// applyFilterToSkipListNode(pSkipList, pExpr, result, param); +//} #endif diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 9fee599a5d734440cc395df43799f20500ce0f37..37bc4b771fed9cd414884ac2b894b26b1dbd1ce6 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -411,7 +411,7 @@ typedef struct STableScanInfo { SResultRowInfo* pResultRowInfo; int32_t* rowCellInfoOffset; SExprInfo* pExpr; - SSDataBlock block; + SSDataBlock* pResBlock; SArray* pColMatchInfo; int32_t numOfOutput; int64_t elapsedTime; @@ -569,6 +569,9 @@ typedef struct SGroupbyOperatorInfo { int32_t groupKeyLen; // total group by column width SGroupResInfo groupResInfo; SAggSupporter aggSup; + SExprInfo* pScalarExprInfo; + int32_t numOfScalarExpr;// the number of scalar expression in group operator + SqlFunctionCtx*pScalarFuncCtx; } SGroupbyOperatorInfo; 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 initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, 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 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, @@ -685,12 +688,11 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI uint64_t* total, SArray* pColList); void doSetOperatorCompleted(SOperatorInfo* pOperator); void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock); -SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t capacity); -SSDataBlock* loadNextDataBlock(void* param); +SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset); SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo); 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, 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, const STableGroupInfo* pTableGroupInfo, 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, - SArray* pGroupColList, SNode* pCondition, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); +SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList, + SNode* pCondition, SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, 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); #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 finalizeQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index b86d75cc7b3bd82e5173b51966ebc678e70f3cae..0eac50782200c29bba13b19a75e7cb941118a18e 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -234,9 +234,8 @@ int32_t operatorDummyOpenFn(SOperatorInfo* pOperator) { void operatorDummyCloseFn(void* param, int32_t numOfCols) {} -static int32_t doCopyToSDataBlock(SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, - SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset); - +static int32_t doCopyToSDataBlock(SSDataBlock* pBlock, int32_t rowCapacity, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo, + int32_t orderType, int32_t* rowCellOffset); static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size); static void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, int64_t keyFirst, int64_t keyLast, STimeWindow* win); @@ -1068,9 +1067,9 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, pCtx[i].size = pBlock->info.rows; pCtx[i].currentStage = MAIN_SCAN; - SExprInfo expr = pOperator->pExpr[i]; - for (int32_t j = 0; j < expr.base.numOfParams; ++j) { - SFunctParam *pFuncParam = &expr.base.pParam[j]; + SExprInfo* pOneExpr = &pOperator->pExpr[i]; + for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) { + SFunctParam *pFuncParam = &pOneExpr->base.pParam[j]; if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) { int32_t slotId = pFuncParam->pCol->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, - int32_t numOfOutput, SArray* pPseudoList) { +void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx, int32_t numOfOutput, SArray* pPseudoList) { setPseudoOutputColInfo(pResult, pCtx, pPseudoList); pResult->info.groupId = pSrcBlock->info.groupId; 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 - SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, k); - colDataAssign(pColInfoData, pCtx[k].input.pData[0], pCtx[k].input.numOfRows); + SColumnInfoData* pColInfoData = taosArrayGet(pResult->pDataBlock, outputSlotId); + colDataAssign(pColInfoData, pfCtx->input.pData[0], pfCtx->input.numOfRows); pResult->info.rows = pSrcBlock->info.rows; } 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) { 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); SScalarParam dest = {0}; - dest.columnData = taosArrayGet(pResult->pDataBlock, k); + dest.columnData = taosArrayGet(pResult->pDataBlock, outputSlotId); scalarCalculate(pExpr[k].pExpr->_optrRoot.pRootNode, pBlockList, &dest); pResult->info.rows = dest.numOfRows; taosArrayDestroy(pBlockList); } 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 - } else if (fmIsNonstandardSQLFunc(pCtx[k].functionId)) { + } else if (fmIsNonstandardSQLFunc(pfCtx->functionId)) { // 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]); - pCtx[k].fpSet.init(&pCtx[k], pResInfo); + pfCtx->fpSet.init(&pCtx[k], pResInfo); - pCtx[k].pOutput = taosArrayGet(pResult->pDataBlock, k); - pCtx[k].offset = pResult->info.rows; // set the start offset + pfCtx->pOutput = taosArrayGet(pResult->pDataBlock, outputSlotId); + pfCtx->offset = pResult->info.rows; // set the start offset if (taosArrayGetSize(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; } else { SArray* pBlockList = taosArrayInit(4, POINTER_BYTES); taosArrayPush(pBlockList, &pSrcBlock); SScalarParam dest = {0}; - dest.columnData = taosArrayGet(pResult->pDataBlock, k); + dest.columnData = taosArrayGet(pResult->pDataBlock, outputSlotId); scalarCalculate((SNode*)pExpr[k].pExpr->_function.pFunctNode, pBlockList, &dest); pResult->info.rows = dest.numOfRows; @@ -1810,7 +1811,7 @@ static int32_t setCtxTagColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutput) { 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)); if (pFuncCtx == 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.pColumnDataAgg = taosMemoryCalloc(pFunct->numOfParams, POINTER_BYTES); - pCtx->pTsOutput = NULL;//taosArrayInit(4, POINTER_BYTES); + pCtx->pTsOutput = NULL; pCtx->resDataInfo.bytes = pFunct->resSchema.bytes; pCtx->resDataInfo.type = pFunct->resSchema.type; pCtx->order = TSDB_ORDER_ASC; - pCtx->start.key = INT64_MIN; - pCtx->end.key = INT64_MIN; + pCtx->start.key = INT64_MIN; + pCtx->end.key = INT64_MIN; #if 0 for (int32_t j = 0; j < pCtx->numOfParams; ++j) { // int16_t type = pFunct->param[j].nType; @@ -3330,8 +3331,7 @@ void setIntervalQueryRange(STaskRuntimeEnv* pRuntimeEnv, TSKEY key) { * @param pQInfo * @param result */ -static int32_t doCopyToSDataBlock(SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, - SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset) { +int32_t doCopyToSDataBlock(SSDataBlock* pBlock, int32_t rowCapacity, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, int32_t* rowCellOffset) { int32_t numOfRows = getNumOfTotalRes(pGroupResInfo); 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; 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); char* in = GET_ROWCELL_INTERBUF(pEntryInfo); @@ -3391,8 +3393,8 @@ static int32_t doCopyToSDataBlock(SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResI return 0; } -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) { assert(pGroupResInfo->currentGroup <= pGroupResInfo->totalGroup); blockDataCleanup(pBlock); @@ -3401,7 +3403,7 @@ void toSDatablock(SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf, SSDataBlock } 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 blockDataUpdateTsWindow(pBlock); @@ -4438,32 +4440,6 @@ _error: 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 void cleanupAggSup(SAggSupporter* pAggSup); @@ -4777,7 +4753,7 @@ static int32_t initGroupCol(SExprInfo* pExprInfo, int32_t numOfCols, SArray* pGr SColumn* pCol = taosArrayGet(pGroupInfo, i); for (int32_t j = 0; j < numOfCols; ++j) { SExprInfo* pe = &pExprInfo[j]; - if (pe->base.resSchema.colId == pCol->colId) { + if (pe->base.resSchema.slotId == pCol->colId) { taosArrayPush(plist, pCol); taosArrayPush(pInfo->groupInfo, &j); len += pCol->bytes; @@ -4816,7 +4792,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t 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); if (pInfo->binfo.pCtx == NULL || pInfo->binfo.pRes == NULL) { @@ -5137,9 +5113,7 @@ static SSDataBlock* doMultiTableAggregate(SOperatorInfo* pOperator, bool* newgro SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; if (pOperator->status == OP_RES_TO_RETURN) { - toSDatablock(&pAggInfo->groupResInfo, pAggInfo->pResultBuf, pInfo->pRes, pAggInfo->binfo.capacity, - pAggInfo->binfo.rowCellInfoOffset); - + toSDatablock(pInfo->pRes, pAggInfo->binfo.capacity, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->pResultBuf, pAggInfo->binfo.rowCellInfoOffset); if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) { 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); initGroupResInfo(&pAggInfo->groupResInfo, &pInfo->resultRowInfo); - toSDatablock(&pAggInfo->groupResInfo, pAggInfo->pResultBuf, pInfo->pRes, pAggInfo->binfo.capacity, - pAggInfo->binfo.rowCellInfoOffset); + toSDatablock(pInfo->pRes, pAggInfo->binfo.capacity, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->pResultBuf, pAggInfo->binfo.rowCellInfoOffset); if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); @@ -5204,6 +5177,7 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup) SSDataBlock* pRes = pInfo->pRes; blockDataCleanup(pRes); + #if 0 if (pProjectInfo->existDataBlock) { // TODO refactor SSDataBlock* pBlock = pProjectInfo->existDataBlock; @@ -5392,8 +5366,7 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator, bool* newgro } blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity); - toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity, - pInfo->binfo.rowCellInfoOffset); + toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset); if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); @@ -5411,8 +5384,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup } if (pOperator->status == OP_RES_TO_RETURN) { - toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity, - pInfo->binfo.rowCellInfoOffset); + toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset); if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) { pOperator->status = OP_EXEC_DONE; } @@ -5447,8 +5419,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity); - toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity, - pInfo->binfo.rowCellInfoOffset); + toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset); ASSERT(pInfo->binfo.pRes->info.rows > 0); pOperator->status = OP_RES_TO_RETURN; @@ -5693,7 +5664,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator, bool* newgroup) { SOptrBasicInfo* pBInfo = &pInfo->binfo; 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)) { doSetOperatorCompleted(pOperator); return NULL; @@ -5725,7 +5696,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator, bool* newgroup) { initGroupResInfo(&pInfo->groupResInfo, &pBInfo->resultRowInfo); 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)) { doSetOperatorCompleted(pOperator); } @@ -5742,7 +5713,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator, bool* newgroup) SOptrBasicInfo* pBInfo = &pInfo->binfo; 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)) { doSetOperatorCompleted(pOperator); return NULL; @@ -5774,7 +5745,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator, bool* newgroup) initGroupResInfo(&pInfo->groupResInfo, &pBInfo->resultRowInfo); 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)) { 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 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->capacity = numOfRows; @@ -6382,8 +6353,6 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim SExprInfo* pExpr, int32_t numOfOutput) { 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); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); @@ -6406,8 +6375,6 @@ SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRun SExprInfo* pExpr, int32_t numOfOutput) { 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); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); @@ -6682,45 +6649,13 @@ bool validateExprColumnInfo(SQueriedTableInfo* pTableInfo, SExprBasicInfo* pExpr 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, const char* name) { SResSchema s = {0}; - s.scale = scale; - s.type = type; - s.bytes = bytes; - s.colId = slotId; + s.scale = scale; + s.type = type; + s.bytes = bytes; + s.slotId = slotId; s.precision = precision; 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); } - SExprInfo* pExp = &pExprs[pTargetNode->slotId]; + SExprInfo* pExp = &pExprs[i]; pExp->pExpr = taosMemoryCalloc(1, sizeof(tExprNode)); pExp->pExpr->_function.num = 1; @@ -6882,8 +6817,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo int32_t numOfCols = 0; tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId); SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); + SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc); + 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) { SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode; 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); SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SExprInfo* pScalarExprInfo = NULL; + int32_t numOfScalarExpr = 0; if (pAggNode->pGroupKeys != NULL) { 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 { return createAggregateOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo); } @@ -7187,10 +7130,15 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod } *numOfOutputCols = 0; - int32_t num = LIST_LENGTH(pOutputNodeList->pSlots); for (int32_t i = 0; i < num; ++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); if (pNode->output) { (*numOfOutputCols) += 1; diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 8a10170fcd848340087c564b127d073089459076..c8a6697d4e944c44923ba0a09f8f995a266eeeef 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -265,7 +265,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou SSDataBlock* pRes = pInfo->binfo.pRes; 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)) { 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 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); doHashGroupbyAgg(pOperator, pBlock); } @@ -305,7 +311,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou initGroupResInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo); 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); bool hasRemain = hasRemainDataInCurrentGroup(&pInfo->groupResInfo); @@ -322,16 +328,21 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou return (pRes->info.rows == 0)? NULL:pRes; } -SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList, SNode* pCondition, SExecTaskInfo* pTaskInfo, - const STableGroupInfo* pTableGroupInfo) { +SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList, + SNode* pCondition, SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) { SGroupbyOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SGroupbyOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { goto _error; } - pInfo->pGroupCols = pGroupColList; - pInfo->pCondition = pCondition; + pInfo->pGroupCols = pGroupColList; + 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); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 4179999c4b9f892fc6806f045cd513d2b6594211..f1502df7437b57dc72091611ed661cb49653ba1a 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -113,7 +113,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) { STableScanInfo* pTableScanInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SSDataBlock* pBlock = &pTableScanInfo->block; + SSDataBlock* pBlock = pTableScanInfo->pResBlock; STableGroupInfo* pTableGroupInfo = &pOperator->pTaskInfo->tableqinfoGroupInfo; *newgroup = false; @@ -218,7 +218,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) { } 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) { assert(repeatTime > 0); @@ -232,12 +232,7 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, return NULL; } - pInfo->block.pDataBlock = taosArrayInit(numOfOutput, sizeof(SColumnInfoData)); - for (int32_t i = 0; i < numOfOutput; ++i) { - SColumnInfoData idata = {0}; - taosArrayPush(pInfo->block.pDataBlock, &idata); - } - + pInfo->pResBlock = pResBlock; pInfo->pFilterNode = pCondition; pInfo->dataReader = pTsdbReadHandle; pInfo->times = repeatTime; @@ -312,7 +307,7 @@ static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator, bool* newgroup) { tsdbGetFileBlocksDistInfo(pTableScanInfo->dataReader, &tableBlockDist); tableBlockDist.numOfRowsInMemTable = (int32_t) tsdbGetNumOfRowsInMemTable(pTableScanInfo->dataReader); - SSDataBlock* pBlock = &pTableScanInfo->block; + SSDataBlock* pBlock = pTableScanInfo->pResBlock; pBlock->info.rows = 1; pBlock->info.numOfCols = 1; @@ -343,13 +338,13 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* } pInfo->dataReader = dataReader; - pInfo->block.pDataBlock = taosArrayInit(1, sizeof(SColumnInfoData)); +// pInfo->block.pDataBlock = taosArrayInit(1, sizeof(SColumnInfoData)); SColumnInfoData infoData = {0}; infoData.info.type = TSDB_DATA_TYPE_BINARY; infoData.info.bytes = 1024; infoData.info.colId = 0; - taosArrayPush(pInfo->block.pDataBlock, &infoData); +// taosArrayPush(pInfo->block.pDataBlock, &infoData); pOperator->name = "DataBlockInfoScanOperator"; // pOperator->operatorType = OP_TableBlockInfoScan; diff --git a/source/libs/function/inc/builtins.h b/source/libs/function/inc/builtins.h index f0349c55b9f722b8be2232a9bcb50a2215cecd31..624a2953c935997c5c35708a21dbe223c29db62a 100644 --- a/source/libs/function/inc/builtins.h +++ b/source/libs/function/inc/builtins.h @@ -22,7 +22,7 @@ extern "C" { #include "functionMgt.h" -#define FUNCTION_NAME_MAX_LENGTH 16 +#define FUNCTION_NAME_MAX_LENGTH 32 #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) typedef int32_t (*FCheckAndGetResultType)(SFunctionNode* pFunc); +typedef EFuncDataRequired (*FFuncDataRequired)(SFunctionNode* pFunc, STimeWindow* pTimeWindow); typedef struct SBuiltinFuncDefinition { char name[FUNCTION_NAME_MAX_LENGTH]; EFunctionType type; uint64_t classification; FCheckAndGetResultType checkFunc; + FFuncDataRequired dataRequiredFunc; FExecGetEnv getEnvFunc; FExecInit initFunc; FExecProcess processFunc; diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index 607bd279c15137550c5f3d738d463670b910e8fd..09c468b61037607a537a04385f88c189374370bb 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -21,10 +21,12 @@ extern "C" { #endif #include "function.h" +#include "functionMgt.h" bool functionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); void functionFinalize(SqlFunctionCtx *pCtx); +EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow); bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t countFunction(SqlFunctionCtx *pCtx); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index b4d886dcdf12525f2548757c16aae5fc96ae2bb5..36de0d11494945aa8ee8cb09d6872a0395b3021a 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -25,8 +25,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "count", .type = FUNCTION_TYPE_COUNT, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED, .checkFunc = checkAndGetResultType, + .dataRequiredFunc = countDataRequired, .getEnvFunc = getCountFuncEnv, .initFunc = functionSetup, .processFunc = countFunction, @@ -389,7 +390,37 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .checkFunc = checkAndGetResultType, .getEnvFunc = 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 }, { @@ -599,7 +630,25 @@ int32_t checkAndGetResultType(SFunctionNode* pFunc) { break; } 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; } diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 133e8f9c93c61d80fe2435d2d7f803dbb989003a..50c65439c0d1c29d6018dc691f74641381f20935 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -55,6 +55,14 @@ void functionFinalize(SqlFunctionCtx *pCtx) { 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) { pEnv->calcMemSize = sizeof(int64_t); return true; diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index c50dea5a9d392beb353408e544daa6aedf3e777b..ea9b3bdf18481dec906b170a7e52351aa3528034 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -76,6 +76,16 @@ int32_t fmGetFuncResultType(SFunctionNode* 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) { if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { return TSDB_CODE_FAILED; @@ -120,6 +130,13 @@ bool fmIsNonstandardSQLFunc(int32_t funcId) { 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* m = gFunMgtService.pFuncNameHashTable; diff --git a/source/libs/function/src/tfill.c b/source/libs/function/src/tfill.c index 1f7e83286b3c912db211d9e8b588e12dad9742b8..b6b53621877c7697b87470f7eacbcfb166f00bf2 100644 --- a/source/libs/function/src/tfill.c +++ b/source/libs/function/src/tfill.c @@ -541,7 +541,7 @@ struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, co pFillCol[i].col.bytes = pExprInfo->base.resSchema.bytes; pFillCol[i].col.type = (int8_t)pExprInfo->base.resSchema.type; 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].flag = pExprInfo->base.pParam[0].pCol->flag; // always be the normal column for table query // pFillCol[i].functionId = pExprInfo->pExpr->_function.functionId; diff --git a/source/libs/monitor/src/monMain.c b/source/libs/monitor/src/monMain.c index c90b1f58e84ecdd17a096c1f95c1357710ee234a..3ece089a2821a4e9db0a5e66853c01a224a2e78c 100644 --- a/source/libs/monitor/src/monMain.c +++ b/source/libs/monitor/src/monMain.c @@ -375,6 +375,9 @@ static void monGenDnodeJson(SMonInfo *pMonitor) { tjsonAddDoubleToObject(pJson, "vnodes_num", pStat->totalVnodes); tjsonAddDoubleToObject(pJson, "masters", pStat->masterNum); 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) { @@ -530,7 +533,7 @@ void monSendReport() { if (pCont != NULL) { EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT; 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); } diff --git a/source/libs/monitor/src/monMsg.c b/source/libs/monitor/src/monMsg.c index 3aafcf071d13983195babf421ed7b76f96dba6ac..adacbf479be27f60e3eb376007730cdf5bd5ef1f 100644 --- a/source/libs/monitor/src/monMsg.c +++ b/source/libs/monitor/src/monMsg.c @@ -194,9 +194,9 @@ int32_t tDecodeSMonVgroupInfo(SCoder *decoder, SMonVgroupInfo *pInfo) { if (tDecodeCStrTo(decoder, desc.database_name) < 0) return -1; if (tDecodeCStrTo(decoder, desc.status) < 0) return -1; for (int32_t j = 0; j < TSDB_MAX_REPLICA; ++j) { - SMonVnodeDesc vdesc = {0}; - if (tDecodeI32(decoder, &vdesc.dnode_id) < 0) return -1; - if (tDecodeCStrTo(decoder, vdesc.vnode_role) < 0) return -1; + SMonVnodeDesc *pVDesc = &desc.vnodes[j]; + if (tDecodeI32(decoder, &pVDesc->dnode_id) < 0) return -1; + if (tDecodeCStrTo(decoder, pVDesc->vnode_role) < 0) return -1; } taosArrayPush(pInfo->vgroups, &desc); } @@ -205,15 +205,15 @@ int32_t tDecodeSMonVgroupInfo(SCoder *decoder, SMonVgroupInfo *pInfo) { int32_t tEncodeSMonGrantInfo(SCoder *encoder, const SMonGrantInfo *pInfo) { if (tEncodeI32(encoder, pInfo->expire_time) < 0) return -1; - if (tEncodeI32(encoder, pInfo->timeseries_used) < 0) return -1; - if (tEncodeI32(encoder, pInfo->timeseries_total) < 0) return -1; + if (tEncodeI64(encoder, pInfo->timeseries_used) < 0) return -1; + if (tEncodeI64(encoder, pInfo->timeseries_total) < 0) return -1; return 0; } int32_t tDecodeSMonGrantInfo(SCoder *decoder, SMonGrantInfo *pInfo) { if (tDecodeI32(decoder, &pInfo->expire_time) < 0) return -1; - if (tDecodeI32(decoder, &pInfo->timeseries_used) < 0) return -1; - if (tDecodeI32(decoder, &pInfo->timeseries_total) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->timeseries_used) < 0) return -1; + if (tDecodeI64(decoder, &pInfo->timeseries_total) < 0) return -1; return 0; } diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index fe3b7cb8a092476d502fee707bdee3bd76925c0f..975036575de0a57ac3e038812599a3308e9df940 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -95,7 +95,6 @@ static void dataTypeCopy(const SDataType* pSrc, SDataType* pDst) { static void exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) { dataTypeCopy(&pSrc->resType, &pDst->resType); COPY_CHAR_ARRAY_FIELD(aliasName); - // CLONE_NODE_LIST_FIELD(pAssociationList); } 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) { + COPY_ALL_SCALAR_FIELDS; COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pScanCols); CLONE_OBJECT_FIELD(pMeta, tableMetaClone); CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone); - COPY_SCALAR_FIELD(scanType); - COPY_SCALAR_FIELD(scanFlag); - COPY_SCALAR_FIELD(scanRange); - COPY_SCALAR_FIELD(tableName); - COPY_SCALAR_FIELD(showRewrite); + CLONE_NODE_LIST_FIELD(pDynamicScanFuncs); + return (SNode*)pDst; +} + +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; } @@ -263,15 +266,8 @@ static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNo static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) { COPY_ALL_SCALAR_FIELDS; COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); - // COPY_SCALAR_FIELD(winType); 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); - // COPY_SCALAR_FIELD(sessionGap); CLONE_NODE_FIELD(pTspk); return (SNode*)pDst; } @@ -360,6 +356,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) { return downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst); case QUERY_NODE_LOGIC_PLAN_SCAN: 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: return logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_PROJECT: diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 13093d63acf8089a147e5cb14194b5b45a06d851..8ab76f57147471c9d987cce1e0c65f60fb219a49 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -723,6 +723,9 @@ static int32_t jsonToPhysiTagScanNode(const SJson* pJson, void* pObj) { static const char* jkTableScanPhysiPlanScanFlag = "ScanFlag"; static const char* jkTableScanPhysiPlanStartKey = "StartKey"; 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) { const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj; @@ -737,6 +740,15 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { 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; } @@ -754,6 +766,15 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { 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; } @@ -2767,6 +2788,7 @@ int32_t nodesStringToList(const char* pStr, SNodeList** pList) { return TSDB_CODE_FAILED; } int32_t code = jsonToNodeListImpl(pJson, pList); + tjsonDelete(pJson); if (TSDB_CODE_SUCCESS != code) { nodesDestroyList(*pList); terrno = code; diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 9f81b342748ed1f9227050e64f86da95286233d7..1c565ddd37b9c4142121cea55c8f94f595a1b0ac 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -158,6 +158,16 @@ SNodeptr nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_FUNCTIONS_STMT: case QUERY_NODE_SHOW_INDEXES_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_SNODES_STMT: return makeNode(type, sizeof(SShowStmt)); @@ -694,6 +704,17 @@ int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr 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) { if (NULL == pTarget || NULL == pSrc) { return TSDB_CODE_FAILED; diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 18bea4736c9c2ca253a8db4e64618fa9761b8d8f..94aec0e744db52a35b730d9378ed3490992e642a 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -79,13 +79,13 @@ alter_account_option ::= USERS literal. alter_account_option ::= CONNS 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 ::= 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 ::= 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_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); } 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 ::= 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 ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); } 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 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 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 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); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 318f7ca5f76dfa97cbd462557210fde7e298d7bb..a14053ada7b184d072b05d0e104b46f8e28b402c 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -257,13 +257,20 @@ SNodeList* addValueNodeFromTypeToList(SAstCreateContext* pCxt, SDataType dataTyp char buf[64] = {0}; //add value node for 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); addNodeToList(pCxt, pList, pNode); //add value node for bytes 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.n = strlen(buf); token.z = buf; diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index c31ec92bdeb3986df3314e9c99d4559cc043e4ce..ead3ec90ad3e1394afaf27a241e543c0db7759e2 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -143,7 +143,7 @@ static int32_t rewriteConditionForFromTable(SCalcConstContext* pCxt, SNode* pTab if (TSDB_CODE_SUCCESS == pCxt->code) { 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); } } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index daeb98b3e61024a9c8f393850e6700c827431bc7..5c2f10f810df14ae078c31f3f01734d2faa1c44d 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -80,6 +80,7 @@ static SKeyword keywordTable[] = { {"FSYNC", TK_FSYNC}, {"FUNCTION", TK_FUNCTION}, {"FUNCTIONS", TK_FUNCTIONS}, + {"GRANTS", TK_GRANTS}, {"GROUP", TK_GROUP}, {"HAVING", TK_HAVING}, {"IF", TK_IF}, @@ -131,10 +132,10 @@ static SKeyword keywordTable[] = { {"PRECISION", TK_PRECISION}, {"PRIVILEGE", TK_PRIVILEGE}, {"PREV", TK_PREV}, - {"_QENDTS", TK_QENDTS}, + {"_QENDTS", TK_QENDTS}, {"QNODE", TK_QNODE}, {"QNODES", TK_QNODES}, - {"_QSTARTTS", TK_QSTARTTS}, + {"_QSTARTTS", TK_QSTARTTS}, {"QTIME", TK_QTIME}, {"QUERIES", TK_QUERIES}, {"QUERY", TK_QUERY}, @@ -144,7 +145,7 @@ static SKeyword keywordTable[] = { {"RESET", TK_RESET}, {"RETENTIONS", TK_RETENTIONS}, {"ROLLUP", TK_ROLLUP}, - {"_ROWTS", TK_ROWTS}, + {"_ROWTS", TK_ROWTS}, {"SCORES", TK_SCORES}, {"SELECT", TK_SELECT}, {"SESSION", TK_SESSION}, @@ -163,7 +164,7 @@ static SKeyword keywordTable[] = { {"STATE", TK_STATE}, {"STATE_WINDOW", TK_STATE_WINDOW}, {"STORAGE", TK_STORAGE}, - {"STREAM", TK_STREAM}, + {"STREAM", TK_STREAM}, {"STREAMS", TK_STREAMS}, {"STREAM_MODE", TK_STREAM_MODE}, {"SYNCDB", TK_SYNCDB}, @@ -192,8 +193,8 @@ static SKeyword keywordTable[] = { {"VGROUPS", TK_VGROUPS}, {"VNODES", TK_VNODES}, {"WAL", TK_WAL}, - {"_WDURATION", TK_WDURATION}, - {"_WENDTS", TK_WENDTS}, + {"_WDURATION", TK_WDURATION}, + {"_WENDTS", TK_WENDTS}, {"WHERE", TK_WHERE}, {"_WSTARTTS", TK_WSTARTTS}, // {"ID", TK_ID}, @@ -221,7 +222,6 @@ static SKeyword keywordTable[] = { // {"UMINUS", TK_UMINUS}, // {"UPLUS", TK_UPLUS}, // {"BITNOT", TK_BITNOT}, - // {"GRANTS", TK_GRANTS}, // {"DOT", TK_DOT}, // {"CTIME", TK_CTIME}, // {"LP", TK_LP}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 8885373b2b3b2d33e57e4740235cba994bbb8e6b..b3947b872e2afa5dffecb40150213310abd7804a 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -21,7 +21,7 @@ #include "parUtil.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 { SParseContext* pParseCxt; @@ -380,6 +380,7 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) { static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { uint8_t precision = (NULL != pCxt->pCurrStmt ? pCxt->pCurrStmt->precision : pVal->node.resType.precision); + pVal->node.resType.precision = precision; if (pVal->isDuration) { if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, precision) != 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.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; } @@ -758,7 +762,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) { size_t nums = taosArrayGetSize(pTables); for (size_t i = 0; i < nums; ++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) { return code; } @@ -825,11 +829,39 @@ static int32_t createFirstLastAllCols(STranslateContext* pCxt, SFunctionNode* pS 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) { if (NULL == pSelect->pProjectionList) { // select * ... return createAllColumns(pCxt, &pSelect->pProjectionList); } else { - // todo : t.* SNode* pNode = NULL; WHERE_EACH(pNode, pSelect->pProjectionList) { if (isFirstLastStar(pNode)) { @@ -840,6 +872,14 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) { INSERT_LIST(pSelect->pProjectionList, pFuncs); ERASE_NODE(pSelect->pProjectionList); 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; } @@ -1041,6 +1081,27 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { 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) { if (NULL != pRetentions) { 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)) { 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) { 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; - int32_t daysToKeep1 = ((SValueNode*)nodesListGetNode(pKeep, 1))->datum.i; - int32_t daysToKeep2 = ((SValueNode*)nodesListGetNode(pKeep, 2))->datum.i; + SValueNode* pKeep0 = (SValueNode*)nodesListGetNode(pKeep, 0); + SValueNode* pKeep1 = (SValueNode*)nodesListGetNode(pKeep, 1); + 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 || daysToKeep0 > TSDB_MAX_KEEP || daysToKeep1 > TSDB_MAX_KEEP || daysToKeep2 > TSDB_MAX_KEEP) { 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); } if (TSDB_CODE_SUCCESS == code) { - code = - checkRangeOption(pCxt, "daysPerFile", pOptions->pDaysPerFile, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE); + code = checkRangeOption(pCxt, "daysPerFile", pOptions->pDaysPerFile, TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE); } if (TSDB_CODE_SUCCESS == code) { code = checkRangeOption(pCxt, "fsyncPeriod", pOptions->pFsyncPeriod, TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD); diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 171324aa99680b2daa6456af8e66a0204d405aeb..85d574d9e7e4d79c9a26e8d32f3ea503b9e90e93 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -62,35 +62,39 @@ static char* getSyntaxErrFormat(int32_t errCode) { case TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL: return "This interval value is too small : %s"; case TSDB_CODE_PAR_DB_NOT_SPECIFIED: - return "db not specified"; + return "Database not specified"; case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME: return "Invalid identifier name : %s"; 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: - 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: - return "invalid option %s: %s"; + return "Invalid option %s: %s"; 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: - 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: - return "invalid number of keep options"; + return "Invalid number of keep options"; 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: - 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: - return "invalid option comment, length cannot exceed %d"; + return "Invalid option comment, length cannot exceed %d"; 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: - 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: - return "invalid option retentions"; + return "Invalid option retentions"; case TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST: 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: return "Out of memory"; default: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index a8f764f0e166a158a7590afde11570025026b2f6..610f6b92633ee44af1da5119bb732b8363d820c6 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -100,24 +100,24 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 313 +#define YYNOCODE 314 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SToken yy21; - bool yy173; - EOrder yy256; - EFillMode yy268; - SDataType yy288; - SAlterOption yy289; - EJoinType yy440; - EOperatorType yy468; - SNodeList* yy476; - ENullOrder yy525; - SNode* yy564; - int32_t yy620; + ENullOrder yy69; + SNode* yy140; + EFillMode yy174; + SAlterOption yy181; + SNodeList* yy220; + EJoinType yy224; + EOrder yy238; + SToken yy253; + bool yy273; + SDataType yy368; + EOperatorType yy480; + int32_t yy528; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -132,18 +132,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 547 -#define YYNRULE 409 -#define YYNRULE_WITH_ACTION 409 -#define YYNTOKEN 207 -#define YY_MAX_SHIFT 546 -#define YY_MIN_SHIFTREDUCE 806 -#define YY_MAX_SHIFTREDUCE 1214 -#define YY_ERROR_ACTION 1215 -#define YY_ACCEPT_ACTION 1216 -#define YY_NO_ACTION 1217 -#define YY_MIN_REDUCE 1218 -#define YY_MAX_REDUCE 1626 +#define YYNSTATE 548 +#define YYNRULE 410 +#define YYNTOKEN 208 +#define YY_MAX_SHIFT 547 +#define YY_MIN_SHIFTREDUCE 807 +#define YY_MAX_SHIFTREDUCE 1216 +#define YY_ERROR_ACTION 1217 +#define YY_ACCEPT_ACTION 1218 +#define YY_NO_ACTION 1219 +#define YY_MIN_REDUCE 1220 +#define YY_MAX_REDUCE 1629 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -210,481 +209,483 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1529) +#define YY_ACTTAB_COUNT (1533) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 25, 194, 1478, 1327, 257, 449, 1494, 462, 269, 312, - /* 10 */ 277, 1427, 30, 28, 1474, 1481, 310, 1418, 1420, 1454, - /* 20 */ 266, 1478, 1050, 274, 429, 32, 31, 29, 27, 26, - /* 30 */ 1511, 21, 1338, 1474, 1480, 306, 461, 445, 1048, 238, - /* 40 */ 1478, 32, 31, 29, 27, 26, 1072, 448, 23, 100, - /* 50 */ 11, 1465, 1474, 1480, 1494, 289, 433, 1055, 32, 31, - /* 60 */ 29, 27, 26, 30, 28, 1157, 1605, 228, 1495, 1496, - /* 70 */ 1500, 266, 216, 1050, 1, 1368, 30, 28, 1511, 131, - /* 80 */ 1558, 137, 98, 1603, 266, 445, 1050, 1605, 1171, 1048, - /* 90 */ 52, 431, 127, 1551, 1552, 448, 1556, 543, 1555, 1465, - /* 100 */ 131, 11, 1048, 96, 1603, 1073, 1216, 50, 1055, 1049, - /* 110 */ 49, 1333, 380, 379, 11, 70, 1495, 1496, 1500, 1544, - /* 120 */ 461, 1055, 347, 1543, 1540, 1, 1219, 932, 485, 484, - /* 130 */ 483, 936, 482, 938, 939, 481, 941, 478, 1, 947, - /* 140 */ 475, 949, 950, 472, 469, 1051, 488, 84, 543, 1329, - /* 150 */ 83, 82, 81, 80, 79, 78, 77, 76, 75, 282, - /* 160 */ 1049, 543, 1054, 1074, 1075, 1101, 1102, 1103, 1104, 1105, - /* 170 */ 1106, 1107, 1108, 1049, 12, 1050, 462, 1070, 164, 30, - /* 180 */ 28, 117, 371, 1230, 132, 311, 382, 266, 376, 1050, - /* 190 */ 1605, 1048, 381, 405, 1465, 97, 1051, 377, 375, 157, - /* 200 */ 378, 1338, 155, 131, 373, 1048, 305, 1603, 304, 1051, - /* 210 */ 1055, 396, 461, 1054, 1074, 1075, 1101, 1102, 1103, 1104, - /* 220 */ 1105, 1106, 1107, 1108, 1055, 419, 1054, 1074, 1075, 1101, - /* 230 */ 1102, 1103, 1104, 1105, 1106, 1107, 1108, 406, 462, 1181, - /* 240 */ 132, 7, 1605, 30, 28, 447, 132, 72, 1074, 1075, - /* 250 */ 543, 266, 462, 1050, 368, 131, 894, 30, 28, 1603, - /* 260 */ 1076, 319, 1049, 1338, 543, 266, 12, 1050, 1605, 1048, - /* 270 */ 416, 1179, 1180, 1182, 1183, 896, 1049, 1338, 52, 424, - /* 280 */ 420, 131, 1494, 1048, 132, 1603, 84, 1605, 1055, 83, - /* 290 */ 82, 81, 80, 79, 78, 77, 76, 75, 1051, 1334, - /* 300 */ 1604, 333, 1055, 65, 1603, 7, 1511, 32, 31, 29, - /* 310 */ 27, 26, 1051, 445, 1511, 1054, 118, 101, 1241, 7, - /* 320 */ 1296, 445, 423, 448, 1330, 1494, 1316, 1465, 543, 1054, - /* 330 */ 1074, 1075, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, - /* 340 */ 1049, 132, 543, 119, 1495, 1496, 1500, 141, 140, 1511, - /* 350 */ 237, 132, 1070, 422, 1049, 462, 445, 122, 497, 326, - /* 360 */ 462, 1558, 338, 1465, 320, 1071, 448, 429, 1378, 346, - /* 370 */ 1465, 339, 1385, 265, 1240, 347, 1051, 189, 256, 1554, - /* 380 */ 1338, 434, 1618, 1383, 59, 1338, 229, 1495, 1496, 1500, - /* 390 */ 1051, 499, 100, 1054, 1074, 1075, 1101, 1102, 1103, 1104, - /* 400 */ 1105, 1106, 1107, 1108, 843, 1331, 842, 1054, 1074, 1075, - /* 410 */ 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 462, 1465, - /* 420 */ 30, 28, 1385, 1385, 844, 98, 1239, 1335, 266, 271, - /* 430 */ 1050, 1267, 114, 1419, 1383, 128, 1551, 1552, 1415, 1556, - /* 440 */ 29, 27, 26, 1338, 337, 139, 1048, 332, 331, 330, - /* 450 */ 329, 328, 1485, 325, 324, 323, 322, 318, 317, 316, - /* 460 */ 315, 314, 313, 462, 1483, 1055, 32, 31, 29, 27, - /* 470 */ 26, 1465, 459, 539, 538, 32, 31, 29, 27, 26, - /* 480 */ 250, 1323, 1, 519, 518, 517, 516, 281, 1338, 515, - /* 490 */ 514, 513, 102, 508, 507, 506, 505, 504, 503, 502, - /* 500 */ 501, 108, 1494, 462, 241, 543, 164, 511, 115, 462, - /* 510 */ 371, 300, 72, 241, 449, 270, 1341, 1049, 460, 374, - /* 520 */ 1428, 1325, 251, 115, 249, 248, 1511, 370, 1338, 1089, - /* 530 */ 1218, 1340, 373, 445, 1338, 842, 276, 1120, 32, 31, - /* 540 */ 29, 27, 26, 448, 115, 404, 1120, 1465, 9, 8, - /* 550 */ 1558, 366, 1340, 1051, 93, 92, 91, 90, 89, 88, - /* 560 */ 87, 86, 85, 225, 1495, 1496, 1500, 1314, 1553, 1122, - /* 570 */ 1054, 1074, 1075, 1101, 1102, 1103, 1104, 1105, 1106, 1107, - /* 580 */ 1108, 387, 1164, 279, 462, 1121, 1385, 1126, 1072, 462, - /* 590 */ 116, 115, 278, 208, 1121, 222, 395, 1383, 280, 1340, - /* 600 */ 1238, 1089, 868, 1125, 1237, 6, 1236, 220, 1270, 1338, - /* 610 */ 166, 22, 1125, 390, 1338, 1385, 497, 500, 384, 1310, - /* 620 */ 142, 869, 1133, 1494, 165, 1235, 1384, 24, 264, 1115, - /* 630 */ 1116, 1117, 1118, 1119, 1123, 1124, 24, 264, 1115, 1116, - /* 640 */ 1117, 1118, 1119, 1123, 1124, 1465, 1077, 1511, 1156, 1465, - /* 650 */ 42, 1465, 1234, 41, 445, 32, 31, 29, 27, 26, - /* 660 */ 382, 1233, 376, 106, 448, 1321, 381, 408, 1465, 97, - /* 670 */ 1465, 377, 375, 433, 378, 512, 510, 1494, 1232, 1229, - /* 680 */ 1228, 1227, 436, 67, 68, 1495, 1496, 1500, 1544, 1226, - /* 690 */ 273, 272, 240, 1540, 394, 9, 8, 1465, 1225, 1224, - /* 700 */ 1063, 1511, 1563, 1152, 1605, 1223, 1465, 392, 432, 1222, - /* 710 */ 48, 47, 309, 1221, 136, 297, 1056, 131, 448, 303, - /* 720 */ 437, 1603, 1465, 1465, 1465, 1465, 1465, 246, 1494, 295, - /* 730 */ 299, 291, 287, 133, 1465, 1055, 440, 444, 69, 1495, - /* 740 */ 1496, 1500, 1544, 1465, 1465, 1152, 259, 1540, 126, 169, - /* 750 */ 1465, 546, 1511, 44, 1465, 1231, 132, 1178, 1465, 432, - /* 760 */ 190, 159, 446, 175, 158, 213, 412, 1571, 95, 448, - /* 770 */ 64, 1494, 1257, 1465, 535, 463, 531, 527, 523, 212, - /* 780 */ 61, 161, 163, 1494, 160, 162, 487, 1059, 1252, 69, - /* 790 */ 1495, 1496, 1500, 1544, 383, 1511, 1494, 259, 1540, 126, - /* 800 */ 1250, 1297, 445, 1213, 1214, 66, 417, 1511, 206, 191, - /* 810 */ 385, 342, 448, 178, 445, 33, 1465, 180, 1572, 1127, - /* 820 */ 1511, 403, 388, 1064, 448, 1379, 33, 445, 1465, 1155, - /* 830 */ 1085, 1494, 231, 1495, 1496, 1500, 184, 448, 458, 1058, - /* 840 */ 1067, 1465, 365, 1494, 69, 1495, 1496, 1500, 1544, 1112, - /* 850 */ 1574, 438, 259, 1540, 1617, 1511, 1512, 70, 1495, 1496, - /* 860 */ 1500, 1544, 445, 1578, 430, 411, 1541, 1511, 171, 441, - /* 870 */ 1057, 193, 448, 1070, 445, 2, 1465, 33, 284, 435, - /* 880 */ 245, 1017, 197, 1034, 448, 168, 199, 94, 1465, 894, - /* 890 */ 247, 454, 69, 1495, 1496, 1500, 1544, 1026, 214, 288, - /* 900 */ 259, 1540, 1617, 1494, 69, 1495, 1496, 1500, 1544, 138, - /* 910 */ 1061, 1601, 259, 1540, 1617, 104, 321, 152, 429, 205, - /* 920 */ 125, 106, 1417, 1562, 327, 925, 364, 1511, 360, 356, - /* 930 */ 352, 151, 44, 467, 445, 335, 920, 953, 104, 1494, - /* 940 */ 340, 1060, 957, 100, 448, 334, 336, 1081, 1465, 341, - /* 950 */ 1494, 1080, 32, 31, 29, 27, 26, 53, 344, 144, - /* 960 */ 149, 1079, 433, 1511, 70, 1495, 1496, 1500, 1544, 343, - /* 970 */ 445, 345, 443, 1540, 1511, 105, 98, 147, 51, 963, - /* 980 */ 448, 445, 348, 429, 1465, 106, 187, 1551, 428, 962, - /* 990 */ 427, 448, 104, 1605, 150, 1465, 107, 1078, 413, 367, - /* 1000 */ 232, 1495, 1496, 1500, 1494, 369, 131, 1328, 100, 1494, - /* 1010 */ 1603, 233, 1495, 1496, 1500, 154, 148, 1324, 121, 156, - /* 1020 */ 145, 74, 372, 397, 109, 110, 1326, 1322, 1511, 111, - /* 1030 */ 112, 255, 425, 1511, 398, 445, 407, 143, 1494, 399, - /* 1040 */ 445, 98, 400, 1077, 170, 448, 173, 418, 409, 1465, - /* 1050 */ 448, 129, 1551, 1552, 1465, 1556, 1575, 263, 1585, 452, - /* 1060 */ 410, 1055, 1511, 1584, 1494, 119, 1495, 1496, 1500, 445, - /* 1070 */ 233, 1495, 1496, 1500, 176, 415, 5, 179, 1211, 448, - /* 1080 */ 258, 421, 1565, 1465, 426, 414, 267, 99, 1511, 4, - /* 1090 */ 1076, 1152, 1559, 124, 183, 445, 34, 185, 260, 233, - /* 1100 */ 1495, 1496, 1500, 442, 1619, 448, 1494, 439, 17, 1465, - /* 1110 */ 456, 1494, 186, 1526, 1426, 450, 192, 1494, 455, 1602, - /* 1120 */ 451, 1620, 1425, 201, 268, 234, 1495, 1496, 1500, 215, - /* 1130 */ 1511, 457, 203, 58, 1339, 1511, 60, 445, 217, 465, - /* 1140 */ 494, 1511, 445, 1311, 211, 1210, 542, 448, 445, 1315, - /* 1150 */ 40, 1465, 448, 223, 224, 219, 1465, 1459, 448, 1494, - /* 1160 */ 221, 1458, 1465, 283, 1455, 285, 286, 226, 1495, 1496, - /* 1170 */ 1500, 1494, 235, 1495, 1496, 1500, 1044, 1045, 227, 1495, - /* 1180 */ 1496, 1500, 134, 1511, 1494, 290, 1453, 1452, 292, 293, - /* 1190 */ 445, 294, 296, 1451, 298, 1511, 1442, 135, 301, 302, - /* 1200 */ 448, 1313, 445, 1029, 1465, 1028, 1436, 1435, 1511, 308, - /* 1210 */ 209, 307, 448, 1494, 493, 445, 1465, 1434, 1433, 1000, - /* 1220 */ 236, 1495, 1496, 1500, 1410, 448, 1409, 1408, 1407, 1465, - /* 1230 */ 1406, 1405, 1508, 1495, 1496, 1500, 495, 1511, 1404, 1494, - /* 1240 */ 1403, 1402, 1401, 1400, 445, 1507, 1495, 1496, 1500, 1399, - /* 1250 */ 1398, 1397, 1396, 1395, 448, 492, 491, 490, 1465, 489, - /* 1260 */ 103, 1394, 209, 1511, 1393, 1494, 493, 1392, 1391, 1390, - /* 1270 */ 445, 1389, 1388, 1494, 243, 1495, 1496, 1500, 1002, 1387, - /* 1280 */ 448, 1386, 1269, 1450, 1465, 1444, 1432, 1423, 495, 1511, - /* 1290 */ 146, 1317, 1268, 1266, 350, 861, 445, 1511, 349, 1494, - /* 1300 */ 1506, 1495, 1496, 1500, 445, 351, 448, 492, 491, 490, - /* 1310 */ 1465, 489, 1264, 353, 448, 1262, 354, 355, 1465, 359, - /* 1320 */ 1260, 363, 357, 1511, 358, 362, 244, 1495, 1496, 1500, - /* 1330 */ 445, 1249, 361, 1248, 242, 1495, 1496, 1500, 1245, 1319, - /* 1340 */ 448, 1494, 73, 970, 1465, 968, 153, 1318, 511, 893, - /* 1350 */ 1258, 892, 891, 1253, 890, 887, 886, 252, 253, 1251, - /* 1360 */ 239, 1495, 1496, 1500, 386, 1511, 509, 254, 389, 1244, - /* 1370 */ 391, 1243, 445, 393, 71, 1449, 43, 167, 1036, 1443, - /* 1380 */ 401, 1431, 448, 113, 1430, 402, 1465, 1422, 123, 172, - /* 1390 */ 14, 15, 37, 54, 1483, 174, 177, 3, 33, 38, - /* 1400 */ 182, 35, 230, 1495, 1496, 1500, 56, 1177, 120, 10, - /* 1410 */ 188, 181, 1199, 8, 20, 19, 1198, 1170, 55, 1113, - /* 1420 */ 261, 1203, 1421, 1202, 1149, 453, 36, 1148, 262, 202, - /* 1430 */ 204, 16, 1204, 466, 1065, 275, 470, 1087, 1086, 13, - /* 1440 */ 18, 198, 130, 196, 473, 1175, 200, 195, 61, 931, - /* 1450 */ 45, 57, 476, 479, 965, 959, 875, 540, 961, 1482, - /* 1460 */ 541, 544, 39, 882, 881, 468, 207, 954, 951, 948, - /* 1470 */ 471, 1265, 859, 474, 464, 942, 940, 477, 480, 496, - /* 1480 */ 900, 880, 879, 878, 877, 876, 895, 62, 897, 872, - /* 1490 */ 871, 870, 46, 63, 867, 866, 498, 486, 865, 210, - /* 1500 */ 1263, 864, 520, 521, 946, 525, 945, 944, 943, 522, - /* 1510 */ 524, 526, 1261, 528, 529, 1259, 530, 532, 533, 534, - /* 1520 */ 1247, 536, 537, 1246, 1242, 1052, 964, 218, 545, + /* 0 */ 463, 25, 194, 52, 257, 306, 1497, 9, 8, 72, + /* 10 */ 277, 388, 30, 28, 463, 274, 369, 1421, 1423, 270, + /* 20 */ 266, 1481, 1052, 310, 1336, 1340, 396, 115, 1072, 1481, + /* 30 */ 1514, 1497, 1481, 1477, 1483, 1342, 1608, 446, 1050, 1340, + /* 40 */ 166, 1477, 1484, 391, 1477, 1483, 462, 449, 385, 131, + /* 50 */ 11, 1468, 406, 1606, 165, 1514, 312, 1057, 29, 27, + /* 60 */ 26, 348, 446, 30, 28, 1159, 463, 119, 1498, 1499, + /* 70 */ 1503, 266, 449, 1052, 1, 72, 1468, 30, 28, 265, + /* 80 */ 42, 1135, 375, 41, 462, 266, 238, 1052, 1497, 1050, + /* 90 */ 1331, 1340, 229, 1498, 1499, 1503, 407, 544, 540, 539, + /* 100 */ 1075, 11, 462, 1050, 450, 435, 1621, 269, 1057, 1051, + /* 110 */ 1430, 463, 1514, 381, 380, 11, 30, 28, 430, 446, + /* 120 */ 311, 117, 1057, 1232, 266, 1, 1052, 1608, 1608, 449, + /* 130 */ 513, 511, 1243, 1468, 430, 1468, 1340, 1124, 12, 1, + /* 140 */ 131, 1607, 1050, 100, 1606, 1606, 1053, 1318, 544, 70, + /* 150 */ 1498, 1499, 1503, 1547, 420, 1128, 12, 1546, 1543, 100, + /* 160 */ 1051, 1057, 544, 1056, 1076, 1077, 1103, 1104, 1105, 1106, + /* 170 */ 1107, 1108, 1109, 1110, 1051, 463, 98, 1468, 7, 22, + /* 180 */ 1242, 30, 28, 448, 319, 132, 128, 1554, 1555, 266, + /* 190 */ 1559, 1052, 98, 132, 118, 132, 348, 1053, 1298, 1387, + /* 200 */ 1340, 544, 129, 1554, 1555, 256, 1559, 1050, 425, 421, + /* 210 */ 1385, 1053, 1074, 1051, 1056, 1076, 1077, 1103, 1104, 1105, + /* 220 */ 1106, 1107, 1108, 1109, 1110, 1468, 1057, 1221, 1056, 1076, + /* 230 */ 1077, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 305, + /* 240 */ 844, 304, 843, 7, 1076, 1077, 9, 8, 84, 132, + /* 250 */ 1053, 83, 82, 81, 80, 79, 78, 77, 76, 75, + /* 260 */ 845, 32, 31, 29, 27, 26, 544, 1056, 1076, 1077, + /* 270 */ 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1051, 132, + /* 280 */ 424, 1418, 52, 30, 28, 237, 65, 1072, 139, 132, + /* 290 */ 383, 266, 377, 1052, 327, 96, 382, 339, 1241, 97, + /* 300 */ 101, 378, 376, 1335, 379, 216, 340, 1332, 1370, 1050, + /* 310 */ 32, 31, 29, 27, 26, 1053, 84, 1566, 1154, 83, + /* 320 */ 82, 81, 80, 79, 78, 77, 76, 75, 1057, 1220, + /* 330 */ 334, 1183, 1056, 1076, 1077, 1103, 1104, 1105, 1106, 1107, + /* 340 */ 1108, 1109, 1110, 1468, 1078, 7, 164, 445, 241, 137, + /* 350 */ 372, 895, 498, 93, 92, 91, 90, 89, 88, 87, + /* 360 */ 86, 85, 417, 1181, 1182, 1184, 1185, 501, 544, 1312, + /* 370 */ 897, 1079, 374, 1091, 250, 50, 141, 140, 49, 338, + /* 380 */ 1051, 1122, 333, 332, 331, 330, 329, 430, 326, 325, + /* 390 */ 324, 323, 322, 318, 317, 316, 315, 314, 313, 463, + /* 400 */ 164, 30, 28, 489, 372, 1561, 463, 450, 320, 266, + /* 410 */ 1561, 1052, 100, 1431, 1387, 347, 251, 1053, 249, 248, + /* 420 */ 271, 371, 1514, 1558, 1340, 1385, 374, 1050, 1557, 446, + /* 430 */ 1123, 1340, 1215, 1216, 1056, 1076, 1077, 1103, 1104, 1105, + /* 440 */ 1106, 1107, 1108, 1109, 1110, 98, 1057, 1269, 1127, 32, + /* 450 */ 31, 29, 27, 26, 432, 127, 1554, 1555, 1317, 1559, + /* 460 */ 1114, 423, 189, 1, 1073, 32, 31, 29, 27, 26, + /* 470 */ 1561, 59, 24, 264, 1117, 1118, 1119, 1120, 1121, 1125, + /* 480 */ 1126, 32, 31, 29, 27, 26, 544, 241, 1556, 175, + /* 490 */ 1166, 157, 1333, 122, 155, 1158, 1074, 1240, 1051, 520, + /* 500 */ 519, 518, 517, 281, 1380, 516, 515, 514, 102, 509, + /* 510 */ 508, 507, 506, 505, 504, 503, 502, 108, 159, 209, + /* 520 */ 1122, 158, 500, 494, 933, 486, 485, 484, 937, 483, + /* 530 */ 939, 940, 482, 942, 479, 1053, 948, 476, 950, 951, + /* 540 */ 473, 470, 1468, 1239, 1173, 496, 116, 1329, 1218, 1316, + /* 550 */ 6, 222, 1056, 1076, 1077, 1103, 1104, 1105, 1106, 1107, + /* 560 */ 1108, 1109, 1110, 220, 493, 492, 491, 21, 490, 1123, + /* 570 */ 161, 437, 23, 160, 843, 1238, 142, 32, 31, 29, + /* 580 */ 27, 26, 32, 31, 29, 27, 26, 1127, 1468, 115, + /* 590 */ 367, 1325, 1213, 152, 1272, 1327, 125, 1343, 498, 463, + /* 600 */ 463, 282, 365, 397, 361, 357, 353, 151, 1337, 460, + /* 610 */ 1387, 24, 264, 1117, 1118, 1119, 1120, 1121, 1125, 1126, + /* 620 */ 1468, 1422, 1323, 169, 1340, 1340, 297, 276, 447, 463, + /* 630 */ 273, 272, 1608, 53, 1608, 115, 149, 1237, 461, 67, + /* 640 */ 1065, 299, 1497, 1342, 1457, 131, 383, 131, 377, 1606, + /* 650 */ 163, 1606, 382, 162, 1340, 97, 1058, 378, 376, 1212, + /* 660 */ 379, 32, 31, 29, 27, 26, 1514, 48, 47, 309, + /* 670 */ 1387, 136, 405, 446, 512, 1057, 303, 1157, 300, 1259, + /* 680 */ 289, 1386, 1468, 449, 246, 1497, 295, 1468, 291, 287, + /* 690 */ 133, 1154, 434, 148, 279, 121, 106, 145, 1497, 1236, + /* 700 */ 409, 384, 115, 68, 1498, 1499, 1503, 1547, 488, 1514, + /* 710 */ 1342, 240, 1543, 132, 143, 464, 433, 32, 31, 29, + /* 720 */ 27, 26, 1514, 1608, 1091, 395, 449, 1061, 463, 446, + /* 730 */ 1468, 1235, 1234, 1299, 441, 438, 131, 208, 393, 449, + /* 740 */ 1606, 1497, 463, 1468, 1468, 1231, 69, 1498, 1499, 1503, + /* 750 */ 1547, 280, 1387, 1340, 259, 1543, 126, 1254, 278, 119, + /* 760 */ 1498, 1499, 1503, 1385, 1066, 1514, 547, 1340, 190, 436, + /* 770 */ 430, 1233, 433, 1230, 413, 1574, 1468, 1468, 1060, 386, + /* 780 */ 213, 1069, 449, 95, 1052, 1252, 1468, 1229, 1228, 536, + /* 790 */ 1468, 532, 528, 524, 212, 100, 1227, 44, 1622, 1226, + /* 800 */ 1050, 1180, 69, 1498, 1499, 1503, 1547, 389, 191, 178, + /* 810 */ 259, 1543, 126, 180, 434, 1225, 1224, 418, 1468, 1057, + /* 820 */ 66, 1223, 33, 206, 1497, 33, 1129, 1059, 98, 1087, + /* 830 */ 343, 1575, 1468, 1468, 1488, 1381, 404, 64, 187, 1554, + /* 840 */ 429, 1468, 428, 114, 1468, 1608, 1486, 61, 1514, 1063, + /* 850 */ 44, 1497, 33, 459, 921, 446, 1019, 366, 131, 544, + /* 860 */ 1468, 1468, 1606, 184, 1577, 449, 1468, 439, 442, 1468, + /* 870 */ 197, 1051, 94, 104, 199, 1514, 455, 205, 1497, 106, + /* 880 */ 1515, 412, 446, 926, 171, 69, 1498, 1499, 1503, 1547, + /* 890 */ 431, 2, 449, 259, 1543, 1620, 1468, 193, 1062, 1036, + /* 900 */ 1072, 168, 1514, 468, 1581, 869, 104, 954, 1053, 446, + /* 910 */ 958, 284, 69, 1498, 1499, 1503, 1547, 288, 245, 449, + /* 920 */ 259, 1543, 1620, 1468, 870, 1056, 105, 895, 1497, 247, + /* 930 */ 964, 1604, 106, 104, 1028, 214, 963, 107, 321, 69, + /* 940 */ 1498, 1499, 1503, 1547, 1420, 138, 328, 259, 1543, 1620, + /* 950 */ 336, 335, 1514, 1497, 337, 1083, 341, 342, 1565, 446, + /* 960 */ 1082, 344, 144, 1081, 345, 346, 1080, 147, 51, 449, + /* 970 */ 349, 150, 368, 1468, 398, 399, 370, 1514, 434, 1330, + /* 980 */ 1497, 154, 411, 400, 446, 1326, 255, 74, 401, 228, + /* 990 */ 1498, 1499, 1503, 156, 449, 373, 109, 408, 1468, 110, + /* 1000 */ 1328, 1324, 111, 112, 1514, 1079, 1497, 170, 173, 1608, + /* 1010 */ 419, 446, 1588, 410, 70, 1498, 1499, 1503, 1547, 453, + /* 1020 */ 1057, 449, 131, 1544, 5, 1468, 1606, 1578, 183, 176, + /* 1030 */ 1514, 416, 1497, 1587, 179, 1568, 258, 446, 422, 427, + /* 1040 */ 1497, 70, 1498, 1499, 1503, 1547, 415, 449, 1154, 444, + /* 1050 */ 1543, 1468, 4, 99, 414, 1078, 1514, 1562, 34, 260, + /* 1060 */ 443, 186, 440, 446, 1514, 17, 1429, 233, 1498, 1499, + /* 1070 */ 1503, 446, 124, 449, 1497, 1529, 451, 1468, 185, 452, + /* 1080 */ 456, 449, 203, 1428, 268, 1468, 201, 1497, 263, 58, + /* 1090 */ 457, 458, 1341, 232, 1498, 1499, 1503, 1623, 1514, 1497, + /* 1100 */ 192, 233, 1498, 1499, 1503, 446, 1605, 466, 215, 1313, + /* 1110 */ 60, 1514, 495, 217, 211, 449, 543, 40, 446, 1468, + /* 1120 */ 219, 223, 267, 1514, 224, 426, 221, 1462, 449, 1461, + /* 1130 */ 446, 283, 1468, 1497, 1458, 233, 1498, 1499, 1503, 285, + /* 1140 */ 449, 286, 1046, 1047, 1468, 134, 290, 1456, 225, 1498, + /* 1150 */ 1499, 1503, 292, 293, 294, 1455, 296, 1514, 1454, 1497, + /* 1160 */ 231, 1498, 1499, 1503, 446, 1445, 298, 135, 301, 302, + /* 1170 */ 1031, 1030, 1439, 1438, 449, 307, 308, 1437, 1468, 103, + /* 1180 */ 1002, 1413, 1412, 1514, 1436, 1497, 1411, 1410, 1409, 1408, + /* 1190 */ 446, 1407, 1406, 1405, 234, 1498, 1499, 1503, 1404, 1403, + /* 1200 */ 449, 1402, 1401, 1400, 1468, 1004, 1391, 1390, 1389, 1514, + /* 1210 */ 1497, 1399, 1398, 1397, 1396, 1395, 446, 1394, 1393, 1392, + /* 1220 */ 226, 1498, 1499, 1503, 1388, 1271, 449, 1453, 1447, 1435, + /* 1230 */ 1468, 1426, 1319, 146, 1514, 1497, 862, 1270, 1268, 352, + /* 1240 */ 1266, 446, 350, 356, 1497, 351, 235, 1498, 1499, 1503, + /* 1250 */ 1264, 449, 1262, 360, 354, 1468, 355, 359, 1251, 1514, + /* 1260 */ 358, 362, 363, 1250, 1247, 1321, 446, 969, 1514, 1320, + /* 1270 */ 1260, 227, 1498, 1499, 1503, 446, 449, 364, 73, 1497, + /* 1280 */ 1468, 971, 894, 252, 893, 449, 892, 891, 1255, 1468, + /* 1290 */ 253, 888, 887, 1253, 387, 254, 236, 1498, 1499, 1503, + /* 1300 */ 390, 1246, 392, 1514, 512, 1511, 1498, 1499, 1503, 1245, + /* 1310 */ 446, 153, 510, 1497, 394, 71, 1452, 167, 43, 1038, + /* 1320 */ 449, 1446, 113, 1434, 1468, 402, 1433, 1425, 172, 14, + /* 1330 */ 54, 3, 403, 1486, 177, 37, 35, 1514, 33, 15, + /* 1340 */ 1510, 1498, 1499, 1503, 446, 38, 1179, 1497, 10, 120, + /* 1350 */ 181, 19, 188, 1172, 449, 182, 1497, 55, 1468, 56, + /* 1360 */ 20, 1151, 1497, 1201, 8, 1150, 1206, 36, 130, 174, + /* 1370 */ 123, 1514, 1200, 16, 243, 1498, 1499, 1503, 446, 261, + /* 1380 */ 1514, 1315, 1205, 1204, 262, 195, 1514, 446, 449, 1089, + /* 1390 */ 1497, 13, 1468, 446, 1088, 196, 18, 449, 1424, 1177, + /* 1400 */ 202, 1468, 1115, 449, 198, 200, 45, 1468, 1509, 1498, + /* 1410 */ 1499, 1503, 57, 61, 1514, 454, 1497, 244, 1498, 1499, + /* 1420 */ 1503, 446, 1485, 242, 1498, 1499, 1503, 204, 207, 1067, + /* 1430 */ 39, 449, 465, 955, 467, 1468, 952, 275, 469, 471, + /* 1440 */ 1514, 472, 209, 949, 474, 475, 494, 446, 943, 477, + /* 1450 */ 478, 239, 1498, 1499, 1503, 941, 480, 449, 481, 947, + /* 1460 */ 932, 1468, 946, 62, 945, 944, 487, 966, 496, 46, + /* 1470 */ 962, 63, 960, 860, 497, 499, 901, 230, 1498, 1499, + /* 1480 */ 1503, 965, 883, 210, 882, 881, 880, 493, 492, 491, + /* 1490 */ 879, 490, 878, 877, 876, 896, 898, 873, 872, 871, + /* 1500 */ 868, 867, 866, 865, 1267, 521, 522, 1265, 1263, 523, + /* 1510 */ 526, 525, 527, 529, 530, 1261, 534, 533, 1249, 531, + /* 1520 */ 535, 537, 538, 1248, 1244, 541, 542, 1219, 1054, 1219, + /* 1530 */ 546, 218, 545, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 276, 277, 255, 235, 238, 251, 210, 216, 254, 216, - /* 10 */ 243, 257, 12, 13, 267, 268, 225, 250, 251, 0, - /* 20 */ 20, 255, 22, 238, 216, 12, 13, 14, 15, 16, - /* 30 */ 234, 2, 241, 267, 268, 260, 20, 241, 38, 246, - /* 40 */ 255, 12, 13, 14, 15, 16, 20, 251, 2, 241, - /* 50 */ 50, 255, 267, 268, 210, 36, 260, 57, 12, 13, - /* 60 */ 14, 15, 16, 12, 13, 14, 291, 271, 272, 273, - /* 70 */ 274, 20, 227, 22, 74, 230, 12, 13, 234, 304, - /* 80 */ 269, 47, 274, 308, 20, 241, 22, 291, 75, 38, - /* 90 */ 218, 283, 284, 285, 286, 251, 288, 97, 287, 255, - /* 100 */ 304, 50, 38, 231, 308, 20, 207, 73, 57, 109, - /* 110 */ 76, 239, 220, 221, 50, 271, 272, 273, 274, 275, - /* 120 */ 20, 57, 49, 279, 280, 74, 0, 88, 89, 90, - /* 130 */ 91, 92, 93, 94, 95, 96, 97, 98, 74, 100, - /* 140 */ 101, 102, 103, 104, 105, 145, 85, 21, 97, 210, - /* 150 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 260, - /* 160 */ 109, 97, 162, 163, 164, 165, 166, 167, 168, 169, - /* 170 */ 170, 171, 172, 109, 74, 22, 216, 20, 61, 12, - /* 180 */ 13, 209, 65, 211, 184, 225, 52, 20, 54, 22, - /* 190 */ 291, 38, 58, 216, 255, 61, 145, 63, 64, 78, - /* 200 */ 66, 241, 81, 304, 87, 38, 144, 308, 146, 145, - /* 210 */ 57, 260, 20, 162, 163, 164, 165, 166, 167, 168, - /* 220 */ 169, 170, 171, 172, 57, 135, 162, 163, 164, 165, - /* 230 */ 166, 167, 168, 169, 170, 171, 172, 260, 216, 162, - /* 240 */ 184, 74, 291, 12, 13, 14, 184, 225, 163, 164, - /* 250 */ 97, 20, 216, 22, 232, 304, 38, 12, 13, 308, - /* 260 */ 20, 225, 109, 241, 97, 20, 74, 22, 291, 38, - /* 270 */ 193, 194, 195, 196, 197, 57, 109, 241, 218, 189, - /* 280 */ 190, 304, 210, 38, 184, 308, 21, 291, 57, 24, - /* 290 */ 25, 26, 27, 28, 29, 30, 31, 32, 145, 239, - /* 300 */ 304, 67, 57, 215, 308, 74, 234, 12, 13, 14, - /* 310 */ 15, 16, 145, 241, 234, 162, 219, 229, 210, 74, - /* 320 */ 223, 241, 20, 251, 236, 210, 0, 255, 97, 162, - /* 330 */ 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, - /* 340 */ 109, 184, 97, 271, 272, 273, 274, 113, 114, 234, - /* 350 */ 18, 184, 20, 273, 109, 216, 241, 233, 49, 27, - /* 360 */ 216, 269, 30, 255, 225, 20, 251, 216, 244, 225, - /* 370 */ 255, 39, 234, 258, 210, 49, 145, 137, 240, 287, - /* 380 */ 241, 309, 310, 245, 215, 241, 271, 272, 273, 274, - /* 390 */ 145, 57, 241, 162, 163, 164, 165, 166, 167, 168, - /* 400 */ 169, 170, 171, 172, 20, 236, 22, 162, 163, 164, - /* 410 */ 165, 166, 167, 168, 169, 170, 171, 172, 216, 255, - /* 420 */ 12, 13, 234, 234, 40, 274, 210, 225, 20, 240, - /* 430 */ 22, 0, 137, 245, 245, 284, 285, 286, 241, 288, - /* 440 */ 14, 15, 16, 241, 112, 248, 38, 115, 116, 117, - /* 450 */ 118, 119, 74, 121, 122, 123, 124, 125, 126, 127, - /* 460 */ 128, 129, 130, 216, 86, 57, 12, 13, 14, 15, - /* 470 */ 16, 255, 225, 213, 214, 12, 13, 14, 15, 16, - /* 480 */ 35, 235, 74, 52, 53, 54, 55, 56, 241, 58, - /* 490 */ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - /* 500 */ 69, 70, 210, 216, 50, 97, 61, 71, 234, 216, - /* 510 */ 65, 75, 225, 50, 251, 226, 242, 109, 225, 232, - /* 520 */ 257, 235, 77, 234, 79, 80, 234, 82, 241, 75, - /* 530 */ 0, 242, 87, 241, 241, 22, 226, 83, 12, 13, - /* 540 */ 14, 15, 16, 251, 234, 263, 83, 255, 1, 2, - /* 550 */ 269, 38, 242, 145, 24, 25, 26, 27, 28, 29, - /* 560 */ 30, 31, 32, 271, 272, 273, 274, 0, 287, 131, - /* 570 */ 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, - /* 580 */ 172, 4, 14, 226, 216, 131, 234, 149, 20, 216, - /* 590 */ 18, 234, 240, 225, 131, 23, 19, 245, 225, 242, - /* 600 */ 210, 75, 38, 149, 210, 43, 210, 35, 0, 241, - /* 610 */ 33, 173, 149, 36, 241, 234, 49, 222, 41, 224, - /* 620 */ 48, 57, 75, 210, 47, 210, 245, 173, 174, 175, - /* 630 */ 176, 177, 178, 179, 180, 181, 173, 174, 175, 176, - /* 640 */ 177, 178, 179, 180, 181, 255, 20, 234, 4, 255, - /* 650 */ 73, 255, 210, 76, 241, 12, 13, 14, 15, 16, - /* 660 */ 52, 210, 54, 71, 251, 235, 58, 75, 255, 61, - /* 670 */ 255, 63, 64, 260, 66, 220, 221, 210, 210, 210, - /* 680 */ 210, 210, 3, 111, 271, 272, 273, 274, 275, 210, - /* 690 */ 12, 13, 279, 280, 21, 1, 2, 255, 210, 210, - /* 700 */ 22, 234, 182, 183, 291, 210, 255, 34, 241, 210, - /* 710 */ 138, 139, 140, 210, 142, 141, 38, 304, 251, 147, - /* 720 */ 71, 308, 255, 255, 255, 255, 255, 155, 210, 157, - /* 730 */ 156, 159, 160, 161, 255, 57, 71, 50, 271, 272, - /* 740 */ 273, 274, 275, 255, 255, 183, 279, 280, 281, 235, - /* 750 */ 255, 19, 234, 71, 255, 211, 184, 75, 255, 241, - /* 760 */ 293, 78, 235, 137, 81, 33, 299, 300, 36, 251, - /* 770 */ 74, 210, 0, 255, 42, 97, 44, 45, 46, 47, - /* 780 */ 84, 78, 78, 210, 81, 81, 235, 109, 0, 271, - /* 790 */ 272, 273, 274, 275, 22, 234, 210, 279, 280, 281, - /* 800 */ 0, 223, 241, 163, 164, 73, 302, 234, 76, 311, - /* 810 */ 22, 251, 251, 71, 241, 71, 255, 75, 300, 75, - /* 820 */ 234, 251, 22, 145, 251, 244, 71, 241, 255, 185, - /* 830 */ 75, 210, 271, 272, 273, 274, 296, 251, 106, 38, - /* 840 */ 162, 255, 213, 210, 271, 272, 273, 274, 275, 162, - /* 850 */ 270, 202, 279, 280, 281, 234, 234, 271, 272, 273, - /* 860 */ 274, 275, 241, 290, 289, 133, 280, 234, 136, 204, - /* 870 */ 38, 305, 251, 20, 241, 292, 255, 71, 216, 200, - /* 880 */ 266, 75, 71, 151, 251, 153, 75, 71, 255, 38, - /* 890 */ 220, 75, 271, 272, 273, 274, 275, 143, 261, 36, - /* 900 */ 279, 280, 281, 210, 271, 272, 273, 274, 275, 120, - /* 910 */ 109, 290, 279, 280, 281, 71, 216, 33, 216, 75, - /* 920 */ 36, 71, 216, 290, 249, 75, 42, 234, 44, 45, - /* 930 */ 46, 47, 71, 71, 241, 131, 75, 75, 71, 210, - /* 940 */ 216, 109, 75, 241, 251, 247, 247, 20, 255, 265, - /* 950 */ 210, 20, 12, 13, 14, 15, 16, 73, 241, 218, - /* 960 */ 76, 20, 260, 234, 271, 272, 273, 274, 275, 259, - /* 970 */ 241, 252, 279, 280, 234, 71, 274, 218, 218, 75, - /* 980 */ 251, 241, 216, 216, 255, 71, 284, 285, 286, 75, - /* 990 */ 288, 251, 71, 291, 218, 255, 75, 20, 258, 212, - /* 1000 */ 271, 272, 273, 274, 210, 234, 304, 234, 241, 210, - /* 1010 */ 308, 271, 272, 273, 274, 234, 132, 234, 134, 234, - /* 1020 */ 136, 216, 220, 241, 234, 234, 234, 234, 234, 234, - /* 1030 */ 234, 212, 303, 234, 265, 241, 259, 153, 210, 152, - /* 1040 */ 241, 274, 264, 20, 215, 251, 215, 192, 241, 255, - /* 1050 */ 251, 284, 285, 286, 255, 288, 270, 258, 301, 191, - /* 1060 */ 252, 57, 234, 301, 210, 271, 272, 273, 274, 241, - /* 1070 */ 271, 272, 273, 274, 256, 255, 199, 256, 138, 251, - /* 1080 */ 255, 255, 298, 255, 198, 187, 258, 241, 234, 186, - /* 1090 */ 20, 183, 269, 295, 297, 241, 120, 294, 206, 271, - /* 1100 */ 272, 273, 274, 203, 310, 251, 210, 201, 74, 255, - /* 1110 */ 253, 210, 282, 278, 256, 255, 306, 210, 134, 307, - /* 1120 */ 255, 312, 256, 241, 255, 271, 272, 273, 274, 230, - /* 1130 */ 234, 252, 215, 215, 241, 234, 74, 241, 216, 237, - /* 1140 */ 220, 234, 241, 224, 215, 205, 212, 251, 241, 0, - /* 1150 */ 262, 255, 251, 228, 228, 217, 255, 0, 251, 210, - /* 1160 */ 208, 0, 255, 64, 0, 38, 158, 271, 272, 273, - /* 1170 */ 274, 210, 271, 272, 273, 274, 38, 38, 271, 272, - /* 1180 */ 273, 274, 38, 234, 210, 158, 0, 0, 38, 38, - /* 1190 */ 241, 158, 38, 0, 38, 234, 0, 74, 149, 148, - /* 1200 */ 251, 0, 241, 109, 255, 145, 0, 0, 234, 141, - /* 1210 */ 61, 53, 251, 210, 65, 241, 255, 0, 0, 86, - /* 1220 */ 271, 272, 273, 274, 0, 251, 0, 0, 0, 255, - /* 1230 */ 0, 0, 271, 272, 273, 274, 87, 234, 0, 210, - /* 1240 */ 0, 0, 0, 0, 241, 271, 272, 273, 274, 0, - /* 1250 */ 0, 0, 0, 0, 251, 106, 107, 108, 255, 110, - /* 1260 */ 120, 0, 61, 234, 0, 210, 65, 0, 0, 0, - /* 1270 */ 241, 0, 0, 210, 271, 272, 273, 274, 22, 0, - /* 1280 */ 251, 0, 0, 0, 255, 0, 0, 0, 87, 234, - /* 1290 */ 43, 0, 0, 0, 36, 51, 241, 234, 38, 210, - /* 1300 */ 271, 272, 273, 274, 241, 43, 251, 106, 107, 108, - /* 1310 */ 255, 110, 0, 38, 251, 0, 36, 43, 255, 43, - /* 1320 */ 0, 43, 38, 234, 36, 36, 271, 272, 273, 274, - /* 1330 */ 241, 0, 38, 0, 271, 272, 273, 274, 0, 0, - /* 1340 */ 251, 210, 83, 38, 255, 22, 81, 0, 71, 38, - /* 1350 */ 0, 38, 38, 0, 38, 38, 38, 22, 22, 0, - /* 1360 */ 271, 272, 273, 274, 39, 234, 71, 22, 38, 0, - /* 1370 */ 22, 0, 241, 22, 20, 0, 137, 154, 38, 0, - /* 1380 */ 22, 0, 251, 150, 0, 137, 255, 0, 134, 43, - /* 1390 */ 188, 188, 137, 74, 86, 132, 75, 71, 71, 71, - /* 1400 */ 71, 182, 271, 272, 273, 274, 4, 75, 74, 188, - /* 1410 */ 86, 74, 38, 2, 71, 74, 38, 75, 74, 162, - /* 1420 */ 38, 38, 0, 38, 75, 135, 71, 75, 38, 43, - /* 1430 */ 132, 71, 75, 38, 22, 38, 38, 75, 75, 74, - /* 1440 */ 74, 74, 86, 75, 38, 75, 74, 86, 84, 22, - /* 1450 */ 74, 74, 38, 38, 38, 22, 22, 22, 38, 86, - /* 1460 */ 21, 21, 74, 38, 38, 74, 86, 75, 75, 75, - /* 1470 */ 74, 0, 51, 74, 85, 75, 75, 74, 74, 50, - /* 1480 */ 57, 38, 38, 38, 38, 38, 38, 74, 57, 38, - /* 1490 */ 38, 38, 74, 74, 38, 38, 72, 87, 38, 71, - /* 1500 */ 0, 38, 38, 36, 99, 36, 99, 99, 99, 43, - /* 1510 */ 38, 43, 0, 38, 36, 0, 43, 38, 36, 43, - /* 1520 */ 0, 38, 37, 0, 0, 22, 109, 22, 20, 313, - /* 1530 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1540 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1550 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1560 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1570 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1580 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1590 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1600 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1610 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1620 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1630 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1640 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1650 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1660 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1670 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1680 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1690 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1700 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1710 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1720 */ 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - /* 1730 */ 313, 313, 313, 313, 313, 313, + /* 0 */ 217, 277, 278, 219, 239, 261, 211, 1, 2, 226, + /* 10 */ 244, 4, 12, 13, 217, 239, 233, 251, 252, 227, + /* 20 */ 20, 256, 22, 226, 240, 242, 19, 235, 20, 256, + /* 30 */ 235, 211, 256, 268, 269, 243, 292, 242, 38, 242, + /* 40 */ 33, 268, 269, 36, 268, 269, 20, 252, 41, 305, + /* 50 */ 50, 256, 217, 309, 47, 235, 217, 57, 14, 15, + /* 60 */ 16, 49, 242, 12, 13, 14, 217, 272, 273, 274, + /* 70 */ 275, 20, 252, 22, 74, 226, 256, 12, 13, 259, + /* 80 */ 73, 75, 233, 76, 20, 20, 247, 22, 211, 38, + /* 90 */ 211, 242, 272, 273, 274, 275, 261, 97, 214, 215, + /* 100 */ 20, 50, 20, 38, 252, 310, 311, 255, 57, 109, + /* 110 */ 258, 217, 235, 221, 222, 50, 12, 13, 217, 242, + /* 120 */ 226, 210, 57, 212, 20, 74, 22, 292, 292, 252, + /* 130 */ 221, 222, 211, 256, 217, 256, 242, 132, 74, 74, + /* 140 */ 305, 305, 38, 242, 309, 309, 146, 0, 97, 272, + /* 150 */ 273, 274, 275, 276, 136, 150, 74, 280, 281, 242, + /* 160 */ 109, 57, 97, 163, 164, 165, 166, 167, 168, 169, + /* 170 */ 170, 171, 172, 173, 109, 217, 275, 256, 74, 174, + /* 180 */ 211, 12, 13, 14, 226, 185, 285, 286, 287, 20, + /* 190 */ 289, 22, 275, 185, 220, 185, 49, 146, 224, 235, + /* 200 */ 242, 97, 285, 286, 287, 241, 289, 38, 190, 191, + /* 210 */ 246, 146, 20, 109, 163, 164, 165, 166, 167, 168, + /* 220 */ 169, 170, 171, 172, 173, 256, 57, 0, 163, 164, + /* 230 */ 165, 166, 167, 168, 169, 170, 171, 172, 173, 145, + /* 240 */ 20, 147, 22, 74, 164, 165, 1, 2, 21, 185, + /* 250 */ 146, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 260 */ 40, 12, 13, 14, 15, 16, 97, 163, 164, 165, + /* 270 */ 166, 167, 168, 169, 170, 171, 172, 173, 109, 185, + /* 280 */ 20, 242, 219, 12, 13, 18, 216, 20, 249, 185, + /* 290 */ 52, 20, 54, 22, 27, 232, 58, 30, 211, 61, + /* 300 */ 230, 63, 64, 240, 66, 228, 39, 237, 231, 38, + /* 310 */ 12, 13, 14, 15, 16, 146, 21, 183, 184, 24, + /* 320 */ 25, 26, 27, 28, 29, 30, 31, 32, 57, 0, + /* 330 */ 67, 163, 163, 164, 165, 166, 167, 168, 169, 170, + /* 340 */ 171, 172, 173, 256, 20, 74, 61, 50, 50, 47, + /* 350 */ 65, 38, 49, 24, 25, 26, 27, 28, 29, 30, + /* 360 */ 31, 32, 194, 195, 196, 197, 198, 223, 97, 225, + /* 370 */ 57, 20, 87, 75, 35, 73, 113, 114, 76, 112, + /* 380 */ 109, 83, 115, 116, 117, 118, 119, 217, 121, 122, + /* 390 */ 123, 124, 125, 126, 127, 128, 129, 130, 131, 217, + /* 400 */ 61, 12, 13, 85, 65, 270, 217, 252, 226, 20, + /* 410 */ 270, 22, 242, 258, 235, 226, 77, 146, 79, 80, + /* 420 */ 241, 82, 235, 288, 242, 246, 87, 38, 288, 242, + /* 430 */ 132, 242, 164, 165, 163, 164, 165, 166, 167, 168, + /* 440 */ 169, 170, 171, 172, 173, 275, 57, 0, 150, 12, + /* 450 */ 13, 14, 15, 16, 284, 285, 286, 287, 0, 289, + /* 460 */ 163, 274, 138, 74, 20, 12, 13, 14, 15, 16, + /* 470 */ 270, 216, 174, 175, 176, 177, 178, 179, 180, 181, + /* 480 */ 182, 12, 13, 14, 15, 16, 97, 50, 288, 138, + /* 490 */ 14, 78, 237, 234, 81, 4, 20, 211, 109, 52, + /* 500 */ 53, 54, 55, 56, 245, 58, 59, 60, 61, 62, + /* 510 */ 63, 64, 65, 66, 67, 68, 69, 70, 78, 61, + /* 520 */ 83, 81, 57, 65, 88, 89, 90, 91, 92, 93, + /* 530 */ 94, 95, 96, 97, 98, 146, 100, 101, 102, 103, + /* 540 */ 104, 105, 256, 211, 75, 87, 18, 236, 208, 0, + /* 550 */ 43, 23, 163, 164, 165, 166, 167, 168, 169, 170, + /* 560 */ 171, 172, 173, 35, 106, 107, 108, 2, 110, 132, + /* 570 */ 78, 3, 2, 81, 22, 211, 48, 12, 13, 14, + /* 580 */ 15, 16, 12, 13, 14, 15, 16, 150, 256, 235, + /* 590 */ 38, 236, 139, 33, 0, 236, 36, 243, 49, 217, + /* 600 */ 217, 261, 42, 261, 44, 45, 46, 47, 226, 226, + /* 610 */ 235, 174, 175, 176, 177, 178, 179, 180, 181, 182, + /* 620 */ 256, 246, 236, 236, 242, 242, 142, 227, 236, 217, + /* 630 */ 12, 13, 292, 73, 292, 235, 76, 211, 226, 111, + /* 640 */ 22, 157, 211, 243, 0, 305, 52, 305, 54, 309, + /* 650 */ 78, 309, 58, 81, 242, 61, 38, 63, 64, 206, + /* 660 */ 66, 12, 13, 14, 15, 16, 235, 139, 140, 141, + /* 670 */ 235, 143, 264, 242, 71, 57, 148, 186, 75, 0, + /* 680 */ 36, 246, 256, 252, 156, 211, 158, 256, 160, 161, + /* 690 */ 162, 184, 261, 133, 227, 135, 71, 137, 211, 211, + /* 700 */ 75, 22, 235, 272, 273, 274, 275, 276, 236, 235, + /* 710 */ 243, 280, 281, 185, 154, 97, 242, 12, 13, 14, + /* 720 */ 15, 16, 235, 292, 75, 21, 252, 109, 217, 242, + /* 730 */ 256, 211, 211, 224, 71, 71, 305, 226, 34, 252, + /* 740 */ 309, 211, 217, 256, 256, 211, 272, 273, 274, 275, + /* 750 */ 276, 226, 235, 242, 280, 281, 282, 0, 241, 272, + /* 760 */ 273, 274, 275, 246, 146, 235, 19, 242, 294, 201, + /* 770 */ 217, 212, 242, 211, 300, 301, 256, 256, 38, 22, + /* 780 */ 33, 163, 252, 36, 22, 0, 256, 211, 211, 42, + /* 790 */ 256, 44, 45, 46, 47, 242, 211, 71, 311, 211, + /* 800 */ 38, 75, 272, 273, 274, 275, 276, 22, 312, 71, + /* 810 */ 280, 281, 282, 75, 261, 211, 211, 303, 256, 57, + /* 820 */ 73, 211, 71, 76, 211, 71, 75, 38, 275, 75, + /* 830 */ 252, 301, 256, 256, 74, 245, 252, 74, 285, 286, + /* 840 */ 287, 256, 289, 138, 256, 292, 86, 84, 235, 109, + /* 850 */ 71, 211, 71, 106, 75, 242, 75, 214, 305, 97, + /* 860 */ 256, 256, 309, 297, 271, 252, 256, 203, 205, 256, + /* 870 */ 71, 109, 71, 71, 75, 235, 75, 75, 211, 71, + /* 880 */ 235, 134, 242, 75, 137, 272, 273, 274, 275, 276, + /* 890 */ 290, 293, 252, 280, 281, 282, 256, 306, 109, 152, + /* 900 */ 20, 154, 235, 71, 291, 38, 71, 75, 146, 242, + /* 910 */ 75, 217, 272, 273, 274, 275, 276, 36, 267, 252, + /* 920 */ 280, 281, 282, 256, 57, 163, 71, 38, 211, 221, + /* 930 */ 75, 291, 71, 71, 144, 262, 75, 75, 217, 272, + /* 940 */ 273, 274, 275, 276, 217, 120, 250, 280, 281, 282, + /* 950 */ 132, 248, 235, 211, 248, 20, 217, 266, 291, 242, + /* 960 */ 20, 260, 219, 20, 242, 253, 20, 219, 219, 252, + /* 970 */ 217, 219, 213, 256, 242, 266, 235, 235, 261, 235, + /* 980 */ 211, 235, 253, 153, 242, 235, 213, 217, 265, 272, + /* 990 */ 273, 274, 275, 235, 252, 221, 235, 260, 256, 235, + /* 1000 */ 235, 235, 235, 235, 235, 20, 211, 216, 216, 292, + /* 1010 */ 193, 242, 302, 242, 272, 273, 274, 275, 276, 192, + /* 1020 */ 57, 252, 305, 281, 200, 256, 309, 271, 298, 257, + /* 1030 */ 235, 256, 211, 302, 257, 299, 256, 242, 256, 199, + /* 1040 */ 211, 272, 273, 274, 275, 276, 188, 252, 184, 280, + /* 1050 */ 281, 256, 187, 242, 259, 20, 235, 270, 120, 207, + /* 1060 */ 204, 283, 202, 242, 235, 74, 257, 272, 273, 274, + /* 1070 */ 275, 242, 296, 252, 211, 279, 256, 256, 295, 256, + /* 1080 */ 135, 252, 216, 257, 256, 256, 242, 211, 259, 216, + /* 1090 */ 254, 253, 242, 272, 273, 274, 275, 313, 235, 211, + /* 1100 */ 307, 272, 273, 274, 275, 242, 308, 238, 231, 225, + /* 1110 */ 74, 235, 221, 217, 216, 252, 213, 263, 242, 256, + /* 1120 */ 218, 229, 259, 235, 229, 304, 209, 0, 252, 0, + /* 1130 */ 242, 64, 256, 211, 0, 272, 273, 274, 275, 38, + /* 1140 */ 252, 159, 38, 38, 256, 38, 159, 0, 272, 273, + /* 1150 */ 274, 275, 38, 38, 159, 0, 38, 235, 0, 211, + /* 1160 */ 272, 273, 274, 275, 242, 0, 38, 74, 150, 149, + /* 1170 */ 109, 146, 0, 0, 252, 53, 142, 0, 256, 120, + /* 1180 */ 86, 0, 0, 235, 0, 211, 0, 0, 0, 0, + /* 1190 */ 242, 0, 0, 0, 272, 273, 274, 275, 0, 0, + /* 1200 */ 252, 0, 0, 0, 256, 22, 0, 0, 0, 235, + /* 1210 */ 211, 0, 0, 0, 0, 0, 242, 0, 0, 0, + /* 1220 */ 272, 273, 274, 275, 0, 0, 252, 0, 0, 0, + /* 1230 */ 256, 0, 0, 43, 235, 211, 51, 0, 0, 43, + /* 1240 */ 0, 242, 38, 43, 211, 36, 272, 273, 274, 275, + /* 1250 */ 0, 252, 0, 43, 38, 256, 36, 36, 0, 235, + /* 1260 */ 38, 38, 36, 0, 0, 0, 242, 22, 235, 0, + /* 1270 */ 0, 272, 273, 274, 275, 242, 252, 43, 83, 211, + /* 1280 */ 256, 38, 38, 22, 38, 252, 38, 38, 0, 256, + /* 1290 */ 22, 38, 38, 0, 39, 22, 272, 273, 274, 275, + /* 1300 */ 38, 0, 22, 235, 71, 272, 273, 274, 275, 0, + /* 1310 */ 242, 81, 71, 211, 22, 20, 0, 155, 138, 38, + /* 1320 */ 252, 0, 151, 0, 256, 22, 0, 0, 43, 189, + /* 1330 */ 74, 71, 138, 86, 75, 138, 183, 235, 71, 189, + /* 1340 */ 272, 273, 274, 275, 242, 71, 75, 211, 189, 74, + /* 1350 */ 74, 74, 86, 75, 252, 71, 211, 74, 256, 4, + /* 1360 */ 71, 75, 211, 38, 2, 75, 75, 71, 86, 133, + /* 1370 */ 135, 235, 38, 71, 272, 273, 274, 275, 242, 38, + /* 1380 */ 235, 0, 38, 38, 38, 86, 235, 242, 252, 75, + /* 1390 */ 211, 74, 256, 242, 75, 75, 74, 252, 0, 75, + /* 1400 */ 43, 256, 163, 252, 74, 74, 74, 256, 272, 273, + /* 1410 */ 274, 275, 74, 84, 235, 136, 211, 272, 273, 274, + /* 1420 */ 275, 242, 86, 272, 273, 274, 275, 133, 86, 22, + /* 1430 */ 74, 252, 85, 75, 38, 256, 75, 38, 74, 38, + /* 1440 */ 235, 74, 61, 75, 38, 74, 65, 242, 75, 38, + /* 1450 */ 74, 272, 273, 274, 275, 75, 38, 252, 74, 99, + /* 1460 */ 22, 256, 99, 74, 99, 99, 87, 38, 87, 74, + /* 1470 */ 38, 74, 22, 51, 50, 72, 57, 272, 273, 274, + /* 1480 */ 275, 109, 38, 71, 38, 38, 38, 106, 107, 108, + /* 1490 */ 38, 110, 38, 38, 22, 38, 57, 38, 38, 38, + /* 1500 */ 38, 38, 38, 38, 0, 38, 36, 0, 0, 43, + /* 1510 */ 36, 38, 43, 38, 36, 0, 36, 38, 0, 43, + /* 1520 */ 43, 38, 37, 0, 0, 22, 21, 314, 22, 314, + /* 1530 */ 20, 22, 21, 314, 314, 314, 314, 314, 314, 314, + /* 1540 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1550 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1560 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1570 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1580 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1590 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1600 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1610 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1620 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1630 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1640 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1650 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1660 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1670 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1680 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1690 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1700 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1710 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1720 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1730 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, + /* 1740 */ 314, }; -#define YY_SHIFT_COUNT (546) +#define YY_SHIFT_COUNT (547) #define YY_SHIFT_MIN (0) #define YY_SHIFT_MAX (1524) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 572, 0, 51, 64, 64, 64, 64, 167, 64, 64, - /* 10 */ 245, 408, 100, 231, 245, 245, 245, 245, 245, 245, - /* 20 */ 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, - /* 30 */ 245, 245, 245, 245, 192, 192, 192, 157, 678, 678, - /* 40 */ 62, 16, 16, 56, 678, 85, 85, 16, 16, 16, - /* 50 */ 16, 16, 16, 73, 26, 302, 56, 26, 16, 16, - /* 60 */ 26, 16, 26, 26, 26, 16, 309, 332, 454, 463, - /* 70 */ 463, 265, 445, 153, 134, 153, 153, 153, 153, 153, - /* 80 */ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - /* 90 */ 153, 153, 153, 153, 85, 384, 326, 218, 240, 240, - /* 100 */ 240, 567, 218, 345, 26, 26, 26, 61, 334, 39, - /* 110 */ 39, 39, 39, 39, 39, 39, 732, 126, 608, 940, - /* 120 */ 77, 85, 117, 85, 90, 513, 626, 520, 562, 520, - /* 130 */ 568, 679, 644, 853, 863, 851, 754, 853, 853, 789, - /* 140 */ 804, 804, 853, 927, 931, 73, 345, 941, 73, 73, - /* 150 */ 853, 73, 977, 26, 26, 26, 26, 26, 26, 26, - /* 160 */ 26, 26, 26, 26, 851, 853, 977, 345, 927, 887, - /* 170 */ 931, 309, 345, 941, 309, 1023, 855, 868, 1004, 855, - /* 180 */ 868, 1004, 1004, 877, 886, 898, 903, 908, 345, 1070, - /* 190 */ 976, 892, 900, 906, 1034, 26, 868, 1004, 1004, 868, - /* 200 */ 1004, 984, 345, 941, 309, 61, 309, 345, 1062, 851, - /* 210 */ 334, 853, 309, 977, 1529, 1529, 1529, 1529, 1529, 431, - /* 220 */ 884, 530, 577, 1149, 1201, 13, 29, 46, 526, 295, - /* 230 */ 643, 643, 643, 643, 643, 643, 643, 34, 234, 426, - /* 240 */ 547, 438, 426, 426, 426, 19, 574, 436, 121, 683, - /* 250 */ 703, 704, 772, 788, 800, 673, 592, 682, 742, 694, - /* 260 */ 640, 649, 665, 744, 687, 755, 378, 806, 811, 816, - /* 270 */ 844, 850, 801, 832, 861, 862, 867, 904, 914, 921, - /* 280 */ 696, 564, 1157, 1161, 1099, 1164, 1127, 1008, 1138, 1139, - /* 290 */ 1144, 1027, 1186, 1150, 1151, 1033, 1187, 1154, 1193, 1156, - /* 300 */ 1196, 1123, 1049, 1051, 1094, 1060, 1206, 1207, 1158, 1068, - /* 310 */ 1217, 1218, 1133, 1224, 1226, 1227, 1228, 1230, 1231, 1238, - /* 320 */ 1240, 1241, 1242, 1243, 1249, 1250, 1251, 1252, 1140, 1253, - /* 330 */ 1261, 1264, 1267, 1268, 1269, 1256, 1271, 1272, 1279, 1281, - /* 340 */ 1282, 1283, 1285, 1286, 1287, 1247, 1291, 1244, 1292, 1293, - /* 350 */ 1260, 1258, 1262, 1312, 1275, 1280, 1274, 1315, 1284, 1288, - /* 360 */ 1276, 1320, 1294, 1289, 1278, 1331, 1333, 1338, 1339, 1259, - /* 370 */ 1265, 1305, 1277, 1323, 1347, 1311, 1313, 1314, 1316, 1295, - /* 380 */ 1277, 1317, 1318, 1350, 1335, 1353, 1336, 1325, 1359, 1345, - /* 390 */ 1330, 1369, 1348, 1371, 1351, 1354, 1375, 1239, 1223, 1340, - /* 400 */ 1379, 1233, 1358, 1248, 1254, 1381, 1384, 1255, 1387, 1319, - /* 410 */ 1346, 1263, 1326, 1327, 1202, 1321, 1328, 1332, 1334, 1337, - /* 420 */ 1341, 1342, 1329, 1308, 1344, 1343, 1203, 1349, 1352, 1324, - /* 430 */ 1219, 1355, 1356, 1357, 1360, 1221, 1402, 1374, 1378, 1382, - /* 440 */ 1383, 1385, 1390, 1411, 1257, 1361, 1362, 1363, 1365, 1366, - /* 450 */ 1368, 1370, 1367, 1372, 1290, 1376, 1422, 1386, 1298, 1377, - /* 460 */ 1364, 1373, 1380, 1412, 1388, 1389, 1392, 1395, 1397, 1391, - /* 470 */ 1393, 1398, 1396, 1394, 1406, 1399, 1400, 1414, 1403, 1401, - /* 480 */ 1415, 1404, 1405, 1407, 1408, 1409, 1427, 1410, 1413, 1416, - /* 490 */ 1417, 1418, 1419, 1420, 1277, 1433, 1421, 1429, 1423, 1424, - /* 500 */ 1428, 1425, 1426, 1443, 1444, 1445, 1446, 1447, 1434, 1431, - /* 510 */ 1295, 1448, 1277, 1451, 1452, 1453, 1456, 1457, 1460, 1463, - /* 520 */ 1471, 1464, 1467, 1466, 1500, 1472, 1469, 1468, 1512, 1475, - /* 530 */ 1478, 1473, 1515, 1479, 1482, 1476, 1520, 1483, 1485, 1523, - /* 540 */ 1524, 1435, 1439, 1503, 1505, 1440, 1508, + /* 0 */ 528, 0, 51, 65, 65, 65, 65, 104, 65, 65, + /* 10 */ 271, 389, 64, 169, 271, 271, 271, 271, 271, 271, + /* 20 */ 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + /* 30 */ 271, 271, 271, 271, 82, 82, 82, 8, 618, 618, + /* 40 */ 94, 26, 26, 10, 618, 80, 80, 26, 26, 26, + /* 50 */ 26, 26, 26, 12, 192, 260, 10, 192, 26, 26, + /* 60 */ 192, 26, 192, 192, 192, 26, 303, 267, 298, 437, + /* 70 */ 437, 295, 339, 762, 238, 762, 762, 762, 762, 762, + /* 80 */ 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, + /* 90 */ 762, 762, 762, 762, 80, 220, 147, 313, 324, 324, + /* 100 */ 324, 549, 313, 444, 192, 192, 192, 318, 465, 436, + /* 110 */ 436, 436, 436, 436, 436, 436, 747, 227, 594, 453, + /* 120 */ 168, 80, 285, 80, 18, 552, 351, 134, 507, 134, + /* 130 */ 476, 568, 491, 880, 881, 889, 790, 880, 880, 825, + /* 140 */ 818, 818, 880, 935, 940, 12, 444, 943, 12, 12, + /* 150 */ 880, 12, 946, 192, 192, 192, 192, 192, 192, 192, + /* 160 */ 192, 192, 192, 192, 889, 880, 946, 444, 935, 830, + /* 170 */ 940, 303, 444, 943, 303, 985, 817, 827, 963, 817, + /* 180 */ 827, 963, 963, 824, 840, 858, 865, 864, 444, 1035, + /* 190 */ 938, 852, 856, 860, 991, 192, 827, 963, 963, 827, + /* 200 */ 963, 945, 444, 943, 303, 318, 303, 444, 1036, 889, + /* 210 */ 465, 880, 303, 946, 1533, 1533, 1533, 1533, 1533, 447, + /* 220 */ 560, 329, 7, 458, 1381, 469, 565, 570, 649, 705, + /* 230 */ 249, 249, 249, 249, 249, 249, 249, 302, 263, 44, + /* 240 */ 6, 5, 44, 44, 44, 644, 484, 603, 413, 440, + /* 250 */ 492, 572, 679, 757, 785, 704, 625, 726, 738, 245, + /* 260 */ 268, 664, 663, 751, 297, 754, 760, 781, 799, 801, + /* 270 */ 802, 808, 740, 789, 779, 832, 835, 855, 861, 862, + /* 280 */ 763, 867, 1127, 1129, 1067, 1134, 1101, 982, 1104, 1105, + /* 290 */ 1107, 987, 1147, 1114, 1115, 995, 1155, 1118, 1158, 1128, + /* 300 */ 1165, 1093, 1018, 1020, 1061, 1025, 1172, 1173, 1122, 1034, + /* 310 */ 1177, 1184, 1094, 1181, 1182, 1186, 1187, 1188, 1189, 1191, + /* 320 */ 1192, 1193, 1198, 1199, 1201, 1202, 1203, 1211, 1212, 1059, + /* 330 */ 1213, 1214, 1215, 1217, 1218, 1219, 1183, 1206, 1207, 1208, + /* 340 */ 1224, 1225, 1227, 1228, 1229, 1231, 1190, 1232, 1185, 1237, + /* 350 */ 1238, 1204, 1209, 1196, 1240, 1216, 1220, 1200, 1250, 1222, + /* 360 */ 1221, 1210, 1252, 1223, 1226, 1234, 1258, 1263, 1264, 1265, + /* 370 */ 1195, 1230, 1243, 1233, 1245, 1269, 1244, 1246, 1248, 1249, + /* 380 */ 1241, 1233, 1253, 1254, 1270, 1261, 1288, 1268, 1255, 1293, + /* 390 */ 1273, 1262, 1301, 1280, 1309, 1292, 1295, 1316, 1180, 1162, + /* 400 */ 1281, 1321, 1171, 1303, 1194, 1235, 1323, 1326, 1197, 1327, + /* 410 */ 1256, 1285, 1236, 1260, 1267, 1140, 1259, 1274, 1271, 1275, + /* 420 */ 1276, 1277, 1278, 1284, 1247, 1283, 1289, 1150, 1286, 1290, + /* 430 */ 1266, 1153, 1296, 1282, 1291, 1302, 1159, 1355, 1325, 1334, + /* 440 */ 1341, 1344, 1345, 1346, 1362, 1239, 1299, 1314, 1319, 1317, + /* 450 */ 1322, 1320, 1324, 1330, 1331, 1279, 1332, 1398, 1357, 1294, + /* 460 */ 1338, 1329, 1336, 1342, 1407, 1356, 1347, 1358, 1396, 1399, + /* 470 */ 1364, 1361, 1401, 1367, 1368, 1406, 1371, 1373, 1411, 1376, + /* 480 */ 1380, 1418, 1384, 1360, 1363, 1365, 1366, 1438, 1379, 1389, + /* 490 */ 1429, 1372, 1395, 1397, 1432, 1233, 1450, 1422, 1424, 1419, + /* 500 */ 1403, 1412, 1444, 1446, 1447, 1448, 1452, 1454, 1455, 1472, + /* 510 */ 1439, 1241, 1457, 1233, 1459, 1460, 1461, 1462, 1463, 1464, + /* 520 */ 1465, 1504, 1467, 1470, 1466, 1507, 1473, 1474, 1469, 1508, + /* 530 */ 1475, 1478, 1476, 1515, 1479, 1480, 1477, 1518, 1483, 1485, + /* 540 */ 1523, 1524, 1503, 1505, 1506, 1509, 1511, 1510, }; #define YY_REDUCE_COUNT (218) #define YY_REDUCE_MIN (-276) -#define YY_REDUCE_MAX (1131) +#define YY_REDUCE_MAX (1205) static const short yy_reduce_ofst[] = { - /* 0 */ -101, 413, 467, 518, 573, 621, 633, -204, -156, 693, - /* 10 */ 72, 586, 702, 115, 740, 729, 794, 799, 828, 292, - /* 20 */ 561, 854, 896, 901, 907, 949, 961, 974, 1003, 1029, - /* 30 */ 1055, 1063, 1089, 1131, -192, 151, 767, -23, -234, -215, - /* 40 */ -225, 22, 287, -49, -253, -246, -233, -209, -40, 36, - /* 50 */ 139, 144, 202, -128, 138, 80, -4, 289, 247, 293, - /* 60 */ 189, 368, 310, 352, 357, 373, 88, -207, -276, -276, - /* 70 */ -276, -28, 124, -61, 97, 108, 164, 216, 390, 394, - /* 80 */ 396, 415, 442, 451, 468, 469, 470, 471, 479, 488, - /* 90 */ 489, 495, 499, 503, 263, 260, 60, -108, -189, 92, - /* 100 */ 281, 169, 455, 197, 274, 188, 381, -155, 395, -232, - /* 110 */ 246, 286, 430, 514, 527, 551, 282, 544, 578, 498, - /* 120 */ 504, 560, 581, 570, 540, 629, 580, 575, 575, 575, - /* 130 */ 622, 566, 583, 662, 614, 670, 637, 700, 706, 675, - /* 140 */ 698, 699, 724, 684, 710, 741, 717, 719, 759, 760, - /* 150 */ 766, 776, 787, 771, 773, 781, 783, 785, 790, 791, - /* 160 */ 792, 793, 795, 796, 802, 805, 819, 782, 769, 778, - /* 170 */ 777, 829, 807, 808, 831, 786, 757, 818, 820, 762, - /* 180 */ 821, 825, 826, 784, 797, 798, 803, 575, 846, 823, - /* 190 */ 830, 809, 812, 810, 835, 622, 858, 860, 865, 866, - /* 200 */ 869, 857, 882, 879, 917, 899, 918, 893, 902, 920, - /* 210 */ 919, 922, 929, 934, 888, 925, 926, 938, 952, + /* 0 */ 340, 431, 474, 530, 613, 640, 667, 717, -123, 769, + /* 10 */ -205, 742, 553, -180, 795, 821, 487, 829, 863, 876, + /* 20 */ 888, 922, 948, 974, 999, 1024, 1033, 1068, 1102, 1136, + /* 30 */ 1145, 1151, 1179, 1205, 170, -99, -83, -165, -235, -224, + /* 40 */ -256, -217, -151, 342, -227, -148, -234, -203, -106, -42, + /* 50 */ 182, 189, 382, 63, -36, 187, -164, -208, 383, 412, + /* 60 */ 179, 511, 400, 517, 467, 525, 70, -161, -276, -276, + /* 70 */ -276, -89, 259, -121, -26, -79, -31, 87, 286, 332, + /* 80 */ 364, 426, 488, 520, 521, 534, 562, 576, 577, 585, + /* 90 */ 588, 604, 605, 610, 155, -116, -216, -108, 135, 140, + /* 100 */ 200, 255, -91, 39, 354, 375, 435, 77, 144, 311, + /* 110 */ 355, 359, 386, 387, 392, 472, 408, 559, 509, 496, + /* 120 */ 514, 578, 590, 584, 566, 643, 593, 600, 600, 600, + /* 130 */ 645, 591, 598, 694, 651, 708, 673, 721, 727, 696, + /* 140 */ 703, 706, 739, 691, 701, 743, 722, 712, 748, 749, + /* 150 */ 753, 752, 759, 741, 744, 746, 750, 758, 761, 764, + /* 160 */ 765, 766, 767, 768, 774, 770, 773, 732, 709, 723, + /* 170 */ 737, 791, 771, 729, 792, 756, 710, 772, 775, 731, + /* 180 */ 777, 780, 782, 736, 730, 776, 783, 600, 811, 787, + /* 190 */ 778, 784, 798, 793, 796, 645, 809, 820, 823, 826, + /* 200 */ 828, 836, 844, 838, 866, 877, 873, 850, 869, 891, + /* 210 */ 884, 896, 898, 903, 854, 892, 895, 902, 917, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 10 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 20 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 30 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 40 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 50 */ 1215, 1215, 1215, 1274, 1215, 1215, 1215, 1215, 1215, 1215, - /* 60 */ 1215, 1215, 1215, 1215, 1215, 1215, 1272, 1411, 1215, 1546, - /* 70 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 80 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 90 */ 1215, 1215, 1215, 1215, 1215, 1215, 1274, 1215, 1557, 1557, - /* 100 */ 1557, 1272, 1215, 1215, 1215, 1215, 1215, 1367, 1215, 1215, - /* 110 */ 1215, 1215, 1215, 1215, 1215, 1215, 1445, 1215, 1215, 1621, - /* 120 */ 1215, 1215, 1320, 1215, 1581, 1215, 1573, 1549, 1563, 1550, - /* 130 */ 1215, 1606, 1566, 1215, 1215, 1215, 1437, 1215, 1215, 1416, - /* 140 */ 1413, 1413, 1215, 1215, 1215, 1274, 1215, 1215, 1274, 1274, - /* 150 */ 1215, 1274, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 160 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1447, - /* 170 */ 1215, 1272, 1215, 1215, 1272, 1215, 1588, 1586, 1215, 1588, - /* 180 */ 1586, 1215, 1215, 1600, 1596, 1579, 1577, 1563, 1215, 1215, - /* 190 */ 1215, 1624, 1612, 1608, 1215, 1215, 1586, 1215, 1215, 1586, - /* 200 */ 1215, 1424, 1215, 1215, 1272, 1215, 1272, 1215, 1336, 1215, - /* 210 */ 1215, 1215, 1272, 1215, 1439, 1370, 1370, 1275, 1220, 1215, - /* 220 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1509, - /* 230 */ 1510, 1599, 1598, 1509, 1523, 1522, 1521, 1215, 1215, 1504, - /* 240 */ 1215, 1215, 1505, 1503, 1502, 1215, 1215, 1215, 1215, 1215, - /* 250 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1547, - /* 260 */ 1215, 1609, 1613, 1215, 1215, 1215, 1484, 1215, 1215, 1215, - /* 270 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 280 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 290 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 300 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 310 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 320 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 330 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 340 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 350 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 360 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 370 */ 1215, 1215, 1381, 1215, 1215, 1215, 1215, 1215, 1215, 1301, - /* 380 */ 1300, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 390 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 400 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 410 */ 1215, 1215, 1570, 1580, 1215, 1215, 1215, 1215, 1215, 1215, - /* 420 */ 1215, 1215, 1215, 1484, 1215, 1597, 1215, 1556, 1552, 1215, - /* 430 */ 1215, 1548, 1215, 1215, 1607, 1215, 1215, 1215, 1215, 1215, - /* 440 */ 1215, 1215, 1215, 1542, 1215, 1215, 1215, 1215, 1215, 1215, - /* 450 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 460 */ 1215, 1483, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1364, - /* 470 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 480 */ 1215, 1215, 1349, 1347, 1346, 1345, 1215, 1342, 1215, 1215, - /* 490 */ 1215, 1215, 1215, 1215, 1372, 1215, 1215, 1215, 1215, 1215, - /* 500 */ 1295, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 510 */ 1286, 1215, 1285, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 520 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 530 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, 1215, - /* 540 */ 1215, 1215, 1215, 1215, 1215, 1215, 1215, + /* 0 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 10 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 20 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 30 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 40 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 50 */ 1217, 1217, 1217, 1276, 1217, 1217, 1217, 1217, 1217, 1217, + /* 60 */ 1217, 1217, 1217, 1217, 1217, 1217, 1274, 1414, 1217, 1549, + /* 70 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 80 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 90 */ 1217, 1217, 1217, 1217, 1217, 1217, 1276, 1217, 1560, 1560, + /* 100 */ 1560, 1274, 1217, 1217, 1217, 1217, 1217, 1369, 1217, 1217, + /* 110 */ 1217, 1217, 1217, 1217, 1217, 1217, 1448, 1217, 1217, 1624, + /* 120 */ 1217, 1217, 1322, 1217, 1584, 1217, 1576, 1552, 1566, 1553, + /* 130 */ 1217, 1609, 1569, 1217, 1217, 1217, 1440, 1217, 1217, 1419, + /* 140 */ 1416, 1416, 1217, 1217, 1217, 1276, 1217, 1217, 1276, 1276, + /* 150 */ 1217, 1276, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 160 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1450, + /* 170 */ 1217, 1274, 1217, 1217, 1274, 1217, 1591, 1589, 1217, 1591, + /* 180 */ 1589, 1217, 1217, 1603, 1599, 1582, 1580, 1566, 1217, 1217, + /* 190 */ 1217, 1627, 1615, 1611, 1217, 1217, 1589, 1217, 1217, 1589, + /* 200 */ 1217, 1427, 1217, 1217, 1274, 1217, 1274, 1217, 1338, 1217, + /* 210 */ 1217, 1217, 1274, 1217, 1442, 1372, 1372, 1277, 1222, 1217, + /* 220 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1512, + /* 230 */ 1513, 1602, 1601, 1512, 1526, 1525, 1524, 1217, 1217, 1507, + /* 240 */ 1217, 1217, 1508, 1506, 1505, 1217, 1217, 1217, 1217, 1217, + /* 250 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1550, + /* 260 */ 1217, 1612, 1616, 1217, 1217, 1217, 1487, 1217, 1217, 1217, + /* 270 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 280 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 290 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 300 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 310 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 320 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 330 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 340 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 350 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 360 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 370 */ 1217, 1217, 1217, 1383, 1217, 1217, 1217, 1217, 1217, 1217, + /* 380 */ 1303, 1302, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 390 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 400 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 410 */ 1217, 1217, 1217, 1573, 1583, 1217, 1217, 1217, 1217, 1217, + /* 420 */ 1217, 1217, 1217, 1217, 1487, 1217, 1600, 1217, 1559, 1555, + /* 430 */ 1217, 1217, 1551, 1217, 1217, 1610, 1217, 1217, 1217, 1217, + /* 440 */ 1217, 1217, 1217, 1217, 1545, 1217, 1217, 1217, 1217, 1217, + /* 450 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 460 */ 1217, 1217, 1486, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 470 */ 1366, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 480 */ 1217, 1217, 1217, 1351, 1349, 1348, 1347, 1217, 1344, 1217, + /* 490 */ 1217, 1217, 1217, 1217, 1217, 1374, 1217, 1217, 1217, 1217, + /* 500 */ 1217, 1297, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 510 */ 1217, 1288, 1217, 1287, 1217, 1217, 1217, 1217, 1217, 1217, + /* 520 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 530 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, + /* 540 */ 1217, 1217, 1217, 1217, 1217, 1217, 1217, 1217, }; /********** End of lemon-generated parsing tables *****************************/ @@ -916,194 +917,195 @@ static const char *const yyTokenName[] = { /* 122 */ "APPS", /* 123 */ "CONNECTIONS", /* 124 */ "LICENCE", - /* 125 */ "QUERIES", - /* 126 */ "SCORES", - /* 127 */ "TOPICS", - /* 128 */ "VARIABLES", - /* 129 */ "BNODES", - /* 130 */ "SNODES", - /* 131 */ "LIKE", - /* 132 */ "INDEX", - /* 133 */ "FULLTEXT", - /* 134 */ "FUNCTION", - /* 135 */ "INTERVAL", - /* 136 */ "TOPIC", - /* 137 */ "AS", - /* 138 */ "DESC", - /* 139 */ "DESCRIBE", - /* 140 */ "RESET", - /* 141 */ "QUERY", - /* 142 */ "EXPLAIN", - /* 143 */ "ANALYZE", - /* 144 */ "VERBOSE", - /* 145 */ "NK_BOOL", - /* 146 */ "RATIO", - /* 147 */ "COMPACT", - /* 148 */ "VNODES", - /* 149 */ "IN", - /* 150 */ "OUTPUTTYPE", - /* 151 */ "AGGREGATE", - /* 152 */ "BUFSIZE", - /* 153 */ "STREAM", - /* 154 */ "INTO", - /* 155 */ "KILL", - /* 156 */ "CONNECTION", - /* 157 */ "MERGE", - /* 158 */ "VGROUP", - /* 159 */ "REDISTRIBUTE", - /* 160 */ "SPLIT", - /* 161 */ "SYNCDB", - /* 162 */ "NULL", - /* 163 */ "FIRST", - /* 164 */ "LAST", - /* 165 */ "NOW", - /* 166 */ "ROWTS", - /* 167 */ "TBNAME", - /* 168 */ "QSTARTTS", - /* 169 */ "QENDTS", - /* 170 */ "WSTARTTS", - /* 171 */ "WENDTS", - /* 172 */ "WDURATION", - /* 173 */ "BETWEEN", - /* 174 */ "IS", - /* 175 */ "NK_LT", - /* 176 */ "NK_GT", - /* 177 */ "NK_LE", - /* 178 */ "NK_GE", - /* 179 */ "NK_NE", - /* 180 */ "MATCH", - /* 181 */ "NMATCH", - /* 182 */ "JOIN", - /* 183 */ "INNER", - /* 184 */ "SELECT", - /* 185 */ "DISTINCT", - /* 186 */ "WHERE", - /* 187 */ "PARTITION", - /* 188 */ "BY", - /* 189 */ "SESSION", - /* 190 */ "STATE_WINDOW", - /* 191 */ "SLIDING", - /* 192 */ "FILL", - /* 193 */ "VALUE", - /* 194 */ "NONE", - /* 195 */ "PREV", - /* 196 */ "LINEAR", - /* 197 */ "NEXT", - /* 198 */ "GROUP", - /* 199 */ "HAVING", - /* 200 */ "ORDER", - /* 201 */ "SLIMIT", - /* 202 */ "SOFFSET", - /* 203 */ "LIMIT", - /* 204 */ "OFFSET", - /* 205 */ "ASC", - /* 206 */ "NULLS", - /* 207 */ "cmd", - /* 208 */ "account_options", - /* 209 */ "alter_account_options", - /* 210 */ "literal", - /* 211 */ "alter_account_option", - /* 212 */ "user_name", - /* 213 */ "dnode_endpoint", - /* 214 */ "dnode_host_name", - /* 215 */ "not_exists_opt", - /* 216 */ "db_name", - /* 217 */ "db_options", - /* 218 */ "exists_opt", - /* 219 */ "alter_db_options", - /* 220 */ "integer_list", - /* 221 */ "variable_list", - /* 222 */ "retention_list", - /* 223 */ "alter_db_option", - /* 224 */ "retention", - /* 225 */ "full_table_name", - /* 226 */ "column_def_list", - /* 227 */ "tags_def_opt", - /* 228 */ "table_options", - /* 229 */ "multi_create_clause", - /* 230 */ "tags_def", - /* 231 */ "multi_drop_clause", - /* 232 */ "alter_table_clause", - /* 233 */ "alter_table_options", - /* 234 */ "column_name", - /* 235 */ "type_name", - /* 236 */ "create_subtable_clause", - /* 237 */ "specific_tags_opt", - /* 238 */ "literal_list", - /* 239 */ "drop_table_clause", - /* 240 */ "col_name_list", - /* 241 */ "table_name", - /* 242 */ "column_def", - /* 243 */ "func_name_list", - /* 244 */ "alter_table_option", - /* 245 */ "col_name", - /* 246 */ "db_name_cond_opt", - /* 247 */ "like_pattern_opt", - /* 248 */ "table_name_cond", - /* 249 */ "from_db_opt", - /* 250 */ "func_name", - /* 251 */ "function_name", - /* 252 */ "index_name", - /* 253 */ "index_options", - /* 254 */ "func_list", - /* 255 */ "duration_literal", - /* 256 */ "sliding_opt", - /* 257 */ "func", - /* 258 */ "expression_list", - /* 259 */ "topic_name", - /* 260 */ "query_expression", - /* 261 */ "analyze_opt", - /* 262 */ "explain_options", - /* 263 */ "agg_func_opt", - /* 264 */ "bufsize_opt", - /* 265 */ "stream_name", - /* 266 */ "dnode_list", - /* 267 */ "signed", - /* 268 */ "signed_literal", - /* 269 */ "table_alias", - /* 270 */ "column_alias", - /* 271 */ "expression", - /* 272 */ "pseudo_column", - /* 273 */ "column_reference", - /* 274 */ "subquery", - /* 275 */ "predicate", - /* 276 */ "compare_op", - /* 277 */ "in_op", - /* 278 */ "in_predicate_value", - /* 279 */ "boolean_value_expression", - /* 280 */ "boolean_primary", - /* 281 */ "common_expression", - /* 282 */ "from_clause", - /* 283 */ "table_reference_list", - /* 284 */ "table_reference", - /* 285 */ "table_primary", - /* 286 */ "joined_table", - /* 287 */ "alias_opt", - /* 288 */ "parenthesized_joined_table", - /* 289 */ "join_type", - /* 290 */ "search_condition", - /* 291 */ "query_specification", - /* 292 */ "set_quantifier_opt", - /* 293 */ "select_list", - /* 294 */ "where_clause_opt", - /* 295 */ "partition_by_clause_opt", - /* 296 */ "twindow_clause_opt", - /* 297 */ "group_by_clause_opt", - /* 298 */ "having_clause_opt", - /* 299 */ "select_sublist", - /* 300 */ "select_item", - /* 301 */ "fill_opt", - /* 302 */ "fill_mode", - /* 303 */ "group_by_list", - /* 304 */ "query_expression_body", - /* 305 */ "order_by_clause_opt", - /* 306 */ "slimit_clause_opt", - /* 307 */ "limit_clause_opt", - /* 308 */ "query_primary", - /* 309 */ "sort_specification_list", - /* 310 */ "sort_specification", - /* 311 */ "ordering_specification_opt", - /* 312 */ "null_ordering_opt", + /* 125 */ "GRANTS", + /* 126 */ "QUERIES", + /* 127 */ "SCORES", + /* 128 */ "TOPICS", + /* 129 */ "VARIABLES", + /* 130 */ "BNODES", + /* 131 */ "SNODES", + /* 132 */ "LIKE", + /* 133 */ "INDEX", + /* 134 */ "FULLTEXT", + /* 135 */ "FUNCTION", + /* 136 */ "INTERVAL", + /* 137 */ "TOPIC", + /* 138 */ "AS", + /* 139 */ "DESC", + /* 140 */ "DESCRIBE", + /* 141 */ "RESET", + /* 142 */ "QUERY", + /* 143 */ "EXPLAIN", + /* 144 */ "ANALYZE", + /* 145 */ "VERBOSE", + /* 146 */ "NK_BOOL", + /* 147 */ "RATIO", + /* 148 */ "COMPACT", + /* 149 */ "VNODES", + /* 150 */ "IN", + /* 151 */ "OUTPUTTYPE", + /* 152 */ "AGGREGATE", + /* 153 */ "BUFSIZE", + /* 154 */ "STREAM", + /* 155 */ "INTO", + /* 156 */ "KILL", + /* 157 */ "CONNECTION", + /* 158 */ "MERGE", + /* 159 */ "VGROUP", + /* 160 */ "REDISTRIBUTE", + /* 161 */ "SPLIT", + /* 162 */ "SYNCDB", + /* 163 */ "NULL", + /* 164 */ "FIRST", + /* 165 */ "LAST", + /* 166 */ "NOW", + /* 167 */ "ROWTS", + /* 168 */ "TBNAME", + /* 169 */ "QSTARTTS", + /* 170 */ "QENDTS", + /* 171 */ "WSTARTTS", + /* 172 */ "WENDTS", + /* 173 */ "WDURATION", + /* 174 */ "BETWEEN", + /* 175 */ "IS", + /* 176 */ "NK_LT", + /* 177 */ "NK_GT", + /* 178 */ "NK_LE", + /* 179 */ "NK_GE", + /* 180 */ "NK_NE", + /* 181 */ "MATCH", + /* 182 */ "NMATCH", + /* 183 */ "JOIN", + /* 184 */ "INNER", + /* 185 */ "SELECT", + /* 186 */ "DISTINCT", + /* 187 */ "WHERE", + /* 188 */ "PARTITION", + /* 189 */ "BY", + /* 190 */ "SESSION", + /* 191 */ "STATE_WINDOW", + /* 192 */ "SLIDING", + /* 193 */ "FILL", + /* 194 */ "VALUE", + /* 195 */ "NONE", + /* 196 */ "PREV", + /* 197 */ "LINEAR", + /* 198 */ "NEXT", + /* 199 */ "GROUP", + /* 200 */ "HAVING", + /* 201 */ "ORDER", + /* 202 */ "SLIMIT", + /* 203 */ "SOFFSET", + /* 204 */ "LIMIT", + /* 205 */ "OFFSET", + /* 206 */ "ASC", + /* 207 */ "NULLS", + /* 208 */ "cmd", + /* 209 */ "account_options", + /* 210 */ "alter_account_options", + /* 211 */ "literal", + /* 212 */ "alter_account_option", + /* 213 */ "user_name", + /* 214 */ "dnode_endpoint", + /* 215 */ "dnode_host_name", + /* 216 */ "not_exists_opt", + /* 217 */ "db_name", + /* 218 */ "db_options", + /* 219 */ "exists_opt", + /* 220 */ "alter_db_options", + /* 221 */ "integer_list", + /* 222 */ "variable_list", + /* 223 */ "retention_list", + /* 224 */ "alter_db_option", + /* 225 */ "retention", + /* 226 */ "full_table_name", + /* 227 */ "column_def_list", + /* 228 */ "tags_def_opt", + /* 229 */ "table_options", + /* 230 */ "multi_create_clause", + /* 231 */ "tags_def", + /* 232 */ "multi_drop_clause", + /* 233 */ "alter_table_clause", + /* 234 */ "alter_table_options", + /* 235 */ "column_name", + /* 236 */ "type_name", + /* 237 */ "create_subtable_clause", + /* 238 */ "specific_tags_opt", + /* 239 */ "literal_list", + /* 240 */ "drop_table_clause", + /* 241 */ "col_name_list", + /* 242 */ "table_name", + /* 243 */ "column_def", + /* 244 */ "func_name_list", + /* 245 */ "alter_table_option", + /* 246 */ "col_name", + /* 247 */ "db_name_cond_opt", + /* 248 */ "like_pattern_opt", + /* 249 */ "table_name_cond", + /* 250 */ "from_db_opt", + /* 251 */ "func_name", + /* 252 */ "function_name", + /* 253 */ "index_name", + /* 254 */ "index_options", + /* 255 */ "func_list", + /* 256 */ "duration_literal", + /* 257 */ "sliding_opt", + /* 258 */ "func", + /* 259 */ "expression_list", + /* 260 */ "topic_name", + /* 261 */ "query_expression", + /* 262 */ "analyze_opt", + /* 263 */ "explain_options", + /* 264 */ "agg_func_opt", + /* 265 */ "bufsize_opt", + /* 266 */ "stream_name", + /* 267 */ "dnode_list", + /* 268 */ "signed", + /* 269 */ "signed_literal", + /* 270 */ "table_alias", + /* 271 */ "column_alias", + /* 272 */ "expression", + /* 273 */ "pseudo_column", + /* 274 */ "column_reference", + /* 275 */ "subquery", + /* 276 */ "predicate", + /* 277 */ "compare_op", + /* 278 */ "in_op", + /* 279 */ "in_predicate_value", + /* 280 */ "boolean_value_expression", + /* 281 */ "boolean_primary", + /* 282 */ "common_expression", + /* 283 */ "from_clause", + /* 284 */ "table_reference_list", + /* 285 */ "table_reference", + /* 286 */ "table_primary", + /* 287 */ "joined_table", + /* 288 */ "alias_opt", + /* 289 */ "parenthesized_joined_table", + /* 290 */ "join_type", + /* 291 */ "search_condition", + /* 292 */ "query_specification", + /* 293 */ "set_quantifier_opt", + /* 294 */ "select_list", + /* 295 */ "where_clause_opt", + /* 296 */ "partition_by_clause_opt", + /* 297 */ "twindow_clause_opt", + /* 298 */ "group_by_clause_opt", + /* 299 */ "having_clause_opt", + /* 300 */ "select_sublist", + /* 301 */ "select_item", + /* 302 */ "fill_opt", + /* 303 */ "fill_mode", + /* 304 */ "group_by_list", + /* 305 */ "query_expression_body", + /* 306 */ "order_by_clause_opt", + /* 307 */ "slimit_clause_opt", + /* 308 */ "limit_clause_opt", + /* 309 */ "query_primary", + /* 310 */ "sort_specification_list", + /* 311 */ "sort_specification", + /* 312 */ "ordering_specification_opt", + /* 313 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1295,231 +1297,232 @@ static const char *const yyRuleName[] = { /* 181 */ "cmd ::= SHOW APPS", /* 182 */ "cmd ::= SHOW CONNECTIONS", /* 183 */ "cmd ::= SHOW LICENCE", - /* 184 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 185 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 186 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 187 */ "cmd ::= SHOW QUERIES", - /* 188 */ "cmd ::= SHOW SCORES", - /* 189 */ "cmd ::= SHOW TOPICS", - /* 190 */ "cmd ::= SHOW VARIABLES", - /* 191 */ "cmd ::= SHOW BNODES", - /* 192 */ "cmd ::= SHOW SNODES", - /* 193 */ "db_name_cond_opt ::=", - /* 194 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 195 */ "like_pattern_opt ::=", - /* 196 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 197 */ "table_name_cond ::= table_name", - /* 198 */ "from_db_opt ::=", - /* 199 */ "from_db_opt ::= FROM db_name", - /* 200 */ "func_name_list ::= func_name", - /* 201 */ "func_name_list ::= func_name_list NK_COMMA col_name", - /* 202 */ "func_name ::= function_name", - /* 203 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 204 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", - /* 205 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", - /* 206 */ "index_options ::=", - /* 207 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 208 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 209 */ "func_list ::= func", - /* 210 */ "func_list ::= func_list NK_COMMA func", - /* 211 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 212 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 213 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", - /* 214 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 215 */ "cmd ::= DESC full_table_name", - /* 216 */ "cmd ::= DESCRIBE full_table_name", - /* 217 */ "cmd ::= RESET QUERY CACHE", - /* 218 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 219 */ "analyze_opt ::=", - /* 220 */ "analyze_opt ::= ANALYZE", - /* 221 */ "explain_options ::=", - /* 222 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 223 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 224 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", - /* 225 */ "cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 226 */ "cmd ::= DROP FUNCTION function_name", - /* 227 */ "agg_func_opt ::=", - /* 228 */ "agg_func_opt ::= AGGREGATE", - /* 229 */ "bufsize_opt ::=", - /* 230 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 231 */ "cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression", - /* 232 */ "cmd ::= DROP STREAM stream_name", - /* 233 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 234 */ "cmd ::= KILL QUERY NK_INTEGER", - /* 235 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 236 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 237 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 238 */ "dnode_list ::= DNODE NK_INTEGER", - /* 239 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 240 */ "cmd ::= SYNCDB db_name REPLICA", - /* 241 */ "cmd ::= query_expression", - /* 242 */ "literal ::= NK_INTEGER", - /* 243 */ "literal ::= NK_FLOAT", - /* 244 */ "literal ::= NK_STRING", - /* 245 */ "literal ::= NK_BOOL", - /* 246 */ "literal ::= TIMESTAMP NK_STRING", - /* 247 */ "literal ::= duration_literal", - /* 248 */ "literal ::= NULL", - /* 249 */ "duration_literal ::= NK_VARIABLE", - /* 250 */ "signed ::= NK_INTEGER", - /* 251 */ "signed ::= NK_PLUS NK_INTEGER", - /* 252 */ "signed ::= NK_MINUS NK_INTEGER", - /* 253 */ "signed ::= NK_FLOAT", - /* 254 */ "signed ::= NK_PLUS NK_FLOAT", - /* 255 */ "signed ::= NK_MINUS NK_FLOAT", - /* 256 */ "signed_literal ::= signed", - /* 257 */ "signed_literal ::= NK_STRING", - /* 258 */ "signed_literal ::= NK_BOOL", - /* 259 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 260 */ "signed_literal ::= duration_literal", - /* 261 */ "signed_literal ::= NULL", - /* 262 */ "literal_list ::= signed_literal", - /* 263 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 264 */ "db_name ::= NK_ID", - /* 265 */ "table_name ::= NK_ID", - /* 266 */ "column_name ::= NK_ID", - /* 267 */ "function_name ::= NK_ID", - /* 268 */ "function_name ::= FIRST", - /* 269 */ "function_name ::= LAST", - /* 270 */ "table_alias ::= NK_ID", - /* 271 */ "column_alias ::= NK_ID", - /* 272 */ "user_name ::= NK_ID", - /* 273 */ "index_name ::= NK_ID", - /* 274 */ "topic_name ::= NK_ID", - /* 275 */ "stream_name ::= NK_ID", - /* 276 */ "expression ::= literal", - /* 277 */ "expression ::= pseudo_column", - /* 278 */ "expression ::= column_reference", - /* 279 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 280 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 281 */ "expression ::= function_name NK_LP expression AS type_name NK_RP", - /* 282 */ "expression ::= subquery", - /* 283 */ "expression ::= NK_LP expression NK_RP", - /* 284 */ "expression ::= NK_PLUS expression", - /* 285 */ "expression ::= NK_MINUS expression", - /* 286 */ "expression ::= expression NK_PLUS expression", - /* 287 */ "expression ::= expression NK_MINUS expression", - /* 288 */ "expression ::= expression NK_STAR expression", - /* 289 */ "expression ::= expression NK_SLASH expression", - /* 290 */ "expression ::= expression NK_REM expression", - /* 291 */ "expression_list ::= expression", - /* 292 */ "expression_list ::= expression_list NK_COMMA expression", - /* 293 */ "column_reference ::= column_name", - /* 294 */ "column_reference ::= table_name NK_DOT column_name", - /* 295 */ "pseudo_column ::= NOW", - /* 296 */ "pseudo_column ::= ROWTS", - /* 297 */ "pseudo_column ::= TBNAME", - /* 298 */ "pseudo_column ::= QSTARTTS", - /* 299 */ "pseudo_column ::= QENDTS", - /* 300 */ "pseudo_column ::= WSTARTTS", - /* 301 */ "pseudo_column ::= WENDTS", - /* 302 */ "pseudo_column ::= WDURATION", - /* 303 */ "predicate ::= expression compare_op expression", - /* 304 */ "predicate ::= expression BETWEEN expression AND expression", - /* 305 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 306 */ "predicate ::= expression IS NULL", - /* 307 */ "predicate ::= expression IS NOT NULL", - /* 308 */ "predicate ::= expression in_op in_predicate_value", - /* 309 */ "compare_op ::= NK_LT", - /* 310 */ "compare_op ::= NK_GT", - /* 311 */ "compare_op ::= NK_LE", - /* 312 */ "compare_op ::= NK_GE", - /* 313 */ "compare_op ::= NK_NE", - /* 314 */ "compare_op ::= NK_EQ", - /* 315 */ "compare_op ::= LIKE", - /* 316 */ "compare_op ::= NOT LIKE", - /* 317 */ "compare_op ::= MATCH", - /* 318 */ "compare_op ::= NMATCH", - /* 319 */ "in_op ::= IN", - /* 320 */ "in_op ::= NOT IN", - /* 321 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 322 */ "boolean_value_expression ::= boolean_primary", - /* 323 */ "boolean_value_expression ::= NOT boolean_primary", - /* 324 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 325 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 326 */ "boolean_primary ::= predicate", - /* 327 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 328 */ "common_expression ::= expression", - /* 329 */ "common_expression ::= boolean_value_expression", - /* 330 */ "from_clause ::= FROM table_reference_list", - /* 331 */ "table_reference_list ::= table_reference", - /* 332 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 333 */ "table_reference ::= table_primary", - /* 334 */ "table_reference ::= joined_table", - /* 335 */ "table_primary ::= table_name alias_opt", - /* 336 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 337 */ "table_primary ::= subquery alias_opt", - /* 338 */ "table_primary ::= parenthesized_joined_table", - /* 339 */ "alias_opt ::=", - /* 340 */ "alias_opt ::= table_alias", - /* 341 */ "alias_opt ::= AS table_alias", - /* 342 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 343 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 344 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 345 */ "join_type ::=", - /* 346 */ "join_type ::= INNER", - /* 347 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 348 */ "set_quantifier_opt ::=", - /* 349 */ "set_quantifier_opt ::= DISTINCT", - /* 350 */ "set_quantifier_opt ::= ALL", - /* 351 */ "select_list ::= NK_STAR", - /* 352 */ "select_list ::= select_sublist", - /* 353 */ "select_sublist ::= select_item", - /* 354 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 355 */ "select_item ::= common_expression", - /* 356 */ "select_item ::= common_expression column_alias", - /* 357 */ "select_item ::= common_expression AS column_alias", - /* 358 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 359 */ "where_clause_opt ::=", - /* 360 */ "where_clause_opt ::= WHERE search_condition", - /* 361 */ "partition_by_clause_opt ::=", - /* 362 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 363 */ "twindow_clause_opt ::=", - /* 364 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 365 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 366 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 367 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 368 */ "sliding_opt ::=", - /* 369 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 370 */ "fill_opt ::=", - /* 371 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 372 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 373 */ "fill_mode ::= NONE", - /* 374 */ "fill_mode ::= PREV", - /* 375 */ "fill_mode ::= NULL", - /* 376 */ "fill_mode ::= LINEAR", - /* 377 */ "fill_mode ::= NEXT", - /* 378 */ "group_by_clause_opt ::=", - /* 379 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 380 */ "group_by_list ::= expression", - /* 381 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 382 */ "having_clause_opt ::=", - /* 383 */ "having_clause_opt ::= HAVING search_condition", - /* 384 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 385 */ "query_expression_body ::= query_primary", - /* 386 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 387 */ "query_primary ::= query_specification", - /* 388 */ "order_by_clause_opt ::=", - /* 389 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 390 */ "slimit_clause_opt ::=", - /* 391 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 392 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 393 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 394 */ "limit_clause_opt ::=", - /* 395 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 396 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 397 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 398 */ "subquery ::= NK_LP query_expression NK_RP", - /* 399 */ "search_condition ::= common_expression", - /* 400 */ "sort_specification_list ::= sort_specification", - /* 401 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 402 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 403 */ "ordering_specification_opt ::=", - /* 404 */ "ordering_specification_opt ::= ASC", - /* 405 */ "ordering_specification_opt ::= DESC", - /* 406 */ "null_ordering_opt ::=", - /* 407 */ "null_ordering_opt ::= NULLS FIRST", - /* 408 */ "null_ordering_opt ::= NULLS LAST", + /* 184 */ "cmd ::= SHOW GRANTS", + /* 185 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 186 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 187 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 188 */ "cmd ::= SHOW QUERIES", + /* 189 */ "cmd ::= SHOW SCORES", + /* 190 */ "cmd ::= SHOW TOPICS", + /* 191 */ "cmd ::= SHOW VARIABLES", + /* 192 */ "cmd ::= SHOW BNODES", + /* 193 */ "cmd ::= SHOW SNODES", + /* 194 */ "db_name_cond_opt ::=", + /* 195 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 196 */ "like_pattern_opt ::=", + /* 197 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 198 */ "table_name_cond ::= table_name", + /* 199 */ "from_db_opt ::=", + /* 200 */ "from_db_opt ::= FROM db_name", + /* 201 */ "func_name_list ::= func_name", + /* 202 */ "func_name_list ::= func_name_list NK_COMMA col_name", + /* 203 */ "func_name ::= function_name", + /* 204 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 205 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", + /* 206 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", + /* 207 */ "index_options ::=", + /* 208 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 209 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 210 */ "func_list ::= func", + /* 211 */ "func_list ::= func_list NK_COMMA func", + /* 212 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 213 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 214 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", + /* 215 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 216 */ "cmd ::= DESC full_table_name", + /* 217 */ "cmd ::= DESCRIBE full_table_name", + /* 218 */ "cmd ::= RESET QUERY CACHE", + /* 219 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 220 */ "analyze_opt ::=", + /* 221 */ "analyze_opt ::= ANALYZE", + /* 222 */ "explain_options ::=", + /* 223 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 224 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 225 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", + /* 226 */ "cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 227 */ "cmd ::= DROP FUNCTION function_name", + /* 228 */ "agg_func_opt ::=", + /* 229 */ "agg_func_opt ::= AGGREGATE", + /* 230 */ "bufsize_opt ::=", + /* 231 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 232 */ "cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression", + /* 233 */ "cmd ::= DROP STREAM stream_name", + /* 234 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 235 */ "cmd ::= KILL QUERY NK_INTEGER", + /* 236 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 237 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 238 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 239 */ "dnode_list ::= DNODE NK_INTEGER", + /* 240 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 241 */ "cmd ::= SYNCDB db_name REPLICA", + /* 242 */ "cmd ::= query_expression", + /* 243 */ "literal ::= NK_INTEGER", + /* 244 */ "literal ::= NK_FLOAT", + /* 245 */ "literal ::= NK_STRING", + /* 246 */ "literal ::= NK_BOOL", + /* 247 */ "literal ::= TIMESTAMP NK_STRING", + /* 248 */ "literal ::= duration_literal", + /* 249 */ "literal ::= NULL", + /* 250 */ "duration_literal ::= NK_VARIABLE", + /* 251 */ "signed ::= NK_INTEGER", + /* 252 */ "signed ::= NK_PLUS NK_INTEGER", + /* 253 */ "signed ::= NK_MINUS NK_INTEGER", + /* 254 */ "signed ::= NK_FLOAT", + /* 255 */ "signed ::= NK_PLUS NK_FLOAT", + /* 256 */ "signed ::= NK_MINUS NK_FLOAT", + /* 257 */ "signed_literal ::= signed", + /* 258 */ "signed_literal ::= NK_STRING", + /* 259 */ "signed_literal ::= NK_BOOL", + /* 260 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 261 */ "signed_literal ::= duration_literal", + /* 262 */ "signed_literal ::= NULL", + /* 263 */ "literal_list ::= signed_literal", + /* 264 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 265 */ "db_name ::= NK_ID", + /* 266 */ "table_name ::= NK_ID", + /* 267 */ "column_name ::= NK_ID", + /* 268 */ "function_name ::= NK_ID", + /* 269 */ "function_name ::= FIRST", + /* 270 */ "function_name ::= LAST", + /* 271 */ "table_alias ::= NK_ID", + /* 272 */ "column_alias ::= NK_ID", + /* 273 */ "user_name ::= NK_ID", + /* 274 */ "index_name ::= NK_ID", + /* 275 */ "topic_name ::= NK_ID", + /* 276 */ "stream_name ::= NK_ID", + /* 277 */ "expression ::= literal", + /* 278 */ "expression ::= pseudo_column", + /* 279 */ "expression ::= column_reference", + /* 280 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 281 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 282 */ "expression ::= function_name NK_LP expression AS type_name NK_RP", + /* 283 */ "expression ::= subquery", + /* 284 */ "expression ::= NK_LP expression NK_RP", + /* 285 */ "expression ::= NK_PLUS expression", + /* 286 */ "expression ::= NK_MINUS expression", + /* 287 */ "expression ::= expression NK_PLUS expression", + /* 288 */ "expression ::= expression NK_MINUS expression", + /* 289 */ "expression ::= expression NK_STAR expression", + /* 290 */ "expression ::= expression NK_SLASH expression", + /* 291 */ "expression ::= expression NK_REM expression", + /* 292 */ "expression_list ::= expression", + /* 293 */ "expression_list ::= expression_list NK_COMMA expression", + /* 294 */ "column_reference ::= column_name", + /* 295 */ "column_reference ::= table_name NK_DOT column_name", + /* 296 */ "pseudo_column ::= NOW", + /* 297 */ "pseudo_column ::= ROWTS", + /* 298 */ "pseudo_column ::= TBNAME", + /* 299 */ "pseudo_column ::= QSTARTTS", + /* 300 */ "pseudo_column ::= QENDTS", + /* 301 */ "pseudo_column ::= WSTARTTS", + /* 302 */ "pseudo_column ::= WENDTS", + /* 303 */ "pseudo_column ::= WDURATION", + /* 304 */ "predicate ::= expression compare_op expression", + /* 305 */ "predicate ::= expression BETWEEN expression AND expression", + /* 306 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 307 */ "predicate ::= expression IS NULL", + /* 308 */ "predicate ::= expression IS NOT NULL", + /* 309 */ "predicate ::= expression in_op in_predicate_value", + /* 310 */ "compare_op ::= NK_LT", + /* 311 */ "compare_op ::= NK_GT", + /* 312 */ "compare_op ::= NK_LE", + /* 313 */ "compare_op ::= NK_GE", + /* 314 */ "compare_op ::= NK_NE", + /* 315 */ "compare_op ::= NK_EQ", + /* 316 */ "compare_op ::= LIKE", + /* 317 */ "compare_op ::= NOT LIKE", + /* 318 */ "compare_op ::= MATCH", + /* 319 */ "compare_op ::= NMATCH", + /* 320 */ "in_op ::= IN", + /* 321 */ "in_op ::= NOT IN", + /* 322 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 323 */ "boolean_value_expression ::= boolean_primary", + /* 324 */ "boolean_value_expression ::= NOT boolean_primary", + /* 325 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 326 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 327 */ "boolean_primary ::= predicate", + /* 328 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 329 */ "common_expression ::= expression", + /* 330 */ "common_expression ::= boolean_value_expression", + /* 331 */ "from_clause ::= FROM table_reference_list", + /* 332 */ "table_reference_list ::= table_reference", + /* 333 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 334 */ "table_reference ::= table_primary", + /* 335 */ "table_reference ::= joined_table", + /* 336 */ "table_primary ::= table_name alias_opt", + /* 337 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 338 */ "table_primary ::= subquery alias_opt", + /* 339 */ "table_primary ::= parenthesized_joined_table", + /* 340 */ "alias_opt ::=", + /* 341 */ "alias_opt ::= table_alias", + /* 342 */ "alias_opt ::= AS table_alias", + /* 343 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 344 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 345 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 346 */ "join_type ::=", + /* 347 */ "join_type ::= INNER", + /* 348 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 349 */ "set_quantifier_opt ::=", + /* 350 */ "set_quantifier_opt ::= DISTINCT", + /* 351 */ "set_quantifier_opt ::= ALL", + /* 352 */ "select_list ::= NK_STAR", + /* 353 */ "select_list ::= select_sublist", + /* 354 */ "select_sublist ::= select_item", + /* 355 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 356 */ "select_item ::= common_expression", + /* 357 */ "select_item ::= common_expression column_alias", + /* 358 */ "select_item ::= common_expression AS column_alias", + /* 359 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 360 */ "where_clause_opt ::=", + /* 361 */ "where_clause_opt ::= WHERE search_condition", + /* 362 */ "partition_by_clause_opt ::=", + /* 363 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 364 */ "twindow_clause_opt ::=", + /* 365 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 366 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 367 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 368 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 369 */ "sliding_opt ::=", + /* 370 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 371 */ "fill_opt ::=", + /* 372 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 373 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 374 */ "fill_mode ::= NONE", + /* 375 */ "fill_mode ::= PREV", + /* 376 */ "fill_mode ::= NULL", + /* 377 */ "fill_mode ::= LINEAR", + /* 378 */ "fill_mode ::= NEXT", + /* 379 */ "group_by_clause_opt ::=", + /* 380 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 381 */ "group_by_list ::= expression", + /* 382 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 383 */ "having_clause_opt ::=", + /* 384 */ "having_clause_opt ::= HAVING search_condition", + /* 385 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 386 */ "query_expression_body ::= query_primary", + /* 387 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 388 */ "query_primary ::= query_specification", + /* 389 */ "order_by_clause_opt ::=", + /* 390 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 391 */ "slimit_clause_opt ::=", + /* 392 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 393 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 394 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 395 */ "limit_clause_opt ::=", + /* 396 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 397 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 398 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 399 */ "subquery ::= NK_LP query_expression NK_RP", + /* 400 */ "search_condition ::= common_expression", + /* 401 */ "sort_specification_list ::= sort_specification", + /* 402 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 403 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 404 */ "ordering_specification_opt ::=", + /* 405 */ "ordering_specification_opt ::= ASC", + /* 406 */ "ordering_specification_opt ::= DESC", + /* 407 */ "null_ordering_opt ::=", + /* 408 */ "null_ordering_opt ::= NULLS FIRST", + /* 409 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1646,156 +1649,156 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 207: /* cmd */ - case 210: /* literal */ - case 217: /* db_options */ - case 219: /* alter_db_options */ - case 224: /* retention */ - case 225: /* full_table_name */ - case 228: /* table_options */ - case 232: /* alter_table_clause */ - case 233: /* alter_table_options */ - case 236: /* create_subtable_clause */ - case 239: /* drop_table_clause */ - case 242: /* column_def */ - case 245: /* col_name */ - case 246: /* db_name_cond_opt */ - case 247: /* like_pattern_opt */ - case 248: /* table_name_cond */ - case 249: /* from_db_opt */ - case 250: /* func_name */ - case 253: /* index_options */ - case 255: /* duration_literal */ - case 256: /* sliding_opt */ - case 257: /* func */ - case 260: /* query_expression */ - case 262: /* explain_options */ - case 267: /* signed */ - case 268: /* signed_literal */ - case 271: /* expression */ - case 272: /* pseudo_column */ - case 273: /* column_reference */ - case 274: /* subquery */ - case 275: /* predicate */ - case 278: /* in_predicate_value */ - case 279: /* boolean_value_expression */ - case 280: /* boolean_primary */ - case 281: /* common_expression */ - case 282: /* from_clause */ - case 283: /* table_reference_list */ - case 284: /* table_reference */ - case 285: /* table_primary */ - case 286: /* joined_table */ - case 288: /* parenthesized_joined_table */ - case 290: /* search_condition */ - case 291: /* query_specification */ - case 294: /* where_clause_opt */ - case 296: /* twindow_clause_opt */ - case 298: /* having_clause_opt */ - case 300: /* select_item */ - case 301: /* fill_opt */ - case 304: /* query_expression_body */ - case 306: /* slimit_clause_opt */ - case 307: /* limit_clause_opt */ - case 308: /* query_primary */ - case 310: /* sort_specification */ + case 208: /* cmd */ + case 211: /* literal */ + case 218: /* db_options */ + case 220: /* alter_db_options */ + case 225: /* retention */ + case 226: /* full_table_name */ + case 229: /* table_options */ + case 233: /* alter_table_clause */ + case 234: /* alter_table_options */ + case 237: /* create_subtable_clause */ + case 240: /* drop_table_clause */ + case 243: /* column_def */ + case 246: /* col_name */ + case 247: /* db_name_cond_opt */ + case 248: /* like_pattern_opt */ + case 249: /* table_name_cond */ + case 250: /* from_db_opt */ + case 251: /* func_name */ + case 254: /* index_options */ + case 256: /* duration_literal */ + case 257: /* sliding_opt */ + case 258: /* func */ + case 261: /* query_expression */ + case 263: /* explain_options */ + case 268: /* signed */ + case 269: /* signed_literal */ + case 272: /* expression */ + case 273: /* pseudo_column */ + case 274: /* column_reference */ + case 275: /* subquery */ + case 276: /* predicate */ + case 279: /* in_predicate_value */ + case 280: /* boolean_value_expression */ + case 281: /* boolean_primary */ + case 282: /* common_expression */ + case 283: /* from_clause */ + case 284: /* table_reference_list */ + case 285: /* table_reference */ + case 286: /* table_primary */ + case 287: /* joined_table */ + case 289: /* parenthesized_joined_table */ + case 291: /* search_condition */ + case 292: /* query_specification */ + case 295: /* where_clause_opt */ + case 297: /* twindow_clause_opt */ + case 299: /* having_clause_opt */ + case 301: /* select_item */ + case 302: /* fill_opt */ + case 305: /* query_expression_body */ + case 307: /* slimit_clause_opt */ + case 308: /* limit_clause_opt */ + case 309: /* query_primary */ + case 311: /* sort_specification */ { - nodesDestroyNode((yypminor->yy564)); + nodesDestroyNode((yypminor->yy140)); } break; - case 208: /* account_options */ - case 209: /* alter_account_options */ - case 211: /* alter_account_option */ - case 264: /* bufsize_opt */ + case 209: /* account_options */ + case 210: /* alter_account_options */ + case 212: /* alter_account_option */ + case 265: /* bufsize_opt */ { } break; - case 212: /* user_name */ - case 213: /* dnode_endpoint */ - case 214: /* dnode_host_name */ - case 216: /* db_name */ - case 234: /* column_name */ - case 241: /* table_name */ - case 251: /* function_name */ - case 252: /* index_name */ - case 259: /* topic_name */ - case 265: /* stream_name */ - case 269: /* table_alias */ - case 270: /* column_alias */ - case 287: /* alias_opt */ + case 213: /* user_name */ + case 214: /* dnode_endpoint */ + case 215: /* dnode_host_name */ + case 217: /* db_name */ + case 235: /* column_name */ + case 242: /* table_name */ + case 252: /* function_name */ + case 253: /* index_name */ + case 260: /* topic_name */ + case 266: /* stream_name */ + case 270: /* table_alias */ + case 271: /* column_alias */ + case 288: /* alias_opt */ { } break; - case 215: /* not_exists_opt */ - case 218: /* exists_opt */ - case 261: /* analyze_opt */ - case 263: /* agg_func_opt */ - case 292: /* set_quantifier_opt */ + case 216: /* not_exists_opt */ + case 219: /* exists_opt */ + case 262: /* analyze_opt */ + case 264: /* agg_func_opt */ + case 293: /* set_quantifier_opt */ { } break; - case 220: /* integer_list */ - case 221: /* variable_list */ - case 222: /* retention_list */ - case 226: /* column_def_list */ - case 227: /* tags_def_opt */ - case 229: /* multi_create_clause */ - case 230: /* tags_def */ - case 231: /* multi_drop_clause */ - case 237: /* specific_tags_opt */ - case 238: /* literal_list */ - case 240: /* col_name_list */ - case 243: /* func_name_list */ - case 254: /* func_list */ - case 258: /* expression_list */ - case 266: /* dnode_list */ - case 293: /* select_list */ - case 295: /* partition_by_clause_opt */ - case 297: /* group_by_clause_opt */ - case 299: /* select_sublist */ - case 303: /* group_by_list */ - case 305: /* order_by_clause_opt */ - case 309: /* sort_specification_list */ + case 221: /* integer_list */ + case 222: /* variable_list */ + case 223: /* retention_list */ + case 227: /* column_def_list */ + case 228: /* tags_def_opt */ + case 230: /* multi_create_clause */ + case 231: /* tags_def */ + case 232: /* multi_drop_clause */ + case 238: /* specific_tags_opt */ + case 239: /* literal_list */ + case 241: /* col_name_list */ + case 244: /* func_name_list */ + case 255: /* func_list */ + case 259: /* expression_list */ + case 267: /* dnode_list */ + case 294: /* select_list */ + case 296: /* partition_by_clause_opt */ + case 298: /* group_by_clause_opt */ + case 300: /* select_sublist */ + case 304: /* group_by_list */ + case 306: /* order_by_clause_opt */ + case 310: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy476)); + nodesDestroyList((yypminor->yy220)); } break; - case 223: /* alter_db_option */ - case 244: /* alter_table_option */ + case 224: /* alter_db_option */ + case 245: /* alter_table_option */ { } break; - case 235: /* type_name */ + case 236: /* type_name */ { } break; - case 276: /* compare_op */ - case 277: /* in_op */ + case 277: /* compare_op */ + case 278: /* in_op */ { } break; - case 289: /* join_type */ + case 290: /* join_type */ { } break; - case 302: /* fill_mode */ + case 303: /* fill_mode */ { } break; - case 311: /* ordering_specification_opt */ + case 312: /* ordering_specification_opt */ { } break; - case 312: /* null_ordering_opt */ + case 313: /* null_ordering_opt */ { } @@ -1923,18 +1926,15 @@ static YYACTIONTYPE yy_find_shift_action( do{ i = yy_shift_ofst[stateno]; assert( i>=0 ); - assert( i<=YY_ACTTAB_COUNT ); - assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); + /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */ assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; - assert( i<(int)YY_NLOOKAHEAD ); - if( yy_lookahead[i]!=iLookAhead ){ + if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ - assert( iLookAhead %s\n", @@ -1949,8 +1949,16 @@ static YYACTIONTYPE yy_find_shift_action( #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; - assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); - if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ + if( +#if YY_SHIFT_MIN+YYWILDCARD<0 + j>=0 && +#endif +#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT + j0 + ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", @@ -1964,7 +1972,6 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && iyytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfoNRhs[yyruleno]; + yysize = yyRuleInfo[yyruleno].nrhs; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; @@ -3000,11 +2595,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,208,&yymsp[0].minor); + yy_destructor(yypParser,209,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,209,&yymsp[0].minor); + yy_destructor(yypParser,210,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3018,20 +2613,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,208,&yymsp[-2].minor); +{ yy_destructor(yypParser,209,&yymsp[-2].minor); { } - yy_destructor(yypParser,210,&yymsp[0].minor); + yy_destructor(yypParser,211,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,211,&yymsp[0].minor); +{ yy_destructor(yypParser,212,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,209,&yymsp[-1].minor); +{ yy_destructor(yypParser,210,&yymsp[-1].minor); { } - yy_destructor(yypParser,211,&yymsp[0].minor); + yy_destructor(yypParser,212,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3045,31 +2640,31 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,210,&yymsp[0].minor); + yy_destructor(yypParser,211,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy21, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy253, &yymsp[0].minor.yy0); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy21, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy253, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy21, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy253, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy21); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy253); } break; case 28: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy21, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy253, NULL); } break; case 29: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy21, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy253, &yymsp[0].minor.yy0); } break; case 30: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 31: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy21); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy253); } break; case 32: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3086,20 +2681,20 @@ static YYACTIONTYPE yy_reduce( case 36: /* dnode_endpoint ::= NK_STRING */ case 37: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==37); case 38: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==38); - case 264: /* db_name ::= NK_ID */ yytestcase(yyruleno==264); - case 265: /* table_name ::= NK_ID */ yytestcase(yyruleno==265); - case 266: /* column_name ::= NK_ID */ yytestcase(yyruleno==266); - case 267: /* function_name ::= NK_ID */ yytestcase(yyruleno==267); - case 268: /* function_name ::= FIRST */ yytestcase(yyruleno==268); - case 269: /* function_name ::= LAST */ yytestcase(yyruleno==269); - case 270: /* table_alias ::= NK_ID */ yytestcase(yyruleno==270); - case 271: /* column_alias ::= NK_ID */ yytestcase(yyruleno==271); - case 272: /* user_name ::= NK_ID */ yytestcase(yyruleno==272); - case 273: /* index_name ::= NK_ID */ yytestcase(yyruleno==273); - case 274: /* topic_name ::= NK_ID */ yytestcase(yyruleno==274); - case 275: /* stream_name ::= NK_ID */ yytestcase(yyruleno==275); -{ yylhsminor.yy21 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy21 = yylhsminor.yy21; + case 265: /* db_name ::= NK_ID */ yytestcase(yyruleno==265); + case 266: /* table_name ::= NK_ID */ yytestcase(yyruleno==266); + case 267: /* column_name ::= NK_ID */ yytestcase(yyruleno==267); + case 268: /* function_name ::= NK_ID */ yytestcase(yyruleno==268); + case 269: /* function_name ::= FIRST */ yytestcase(yyruleno==269); + case 270: /* function_name ::= LAST */ yytestcase(yyruleno==270); + case 271: /* table_alias ::= NK_ID */ yytestcase(yyruleno==271); + case 272: /* column_alias ::= NK_ID */ yytestcase(yyruleno==272); + case 273: /* user_name ::= NK_ID */ yytestcase(yyruleno==273); + case 274: /* index_name ::= NK_ID */ yytestcase(yyruleno==274); + case 275: /* topic_name ::= NK_ID */ yytestcase(yyruleno==275); + case 276: /* stream_name ::= NK_ID */ yytestcase(yyruleno==276); +{ yylhsminor.yy253 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy253 = yylhsminor.yy253; break; case 39: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3132,408 +2727,408 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 49: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy173, &yymsp[-1].minor.yy21, yymsp[0].minor.yy564); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy273, &yymsp[-1].minor.yy253, yymsp[0].minor.yy140); } break; case 50: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy173, &yymsp[0].minor.yy21); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy273, &yymsp[0].minor.yy253); } break; case 51: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy21); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy253); } break; case 52: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy21, yymsp[0].minor.yy564); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy253, yymsp[0].minor.yy140); } break; case 53: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy173 = true; } +{ yymsp[-2].minor.yy273 = true; } break; case 54: /* not_exists_opt ::= */ case 56: /* exists_opt ::= */ yytestcase(yyruleno==56); - case 219: /* analyze_opt ::= */ yytestcase(yyruleno==219); - case 227: /* agg_func_opt ::= */ yytestcase(yyruleno==227); - case 348: /* set_quantifier_opt ::= */ yytestcase(yyruleno==348); -{ yymsp[1].minor.yy173 = false; } + case 220: /* analyze_opt ::= */ yytestcase(yyruleno==220); + case 228: /* agg_func_opt ::= */ yytestcase(yyruleno==228); + case 349: /* set_quantifier_opt ::= */ yytestcase(yyruleno==349); +{ yymsp[1].minor.yy273 = false; } break; case 55: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy173 = true; } +{ yymsp[-1].minor.yy273 = true; } break; case 57: /* db_options ::= */ -{ yymsp[1].minor.yy564 = createDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy140 = createDatabaseOptions(pCxt); } break; case 58: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pNumOfBlocks = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pNumOfBlocks = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 59: /* db_options ::= db_options CACHE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pCacheBlockSize = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pCacheBlockSize = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 60: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pCachelast = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pCachelast = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 61: /* db_options ::= db_options COMP NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pCompressionLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pCompressionLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 62: /* db_options ::= db_options DAYS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pDaysPerFile = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pDaysPerFile = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 63: /* db_options ::= db_options DAYS NK_VARIABLE */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pDaysPerFile = (SValueNode*)createDurationValueNode(pCxt, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 64: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pFsyncPeriod = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pFsyncPeriod = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 65: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pMaxRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pMaxRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 66: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pMinRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pMinRowsPerBlock = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 67: /* db_options ::= db_options KEEP integer_list */ case 68: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==68); -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pKeep = yymsp[0].minor.yy476; yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pKeep = yymsp[0].minor.yy220; yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 69: /* db_options ::= db_options PRECISION NK_STRING */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pPrecision = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pPrecision = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 70: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pQuorum = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pQuorum = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 71: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pReplica = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pReplica = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 72: /* db_options ::= db_options TTL NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 73: /* db_options ::= db_options WAL NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pWalLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pWalLevel = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 74: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pNumOfVgroups = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pNumOfVgroups = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 75: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pSingleStable = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pSingleStable = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 76: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pStreamMode = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pStreamMode = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 77: /* db_options ::= db_options RETENTIONS retention_list */ -{ ((SDatabaseOptions*)yymsp[-2].minor.yy564)->pRetentions = yymsp[0].minor.yy476; yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((SDatabaseOptions*)yymsp[-2].minor.yy140)->pRetentions = yymsp[0].minor.yy220; yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 78: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy564 = createDatabaseOptions(pCxt); yylhsminor.yy564 = setDatabaseAlterOption(pCxt, yylhsminor.yy564, &yymsp[0].minor.yy289); } - yymsp[0].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createDatabaseOptions(pCxt); yylhsminor.yy140 = setDatabaseAlterOption(pCxt, yylhsminor.yy140, &yymsp[0].minor.yy181); } + yymsp[0].minor.yy140 = yylhsminor.yy140; break; case 79: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy564 = setDatabaseAlterOption(pCxt, yymsp[-1].minor.yy564, &yymsp[0].minor.yy289); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = setDatabaseAlterOption(pCxt, yymsp[-1].minor.yy140, &yymsp[0].minor.yy181); } + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; case 80: /* alter_db_option ::= BLOCKS NK_INTEGER */ -{ yymsp[-1].minor.yy289.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy289.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy181.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy181.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 81: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy289.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy289.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy181.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy181.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 82: /* alter_db_option ::= KEEP integer_list */ case 83: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==83); -{ yymsp[-1].minor.yy289.type = DB_OPTION_KEEP; yymsp[-1].minor.yy289.pList = yymsp[0].minor.yy476; } +{ yymsp[-1].minor.yy181.type = DB_OPTION_KEEP; yymsp[-1].minor.yy181.pList = yymsp[0].minor.yy220; } break; case 84: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy289.type = DB_OPTION_WAL; yymsp[-1].minor.yy289.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy181.type = DB_OPTION_WAL; yymsp[-1].minor.yy181.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 85: /* alter_db_option ::= QUORUM NK_INTEGER */ -{ yymsp[-1].minor.yy289.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy289.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy181.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy181.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 86: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy289.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy289.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy181.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy181.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 87: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy289.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy289.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy181.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy181.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 88: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy476 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy476 = yylhsminor.yy476; +{ yylhsminor.yy220 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy220 = yylhsminor.yy220; break; case 89: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 239: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==239); -{ yylhsminor.yy476 = addNodeToList(pCxt, yymsp[-2].minor.yy476, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy476 = yylhsminor.yy476; + case 240: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==240); +{ yylhsminor.yy220 = addNodeToList(pCxt, yymsp[-2].minor.yy220, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy220 = yylhsminor.yy220; break; case 90: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy476 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy476 = yylhsminor.yy476; +{ yylhsminor.yy220 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy220 = yylhsminor.yy220; break; case 91: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy476 = addNodeToList(pCxt, yymsp[-2].minor.yy476, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy476 = yylhsminor.yy476; +{ yylhsminor.yy220 = addNodeToList(pCxt, yymsp[-2].minor.yy220, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy220 = yylhsminor.yy220; break; case 92: /* retention_list ::= retention */ case 112: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==112); case 115: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==115); case 122: /* column_def_list ::= column_def */ yytestcase(yyruleno==122); case 165: /* col_name_list ::= col_name */ yytestcase(yyruleno==165); - case 200: /* func_name_list ::= func_name */ yytestcase(yyruleno==200); - case 209: /* func_list ::= func */ yytestcase(yyruleno==209); - case 262: /* literal_list ::= signed_literal */ yytestcase(yyruleno==262); - case 353: /* select_sublist ::= select_item */ yytestcase(yyruleno==353); - case 400: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==400); -{ yylhsminor.yy476 = createNodeList(pCxt, yymsp[0].minor.yy564); } - yymsp[0].minor.yy476 = yylhsminor.yy476; + case 201: /* func_name_list ::= func_name */ yytestcase(yyruleno==201); + case 210: /* func_list ::= func */ yytestcase(yyruleno==210); + case 263: /* literal_list ::= signed_literal */ yytestcase(yyruleno==263); + case 354: /* select_sublist ::= select_item */ yytestcase(yyruleno==354); + case 401: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==401); +{ yylhsminor.yy220 = createNodeList(pCxt, yymsp[0].minor.yy140); } + yymsp[0].minor.yy220 = yylhsminor.yy220; break; case 93: /* retention_list ::= retention_list NK_COMMA retention */ case 123: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==123); case 166: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==166); - case 201: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==201); - case 210: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==210); - case 263: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==263); - case 354: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==354); - case 401: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==401); -{ yylhsminor.yy476 = addNodeToList(pCxt, yymsp[-2].minor.yy476, yymsp[0].minor.yy564); } - yymsp[-2].minor.yy476 = yylhsminor.yy476; + case 202: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==202); + case 211: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==211); + case 264: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==264); + case 355: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==355); + case 402: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==402); +{ yylhsminor.yy220 = addNodeToList(pCxt, yymsp[-2].minor.yy220, yymsp[0].minor.yy140); } + yymsp[-2].minor.yy220 = yylhsminor.yy220; break; case 94: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy564 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 95: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 97: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==97); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy173, yymsp[-5].minor.yy564, yymsp[-3].minor.yy476, yymsp[-1].minor.yy476, yymsp[0].minor.yy564); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy273, yymsp[-5].minor.yy140, yymsp[-3].minor.yy220, yymsp[-1].minor.yy220, yymsp[0].minor.yy140); } break; case 96: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy476); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy220); } break; case 98: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy476); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy220); } break; case 99: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy173, yymsp[0].minor.yy564); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy273, yymsp[0].minor.yy140); } break; case 100: /* cmd ::= ALTER TABLE alter_table_clause */ case 101: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==101); - case 241: /* cmd ::= query_expression */ yytestcase(yyruleno==241); -{ pCxt->pRootNode = yymsp[0].minor.yy564; } + case 242: /* cmd ::= query_expression */ yytestcase(yyruleno==242); +{ pCxt->pRootNode = yymsp[0].minor.yy140; } break; case 102: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy564 = createAlterTableOption(pCxt, yymsp[-1].minor.yy564, yymsp[0].minor.yy564); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createAlterTableOption(pCxt, yymsp[-1].minor.yy140, yymsp[0].minor.yy140); } + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; case 103: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy564 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy564, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy21, yymsp[0].minor.yy288); } - yymsp[-4].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy253, yymsp[0].minor.yy368); } + yymsp[-4].minor.yy140 = yylhsminor.yy140; break; case 104: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy564 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy564, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy21); } - yymsp[-3].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy140, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy253); } + yymsp[-3].minor.yy140 = yylhsminor.yy140; break; case 105: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy564 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy564, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy21, yymsp[0].minor.yy288); } - yymsp[-4].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy253, yymsp[0].minor.yy368); } + yymsp[-4].minor.yy140 = yylhsminor.yy140; break; case 106: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy564 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy564, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy21, &yymsp[0].minor.yy21); } - yymsp[-4].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy253, &yymsp[0].minor.yy253); } + yymsp[-4].minor.yy140 = yylhsminor.yy140; break; case 107: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy564 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy564, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy21, yymsp[0].minor.yy288); } - yymsp[-4].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy253, yymsp[0].minor.yy368); } + yymsp[-4].minor.yy140 = yylhsminor.yy140; break; case 108: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy564 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy564, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy21); } - yymsp[-3].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy140, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy253); } + yymsp[-3].minor.yy140 = yylhsminor.yy140; break; case 109: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy564 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy564, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy21, yymsp[0].minor.yy288); } - yymsp[-4].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy253, yymsp[0].minor.yy368); } + yymsp[-4].minor.yy140 = yylhsminor.yy140; break; case 110: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy564 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy564, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy21, &yymsp[0].minor.yy21); } - yymsp[-4].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy140, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy253, &yymsp[0].minor.yy253); } + yymsp[-4].minor.yy140 = yylhsminor.yy140; break; case 111: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ -{ yylhsminor.yy564 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy564, &yymsp[-2].minor.yy21, yymsp[0].minor.yy564); } - yymsp[-5].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy140, &yymsp[-2].minor.yy253, yymsp[0].minor.yy140); } + yymsp[-5].minor.yy140 = yylhsminor.yy140; break; case 113: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 116: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==116); -{ yylhsminor.yy476 = addNodeToList(pCxt, yymsp[-1].minor.yy476, yymsp[0].minor.yy564); } - yymsp[-1].minor.yy476 = yylhsminor.yy476; +{ yylhsminor.yy220 = addNodeToList(pCxt, yymsp[-1].minor.yy220, yymsp[0].minor.yy140); } + yymsp[-1].minor.yy220 = yylhsminor.yy220; break; case 114: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy564 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy173, yymsp[-7].minor.yy564, yymsp[-5].minor.yy564, yymsp[-4].minor.yy476, yymsp[-1].minor.yy476); } - yymsp[-8].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy273, yymsp[-7].minor.yy140, yymsp[-5].minor.yy140, yymsp[-4].minor.yy220, yymsp[-1].minor.yy220); } + yymsp[-8].minor.yy140 = yylhsminor.yy140; break; case 117: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy564 = createDropTableClause(pCxt, yymsp[-1].minor.yy173, yymsp[0].minor.yy564); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createDropTableClause(pCxt, yymsp[-1].minor.yy273, yymsp[0].minor.yy140); } + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; case 118: /* specific_tags_opt ::= */ case 149: /* tags_def_opt ::= */ yytestcase(yyruleno==149); - case 361: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==361); - case 378: /* group_by_clause_opt ::= */ yytestcase(yyruleno==378); - case 388: /* order_by_clause_opt ::= */ yytestcase(yyruleno==388); -{ yymsp[1].minor.yy476 = NULL; } + case 362: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==362); + case 379: /* group_by_clause_opt ::= */ yytestcase(yyruleno==379); + case 389: /* order_by_clause_opt ::= */ yytestcase(yyruleno==389); +{ yymsp[1].minor.yy220 = NULL; } break; case 119: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy476 = yymsp[-1].minor.yy476; } +{ yymsp[-2].minor.yy220 = yymsp[-1].minor.yy220; } break; case 120: /* full_table_name ::= table_name */ -{ yylhsminor.yy564 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy21, NULL); } - yymsp[0].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy253, NULL); } + yymsp[0].minor.yy140 = yylhsminor.yy140; break; case 121: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy564 = createRealTableNode(pCxt, &yymsp[-2].minor.yy21, &yymsp[0].minor.yy21, NULL); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createRealTableNode(pCxt, &yymsp[-2].minor.yy253, &yymsp[0].minor.yy253, NULL); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 124: /* column_def ::= column_name type_name */ -{ yylhsminor.yy564 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy21, yymsp[0].minor.yy288, NULL); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy253, yymsp[0].minor.yy368, NULL); } + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; case 125: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy564 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy21, yymsp[-2].minor.yy288, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy253, yymsp[-2].minor.yy368, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy140 = yylhsminor.yy140; break; case 126: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 127: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 128: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 129: /* type_name ::= INT */ case 130: /* type_name ::= INTEGER */ yytestcase(yyruleno==130); -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_INT); } break; case 131: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 132: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 133: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 134: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy288 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy368 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 135: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 136: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy288 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy368 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 137: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy288 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy368 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 138: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy288 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy368 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 139: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy288 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy368 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 140: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy288 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy368 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 141: /* type_name ::= JSON */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 142: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy288 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy368 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 143: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 144: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 145: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy288 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy368 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 146: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy288 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy368 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 147: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy288 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy368 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 148: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy288 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy368 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 150: /* tags_def_opt ::= tags_def */ - case 352: /* select_list ::= select_sublist */ yytestcase(yyruleno==352); -{ yylhsminor.yy476 = yymsp[0].minor.yy476; } - yymsp[0].minor.yy476 = yylhsminor.yy476; + case 353: /* select_list ::= select_sublist */ yytestcase(yyruleno==353); +{ yylhsminor.yy220 = yymsp[0].minor.yy220; } + yymsp[0].minor.yy220 = yylhsminor.yy220; break; case 151: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy476 = yymsp[-1].minor.yy476; } +{ yymsp[-3].minor.yy220 = yymsp[-1].minor.yy220; } break; case 152: /* table_options ::= */ -{ yymsp[1].minor.yy564 = createTableOptions(pCxt); } +{ yymsp[1].minor.yy140 = createTableOptions(pCxt); } break; case 153: /* table_options ::= table_options COMMENT NK_STRING */ -{ ((STableOptions*)yymsp[-2].minor.yy564)->pComments = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((STableOptions*)yymsp[-2].minor.yy140)->pComments = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 154: /* table_options ::= table_options KEEP integer_list */ -{ ((STableOptions*)yymsp[-2].minor.yy564)->pKeep = yymsp[0].minor.yy476; yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((STableOptions*)yymsp[-2].minor.yy140)->pKeep = yymsp[0].minor.yy220; yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 155: /* table_options ::= table_options TTL NK_INTEGER */ -{ ((STableOptions*)yymsp[-2].minor.yy564)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((STableOptions*)yymsp[-2].minor.yy140)->pTtl = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 156: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ ((STableOptions*)yymsp[-4].minor.yy564)->pSma = yymsp[-1].minor.yy476; yylhsminor.yy564 = yymsp[-4].minor.yy564; } - yymsp[-4].minor.yy564 = yylhsminor.yy564; +{ ((STableOptions*)yymsp[-4].minor.yy140)->pSma = yymsp[-1].minor.yy220; yylhsminor.yy140 = yymsp[-4].minor.yy140; } + yymsp[-4].minor.yy140 = yylhsminor.yy140; break; case 157: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ ((STableOptions*)yymsp[-4].minor.yy564)->pFuncs = yymsp[-1].minor.yy476; yylhsminor.yy564 = yymsp[-4].minor.yy564; } - yymsp[-4].minor.yy564 = yylhsminor.yy564; +{ ((STableOptions*)yymsp[-4].minor.yy140)->pFuncs = yymsp[-1].minor.yy220; yylhsminor.yy140 = yymsp[-4].minor.yy140; } + yymsp[-4].minor.yy140 = yylhsminor.yy140; break; case 158: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ -{ ((STableOptions*)yymsp[-2].minor.yy564)->pFilesFactor = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((STableOptions*)yymsp[-2].minor.yy140)->pFilesFactor = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 159: /* table_options ::= table_options DELAY NK_INTEGER */ -{ ((STableOptions*)yymsp[-2].minor.yy564)->pDelay = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy564 = yymsp[-2].minor.yy564; } - yymsp[-2].minor.yy564 = yylhsminor.yy564; +{ ((STableOptions*)yymsp[-2].minor.yy140)->pDelay = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); yylhsminor.yy140 = yymsp[-2].minor.yy140; } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; case 160: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy564 = createTableOptions(pCxt); yylhsminor.yy564 = setTableAlterOption(pCxt, yylhsminor.yy564, &yymsp[0].minor.yy289); } - yymsp[0].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createTableOptions(pCxt); yylhsminor.yy140 = setTableAlterOption(pCxt, yylhsminor.yy140, &yymsp[0].minor.yy181); } + yymsp[0].minor.yy140 = yylhsminor.yy140; break; case 161: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy564 = setTableAlterOption(pCxt, yymsp[-1].minor.yy564, &yymsp[0].minor.yy289); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = setTableAlterOption(pCxt, yymsp[-1].minor.yy140, &yymsp[0].minor.yy181); } + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; case 162: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy289.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy289.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy181.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy181.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 163: /* alter_table_option ::= KEEP integer_list */ -{ yymsp[-1].minor.yy289.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy289.pList = yymsp[0].minor.yy476; } +{ yymsp[-1].minor.yy181.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy181.pList = yymsp[0].minor.yy220; } break; case 164: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy289.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy289.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy181.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy181.pVal = (SValueNode*)createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 167: /* col_name ::= column_name */ -{ yylhsminor.yy564 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy21); } - yymsp[0].minor.yy564 = yylhsminor.yy564; +{ yylhsminor.yy140 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy253); } + yymsp[0].minor.yy140 = yylhsminor.yy140; break; case 168: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); } @@ -3545,13 +3140,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL, NULL); } break; case 171: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy564, yymsp[0].minor.yy564); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy140, yymsp[0].minor.yy140); } break; case 172: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy564, yymsp[0].minor.yy564); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy140, yymsp[0].minor.yy140); } break; case 173: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy564, NULL); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy140, NULL); } break; case 174: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); } @@ -3566,7 +3161,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); } break; case 178: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy564, yymsp[0].minor.yy564); } +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy140, yymsp[0].minor.yy140); } break; case 179: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } @@ -3581,644 +3176,645 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT, NULL, NULL); } break; case 183: /* cmd ::= SHOW LICENCE */ + case 184: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==184); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); } break; - case 184: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy21); } + case 185: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy253); } break; - case 185: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy564); } + case 186: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy140); } break; - case 186: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy564); } + case 187: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy140); } break; - case 187: /* cmd ::= SHOW QUERIES */ + case 188: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT, NULL, NULL); } break; - case 188: /* cmd ::= SHOW SCORES */ + case 189: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT, NULL, NULL); } break; - case 189: /* cmd ::= SHOW TOPICS */ + case 190: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT, NULL, NULL); } break; - case 190: /* cmd ::= SHOW VARIABLES */ + case 191: /* cmd ::= SHOW VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLE_STMT, NULL, NULL); } break; - case 191: /* cmd ::= SHOW BNODES */ + case 192: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT, NULL, NULL); } break; - case 192: /* cmd ::= SHOW SNODES */ + case 193: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT, NULL, NULL); } break; - case 193: /* db_name_cond_opt ::= */ - case 198: /* from_db_opt ::= */ yytestcase(yyruleno==198); -{ yymsp[1].minor.yy564 = createDefaultDatabaseCondValue(pCxt); } + case 194: /* db_name_cond_opt ::= */ + case 199: /* from_db_opt ::= */ yytestcase(yyruleno==199); +{ yymsp[1].minor.yy140 = createDefaultDatabaseCondValue(pCxt); } break; - case 194: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy21); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; + case 195: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy253); } + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; - case 195: /* like_pattern_opt ::= */ - case 206: /* index_options ::= */ yytestcase(yyruleno==206); - case 359: /* where_clause_opt ::= */ yytestcase(yyruleno==359); - case 363: /* twindow_clause_opt ::= */ yytestcase(yyruleno==363); - case 368: /* sliding_opt ::= */ yytestcase(yyruleno==368); - case 370: /* fill_opt ::= */ yytestcase(yyruleno==370); - case 382: /* having_clause_opt ::= */ yytestcase(yyruleno==382); - case 390: /* slimit_clause_opt ::= */ yytestcase(yyruleno==390); - case 394: /* limit_clause_opt ::= */ yytestcase(yyruleno==394); -{ yymsp[1].minor.yy564 = NULL; } + case 196: /* like_pattern_opt ::= */ + case 207: /* index_options ::= */ yytestcase(yyruleno==207); + case 360: /* where_clause_opt ::= */ yytestcase(yyruleno==360); + case 364: /* twindow_clause_opt ::= */ yytestcase(yyruleno==364); + case 369: /* sliding_opt ::= */ yytestcase(yyruleno==369); + case 371: /* fill_opt ::= */ yytestcase(yyruleno==371); + case 383: /* having_clause_opt ::= */ yytestcase(yyruleno==383); + case 391: /* slimit_clause_opt ::= */ yytestcase(yyruleno==391); + case 395: /* limit_clause_opt ::= */ yytestcase(yyruleno==395); +{ yymsp[1].minor.yy140 = NULL; } break; - case 196: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 197: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 197: /* table_name_cond ::= table_name */ -{ yylhsminor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy21); } - yymsp[0].minor.yy564 = yylhsminor.yy564; + case 198: /* table_name_cond ::= table_name */ +{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy253); } + yymsp[0].minor.yy140 = yylhsminor.yy140; break; - case 199: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy21); } + case 200: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy253); } break; - case 202: /* func_name ::= function_name */ -{ yylhsminor.yy564 = createFunctionNode(pCxt, &yymsp[0].minor.yy21, NULL); } - yymsp[0].minor.yy564 = yylhsminor.yy564; + case 203: /* func_name ::= function_name */ +{ yylhsminor.yy140 = createFunctionNode(pCxt, &yymsp[0].minor.yy253, NULL); } + yymsp[0].minor.yy140 = yylhsminor.yy140; break; - case 203: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy173, &yymsp[-3].minor.yy21, &yymsp[-1].minor.yy21, NULL, yymsp[0].minor.yy564); } + case 204: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy273, &yymsp[-3].minor.yy253, &yymsp[-1].minor.yy253, NULL, yymsp[0].minor.yy140); } break; - case 204: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy173, &yymsp[-5].minor.yy21, &yymsp[-3].minor.yy21, yymsp[-1].minor.yy476, NULL); } + case 205: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy273, &yymsp[-5].minor.yy253, &yymsp[-3].minor.yy253, yymsp[-1].minor.yy220, NULL); } break; - case 205: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy173, &yymsp[-2].minor.yy21, &yymsp[0].minor.yy21); } + case 206: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy273, &yymsp[-2].minor.yy253, &yymsp[0].minor.yy253); } break; - case 207: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy564 = createIndexOption(pCxt, yymsp[-6].minor.yy476, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), NULL, yymsp[0].minor.yy564); } + case 208: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy140 = createIndexOption(pCxt, yymsp[-6].minor.yy220, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), NULL, yymsp[0].minor.yy140); } break; - case 208: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy564 = createIndexOption(pCxt, yymsp[-8].minor.yy476, releaseRawExprNode(pCxt, yymsp[-4].minor.yy564), releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), yymsp[0].minor.yy564); } + case 209: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ +{ yymsp[-10].minor.yy140 = createIndexOption(pCxt, yymsp[-8].minor.yy220, releaseRawExprNode(pCxt, yymsp[-4].minor.yy140), releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), yymsp[0].minor.yy140); } break; - case 211: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy564 = createFunctionNode(pCxt, &yymsp[-3].minor.yy21, yymsp[-1].minor.yy476); } - yymsp[-3].minor.yy564 = yylhsminor.yy564; + case 212: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy140 = createFunctionNode(pCxt, &yymsp[-3].minor.yy253, yymsp[-1].minor.yy220); } + yymsp[-3].minor.yy140 = yylhsminor.yy140; break; - case 212: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy173, &yymsp[-2].minor.yy21, yymsp[0].minor.yy564, NULL); } + case 213: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy273, &yymsp[-2].minor.yy253, yymsp[0].minor.yy140, NULL); } break; - case 213: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy173, &yymsp[-2].minor.yy21, NULL, &yymsp[0].minor.yy21); } + case 214: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy273, &yymsp[-2].minor.yy253, NULL, &yymsp[0].minor.yy253); } break; - case 214: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy173, &yymsp[0].minor.yy21); } + case 215: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy273, &yymsp[0].minor.yy253); } break; - case 215: /* cmd ::= DESC full_table_name */ - case 216: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==216); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy564); } + case 216: /* cmd ::= DESC full_table_name */ + case 217: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==217); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy140); } break; - case 217: /* cmd ::= RESET QUERY CACHE */ + case 218: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 218: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy173, yymsp[-1].minor.yy564, yymsp[0].minor.yy564); } + case 219: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy273, yymsp[-1].minor.yy140, yymsp[0].minor.yy140); } break; - case 220: /* analyze_opt ::= ANALYZE */ - case 228: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==228); - case 349: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==349); -{ yymsp[0].minor.yy173 = true; } + case 221: /* analyze_opt ::= ANALYZE */ + case 229: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==229); + case 350: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==350); +{ yymsp[0].minor.yy273 = true; } break; - case 221: /* explain_options ::= */ -{ yymsp[1].minor.yy564 = createDefaultExplainOptions(pCxt); } + case 222: /* explain_options ::= */ +{ yymsp[1].minor.yy140 = createDefaultExplainOptions(pCxt); } break; - case 222: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy564 = setExplainVerbose(pCxt, yymsp[-2].minor.yy564, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + case 223: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy140 = setExplainVerbose(pCxt, yymsp[-2].minor.yy140, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 223: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy564 = setExplainRatio(pCxt, yymsp[-2].minor.yy564, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + case 224: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy140 = setExplainRatio(pCxt, yymsp[-2].minor.yy140, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 224: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy476); } + case 225: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy220); } break; - case 225: /* cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy173, &yymsp[-5].minor.yy21, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy288, yymsp[0].minor.yy620); } + case 226: /* cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy273, &yymsp[-5].minor.yy253, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy368, yymsp[0].minor.yy528); } break; - case 226: /* cmd ::= DROP FUNCTION function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, &yymsp[0].minor.yy21); } + case 227: /* cmd ::= DROP FUNCTION function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, &yymsp[0].minor.yy253); } break; - case 229: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy620 = 0; } + case 230: /* bufsize_opt ::= */ +{ yymsp[1].minor.yy528 = 0; } break; - case 230: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy620 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + case 231: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy528 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 231: /* cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, &yymsp[-4].minor.yy21, &yymsp[-2].minor.yy21, yymsp[0].minor.yy564); } + case 232: /* cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, &yymsp[-4].minor.yy253, &yymsp[-2].minor.yy253, yymsp[0].minor.yy140); } break; - case 232: /* cmd ::= DROP STREAM stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, &yymsp[0].minor.yy21); } + case 233: /* cmd ::= DROP STREAM stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, &yymsp[0].minor.yy253); } break; - case 233: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 234: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 234: /* cmd ::= KILL QUERY NK_INTEGER */ + case 235: /* cmd ::= KILL QUERY NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &yymsp[0].minor.yy0); } break; - case 235: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 236: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 236: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy476); } + case 237: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy220); } break; - case 237: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 238: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 238: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy476 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - break; - case 240: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy21); } - break; - case 242: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy564 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy564 = yylhsminor.yy564; - break; - case 243: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy564 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy564 = yylhsminor.yy564; - break; - case 244: /* literal ::= NK_STRING */ -{ yylhsminor.yy564 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy564 = yylhsminor.yy564; - break; - case 245: /* literal ::= NK_BOOL */ -{ yylhsminor.yy564 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy564 = yylhsminor.yy564; - break; - case 246: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; - break; - case 247: /* literal ::= duration_literal */ - case 256: /* signed_literal ::= signed */ yytestcase(yyruleno==256); - case 276: /* expression ::= literal */ yytestcase(yyruleno==276); - case 277: /* expression ::= pseudo_column */ yytestcase(yyruleno==277); - case 278: /* expression ::= column_reference */ yytestcase(yyruleno==278); - case 282: /* expression ::= subquery */ yytestcase(yyruleno==282); - case 322: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==322); - case 326: /* boolean_primary ::= predicate */ yytestcase(yyruleno==326); - case 328: /* common_expression ::= expression */ yytestcase(yyruleno==328); - case 329: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==329); - case 331: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==331); - case 333: /* table_reference ::= table_primary */ yytestcase(yyruleno==333); - case 334: /* table_reference ::= joined_table */ yytestcase(yyruleno==334); - case 338: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==338); - case 385: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==385); - case 387: /* query_primary ::= query_specification */ yytestcase(yyruleno==387); -{ yylhsminor.yy564 = yymsp[0].minor.yy564; } - yymsp[0].minor.yy564 = yylhsminor.yy564; - break; - case 248: /* literal ::= NULL */ -{ yylhsminor.yy564 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } - yymsp[0].minor.yy564 = yylhsminor.yy564; - break; - case 249: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy564 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy564 = yylhsminor.yy564; - break; - case 250: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy564 = yylhsminor.yy564; - break; - case 251: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - break; - case 252: /* signed ::= NK_MINUS NK_INTEGER */ + case 239: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy220 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + break; + case 241: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy253); } + break; + case 243: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy140 = yylhsminor.yy140; + break; + case 244: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy140 = yylhsminor.yy140; + break; + case 245: /* literal ::= NK_STRING */ +{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy140 = yylhsminor.yy140; + break; + case 246: /* literal ::= NK_BOOL */ +{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy140 = yylhsminor.yy140; + break; + case 247: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy140 = yylhsminor.yy140; + break; + case 248: /* literal ::= duration_literal */ + case 257: /* signed_literal ::= signed */ yytestcase(yyruleno==257); + case 277: /* expression ::= literal */ yytestcase(yyruleno==277); + case 278: /* expression ::= pseudo_column */ yytestcase(yyruleno==278); + case 279: /* expression ::= column_reference */ yytestcase(yyruleno==279); + case 283: /* expression ::= subquery */ yytestcase(yyruleno==283); + case 323: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==323); + case 327: /* boolean_primary ::= predicate */ yytestcase(yyruleno==327); + case 329: /* common_expression ::= expression */ yytestcase(yyruleno==329); + case 330: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==330); + case 332: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==332); + case 334: /* table_reference ::= table_primary */ yytestcase(yyruleno==334); + case 335: /* table_reference ::= joined_table */ yytestcase(yyruleno==335); + case 339: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==339); + case 386: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==386); + case 388: /* query_primary ::= query_specification */ yytestcase(yyruleno==388); +{ yylhsminor.yy140 = yymsp[0].minor.yy140; } + yymsp[0].minor.yy140 = yylhsminor.yy140; + break; + case 249: /* literal ::= NULL */ +{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } + yymsp[0].minor.yy140 = yylhsminor.yy140; + break; + case 250: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy140 = yylhsminor.yy140; + break; + case 251: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy140 = yylhsminor.yy140; + break; + case 252: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + break; + case 253: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; - case 253: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy564 = yylhsminor.yy564; + case 254: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy140 = yylhsminor.yy140; break; - case 254: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 255: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 255: /* signed ::= NK_MINUS NK_FLOAT */ + case 256: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; - case 257: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy564 = yylhsminor.yy564; + case 258: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy140 = yylhsminor.yy140; break; - case 258: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy564 = yylhsminor.yy564; + case 259: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy140 = yylhsminor.yy140; break; - case 259: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 260: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 260: /* signed_literal ::= duration_literal */ - case 355: /* select_item ::= common_expression */ yytestcase(yyruleno==355); - case 399: /* search_condition ::= common_expression */ yytestcase(yyruleno==399); -{ yylhsminor.yy564 = releaseRawExprNode(pCxt, yymsp[0].minor.yy564); } - yymsp[0].minor.yy564 = yylhsminor.yy564; + case 261: /* signed_literal ::= duration_literal */ + case 356: /* select_item ::= common_expression */ yytestcase(yyruleno==356); + case 400: /* search_condition ::= common_expression */ yytestcase(yyruleno==400); +{ yylhsminor.yy140 = releaseRawExprNode(pCxt, yymsp[0].minor.yy140); } + yymsp[0].minor.yy140 = yylhsminor.yy140; break; - case 261: /* signed_literal ::= NULL */ -{ yymsp[0].minor.yy564 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } + case 262: /* signed_literal ::= NULL */ +{ yymsp[0].minor.yy140 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } break; - case 279: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy21, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy21, yymsp[-1].minor.yy476)); } - yymsp[-3].minor.yy564 = yylhsminor.yy564; + case 280: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy253, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy253, yymsp[-1].minor.yy220)); } + yymsp[-3].minor.yy140 = yylhsminor.yy140; break; - case 280: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy21, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy21, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy564 = yylhsminor.yy564; + case 281: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy253, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy253, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy140 = yylhsminor.yy140; break; - case 281: /* expression ::= function_name NK_LP expression AS type_name NK_RP */ + case 282: /* expression ::= function_name NK_LP expression AS type_name NK_RP */ { - SNodeList *p = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy564)); - p = addValueNodeFromTypeToList(pCxt, yymsp[-1].minor.yy288, p); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy21, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-5].minor.yy21, p)); + SNodeList *p = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy140)); + p = addValueNodeFromTypeToList(pCxt, yymsp[-1].minor.yy368, p); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy253, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-5].minor.yy253, p)); } - yymsp[-5].minor.yy564 = yylhsminor.yy564; + yymsp[-5].minor.yy140 = yylhsminor.yy140; break; - case 283: /* expression ::= NK_LP expression NK_RP */ - case 327: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==327); -{ yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy564)); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + case 284: /* expression ::= NK_LP expression NK_RP */ + case 328: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==328); +{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy140)); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 284: /* expression ::= NK_PLUS expression */ + case 285: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy564)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy140)); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; - case 285: /* expression ::= NK_MINUS expression */ + case 286: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy564), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy140), NULL)); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; - case 286: /* expression ::= expression NK_PLUS expression */ + case 287: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy564); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 287: /* expression ::= expression NK_MINUS expression */ + case 288: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy564); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 288: /* expression ::= expression NK_STAR expression */ + case 289: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy564); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 289: /* expression ::= expression NK_SLASH expression */ + case 290: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy564); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 290: /* expression ::= expression NK_REM expression */ + case 291: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy564); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; - break; - case 291: /* expression_list ::= expression */ -{ yylhsminor.yy476 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy564)); } - yymsp[0].minor.yy476 = yylhsminor.yy476; - break; - case 292: /* expression_list ::= expression_list NK_COMMA expression */ -{ yylhsminor.yy476 = addNodeToList(pCxt, yymsp[-2].minor.yy476, releaseRawExprNode(pCxt, yymsp[0].minor.yy564)); } - yymsp[-2].minor.yy476 = yylhsminor.yy476; - break; - case 293: /* column_reference ::= column_name */ -{ yylhsminor.yy564 = createRawExprNode(pCxt, &yymsp[0].minor.yy21, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy21)); } - yymsp[0].minor.yy564 = yylhsminor.yy564; - break; - case 294: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy21, &yymsp[0].minor.yy21, createColumnNode(pCxt, &yymsp[-2].minor.yy21, &yymsp[0].minor.yy21)); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; - break; - case 295: /* pseudo_column ::= NOW */ - case 296: /* pseudo_column ::= ROWTS */ yytestcase(yyruleno==296); - case 297: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==297); - case 298: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==298); - case 299: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==299); - case 300: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==300); - case 301: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==301); - case 302: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==302); -{ yylhsminor.yy564 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy564 = yylhsminor.yy564; - break; - case 303: /* predicate ::= expression compare_op expression */ - case 308: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==308); + yymsp[-2].minor.yy140 = yylhsminor.yy140; + break; + case 292: /* expression_list ::= expression */ +{ yylhsminor.yy220 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy140)); } + yymsp[0].minor.yy220 = yylhsminor.yy220; + break; + case 293: /* expression_list ::= expression_list NK_COMMA expression */ +{ yylhsminor.yy220 = addNodeToList(pCxt, yymsp[-2].minor.yy220, releaseRawExprNode(pCxt, yymsp[0].minor.yy140)); } + yymsp[-2].minor.yy220 = yylhsminor.yy220; + break; + case 294: /* column_reference ::= column_name */ +{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy253, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy253)); } + yymsp[0].minor.yy140 = yylhsminor.yy140; + break; + case 295: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy253, &yymsp[0].minor.yy253, createColumnNode(pCxt, &yymsp[-2].minor.yy253, &yymsp[0].minor.yy253)); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; + break; + case 296: /* pseudo_column ::= NOW */ + case 297: /* pseudo_column ::= ROWTS */ yytestcase(yyruleno==297); + case 298: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==298); + case 299: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==299); + case 300: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==300); + case 301: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==301); + case 302: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==302); + case 303: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==303); +{ yylhsminor.yy140 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy140 = yylhsminor.yy140; + break; + case 304: /* predicate ::= expression compare_op expression */ + case 309: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==309); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy564); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy468, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy480, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 304: /* predicate ::= expression BETWEEN expression AND expression */ + case 305: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy564); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy564), releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy140); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy140), releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-4].minor.yy564 = yylhsminor.yy564; + yymsp[-4].minor.yy140 = yylhsminor.yy140; break; - case 305: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 306: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy564); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), releaseRawExprNode(pCxt, yymsp[-5].minor.yy564), releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy140); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[-5].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-5].minor.yy564 = yylhsminor.yy564; + yymsp[-5].minor.yy140 = yylhsminor.yy140; break; - case 306: /* predicate ::= expression IS NULL */ + case 307: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), NULL)); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 307: /* predicate ::= expression IS NOT NULL */ + case 308: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy564), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy140), NULL)); } - yymsp[-3].minor.yy564 = yylhsminor.yy564; + yymsp[-3].minor.yy140 = yylhsminor.yy140; break; - case 309: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy468 = OP_TYPE_LOWER_THAN; } + case 310: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy480 = OP_TYPE_LOWER_THAN; } break; - case 310: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy468 = OP_TYPE_GREATER_THAN; } + case 311: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy480 = OP_TYPE_GREATER_THAN; } break; - case 311: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy468 = OP_TYPE_LOWER_EQUAL; } + case 312: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy480 = OP_TYPE_LOWER_EQUAL; } break; - case 312: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy468 = OP_TYPE_GREATER_EQUAL; } + case 313: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy480 = OP_TYPE_GREATER_EQUAL; } break; - case 313: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy468 = OP_TYPE_NOT_EQUAL; } + case 314: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy480 = OP_TYPE_NOT_EQUAL; } break; - case 314: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy468 = OP_TYPE_EQUAL; } + case 315: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy480 = OP_TYPE_EQUAL; } break; - case 315: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy468 = OP_TYPE_LIKE; } + case 316: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy480 = OP_TYPE_LIKE; } break; - case 316: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy468 = OP_TYPE_NOT_LIKE; } + case 317: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy480 = OP_TYPE_NOT_LIKE; } break; - case 317: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy468 = OP_TYPE_MATCH; } + case 318: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy480 = OP_TYPE_MATCH; } break; - case 318: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy468 = OP_TYPE_NMATCH; } + case 319: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy480 = OP_TYPE_NMATCH; } break; - case 319: /* in_op ::= IN */ -{ yymsp[0].minor.yy468 = OP_TYPE_IN; } + case 320: /* in_op ::= IN */ +{ yymsp[0].minor.yy480 = OP_TYPE_IN; } break; - case 320: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy468 = OP_TYPE_NOT_IN; } + case 321: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy480 = OP_TYPE_NOT_IN; } break; - case 321: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy476)); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + case 322: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy220)); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 323: /* boolean_value_expression ::= NOT boolean_primary */ + case 324: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy564), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy140), NULL)); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; - case 324: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 325: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy564); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 325: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 326: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy564); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy564); - yylhsminor.yy564 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy140); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy140); + yylhsminor.yy140 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 330: /* from_clause ::= FROM table_reference_list */ - case 360: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==360); - case 383: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==383); -{ yymsp[-1].minor.yy564 = yymsp[0].minor.yy564; } + case 331: /* from_clause ::= FROM table_reference_list */ + case 361: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==361); + case 384: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==384); +{ yymsp[-1].minor.yy140 = yymsp[0].minor.yy140; } break; - case 332: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy564 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy564, yymsp[0].minor.yy564, NULL); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + case 333: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy140 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy140, yymsp[0].minor.yy140, NULL); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 335: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy564 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy21, &yymsp[0].minor.yy21); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; + case 336: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy140 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy253, &yymsp[0].minor.yy253); } + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; - case 336: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy564 = createRealTableNode(pCxt, &yymsp[-3].minor.yy21, &yymsp[-1].minor.yy21, &yymsp[0].minor.yy21); } - yymsp[-3].minor.yy564 = yylhsminor.yy564; + case 337: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy140 = createRealTableNode(pCxt, &yymsp[-3].minor.yy253, &yymsp[-1].minor.yy253, &yymsp[0].minor.yy253); } + yymsp[-3].minor.yy140 = yylhsminor.yy140; break; - case 337: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy564 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy564), &yymsp[0].minor.yy21); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; + case 338: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy140 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy140), &yymsp[0].minor.yy253); } + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; - case 339: /* alias_opt ::= */ -{ yymsp[1].minor.yy21 = nil_token; } + case 340: /* alias_opt ::= */ +{ yymsp[1].minor.yy253 = nil_token; } break; - case 340: /* alias_opt ::= table_alias */ -{ yylhsminor.yy21 = yymsp[0].minor.yy21; } - yymsp[0].minor.yy21 = yylhsminor.yy21; + case 341: /* alias_opt ::= table_alias */ +{ yylhsminor.yy253 = yymsp[0].minor.yy253; } + yymsp[0].minor.yy253 = yylhsminor.yy253; break; - case 341: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy21 = yymsp[0].minor.yy21; } + case 342: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy253 = yymsp[0].minor.yy253; } break; - case 342: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 343: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==343); -{ yymsp[-2].minor.yy564 = yymsp[-1].minor.yy564; } + case 343: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 344: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==344); +{ yymsp[-2].minor.yy140 = yymsp[-1].minor.yy140; } break; - case 344: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy564 = createJoinTableNode(pCxt, yymsp[-4].minor.yy440, yymsp[-5].minor.yy564, yymsp[-2].minor.yy564, yymsp[0].minor.yy564); } - yymsp[-5].minor.yy564 = yylhsminor.yy564; + case 345: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy140 = createJoinTableNode(pCxt, yymsp[-4].minor.yy224, yymsp[-5].minor.yy140, yymsp[-2].minor.yy140, yymsp[0].minor.yy140); } + yymsp[-5].minor.yy140 = yylhsminor.yy140; break; - case 345: /* join_type ::= */ -{ yymsp[1].minor.yy440 = JOIN_TYPE_INNER; } + case 346: /* join_type ::= */ +{ yymsp[1].minor.yy224 = JOIN_TYPE_INNER; } break; - case 346: /* join_type ::= INNER */ -{ yymsp[0].minor.yy440 = JOIN_TYPE_INNER; } + case 347: /* join_type ::= INNER */ +{ yymsp[0].minor.yy224 = JOIN_TYPE_INNER; } break; - case 347: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 348: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy564 = createSelectStmt(pCxt, yymsp[-7].minor.yy173, yymsp[-6].minor.yy476, yymsp[-5].minor.yy564); - yymsp[-8].minor.yy564 = addWhereClause(pCxt, yymsp[-8].minor.yy564, yymsp[-4].minor.yy564); - yymsp[-8].minor.yy564 = addPartitionByClause(pCxt, yymsp[-8].minor.yy564, yymsp[-3].minor.yy476); - yymsp[-8].minor.yy564 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy564, yymsp[-2].minor.yy564); - yymsp[-8].minor.yy564 = addGroupByClause(pCxt, yymsp[-8].minor.yy564, yymsp[-1].minor.yy476); - yymsp[-8].minor.yy564 = addHavingClause(pCxt, yymsp[-8].minor.yy564, yymsp[0].minor.yy564); + yymsp[-8].minor.yy140 = createSelectStmt(pCxt, yymsp[-7].minor.yy273, yymsp[-6].minor.yy220, yymsp[-5].minor.yy140); + yymsp[-8].minor.yy140 = addWhereClause(pCxt, yymsp[-8].minor.yy140, yymsp[-4].minor.yy140); + yymsp[-8].minor.yy140 = addPartitionByClause(pCxt, yymsp[-8].minor.yy140, yymsp[-3].minor.yy220); + yymsp[-8].minor.yy140 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy140, yymsp[-2].minor.yy140); + yymsp[-8].minor.yy140 = addGroupByClause(pCxt, yymsp[-8].minor.yy140, yymsp[-1].minor.yy220); + yymsp[-8].minor.yy140 = addHavingClause(pCxt, yymsp[-8].minor.yy140, yymsp[0].minor.yy140); } break; - case 350: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy173 = false; } + case 351: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy273 = false; } break; - case 351: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy476 = NULL; } + case 352: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy220 = NULL; } break; - case 356: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy564 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy564), &yymsp[0].minor.yy21); } - yymsp[-1].minor.yy564 = yylhsminor.yy564; + case 357: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy140 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy140), &yymsp[0].minor.yy253); } + yymsp[-1].minor.yy140 = yylhsminor.yy140; break; - case 357: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy564 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), &yymsp[0].minor.yy21); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + case 358: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy140 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), &yymsp[0].minor.yy253); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 358: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy564 = createColumnNode(pCxt, &yymsp[-2].minor.yy21, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + case 359: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy140 = createColumnNode(pCxt, &yymsp[-2].minor.yy253, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 362: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 379: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==379); - case 389: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==389); -{ yymsp[-2].minor.yy476 = yymsp[0].minor.yy476; } + case 363: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 380: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==380); + case 390: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==390); +{ yymsp[-2].minor.yy220 = yymsp[0].minor.yy220; } break; - case 364: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy564 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy564), releaseRawExprNode(pCxt, yymsp[-1].minor.yy564)); } + case 365: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy140 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy140), releaseRawExprNode(pCxt, yymsp[-1].minor.yy140)); } break; - case 365: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy564 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy564)); } + case 366: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy140 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy140)); } break; - case 366: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy564 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy564), NULL, yymsp[-1].minor.yy564, yymsp[0].minor.yy564); } + case 367: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy140 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy140), NULL, yymsp[-1].minor.yy140, yymsp[0].minor.yy140); } break; - case 367: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy564 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy564), releaseRawExprNode(pCxt, yymsp[-3].minor.yy564), yymsp[-1].minor.yy564, yymsp[0].minor.yy564); } + case 368: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy140 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy140), releaseRawExprNode(pCxt, yymsp[-3].minor.yy140), yymsp[-1].minor.yy140, yymsp[0].minor.yy140); } break; - case 369: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy564 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy564); } + case 370: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy140 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy140); } break; - case 371: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy564 = createFillNode(pCxt, yymsp[-1].minor.yy268, NULL); } + case 372: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy140 = createFillNode(pCxt, yymsp[-1].minor.yy174, NULL); } break; - case 372: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy564 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy476)); } + case 373: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy140 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy220)); } break; - case 373: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy268 = FILL_MODE_NONE; } + case 374: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy174 = FILL_MODE_NONE; } break; - case 374: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy268 = FILL_MODE_PREV; } + case 375: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy174 = FILL_MODE_PREV; } break; - case 375: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy268 = FILL_MODE_NULL; } + case 376: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy174 = FILL_MODE_NULL; } break; - case 376: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy268 = FILL_MODE_LINEAR; } + case 377: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy174 = FILL_MODE_LINEAR; } break; - case 377: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy268 = FILL_MODE_NEXT; } + case 378: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy174 = FILL_MODE_NEXT; } break; - case 380: /* group_by_list ::= expression */ -{ yylhsminor.yy476 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); } - yymsp[0].minor.yy476 = yylhsminor.yy476; + case 381: /* group_by_list ::= expression */ +{ yylhsminor.yy220 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } + yymsp[0].minor.yy220 = yylhsminor.yy220; break; - case 381: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy476 = addNodeToList(pCxt, yymsp[-2].minor.yy476, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy564))); } - yymsp[-2].minor.yy476 = yylhsminor.yy476; + case 382: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy220 = addNodeToList(pCxt, yymsp[-2].minor.yy220, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy140))); } + yymsp[-2].minor.yy220 = yylhsminor.yy220; break; - case 384: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 385: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy564 = addOrderByClause(pCxt, yymsp[-3].minor.yy564, yymsp[-2].minor.yy476); - yylhsminor.yy564 = addSlimitClause(pCxt, yylhsminor.yy564, yymsp[-1].minor.yy564); - yylhsminor.yy564 = addLimitClause(pCxt, yylhsminor.yy564, yymsp[0].minor.yy564); + yylhsminor.yy140 = addOrderByClause(pCxt, yymsp[-3].minor.yy140, yymsp[-2].minor.yy220); + yylhsminor.yy140 = addSlimitClause(pCxt, yylhsminor.yy140, yymsp[-1].minor.yy140); + yylhsminor.yy140 = addLimitClause(pCxt, yylhsminor.yy140, yymsp[0].minor.yy140); } - yymsp[-3].minor.yy564 = yylhsminor.yy564; + yymsp[-3].minor.yy140 = yylhsminor.yy140; break; - case 386: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy564 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy564, yymsp[0].minor.yy564); } - yymsp[-3].minor.yy564 = yylhsminor.yy564; + case 387: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy140 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy140, yymsp[0].minor.yy140); } + yymsp[-3].minor.yy140 = yylhsminor.yy140; break; - case 391: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 395: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==395); -{ yymsp[-1].minor.yy564 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 392: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 396: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==396); +{ yymsp[-1].minor.yy140 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 392: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 396: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==396); -{ yymsp[-3].minor.yy564 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 393: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 397: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==397); +{ yymsp[-3].minor.yy140 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 393: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 397: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==397); -{ yymsp[-3].minor.yy564 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 394: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 398: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==398); +{ yymsp[-3].minor.yy140 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 398: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy564 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy564); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + case 399: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy140 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy140); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 402: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy564 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy564), yymsp[-1].minor.yy256, yymsp[0].minor.yy525); } - yymsp[-2].minor.yy564 = yylhsminor.yy564; + case 403: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy140 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), yymsp[-1].minor.yy238, yymsp[0].minor.yy69); } + yymsp[-2].minor.yy140 = yylhsminor.yy140; break; - case 403: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy256 = ORDER_ASC; } + case 404: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy238 = ORDER_ASC; } break; - case 404: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy256 = ORDER_ASC; } + case 405: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy238 = ORDER_ASC; } break; - case 405: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy256 = ORDER_DESC; } + case 406: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy238 = ORDER_DESC; } break; - case 406: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy525 = NULL_ORDER_DEFAULT; } + case 407: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy69 = NULL_ORDER_DEFAULT; } break; - case 407: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy525 = NULL_ORDER_FIRST; } + case 408: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy69 = NULL_ORDER_FIRST; } break; - case 408: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy525 = NULL_ORDER_LAST; } + case 409: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy69 = NULL_ORDER_LAST; } break; default: break; /********** End reduce actions ************************************************/ }; - assert( yyruleno 10 and c1 is not null"); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, selectPseudoColumn) { setDatabase("root", "test"); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index bd5ce0f4949957d78d113c487b9e942760919aae..1d8400e1ebe0c96d8531cba65786a0d72c8b1787 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -200,6 +200,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect strcpy(pScan->tableName.tname, pRealTable->table.tableName); pScan->showRewrite = pCxt->pPlanCxt->showRewrite; pScan->ratio = pRealTable->ratio; + pScan->dataRequired = FUNC_DATA_REQUIRED_ALL_NEEDED; // set columns to scan SNodeList* pCols = NULL; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 2a36e38ce1f7f84de807a4f2eeee1229fcdc41ec..c56e113d4072743f776749e43cc22f5357832e1d 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -14,7 +14,231 @@ */ #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; +} + +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); +} diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index f34452f84ac1f141fdba6b54a4450b1b8e366b1e..8459f4bebaced1bf67e754b96e6c03fc24cba2f1 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -437,6 +437,12 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp taosArrayPush(pCxt->pExecNodeList, &pSubplan->execNode); pSubplan->execNodeStat.tableNum = pScanLogicNode->pVgroupList->vgroups[0].numOfTable; 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); } @@ -486,58 +492,25 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, 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) { SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_JOIN); if (NULL == pJoin) { return TSDB_CODE_OUT_OF_MEMORY; } - SDataBlockDescNode* pLeftDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc; - SDataBlockDescNode* pRightDesc = ((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc; + int32_t code = TSDB_CODE_SUCCESS; - 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) { - 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) { code = addDataBlockSlots(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc); diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index aadbaf6fd874c1348906fa936785f00273282f52..0b21052955a6cb6609f2e838444e121714274373 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -23,18 +23,14 @@ #define SPLIT_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0) typedef struct SSplitContext { - int32_t errCode; int32_t groupId; - bool match; - void* pInfo; + bool split; } SSplitContext; -typedef int32_t (*FMatch)(SSplitContext* pCxt, SLogicSubplan* pSubplan); -typedef int32_t (*FSplit)(SSplitContext* pCxt); +typedef int32_t (*FSplit)(SSplitContext* pCxt, SLogicSubplan* pSubplan); typedef struct SSplitRule { char* pName; - FMatch matchFunc; FSplit splitFunc; } SSplitRule; @@ -58,30 +54,25 @@ static SLogicNode* stsMatchByNode(SLogicNode* pNode) { return NULL; } -static int32_t stsMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan) { - if (SPLIT_FLAG_TEST_MASK(pSubplan->splitFlag, SPLIT_FLAG_STS)) { - return TSDB_CODE_SUCCESS; - } +static void stsFindSplitNode(SLogicSubplan* pSubplan, SStsInfo* pInfo) { SLogicNode* pSplitNode = stsMatchByNode(pSubplan->pNode); if (NULL != pSplitNode) { - SStsInfo* pInfo = taosMemoryCalloc(1, sizeof(SStsInfo)); - if (NULL == pInfo) { - return TSDB_CODE_OUT_OF_MEMORY; - } pInfo->pScan = (SScanLogicNode*)pSplitNode; 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; FOREACH(pChild, pSubplan->pChildren) { - int32_t code = stsMatch(pCxt, (SLogicSubplan*)pChild); - if (TSDB_CODE_SUCCESS != code || pCxt->match) { - return code; + stsMatch(pCxt, (SLogicSubplan*)pChild, pInfo); + if (NULL != pInfo->pScan) { + break; } } - return TSDB_CODE_SUCCESS; + return; } static SLogicSubplan* stsCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode* pScan) { @@ -128,46 +119,44 @@ static int32_t stsCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla return TSDB_CODE_FAILED; } -static int32_t stsSplit(SSplitContext* pCxt) { - SStsInfo* pInfo = pCxt->pInfo; - if (NULL == pInfo->pSubplan->pChildren) { - pInfo->pSubplan->pChildren = nodesMakeList(); - if (NULL == pInfo->pSubplan->pChildren) { +static int32_t stsSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { + SStsInfo info = {0}; + stsMatch(pCxt, pSubplan, &info); + if (NULL == info.pScan) { + return TSDB_CODE_SUCCESS; + } + if (NULL == info.pSubplan->pChildren) { + info.pSubplan->pChildren = nodesMakeList(); + if (NULL == info.pSubplan->pChildren) { 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) { - code = stsCreateExchangeNode(pCxt, pInfo->pSubplan, pInfo->pScan); + code = stsCreateExchangeNode(pCxt, info.pSubplan, info.pScan); } ++(pCxt->groupId); - taosMemoryFreeClear(pCxt->pInfo); + pCxt->split = true; return code; } static const SSplitRule splitRuleSet[] = { - { .pName = "SuperTableScan", .matchFunc = stsMatch, .splitFunc = stsSplit } + { .pName = "SuperTableScan", .splitFunc = stsSplit } }; static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule)); static int32_t applySplitRule(SLogicSubplan* pSubplan) { - SSplitContext cxt = { .errCode = TSDB_CODE_SUCCESS, .groupId = pSubplan->id.groupId + 1, .match = false, .pInfo = NULL }; - bool split = false; + SSplitContext cxt = { .groupId = pSubplan->id.groupId + 1, .split = false }; do { - split = false; + cxt.split = false; for (int32_t i = 0; i < splitRuleNum; ++i) { - cxt.match = false; - int32_t code = splitRuleSet[i].matchFunc(&cxt, pSubplan); - if (TSDB_CODE_SUCCESS == code && cxt.match) { - code = splitRuleSet[i].splitFunc(&cxt); - split = true; - } + int32_t code = splitRuleSet[i].splitFunc(&cxt, pSubplan); if (TSDB_CODE_SUCCESS != code) { return code; } } - } while (split); + } while (cxt.split); return TSDB_CODE_SUCCESS; } @@ -201,6 +190,7 @@ int32_t splitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan pSubplan->subplanType = SUBPLAN_TYPE_SCAN; } pSubplan->id.queryId = pCxt->queryId; + pSubplan->id.groupId = 1; setLogicNodeParent(pSubplan->pNode); int32_t code = applySplitRule(pSubplan); diff --git a/source/libs/planner/test/plannerTest.cpp b/source/libs/planner/test/plannerTest.cpp index 697c562b1ea1f28a44a23ba93ca4b14888854a17..fd0084c01ecd8ae830ba615cfa26d2d490fcf68e 100644 --- a/source/libs/planner/test/plannerTest.cpp +++ b/source/libs/planner/test/plannerTest.cpp @@ -150,7 +150,7 @@ private: SQuery* query_; }; -TEST_F(PlannerTest, simple) { +TEST_F(PlannerTest, selectBasic) { setDatabase("root", "test"); bind("SELECT * FROM t1"); @@ -164,37 +164,50 @@ TEST_F(PlannerTest, selectConstant) { ASSERT_TRUE(run()); } -TEST_F(PlannerTest, stSimple) { +TEST_F(PlannerTest, selectStableBasic) { setDatabase("root", "test"); bind("SELECT * FROM st1"); ASSERT_TRUE(run()); } -TEST_F(PlannerTest, groupBy) { +TEST_F(PlannerTest, selectJoin) { setDatabase("root", "test"); - bind("SELECT count(*) FROM t1"); + bind("SELECT * FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts"); ASSERT_TRUE(run()); - bind("SELECT c1, max(c3), min(c2), count(*) FROM t1 GROUP BY c1"); + bind("SELECT * FROM st1s1 t1 join st1s2 t2 on t1.ts = t2.ts where t1.c1 > t2.c1"); ASSERT_TRUE(run()); - bind("SELECT c1 + c3, c1 + count(*) FROM t1 where c2 = 'abc' GROUP BY c1, c3"); + 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"); - bind("SELECT c1 + c3, sum(c4 * c5) FROM t1 where concat(c2, 'wwww') = 'abcwww' GROUP BY c1 + c3"); + bind("SELECT count(*) FROM t1"); ASSERT_TRUE(run()); + + // bind("SELECT c1, max(c3), min(c2), count(*) FROM t1 GROUP BY c1"); + // ASSERT_TRUE(run()); + + // bind("SELECT c1 + c3, c1 + count(*) FROM t1 where c2 = 'abc' GROUP BY c1, c3"); + // ASSERT_TRUE(run()); + + // bind("SELECT c1 + c3, sum(c4 * c5) FROM t1 where concat(c2, 'wwww') = 'abcwww' GROUP BY c1 + c3"); + // ASSERT_TRUE(run()); } -TEST_F(PlannerTest, subquery) { +TEST_F(PlannerTest, selectSubquery) { 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"); ASSERT_TRUE(run()); } -TEST_F(PlannerTest, interval) { +TEST_F(PlannerTest, selectInterval) { setDatabase("root", "test"); bind("SELECT count(*) FROM t1 interval(10s)"); @@ -210,14 +223,14 @@ TEST_F(PlannerTest, interval) { ASSERT_TRUE(run()); } -TEST_F(PlannerTest, sessionWindow) { +TEST_F(PlannerTest, selectSessionWindow) { setDatabase("root", "test"); bind("SELECT count(*) FROM t1 session(ts, 10s)"); ASSERT_TRUE(run()); } -TEST_F(PlannerTest, stateWindow) { +TEST_F(PlannerTest, selectStateWindow) { setDatabase("root", "test"); bind("SELECT count(*) FROM t1 state_window(c1)"); @@ -227,7 +240,7 @@ TEST_F(PlannerTest, stateWindow) { ASSERT_TRUE(run()); } -TEST_F(PlannerTest, partitionBy) { +TEST_F(PlannerTest, selectPartitionBy) { setDatabase("root", "test"); bind("SELECT * FROM t1 partition by c1"); @@ -243,7 +256,7 @@ TEST_F(PlannerTest, partitionBy) { ASSERT_TRUE(run()); } -TEST_F(PlannerTest, orderBy) { +TEST_F(PlannerTest, selectOrderBy) { setDatabase("root", "test"); bind("SELECT c1 FROM t1 order by c1"); @@ -259,7 +272,7 @@ TEST_F(PlannerTest, orderBy) { ASSERT_TRUE(run()); } -TEST_F(PlannerTest, groupByOrderBy) { +TEST_F(PlannerTest, selectGroupByOrderBy) { setDatabase("root", "test"); bind("select count(*), sum(c1) from t1 order by sum(c1)"); @@ -269,7 +282,7 @@ TEST_F(PlannerTest, groupByOrderBy) { ASSERT_TRUE(run()); } -TEST_F(PlannerTest, distinct) { +TEST_F(PlannerTest, selectDistinct) { setDatabase("root", "test"); bind("SELECT distinct c1 FROM t1"); @@ -282,7 +295,7 @@ TEST_F(PlannerTest, distinct) { ASSERT_TRUE(run()); } -TEST_F(PlannerTest, limit) { +TEST_F(PlannerTest, selectLimit) { setDatabase("root", "test"); bind("SELECT * FROM t1 limit 2"); @@ -295,7 +308,7 @@ TEST_F(PlannerTest, limit) { ASSERT_TRUE(run()); } -TEST_F(PlannerTest, slimit) { +TEST_F(PlannerTest, selectSlimit) { setDatabase("root", "test"); bind("SELECT * FROM t1 partition by c1 slimit 2"); diff --git a/source/libs/scalar/inc/sclInt.h b/source/libs/scalar/inc/sclInt.h index 58b62bb05e40ff80f50a59601fd1256eb4cc00e3..3d59ffd93d7ac7e59ac1aa9e81023f3d2cb30636 100644 --- a/source/libs/scalar/inc/sclInt.h +++ b/source/libs/scalar/inc/sclInt.h @@ -46,8 +46,9 @@ typedef struct SScalarCtx { int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out); SColumnInfoData* createColumnInfoData(SDataType* pType, int32_t numOfRows); -#define GET_PARAM_TYPE(_c) ((_c)->columnData->info.type) -#define GET_PARAM_BYTES(_c) ((_c)->columnData->info.bytes) +#define GET_PARAM_TYPE(_c) ((_c)->columnData->info.type) +#define GET_PARAM_BYTES(_c) ((_c)->columnData->info.bytes) +#define GET_PARAM_PRECISON(_c) ((_c)->columnData->info.precision) void sclFreeParam(SScalarParam *param); diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 0956c2add56970ff23d99498a3599fcbdcd1f075..b53dc955de2436f93ab6498b8386f607aa03f4db 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1,6 +1,7 @@ #include "function.h" #include "scalar.h" #include "tdatablock.h" +#include "ttime.h" #include "sclInt.h" #include "sclvector.h" @@ -647,6 +648,461 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu 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) { return doScalarFunctionUnique(pInput, inputNum, pOutput, atan); diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c index cd1fbf8e0e20d0eec0da0faba075df34ec5477e0..c747e6933923ef970097d8ea0bcf11a6335b897a 100644 --- a/source/libs/transport/src/thttp.c +++ b/source/libs/transport/src/thttp.c @@ -164,8 +164,8 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32 wb[1] = uv_buf_init((char*)pCont, contLen); connect->data = wb; - uv_tcp_connect(connect, &socket_tcp, (const struct sockaddr*)&dest, clientConnCb); terrno = 0; + uv_tcp_connect(connect, &socket_tcp, (const struct sockaddr*)&dest, clientConnCb); uv_run(loop, UV_RUN_DEFAULT); uv_loop_close(loop); taosMemoryFree(connect); diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index b4058b3c0ed3218694e24ad6ce429064d329ff03..a955fb3b0a88d53beae43e49ed03df735388c0d2 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -76,6 +76,47 @@ int32_t taosMkDir(const char *dirname) { 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) { DIR *dir = opendir(dirname); if (dir == NULL) return; diff --git a/source/os/src/osProc.c b/source/os/src/osProc.c index 1cdd41ad78e448caed56a412b340399f624ba4a5..b6de638ac2e4c9fe851d7c73515a9d509ef2ae95 100644 --- a/source/os/src/osProc.c +++ b/source/os/src/osProc.c @@ -24,7 +24,7 @@ int32_t taosNewProc(char **args) { if (pid == 0) { args[0] = tsProcPath; // close(STDIN_FILENO); - close(STDOUT_FILENO); + // close(STDOUT_FILENO); // close(STDERR_FILENO); return execvp(tsProcPath, args); } else { diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index 26de26ab6778e327d787a97ad538111dcfcf2781..4ffbc13fb3b33aa9d4e44b55e53caf3aa6476713 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -369,53 +369,33 @@ int32_t taosGetCpuCores(float *numOfCores) { #endif } -int32_t taosGetCpuUsage(double *cpu_system, double *cpu_engine) { -#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) - *cpu_system = 0; - *cpu_engine = 0; - return 0; -#elif defined(_TD_DARWIN_64) +void taosGetCpuUsage(double *cpu_system, double *cpu_engine) { + 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_engine = 0; - return 0; -#else - static uint64_t lastSysUsed = 0; - static uint64_t lastSysTotal = 0; - static uint64_t lastProcTotal = 0; - - SysCpuInfo sysCpu; - ProcCpuInfo procCpu; - if (taosGetSysCpuInfo(&sysCpu) != 0) { - return -1; - } - 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; + SysCpuInfo sysCpu = {0}; + ProcCpuInfo procCpu = {0}; + if (taosGetSysCpuInfo(&sysCpu) == 0 && taosGetProcCpuInfo(&procCpu) == 0) { + curSysUsed = sysCpu.user + sysCpu.nice + sysCpu.system; + curSysTotal = curSysUsed + sysCpu.idle; + 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 && curSysUsed >= lastSysUsed && curProcTotal >= lastProcTotal) { + *cpu_engine = (curSysUsed - lastSysUsed) / (double)(curSysTotal - lastSysTotal) * 100; + *cpu_system = (curProcTotal - lastProcTotal) / (double)(curSysTotal - lastSysTotal) * 100; + } - if (curSysTotal == lastSysTotal) { - return -1; + lastSysUsed = curSysUsed; + lastSysTotal = curSysTotal; + lastProcTotal = curProcTotal; } - - *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) { @@ -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_read_bytes = 0; static int64_t last_write_bytes = 0; - static int64_t cur_rchars = 0; static int64_t cur_wchars = 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_read_bytes = cur_read_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) { static int64_t last_receive_bytes = 0; static int64_t last_transmit_bytes = 0; - static int64_t cur_receive_bytes = 0; static int64_t 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; last_receive_bytes = cur_receive_bytes; last_transmit_bytes = cur_transmit_bytes; + } else { + *receive_bytes = 0; + *transmit_bytes = 0; } } diff --git a/tests/script/tmp/back.sim b/tests/script/tmp/back.sim new file mode 100644 index 0000000000000000000000000000000000000000..9202e90594bc3bed6e4b63f2ac1f863af91620be --- /dev/null +++ b/tests/script/tmp/back.sim @@ -0,0 +1,6 @@ +sql connect +$x = 1 +begin: + sql insert into db.tb values(now, $x ) -x begin + $x = $x + 1 +goto begin diff --git a/tests/script/tmp/data.sim b/tests/script/tmp/data.sim new file mode 100644 index 0000000000000000000000000000000000000000..faac5b28289099c4050579f51099cfda716ad887 --- /dev/null +++ b/tests/script/tmp/data.sim @@ -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 diff --git a/tests/script/tmp/monitor.sim b/tests/script/tmp/monitor.sim new file mode 100644 index 0000000000000000000000000000000000000000..ba98bec2d05ef9c976ac93c8092b2d5051caf62e --- /dev/null +++ b/tests/script/tmp/monitor.sim @@ -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 diff --git a/tests/script/tsim/query/complex_group.sim b/tests/script/tsim/query/complex_group.sim index 3a1ec523fe8f449fc884e8e3867dadde32898715..d6ce26b69a05e404fc8b60907285d1a47178f376 100644 --- a/tests/script/tsim/query/complex_group.sim +++ b/tests/script/tsim/query/complex_group.sim @@ -97,167 +97,167 @@ print ================ query 1 group by filter sql select count(*) from ct3 group by c1 print ====> sql : select count(*) from ct3 group by c1 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c2 print ====> sql : select count(*) from ct3 group by c2 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c3 print ====> sql : select count(*) from ct3 group by c3 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c4 print ====> sql : select count(*) from ct3 group by c4 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c5 print ====> sql : select count(*) from ct3 group by c5 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c6 print ====> sql : select count(*) from ct3 group by c6 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c7 print ====> sql : select count(*) from ct3 group by c7 print ====> rows: $rows -if $rows != 2 then +if $rows != 3 then return -1 endi sql select count(*) from ct3 group by c8 print ====> sql : select count(*) from ct3 group by c8 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c9 print ====> sql : select count(*) from ct3 group by c9 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c10 print ====> sql : select count(*) from ct3 group by c10 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi print ================ query 2 complex with group by 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 if $rows != 1 then return -1 endi -sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 @@ -307,170 +307,170 @@ print ================ query 1 group by filter sql select count(*) from ct3 group by c1 print ====> sql : select count(*) from ct3 group by c1 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c2 print ====> sql : select count(*) from ct3 group by c2 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c3 print ====> sql : select count(*) from ct3 group by c3 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c4 print ====> sql : select count(*) from ct3 group by c4 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c5 print ====> sql : select count(*) from ct3 group by c5 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c6 print ====> sql : select count(*) from ct3 group by c6 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c7 print ====> sql : select count(*) from ct3 group by c7 print ====> rows: $rows -if $rows != 2 then +if $rows != 3 then return -1 endi sql select count(*) from ct3 group by c8 print ====> sql : select count(*) from ct3 group by c8 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c9 print ====> sql : select count(*) from ct3 group by c9 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi sql select count(*) from ct3 group by c10 print ====> sql : select count(*) from ct3 group by c10 print ====> rows: $rows -if $rows != 8 then +if $rows != 9 then return -1 endi print ================ query 2 complex with group by 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 if $rows != 1 then return -1 endi -sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 -print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +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 c1 limit 1 offset 2 print ====> rows: $rows if $rows != 1 then return -1 endi -#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/query/complex_having.sim b/tests/script/tsim/query/complex_having.sim new file mode 100644 index 0000000000000000000000000000000000000000..10283153d89c1cd6839db0b1cdc24b7f562fd623 --- /dev/null +++ b/tests/script/tsim/query/complex_having.sim @@ -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 \ No newline at end of file diff --git a/tests/script/tsim/query/complex_where.sim b/tests/script/tsim/query/complex_where.sim index 7a5de85a3c39cc8cffcba644125a321ea5e2f619..312c1d98ed1d5bdb189612de5293e7d2967a1309 100644 --- a/tests/script/tsim/query/complex_where.sim +++ b/tests/script/tsim/query/complex_where.sim @@ -192,14 +192,14 @@ if $data01 != 1 then return -1 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 ====> rows: $rows print ====> rows0: $data00 -if $rows != 4 then +if $rows != 3 then return -1 endi -if $data01 != 6 then +if $data00 != 6 then return -1 endi @@ -210,7 +210,7 @@ print ====> rows0: $data00 if $rows != 32 then return -1 endi -if $data01 != 1 then +if $data00 != 1 then return -1 endi @@ -221,7 +221,7 @@ print ====> rows0: $data00 if $rows != 17 then return -1 endi -if $data01 != 5 then +if $data00 != 5 then return -1 endi @@ -240,7 +240,7 @@ if $rows != 12 then return -1 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) print ====> sql : select c1 from stb1 where c1 in (1,2,3) @@ -272,98 +272,98 @@ endi 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then @@ -510,14 +510,14 @@ if $data01 != 1 then return -1 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 ====> rows: $rows print ====> rows0: $data00 -if $rows != 4 then +if $rows != 3 then return -1 endi -if $data01 != 6 then +if $data00 != 6 then return -1 endi @@ -528,7 +528,7 @@ print ====> rows0: $data00 if $rows != 32 then return -1 endi -if $data01 != 1 then +if $data00 != 1 then return -1 endi @@ -539,7 +539,7 @@ print ====> rows0: $data00 if $rows != 17 then return -1 endi -if $data01 != 5 then +if $data00 != 5 then return -1 endi @@ -558,7 +558,7 @@ if $rows != 12 then return -1 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) print ====> sql : select c1 from stb1 where c1 in (1,2,3) @@ -590,98 +590,98 @@ endi 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then return -1 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 ====> rows: $rows if $rows != 1 then diff --git a/tests/script/tsim/query/diff.sim b/tests/script/tsim/query/diff.sim index ebbd4709441e589507d077f8c3fc4fcc3a09f420..c55b080e4439613bb28182d6b75e1420e3efa84c 100644 --- a/tests/script/tsim/query/diff.sim +++ b/tests/script/tsim/query/diff.sim @@ -63,20 +63,21 @@ print =============== step2 $i = 1 $tb = $tbPrefix . $i -print ===> select diff(tbcol) from $tb -sql select diff(tbcol) from $tb +print ===> select _rowts, diff(tbcol) from $tb +sql select _rowts, diff(tbcol) from $tb print ===> rows: $rows print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 -if $data11 != 1 then +if $data11 != 1 then + print expect 1, actual: $data11 return -1 endi print =============== step3 $cc = 4 * 60000 $ms = 1601481600000 + $cc -print ===> select diff(tbcol) from $tb where ts > $ms -sql select diff(tbcol) from $tb where ts > $ms +print ===> select _rowts, diff(tbcol) from $tb where ts > $ms +sql select _rowts, diff(tbcol) from $tb where ts > $ms print ===> rows: $rows print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 @@ -86,8 +87,8 @@ endi $cc = 4 * 60000 $ms = 1601481600000 + $cc -print ===> select diff(tbcol) from $tb where ts <= $ms -sql select diff(tbcol) from $tb where ts <= $ms +print ===> select _rowts, diff(tbcol) from $tb where ts <= $ms +sql select _rowts, diff(tbcol) from $tb where ts <= $ms print ===> rows: $rows print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 @@ -96,8 +97,8 @@ if $data11 != 1 then endi print =============== step4 -print ===> select diff(tbcol) as b from $tb -sql select diff(tbcol) as b from $tb +print ===> select _rowts, diff(tbcol) as b from $tb +sql select _rowts, diff(tbcol) as b from $tb print ===> rows: $rows print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 @@ -105,24 +106,24 @@ if $data11 != 1 then return -1 endi -print =============== step5 -print ===> select diff(tbcol) as b from $tb interval(1m) -sql select diff(tbcol) as b from $tb interval(1m) -x step5 - return -1 -step5: - -print =============== step6 -$cc = 4 * 60000 -$ms = 1601481600000 + $cc -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 - return -1 +#print =============== step5 +#print ===> select diff(tbcol) as b from $tb interval(1m) +#sql select diff(tbcol) as b from $tb interval(1m) -x step5 +# return -1 +#step5: +# +#print =============== step6 +#$cc = 4 * 60000 +#$ms = 1601481600000 + $cc +#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 +# return -1 step6: print =============== clear sql drop database $db sql show databases -if $rows != 0 then +if $rows != 1 then return -1 endi diff --git a/tests/script/tsim/tmq/insertDataV1.sim b/tests/script/tsim/tmq/insertDataV1.sim new file mode 100644 index 0000000000000000000000000000000000000000..a349c55dbdd9facc451e8bba3d91fae9a2110736 --- /dev/null +++ b/tests/script/tsim/tmq/insertDataV1.sim @@ -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 + + diff --git a/tests/script/tsim/tmq/insertDataV4.sim b/tests/script/tsim/tmq/insertDataV4.sim new file mode 100644 index 0000000000000000000000000000000000000000..72c1358e7f30e750ef0f3bbba8d15bf27513dbb2 --- /dev/null +++ b/tests/script/tsim/tmq/insertDataV4.sim @@ -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 + + diff --git a/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim b/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim new file mode 100644 index 0000000000000000000000000000000000000000..0df7a8ba57de9a25e75d079fe6898af0e99e1b9f --- /dev/null +++ b/tests/script/tsim/tmq/mainConsumerInMultiTopic.sim @@ -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: +# enable.auto.commit: +# auto.offset.reset: +# td.connect.ip: +# 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 diff --git a/tests/script/tsim/tmq/mainConsumerInOneTopic.sim b/tests/script/tsim/tmq/mainConsumerInOneTopic.sim new file mode 100644 index 0000000000000000000000000000000000000000..b9a867921e79d7323c59e6759381b2f70d39baf5 --- /dev/null +++ b/tests/script/tsim/tmq/mainConsumerInOneTopic.sim @@ -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: +# enable.auto.commit: +# auto.offset.reset: +# td.connect.ip: +# 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 diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c index 273852b4984cd75a0d9e0c29291292deed37e705..2527f1d01a32e9c8650e251c522ca59b6d39abde 100644 --- a/tests/test/c/tmqSim.c +++ b/tests/test/c/tmqSim.c @@ -42,6 +42,8 @@ typedef struct { char topicString[256]; char keyString[1024]; int32_t showMsgFlag; + int32_t consumeDelay; // unit s + int32_t consumeMsgCnt; // save result after parse agrvs 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\n", indent, "-g"); 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); } void parseArgument(int32_t argc, char *argv[]) { 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++) { 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]); } else if (strcmp(argv[i], "-g") == 0) { 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 { printf("%s unknow para: %s %s", GREEN, argv[++i], NC); exit(-1); @@ -256,6 +269,48 @@ void loop_consume(tmq_t* tmq) { 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[]) { parseArgument(argc, argv); parseInputString(); @@ -271,8 +326,12 @@ int main(int32_t argc, char *argv[]) { printf("tmq_subscribe() fail, reason: %s\n", tmq_err2str(err)); exit(-1); } - - loop_consume(tmq); + + if (0 == g_stConfInfo.consumeMsgCnt) { + loop_consume(tmq); + } else { + parallel_consume(tmq); + } err = tmq_unsubscribe(tmq); if (err) { diff --git a/tests/tsim/src/simSystem.c b/tests/tsim/src/simSystem.c index eb5fb682642dce2601167f671370d9a2320c3b8b..5bbcceada5591454c6dcb639d6ee22112baf6073 100644 --- a/tests/tsim/src/simSystem.c +++ b/tests/tsim/src/simSystem.c @@ -80,24 +80,24 @@ SScript *simProcessCallOver(SScript *script) { simExecSuccess = false; simInfo("script:" FAILED_PREFIX "%s" FAILED_POSTFIX ", " FAILED_PREFIX "failed" FAILED_POSTFIX ", error:%s", script->fileName, script->error); - return NULL; } else { simExecSuccess = true; simInfo("script:" SUCCESS_PREFIX "%s" SUCCESS_POSTFIX ", " SUCCESS_PREFIX "success" SUCCESS_POSTFIX, 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 { simDebug("script:%s, is stopped", script->fileName); simFreeScript(script); diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 0e611f379410245a041002bf27bc7b11b9557f46..b89d517ad3e4396d1472e0b0a6a8a7d2333ab7c5 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -26,6 +26,7 @@ #include "tglobal.h" #include "ttypes.h" #include "tutil.h" +#include "tconfig.h" #include #include @@ -90,6 +91,11 @@ TAOS *shellInit(SShellArguments *_args) { _args->user = TSDB_DEFAULT_USER; } + SConfig *pCfg = cfgInit(); + if (NULL == pCfg) return NULL; + + if (0 != taosAddClientLogCfg(pCfg)) return NULL; + // Connect to the database. TAOS *con = NULL; if (_args->auth == NULL) { diff --git a/tools/taos-tools b/tools/taos-tools index 33cdfe4f90a209f105c1b6091439798a9cde1e93..bf6c766986c61ff4fc80421fdea682a8fd4b5b32 160000 --- a/tools/taos-tools +++ b/tools/taos-tools @@ -1 +1 @@ -Subproject commit 33cdfe4f90a209f105c1b6091439798a9cde1e93 +Subproject commit bf6c766986c61ff4fc80421fdea682a8fd4b5b32