From b8725618f066cd707da0e0bae481e77450136d3b Mon Sep 17 00:00:00 2001 From: lyh250-666 Date: Wed, 23 Oct 2024 23:26:44 +0800 Subject: [PATCH 01/40] opti:modify time range of select ts in --- source/libs/scalar/src/filter.c | 33 ++++++++++++++++++++++++++++++--- tests/script/tsim/scalar/in.sim | 15 +++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 03bc2b544b..c9740b8c25 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -4541,6 +4541,7 @@ int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict) { if (info->scalarMode) { SArray *colRanges = info->sclCtx.fltSclRange; + SOperatorNode *optNode = (SOperatorNode *) pNode; if (taosArrayGetSize(colRanges) == 1) { SFltSclColumnRange *colRange = taosArrayGet(colRanges, 0); if (NULL == colRange) { @@ -4560,7 +4561,8 @@ int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict) { FLT_ERR_JRET(fltSclGetTimeStampDatum(endPt, &end)); win->skey = start.i; win->ekey = end.i; - *isStrict = true; + if(optNode->opType == OP_TYPE_IN) *isStrict = false; + else *isStrict = true; goto _return; } else if (taosArrayGetSize(points) == 0) { *win = TSWINDOW_DESC_INITIALIZER; @@ -5023,6 +5025,29 @@ int32_t fltSclBuildRangePoints(SFltSclOperator *oper, SArray *points) { } break; } + case OP_TYPE_IN: { + SNodeListNode *listNode = (SNodeListNode *)oper->valNode; + SListCell *cell = listNode->pNodeList->pHead; + SFltSclDatum minDatum = {.kind = FLT_SCL_DATUM_KIND_INT64, .i = INT64_MAX, .type = oper->colNode->node.resType}; + SFltSclDatum maxDatum = {.kind = FLT_SCL_DATUM_KIND_INT64, .i = INT64_MIN, .type = oper->colNode->node.resType}; + for (int32_t i = 0; i < listNode->pNodeList->length; ++i) { + SValueNode *valueNode = (SValueNode *)cell->pNode; + SFltSclDatum valDatum; + FLT_ERR_RET(fltSclBuildDatumFromValueNode(&valDatum, valueNode)); + minDatum.i = TMIN(minDatum.i, valDatum.i); + maxDatum.i = TMAX(maxDatum.i, valDatum.i); + cell = cell->pNext; + } + SFltSclPoint startPt = {.start = true, .excl = false, .val = minDatum}; + SFltSclPoint endPt = {.start = false, .excl = false, .val = maxDatum}; + if (NULL == taosArrayPush(points, &startPt)) { + FLT_ERR_RET(terrno); + } + if (NULL == taosArrayPush(points, &endPt)) { + FLT_ERR_RET(terrno); + } + break; + } default: { qError("not supported operator type : %d when build range points", oper->type); break; @@ -5075,11 +5100,13 @@ static bool fltSclIsCollectableNode(SNode *pNode) { if (!(pOper->opType == OP_TYPE_GREATER_THAN || pOper->opType == OP_TYPE_GREATER_EQUAL || pOper->opType == OP_TYPE_LOWER_THAN || pOper->opType == OP_TYPE_LOWER_EQUAL || - pOper->opType == OP_TYPE_NOT_EQUAL || pOper->opType == OP_TYPE_EQUAL)) { + pOper->opType == OP_TYPE_NOT_EQUAL || pOper->opType == OP_TYPE_EQUAL || + pOper->opType == OP_TYPE_IN)) { return false; } - if (!(nodeType(pOper->pLeft) == QUERY_NODE_COLUMN && nodeType(pOper->pRight) == QUERY_NODE_VALUE)) { + if (!((nodeType(pOper->pLeft) == QUERY_NODE_COLUMN && nodeType(pOper->pRight) == QUERY_NODE_VALUE) || + (nodeType(pOper->pLeft) == QUERY_NODE_COLUMN && nodeType(pOper->pRight) == QUERY_NODE_NODE_LIST))) { return false; } return true; diff --git a/tests/script/tsim/scalar/in.sim b/tests/script/tsim/scalar/in.sim index 75e1face88..d241bbc1bf 100644 --- a/tests/script/tsim/scalar/in.sim +++ b/tests/script/tsim/scalar/in.sim @@ -35,6 +35,14 @@ if $rows != 3 then return -1 endi +sql explain verbose true select * from tb1 where tts in ('2022-07-10 16:31:01', '2022-07-10 16:31:03', 1657441865000); +if $rows != 3 then + return -1 +endi +if $data20 != @ Time Range: [-9223372036854775808, 9223372036854775807]@ then + return -1 +endi + sql select * from tb1 where fbool in (0, 3); if $rows != 5 then return -1 @@ -80,4 +88,11 @@ if $rows != 0 then return -1 endi +sql explain verbose true select * from tb1 where fts in ('2022-07-10 16:31:00', '2022-07-10 16:33:00', 1657441840000); +if $rows != 4 then + return -1 +endi +if $data20 != @ Time Range: [1657441840000, 1657441980000]@ then + return -1 +endi system sh/exec.sh -n dnode1 -s stop -x SIGINT From 736149daeae74f38510ec4ab2e84026ac3e24316 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 24 Oct 2024 17:41:37 +0800 Subject: [PATCH 02/40] feat: from 3.3.1.0~ 3.3.3.0 new key add --- tools/shell/src/shellAuto.c | 155 ++++++++++++++++++++++++++++-------- 1 file changed, 121 insertions(+), 34 deletions(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 65ae9fad54..9e6b0fe79e 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -99,6 +99,8 @@ SWords shellCommands[] = { {"create qnode on dnode ;", 0, 0, NULL}, {"create stream into as select", 0, 0, NULL}, // 26 append sub sql {"create topic as select", 0, 0, NULL}, // 27 append sub sql + {"create tsma on function", 0, 0, NULL}, + {"create recursive tsma on interval(", 0, 0, NULL}, {"create function as outputtype language ", 0, 0, NULL}, {"create or replace as outputtype language ", 0, 0, NULL}, {"create aggregate function as outputtype bufsize language ", 0, 0, NULL}, @@ -123,6 +125,7 @@ SWords shellCommands[] = { {"drop consumer group on ", 0, 0, NULL}, {"drop topic ;", 0, 0, NULL}, {"drop stream ;", 0, 0, NULL}, + {"drop tsma ;", 0, 0, NULL}, {"explain select", 0, 0, NULL}, // 44 append sub sql {"flush database ;", 0, 0, NULL}, {"help;", 0, 0, NULL}, @@ -163,12 +166,14 @@ SWords shellCommands[] = { {"show create database \\G;", 0, 0, NULL}, {"show create stable \\G;", 0, 0, NULL}, {"show create table \\G;", 0, 0, NULL}, + {"show create tsma \\G;", 0, 0, NULL}, #ifdef TD_ENTERPRISE {"show create view \\G;", 0, 0, NULL}, -#endif - {"show connections;", 0, 0, NULL}, {"show compact", 0, 0, NULL}, {"show compacts;", 0, 0, NULL}, + +#endif + {"show connections;", 0, 0, NULL}, {"show cluster;", 0, 0, NULL}, {"show cluster alive;", 0, 0, NULL}, {"show cluster machines;", 0, 0, NULL}, @@ -196,10 +201,12 @@ SWords shellCommands[] = { {"show table tags from ", 0, 0, NULL}, {"show topics;", 0, 0, NULL}, {"show transactions;", 0, 0, NULL}, + {"show tsmas;", 0, 0, NULL}, {"show users;", 0, 0, NULL}, {"show variables;", 0, 0, NULL}, {"show local variables;", 0, 0, NULL}, - {"show vnodes ", 0, 0, NULL}, + {"show vnodes;", 0, 0, NULL}, + {"show vnodes on dnode ;", 0, 0, NULL}, {"show vgroups;", 0, 0, NULL}, {"show consumers;", 0, 0, NULL}, {"show grants;", 0, 0, NULL}, @@ -207,22 +214,26 @@ SWords shellCommands[] = { {"show grants logs;", 0, 0, NULL}, #ifdef TD_ENTERPRISE {"show views;", 0, 0, NULL}, + {"show arbgroups;", 0, 0, NULL}, {"split vgroup ", 0, 0, NULL}, + {"s3migrate database ", 0, 0, NULL}, #endif {"insert into values(", 0, 0, NULL}, {"insert into using tags(", 0, 0, NULL}, {"insert into using values(", 0, 0, NULL}, {"insert into file ", 0, 0, NULL}, {"trim database ", 0, 0, NULL}, - {"s3migrate database ", 0, 0, NULL}, {"use ", 0, 0, NULL}, {"quit", 0, 0, NULL}}; +// where keyword char* keywords[] = { "and ", "asc ", "desc ", "from ", "fill(", "limit ", "where ", "interval(", "order by ", "order by ", "offset ", "or ", "group by ", "now()", "session(", "sliding ", "slimit ", "soffset ", "state_window(", "today() ", "union all select ", - "partition by "}; + "partition by ", "match", "nmatch ", "between ", "like ", "is null ", "is not null ", + "state_window(", "event_window ", "count_window(" +}; char* functions[] = { "count(", "sum(", @@ -255,6 +266,20 @@ char* functions[] = { "timezone(", "timetruncate(", "twa(", "to_unixtimestamp(", "unique(", "upper(", + "pi(", "round(", + "truncate(", "exp(", + "ln(", "mod(", + "rand(", "sign(", + "degrees(", "radians(", + "greatest(", "least(", + "char_length(", "char(", + "ascii(", "position(", + "trim(", "replace(", + "repeat(", "substring(", + "substring_index(","timediff(", + "week(", "weekday(", + "weekofyear(", "dayofweek(", + "stddev_pop(", "var_pop(" }; char* tb_actions[] = { @@ -275,7 +300,7 @@ char* db_options[] = {"keep ", "cachesize ", "comp ", "duration ", - "wal_fsync_period", + "wal_fsync_period ", "maxrows ", "minrows ", "pages ", @@ -284,17 +309,22 @@ char* db_options[] = {"keep ", "wal_level ", "vgroups ", "single_stable ", - "s3_chunksize ", - "s3_keeplocal ", - "s3_compact ", + "s3_chunksize ", + "s3_keeplocal ", + "s3_compact ", "wal_retention_period ", "wal_roll_period ", "wal_retention_size ", - "wal_segment_size "}; +#ifdef TD_ENTERPRISE + "encrypt_algorithm " +#endif + "keep_time_offset ", + "wal_segment_size " +}; char* alter_db_options[] = {"cachemodel ", "replica ", "keep ", "stt_trigger ", "wal_retention_period ", "wal_retention_size ", "cachesize ", - "s3_keeplocal ", "s3_compact ", + "s3_keeplocal ", "s3_compact ", "wal_fsync_period ", "buffer ", "pages " ,"wal_level "}; char* data_types[] = {"timestamp", "int", @@ -304,6 +334,7 @@ char* data_types[] = {"timestamp", "int", "bigint", "bigint unsigned", "smallint", "smallint unsigned", "tinyint", "tinyint unsigned", + "geometry", "varbinary(16)", "bool", "json"}; char* key_tags[] = {"tags("}; @@ -319,6 +350,15 @@ char* key_systable[] = { char* udf_language[] = {"\'Python\'", "\'C\'"}; +char* field_options[] = { + "encode ", "compress ", "level ", + "lz4 ", "zlib ", "zstd ", "xz ", "tsz ", "disabled ", // compress + "simple8b ", "delta-i ", "delta-d ", "bit-packing ", + "high ", "medium ", "low ", + "comment ", + "primary key " +}; + // global keys can tips on anywhere char* global_keys[] = { "tbname", @@ -354,27 +394,29 @@ bool waitAutoFill = false; #define WT_VAR_STREAM 6 #define WT_VAR_UDFNAME 7 #define WT_VAR_VGROUPID 8 +#define WT_VAR_TSMA 9 -#define WT_FROM_DB_MAX 8 // max get content from db +#define WT_FROM_DB_MAX 9 // max get content from db #define WT_FROM_DB_CNT (WT_FROM_DB_MAX + 1) -#define WT_VAR_ALLTABLE 9 -#define WT_VAR_FUNC 10 -#define WT_VAR_KEYWORD 11 -#define WT_VAR_TBACTION 12 -#define WT_VAR_DBOPTION 13 -#define WT_VAR_ALTER_DBOPTION 14 -#define WT_VAR_DATATYPE 15 -#define WT_VAR_KEYTAGS 16 -#define WT_VAR_ANYWORD 17 -#define WT_VAR_TBOPTION 18 -#define WT_VAR_USERACTION 19 -#define WT_VAR_KEYSELECT 20 -#define WT_VAR_SYSTABLE 21 -#define WT_VAR_LANGUAGE 22 -#define WT_VAR_GLOBALKEYS 23 +#define WT_VAR_ALLTABLE 10 +#define WT_VAR_FUNC 11 +#define WT_VAR_KEYWORD 12 +#define WT_VAR_TBACTION 13 +#define WT_VAR_DBOPTION 14 +#define WT_VAR_ALTER_DBOPTION 15 +#define WT_VAR_DATATYPE 16 +#define WT_VAR_KEYTAGS 17 +#define WT_VAR_ANYWORD 18 +#define WT_VAR_TBOPTION 19 +#define WT_VAR_USERACTION 20 +#define WT_VAR_KEYSELECT 21 +#define WT_VAR_SYSTABLE 22 +#define WT_VAR_LANGUAGE 23 +#define WT_VAR_GLOBALKEYS 24 +#define WT_VAR_FIELD_OPTIONS 25 -#define WT_VAR_CNT 24 +#define WT_VAR_CNT 26 #define WT_TEXT 0xFF @@ -387,12 +429,17 @@ TdThreadMutex tiresMutex; TdThread* threads[WT_FROM_DB_CNT]; // obtain var name with sql from server char varTypes[WT_VAR_CNT][64] = { + // get from db "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", ""}; + "", "", "", + // get from code + "", "", "", "", "", "", + "", "", "", "", "", "", "", + "", "", ""}; char varSqls[WT_FROM_DB_CNT][64] = {"show databases;", "show stables;", "show tables;", "show dnodes;", - "show users;", "show topics;", "show streams;", "show functions;", "show vgroups;"}; + "show users;", "show topics;", "show streams;", "show functions;", + "show vgroups;", "show tsmas;"}; // var words current cursor, if user press any one key except tab, cursorVar can be reset to -1 int cursorVar = -1; @@ -567,7 +614,8 @@ void showHelp() { show users;\n\ show variables;\n\ show local variables;\n\ - show vnodes \n\ + show vnodes;\n\ + show vnodes on dnode ;\n\ show vgroups;\n\ show consumers;\n\ show grants;\n\ @@ -588,8 +636,10 @@ void showHelp() { create view as select ...\n\ redistribute vgroup dnode ;\n\ split vgroup ;\n\ + s3migrate database ;\n\ show compacts;\n\ show compact \n\ + show arbgroups;\n\ show views;\n\ show create view ;"); #endif @@ -756,6 +806,7 @@ bool shellAutoInit() { GenerateVarType(WT_VAR_SYSTABLE, key_systable, sizeof(key_systable) / sizeof(char*)); GenerateVarType(WT_VAR_LANGUAGE, udf_language, sizeof(udf_language) / sizeof(char*)); GenerateVarType(WT_VAR_GLOBALKEYS, global_keys, sizeof(global_keys) / sizeof(char*)); + GenerateVarType(WT_VAR_FIELD_OPTIONS, field_options, sizeof(field_options) / sizeof(char*)); return true; } @@ -1648,6 +1699,36 @@ bool matchSelectQuery(TAOS* con, SShellCmd* cmd) { return appendAfterSelect(con, cmd, p, len); } +// is fields option area +bool fieldOptionsArea(char* p) { + char* p1 = strrchr(p, '('); + char* p2 = strrchr(p, ','); + if (p1 == NULL && p2 == NULL) { + return false; + } + + if(p2 == NULL) { + // first field area + p2 = p1; + } + + // find blank count + int32_t cnt = 0; + while(p2) { + p2 = strchr(p2, ' '); + if(p2) { + cnt ++; + while (p2[1] != 0 && p2[1] == ' ') { + // move next if blank again + p2 += 1; + } + } + } + + // like create table st(ts timestamp TAB-KEY or st(ts timestamp , age int TAB-KEY + return cnt >= 2; +} + // if is input create fields or tags area, return true bool isCreateFieldsArea(char* p) { // put to while, support like create table st(ts timestamp, bin1 binary(16), bin2 + blank + TAB @@ -1717,8 +1798,14 @@ bool matchCreateTable(TAOS* con, SShellCmd* cmd) { char* last = lastWord(ps); // check in create fields or tags input area - if (isCreateFieldsArea(ps)) { - ret = fillWithType(con, cmd, last, WT_VAR_DATATYPE); + if (isCreateFieldsArea(ps)) { + if (fieldOptionsArea(ps)) { + // fill field options + ret = fillWithType(con, cmd, last, WT_VAR_FIELD_OPTIONS); + } else { + // fill field + ret = fillWithType(con, cmd, last, WT_VAR_DATATYPE); + } } // tags From b5e6c557497669a611a5803c0e9a33074ca2fd2c Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 24 Oct 2024 19:55:26 +0800 Subject: [PATCH 03/40] feat: auto append end char ; to command --- tools/shell/src/shellAuto.c | 119 ++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 52 deletions(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 9e6b0fe79e..a12efb7e96 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -46,6 +46,7 @@ typedef struct SWord { int32_t len; struct SWord* next; bool free; // if true need free + bool end; // if true is last keyword } SWord; typedef struct { @@ -95,62 +96,62 @@ SWords shellCommands[] = { " ;", 0, 0, NULL}, {"create dnode ", 0, 0, NULL}, {"create index on ()", 0, 0, NULL}, - {"create mnode on dnode ;", 0, 0, NULL}, - {"create qnode on dnode ;", 0, 0, NULL}, + {"create mnode on dnode ;", 0, 0, NULL}, + {"create qnode on dnode ;", 0, 0, NULL}, {"create stream into as select", 0, 0, NULL}, // 26 append sub sql {"create topic as select", 0, 0, NULL}, // 27 append sub sql {"create tsma on function", 0, 0, NULL}, {"create recursive tsma on interval(", 0, 0, NULL}, - {"create function as outputtype language ", 0, 0, NULL}, - {"create or replace as outputtype language ", 0, 0, NULL}, - {"create aggregate function as outputtype bufsize language ", 0, 0, NULL}, - {"create or replace aggregate function as outputtype bufsize language ", 0, 0, NULL}, + {"create function as outputtype language ;", 0, 0, NULL}, + {"create or replace as outputtype language ;", 0, 0, NULL}, + {"create aggregate function as outputtype bufsize language ;", 0, 0, NULL}, + {"create or replace aggregate function as outputtype bufsize language ;", 0, 0, NULL}, {"create user pass sysinfo 0;", 0, 0, NULL}, {"create user pass sysinfo 1;", 0, 0, NULL}, #ifdef TD_ENTERPRISE {"create view as select", 0, 0, NULL}, {"compact database ", 0, 0, NULL}, #endif - {"describe ", 0, 0, NULL}, + {"describe ;", 0, 0, NULL}, {"delete from where ", 0, 0, NULL}, - {"drop database ", 0, 0, NULL}, - {"drop index ", 0, 0, NULL}, - {"drop table ", 0, 0, NULL}, - {"drop dnode ", 0, 0, NULL}, - {"drop mnode on dnode ;", 0, 0, NULL}, - {"drop qnode on dnode ;", 0, 0, NULL}, - {"drop user ;", 0, 0, NULL}, + {"drop database ;", 0, 0, NULL}, + {"drop index ;", 0, 0, NULL}, + {"drop table ;", 0, 0, NULL}, + {"drop dnode ;", 0, 0, NULL}, + {"drop mnode on dnode ;", 0, 0, NULL}, + {"drop qnode on dnode ;", 0, 0, NULL}, + {"drop user ;", 0, 0, NULL}, // 40 - {"drop function ;", 0, 0, NULL}, + {"drop function ;", 0, 0, NULL}, {"drop consumer group on ", 0, 0, NULL}, - {"drop topic ;", 0, 0, NULL}, - {"drop stream ;", 0, 0, NULL}, - {"drop tsma ;", 0, 0, NULL}, - {"explain select", 0, 0, NULL}, // 44 append sub sql - {"flush database ;", 0, 0, NULL}, + {"drop topic ;", 0, 0, NULL}, + {"drop stream ;", 0, 0, NULL}, + {"drop tsma ;", 0, 0, NULL}, + {"explain select ", 0, 0, NULL}, // 44 append sub sql + {"flush database ;", 0, 0, NULL}, {"help;", 0, 0, NULL}, - {"grant all on to ;", 0, 0, NULL}, - {"grant read on to ;", 0, 0, NULL}, - {"grant write on to ;", 0, 0, NULL}, - {"kill connection ;", 0, 0, NULL}, + {"grant all on to ;", 0, 0, NULL}, + {"grant read on to ;", 0, 0, NULL}, + {"grant write on to ;", 0, 0, NULL}, + {"kill connection ;", 0, 0, NULL}, {"kill query ", 0, 0, NULL}, {"kill transaction ", 0, 0, NULL}, #ifdef TD_ENTERPRISE - {"merge vgroup ", 0, 0, NULL}, + {"merge vgroup ;", 0, 0, NULL}, #endif - {"pause stream ;", 0, 0, NULL}, + {"pause stream ;", 0, 0, NULL}, #ifdef TD_ENTERPRISE - {"redistribute vgroup dnode ;", 0, 0, NULL}, + {"redistribute vgroup dnode ;", 0, 0, NULL}, #endif - {"resume stream ;", 0, 0, NULL}, + {"resume stream ;", 0, 0, NULL}, {"reset query cache;", 0, 0, NULL}, - {"restore dnode ;", 0, 0, NULL}, - {"restore vnode on dnode ;", 0, 0, NULL}, - {"restore mnode on dnode ;", 0, 0, NULL}, - {"restore qnode on dnode ;", 0, 0, NULL}, - {"revoke all on from ;", 0, 0, NULL}, - {"revoke read on from ;", 0, 0, NULL}, - {"revoke write on from ;", 0, 0, NULL}, + {"restore dnode ;", 0, 0, NULL}, + {"restore vnode on dnode ;", 0, 0, NULL}, + {"restore mnode on dnode ;", 0, 0, NULL}, + {"restore qnode on dnode ;", 0, 0, NULL}, + {"revoke all on from ;", 0, 0, NULL}, + {"revoke read on from ;", 0, 0, NULL}, + {"revoke write on from ;", 0, 0, NULL}, {"select * from ", 0, 0, NULL}, {"select client_version();", 0, 0, NULL}, // 60 @@ -163,6 +164,7 @@ SWords shellCommands[] = { {"select timezone();", 0, 0, NULL}, {"set max_binary_display_width ", 0, 0, NULL}, {"show apps;", 0, 0, NULL}, + {"show alive;", 0, 0, NULL}, {"show create database \\G;", 0, 0, NULL}, {"show create stable \\G;", 0, 0, NULL}, {"show create table \\G;", 0, 0, NULL}, @@ -195,10 +197,9 @@ SWords shellCommands[] = { {"show subscriptions;", 0, 0, NULL}, {"show tables;", 0, 0, NULL}, {"show tables like", 0, 0, NULL}, - {"show table distributed ", 0, 0, NULL}, - {"show tags from ", 0, 0, NULL}, - {"show tags from ", 0, 0, NULL}, - {"show table tags from ", 0, 0, NULL}, + {"show table distributed ;", 0, 0, NULL}, + {"show tags from ;", 0, 0, NULL}, + {"show table tags from ;", 0, 0, NULL}, {"show topics;", 0, 0, NULL}, {"show transactions;", 0, 0, NULL}, {"show tsmas;", 0, 0, NULL}, @@ -206,7 +207,7 @@ SWords shellCommands[] = { {"show variables;", 0, 0, NULL}, {"show local variables;", 0, 0, NULL}, {"show vnodes;", 0, 0, NULL}, - {"show vnodes on dnode ;", 0, 0, NULL}, + {"show vnodes on dnode ;", 0, 0, NULL}, {"show vgroups;", 0, 0, NULL}, {"show consumers;", 0, 0, NULL}, {"show grants;", 0, 0, NULL}, @@ -215,15 +216,15 @@ SWords shellCommands[] = { #ifdef TD_ENTERPRISE {"show views;", 0, 0, NULL}, {"show arbgroups;", 0, 0, NULL}, - {"split vgroup ", 0, 0, NULL}, - {"s3migrate database ", 0, 0, NULL}, + {"split vgroup ;", 0, 0, NULL}, + {"s3migrate database ;", 0, 0, NULL}, #endif {"insert into values(", 0, 0, NULL}, {"insert into using tags(", 0, 0, NULL}, {"insert into using values(", 0, 0, NULL}, {"insert into file ", 0, 0, NULL}, - {"trim database ", 0, 0, NULL}, - {"use ", 0, 0, NULL}, + {"trim database ;", 0, 0, NULL}, + {"use ;", 0, 0, NULL}, {"quit", 0, 0, NULL}}; // where keyword @@ -362,7 +363,8 @@ char* field_options[] = { // global keys can tips on anywhere char* global_keys[] = { "tbname", - "now", + "now", + "vgroups", "_wstart", "_wend", "_wduration", @@ -581,6 +583,7 @@ void showHelp() { select timezone();\n\ set max_binary_display_width ...\n\ show apps;\n\ + show alive;\n\ show create database ;\n\ show create stable ;\n\ show create table ;\n\ @@ -698,7 +701,12 @@ SWord* addWord(const char* p, int32_t len, bool pattern) { // check format if (pattern && len > 0) { - word->type = wordType(p, len); + if (p[len-1] == ';') { + word->type = wordType(p, len - 1); + word->end = true; + } else { + word->type = wordType(p, len); + } } else { word->type = WT_TEXT; } @@ -1304,10 +1312,10 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) { // first tab press const char* str = NULL; int strLen = 0; - + + SWord* word = MATCH_WORD(match); if (firstMatchIndex == curMatchIndex && lastWordBytes == -1) { // first press tab - SWord* word = MATCH_WORD(match); str = word->word + match->matchLen; strLen = word->len - match->matchLen; lastMatchIndex = firstMatchIndex; @@ -1315,8 +1323,6 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) { } else { if (lastWordBytes == -1) return; deleteCount(cmd, lastWordBytes); - - SWord* word = MATCH_WORD(match); str = word->word; strLen = word->len; // set current to last @@ -1324,8 +1330,17 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) { lastWordBytes = word->len; } - // insert new - shellInsertStr(cmd, (char*)str, strLen); + if (word->end) { + // append end ';' + char *p = taosMemoryMalloc(strLen + 8); + strcpy(p, str); + strcat(p, ";"); + shellInsertStr(cmd, (char *)p, strLen + 1); + taosMemoryFree(p); + } else { + // insert new + shellInsertStr(cmd, (char *)str, strLen); + } } // main key press tab , matched return true else false From de31de5d11940a3b9cae0e9b96607bda67177241 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 25 Oct 2024 09:59:30 +0800 Subject: [PATCH 04/40] fix: parse blank count error --- tools/shell/src/shellAuto.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index a12efb7e96..05a996dafc 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -1731,13 +1731,19 @@ bool fieldOptionsArea(char* p) { int32_t cnt = 0; while(p2) { p2 = strchr(p2, ' '); - if(p2) { - cnt ++; + if (p2) { + if ((p2 - 1)[0] != ',') { + // blank if before comma, not calc count. like st(ts timestamp, age int + BLANK + TAB only two blank + cnt ++; + } + + // continue blank is one blank while (p2[1] != 0 && p2[1] == ' ') { // move next if blank again p2 += 1; } - } + p2 += 1; + } } // like create table st(ts timestamp TAB-KEY or st(ts timestamp , age int TAB-KEY From 48444f2aca16f9efd778f6e2c29595c0ce933866 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 25 Oct 2024 10:16:10 +0800 Subject: [PATCH 05/40] fix: compress and encode algo add single quotes --- tools/shell/src/shellAuto.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 05a996dafc..b8d346f34f 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -353,9 +353,9 @@ char* udf_language[] = {"\'Python\'", "\'C\'"}; char* field_options[] = { "encode ", "compress ", "level ", - "lz4 ", "zlib ", "zstd ", "xz ", "tsz ", "disabled ", // compress - "simple8b ", "delta-i ", "delta-d ", "bit-packing ", - "high ", "medium ", "low ", + "\'lz4\' ", "\'zlib\' ", "\'zstd\' ", "\'xz\' ", "\'tsz\' ", "\'disabled\' ", // compress + "\'simple8b\' ", "\'delta-i\' ", "\'delta-d\' ", "\'bit-packing\' ", + "\'high\' ", "\'medium\' ", "\'low\' ", "comment ", "primary key " }; From 1b2ac1e5376c0b1512a890f2e1df6f1f7642a690 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 25 Oct 2024 10:44:23 +0800 Subject: [PATCH 06/40] fix: create talbe fields area support blank on left bracket --- tools/shell/src/shellAuto.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index b8d346f34f..89d882d52b 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -1732,7 +1732,9 @@ bool fieldOptionsArea(char* p) { while(p2) { p2 = strchr(p2, ' '); if (p2) { - if ((p2 - 1)[0] != ',') { + // get prev char + char prec = *(p2 - 1); + if (prec != ',' && prec != '(') { // blank if before comma, not calc count. like st(ts timestamp, age int + BLANK + TAB only two blank cnt ++; } From 86dbba5c8cf2e39feaeb41e8eafd5e95c3568698 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 25 Oct 2024 10:58:25 +0800 Subject: [PATCH 07/40] fix: create table tags area --- tools/shell/src/shellAuto.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 89d882d52b..defbf1cb82 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -1722,6 +1722,11 @@ bool fieldOptionsArea(char* p) { return false; } + // find tags + if(strstr(p, " tags") != NULL) { + return false; + } + if(p2 == NULL) { // first field area p2 = p1; From a10e6457bf173d8ed0587c6574547f4d39d3c269 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 25 Oct 2024 14:00:32 +0800 Subject: [PATCH 08/40] fix: blank and double quotes --- tools/shell/src/shellAuto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index defbf1cb82..2b203953dd 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -229,7 +229,7 @@ SWords shellCommands[] = { // where keyword char* keywords[] = { - "and ", "asc ", "desc ", "from ", "fill(", "limit ", "where ", + "where ", "and ", "asc ", "desc ", "from ", "fill(", "limit ", "interval(", "order by ", "order by ", "offset ", "or ", "group by ", "now()", "session(", "sliding ", "slimit ", "soffset ", "state_window(", "today() ", "union all select ", "partition by ", "match", "nmatch ", "between ", "like ", "is null ", "is not null ", @@ -1330,7 +1330,7 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) { lastWordBytes = word->len; } - if (word->end) { + if (word->end && str[strLen - 1] != ';') { // append end ';' char *p = taosMemoryMalloc(strLen + 8); strcpy(p, str); From fa9f27344950405d905ffa501e81471cd448820b Mon Sep 17 00:00:00 2001 From: lyh250-666 Date: Fri, 25 Oct 2024 14:39:03 +0800 Subject: [PATCH 09/40] opti:add case for double and float --- source/libs/scalar/src/filter.c | 9 +++++++-- tests/script/tsim/scalar/in.sim | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index c9740b8c25..2c449fced6 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -5034,8 +5034,13 @@ int32_t fltSclBuildRangePoints(SFltSclOperator *oper, SArray *points) { SValueNode *valueNode = (SValueNode *)cell->pNode; SFltSclDatum valDatum; FLT_ERR_RET(fltSclBuildDatumFromValueNode(&valDatum, valueNode)); - minDatum.i = TMIN(minDatum.i, valDatum.i); - maxDatum.i = TMAX(maxDatum.i, valDatum.i); + if(valueNode->node.resType.type == TSDB_DATA_TYPE_FLOAT || valueNode->node.resType.type == TSDB_DATA_TYPE_DOUBLE) { + minDatum.i = TMIN(minDatum.i, valDatum.d); + maxDatum.i = TMAX(maxDatum.i, valDatum.d); + } else { + minDatum.i = TMIN(minDatum.i, valDatum.i); + maxDatum.i = TMAX(maxDatum.i, valDatum.i); + } cell = cell->pNext; } SFltSclPoint startPt = {.start = true, .excl = false, .val = minDatum}; diff --git a/tests/script/tsim/scalar/in.sim b/tests/script/tsim/scalar/in.sim index d241bbc1bf..f7fa2bcd2d 100644 --- a/tests/script/tsim/scalar/in.sim +++ b/tests/script/tsim/scalar/in.sim @@ -95,4 +95,38 @@ endi if $data20 != @ Time Range: [1657441840000, 1657441980000]@ then return -1 endi + +sql explain verbose true select * from tb1 where fts in ('2022-07-10 16:31:00', '2022-07-10 16:33:00', 1657441840000, true); +if $rows != 4 then + return -1 +endi +if $data20 != @ Time Range: [0, 1657441980000]@ then + return -1 +endi + +sql explain verbose true select * from tb1 where fts in ('2022-07-10 16:31:00', '2022-07-10 16:33:00', 1657441840000, false); +if $rows != 4 then + return -1 +endi +if $data20 != @ Time Range: [1, 1657441980000]@ then + return -1 +endi + +sql explain verbose true select * from tb1 where fts in ('2022-07-10 16:31:00', '2022-07-10 16:33:00', 1657441840000, 1.02); +if $rows != 4 then + return -1 +endi +if $data20 != @ Time Range: [1, 1657441980000]@ then + return -1 +endi + +sql explain verbose true select * from tb1 where fts in ('2022-07-10 16:31:00', '2022-07-10 16:33:00', 1657441840000, -1.02); +if $rows != 4 then + return -1 +endi +if $data20 != @ Time Range: [-1, 1657441980000]@ then + return -1 +endi + +sql_error explain verbose true select * from tb1 where fts in ('2022-07-10 16:31:00', '2022-07-10 16:33:00', 1657441840000, 'abc'); system sh/exec.sh -n dnode1 -s stop -x SIGINT From 9dce56d552c4f99b7bbf45f4ff9c35e7c2110e6e Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 25 Oct 2024 16:49:45 +0800 Subject: [PATCH 10/40] fix: fields area left right quotes change total method --- tools/shell/src/shellAuto.c | 45 +++++++++++++------------------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 2b203953dd..81021965a2 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -168,7 +168,6 @@ SWords shellCommands[] = { {"show create database \\G;", 0, 0, NULL}, {"show create stable \\G;", 0, 0, NULL}, {"show create table \\G;", 0, 0, NULL}, - {"show create tsma \\G;", 0, 0, NULL}, #ifdef TD_ENTERPRISE {"show create view \\G;", 0, 0, NULL}, {"show compact", 0, 0, NULL}, @@ -290,7 +289,7 @@ char* tb_actions[] = { char* user_actions[] = {"pass ", "enable ", "sysinfo "}; -char* tb_options[] = {"comment ", "watermark ", "max_delay ", "ttl ", "rollup(", "sma("}; +char* tb_options[] = {"tags(", "comment ", "watermark ", "max_delay ", "ttl ", "rollup(", "sma("}; char* db_options[] = {"keep ", "replica ", @@ -335,7 +334,7 @@ char* data_types[] = {"timestamp", "int", "bigint", "bigint unsigned", "smallint", "smallint unsigned", "tinyint", "tinyint unsigned", - "geometry", "varbinary(16)", + "geometry(64)", "varbinary(16)", "bool", "json"}; char* key_tags[] = {"tags("}; @@ -1759,36 +1758,24 @@ bool fieldOptionsArea(char* p) { // if is input create fields or tags area, return true bool isCreateFieldsArea(char* p) { - // put to while, support like create table st(ts timestamp, bin1 binary(16), bin2 + blank + TAB - char* p1 = taosStrdup(p); - bool ret = false; - while (1) { - char* left = strrchr(p1, '('); - if (left == NULL) { - // like 'create table st' - ret = false; + int32_t n = 0; // count + char *p1 = p; + while (*p1 != 0) { + switch (*p1) { + case '(': + ++ n; + break; + case ')': + -- n; + break; + default: break; } - - char* right = strrchr(p1, ')'); - if (right == NULL) { - // like 'create table st( ' - ret = true; - break; - } - - if (left > right) { - // like 'create table st( ts timestamp, age int) tags(area ' - ret = true; - break; - } - - // set string end by small for next strrchr search - *left = 0; + // move next + ++p1; } - taosMemoryFree(p1); - return ret; + return n > 0; } bool matchCreateTable(TAOS* con, SShellCmd* cmd) { From fca6e89dc576d4a424f87339f692fa6dc0c57058 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 25 Oct 2024 17:03:01 +0800 Subject: [PATCH 11/40] fix: fill tags is passed --- tools/shell/src/shellAuto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 81021965a2..18b9bb8860 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -289,7 +289,7 @@ char* tb_actions[] = { char* user_actions[] = {"pass ", "enable ", "sysinfo "}; -char* tb_options[] = {"tags(", "comment ", "watermark ", "max_delay ", "ttl ", "rollup(", "sma("}; +char* tb_options[] = {"comment ", "watermark ", "max_delay ", "ttl ", "rollup(", "sma("}; char* db_options[] = {"keep ", "replica ", From dffab4422ff714aad58ce67e05865cbc7799ec7e Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 25 Oct 2024 17:05:33 +0800 Subject: [PATCH 12/40] fix: fill tags is passed1 --- tools/shell/src/shellAuto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 18b9bb8860..f0d61e4a54 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -1828,7 +1828,7 @@ bool matchCreateTable(TAOS* con, SShellCmd* cmd) { // find only one ')' , can insert tags char* p1 = strchr(ps, ')'); if (p1) { - if (strchr(p1 + 1, ')') == NULL && strstr(p1 + 1, "tags") == NULL) { + if (strstr(p1 + 1, "tags") == NULL) { // can insert tags keyword ret = fillWithType(con, cmd, last, WT_VAR_KEYTAGS); } From 4df8aeded9024c47df2cfb1bfb6e065fbe19129e Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 27 Oct 2024 11:25:51 +0800 Subject: [PATCH 13/40] fix: repeat double state_window( keyword --- tools/shell/src/shellAuto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index f0d61e4a54..201389f20b 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -232,7 +232,7 @@ char* keywords[] = { "interval(", "order by ", "order by ", "offset ", "or ", "group by ", "now()", "session(", "sliding ", "slimit ", "soffset ", "state_window(", "today() ", "union all select ", "partition by ", "match", "nmatch ", "between ", "like ", "is null ", "is not null ", - "state_window(", "event_window ", "count_window(" + "event_window ", "count_window(" }; char* functions[] = { From 651a652376a28f39a46472b4488b6334624783d8 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 27 Oct 2024 18:04:21 +0800 Subject: [PATCH 14/40] feat: add unit test to shell --- tools/shell/CMakeLists.txt | 50 +++++++++++++ tools/shell/inc/shellAuto.h | 8 +++ tools/shell/src/shellEngine.c | 2 + tools/shell/src/shellMain.c | 3 +- tools/shell/test/shellTest.cpp | 128 +++++++++++++++++++++++++++++++++ 5 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 tools/shell/test/shellTest.cpp diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index fd46870ac5..9fdc0e98f4 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -14,14 +14,17 @@ IF(TD_LINUX AND TD_WEBSOCKET) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include -ltaosws) SET(LINK_WEBSOCKET "-L${CMAKE_BINARY_DIR}/build/lib -ltaosws") ADD_DEPENDENCIES(shell taosws-rs) + ADD_DEPENDENCIES(shell_ut taosws-rs) ELSEIF(TD_DARWIN AND TD_WEBSOCKET) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include) SET(LINK_WEBSOCKET "${CMAKE_BINARY_DIR}/build/lib/libtaosws.dylib") ADD_DEPENDENCIES(shell taosws-rs) + ADD_DEPENDENCIES(shell_ut taosws-rs) ELSEIF(TD_WINDOWS AND TD_WEBSOCKET) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include) SET(LINK_WEBSOCKET "${CMAKE_BINARY_DIR}/build/lib/taosws.lib") ADD_DEPENDENCIES(shell taosws-rs) + ADD_DEPENDENCIES(shell_ut taosws-rs) ELSE() SET(LINK_WEBSOCKET "") ENDIF() @@ -49,3 +52,50 @@ target_include_directories( ) SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) + +# +# generator library shell_ut for uint test +# + +# include +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) + +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellMain.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellAuto.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellTire.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellArguments.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellCommand.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellEngine.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellUtil.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellNettest.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellWebsocket.c) + + + +# shell_ut library +add_library(shell_ut STATIC ${SHELL_UT_SRC}) + +# link public +if(TD_WINDOWS) + target_link_libraries(shell_ut PUBLIC taos_static ${LINK_WEBSOCKET}) +else() + target_link_libraries(shell_ut PUBLIC taos ${LINK_WEBSOCKET} ${LINK_JEMALLOC} ${LINK_ARGP}) +endif() + +# link private +target_link_libraries( + shell_ut + PRIVATE os common transport geometry util +) + +# util depends +target_link_directories( + shell_ut + PUBLIC "${TD_SOURCE_DIR}/contrib/lzma2" + PUBLIC "${TD_SOURCE_DIR}/contrib/pcre2" +) + +# unit test +if(${BUILD_TEST}) + ADD_SUBDIRECTORY(test) +endif(${BUILD_TEST}) \ No newline at end of file diff --git a/tools/shell/inc/shellAuto.h b/tools/shell/inc/shellAuto.h index bcf500fefc..7fe249251b 100644 --- a/tools/shell/inc/shellAuto.h +++ b/tools/shell/inc/shellAuto.h @@ -47,4 +47,12 @@ void showAD(bool end); // show all commands help void showHelp(); + +// +// for unit test +// +bool fieldOptionsArea(char* p); +bool isCreateFieldsArea(char* p); + + #endif diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 2a583f948e..50a7fe8119 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -22,6 +22,8 @@ #include "shellAuto.h" #include "shellInt.h" +SShellObj shell = {0}; + typedef struct { const char *sql; bool vertical; diff --git a/tools/shell/src/shellMain.c b/tools/shell/src/shellMain.c index 71acf23e41..fc6ba0f7d8 100644 --- a/tools/shell/src/shellMain.c +++ b/tools/shell/src/shellMain.c @@ -17,8 +17,7 @@ #include "shellInt.h" #include "shellAuto.h" -SShellObj shell = {0}; - +extern SShellObj shell; void shellCrashHandler(int signum, void *sigInfo, void *context) { taosIgnSignal(SIGTERM); diff --git a/tools/shell/test/shellTest.cpp b/tools/shell/test/shellTest.cpp new file mode 100644 index 0000000000..1f3f1b1b2a --- /dev/null +++ b/tools/shell/test/shellTest.cpp @@ -0,0 +1,128 @@ +/* + * 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 . + */ + +#include +#include +#include "shellAuto.h" + + +TEST(fieldOptionsArea, autoTabTest) { + printf("hellow world SHELL tab test\n"); + + // str false + const char *s0 [] = { + "create table st(ts ", + "create table st(ts timestamp, age ", + "create table st(ts timestamp, age", + "create table st(ts timestamp, age int , name ", + "create table st(ts timestamp, age int , name binary(16)", + "create table st(ts timestamp, age int , name binary(16) ) tags( ", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int, addr ", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int,addr varbinary", + "create table st(ts timestamp, age int, name binary(16)) tags(area int , addr varbinary(32)", + "create table st( ts timestamp, age int, name binary(16)) tags( area int, addr", + "create table st (ts timestamp , age int, name binary(16) , area int,", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int ,addr varbinary", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) level 'high' , no i", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) encode 'simple8b' level 'high', no in", + }; + + // str true + const char *s1 [] = { + "create table st(ts timestamp ", + "create table st(ts timestamp, age int ", + "create table st(ts timestamp, age int ", + "create table st(ts timestamp, age int , name binary(16) ", + "create table st(ts timestamp, age int , name binary(16) ", + "create table st(ts timestamp, age int , name binary(16) , addr varbinary( 32 ) ", + "create table st(ts timestamp, age int , name binary(16) ,area int, addr varbinary(32) ", + "create table st(ts timestamp, age int , name binary(16), area int,addr varbinary(32) ", + "create table st(ts timestamp, age int, name binary(16) , area int,addr varbinary(32) ", + "create table st( ts timestamp, age int, name binary(16) ,area int,addr varbinary(32) ", + "create table st (ts timestamp , age int, name binary(16), area int,addr varbinary(32) ", + "create table st (ts timestamp , age int, name binary(16), area int , addr varbinary(32) compress 'zlib' ", + "create table st (ts timestamp , age int, name binary(16), area int , addr varbinary(32) level 'high' ", + "create table st (ts timestamp , age int, name binary(16) , area int , addr varbinary(32) encode 'simple8b' level 'high' ", + }; + + // s0 is false + for(int32_t i = 0; i < sizeof(s0)/sizeof(char*) ; i++) { + printf("s0 i=%d fieldOptionsArea %s expect false \n", i, s0[i]); + ASSERT (fieldOptionsArea((char *)s0[i]) == false); + } + + // s1 is true + for(int32_t i = 0; i < sizeof(s1)/sizeof(char*) ; i++) { + printf("s1 i=%d fieldOptionsArea %s expect true \n", i, s1[i]); + ASSERT (fieldOptionsArea((char *)s1[i]) == true); + } +} + +TEST(isCreateFieldsArea, autoTabTest) { + printf("hellow world SHELL tab test\n"); + + // str false + const char *s0 [] = { + "create table st(ts )", + "create table st(ts timestamp, age) ", + "create table st(ts timestamp, age)", + "create table st(ts timestamp, age int , name binary(16) )", + "create table st(ts timestamp, age int , name binary(16))", + "create table st(ts timestamp, age int , name binary(16) ) tags( )", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int, addr )", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int,addr varbinary)", + "create table st(ts timestamp, age int, name binary(16)) tags(area int , addr varbinary(32))", + "create table st( ts timestamp, age int, name binary(16)) tags( area int, addr int)", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int,addr varbinary(32) )", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int ,addr varbinary(14))", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) level 'high' )", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) encode 'simple8b' level 'high' ) ", + }; + + // str true + const char *s1 [] = { + "create table st(ts timestamp ", + "create table st(ts timestamp, age int ", + "create table st(ts timestamp, age int ,", + "create table st(ts timestamp, age int , name binary(16), ", + "create table st(ts timestamp, age int , name binary(16) ", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int ", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int, addr varbinary(32) ", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int,addr varbinary(32)", + "create table st(ts timestamp, age int, name binary(16)) tags(area int,addr varbinary(32) ", + "create table st( ts timestamp, age int, name binary(16)) tags(area int,addr varbinary(32) ", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int, addr varbinary(32) ", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) compress 'zlib' ", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) level 'high' ", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) encode 'simple8b' level 'high' ", + }; + + // s0 is false + for(int32_t i = 0; i < sizeof(s0)/sizeof(char*) ; i++) { + printf("s0 i=%d isCreateFieldsArea %s expect false. \n", i, s0[i]); + ASSERT (isCreateFieldsArea((char *)s0[i]) == false); + } + + // s1 is true + for(int32_t i = 0; i < sizeof(s1)/sizeof(char*) ; i++) { + printf("s1 i=%d isCreateFieldsArea %s expect true. \n", i, s1[i]); + ASSERT (isCreateFieldsArea((char *)s1[i]) == true); + } +} + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file From efa6db21502f7162aea6143f8d4b408e146f41aa Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 27 Oct 2024 18:12:33 +0800 Subject: [PATCH 15/40] fix: websocket build --- tools/shell/CMakeLists.txt | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 9fdc0e98f4..3c9ae1d962 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -2,6 +2,22 @@ aux_source_directory(src SHELL_SRC) add_executable(shell ${SHELL_SRC}) +# include +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) + +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellMain.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellAuto.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellTire.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellArguments.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellCommand.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellEngine.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellUtil.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellNettest.c) +LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellWebsocket.c) + +# shell_ut library +add_library(shell_ut STATIC ${SHELL_UT_SRC}) + IF(TD_LINUX_64 AND JEMALLOC_ENABLED) ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc) SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc") @@ -57,24 +73,6 @@ SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) # generator library shell_ut for uint test # -# include -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) - -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellMain.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellAuto.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellTire.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellArguments.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellCommand.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellEngine.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellUtil.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellNettest.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellWebsocket.c) - - - -# shell_ut library -add_library(shell_ut STATIC ${SHELL_UT_SRC}) - # link public if(TD_WINDOWS) target_link_libraries(shell_ut PUBLIC taos_static ${LINK_WEBSOCKET}) From 3ce942f5fbc23fec76900ea10eacbd5a0cffcc4c Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 27 Oct 2024 18:30:36 +0800 Subject: [PATCH 16/40] fix: PR error --- tools/shell/CMakeLists.txt | 61 +++++++++++++------------------------- 1 file changed, 21 insertions(+), 40 deletions(-) diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 3c9ae1d962..317fb69c62 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -2,21 +2,6 @@ aux_source_directory(src SHELL_SRC) add_executable(shell ${SHELL_SRC}) -# include -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) - -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellMain.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellAuto.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellTire.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellArguments.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellCommand.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellEngine.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellUtil.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellNettest.c) -LIST(APPEND SHELL_UT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/shellWebsocket.c) - -# shell_ut library -add_library(shell_ut STATIC ${SHELL_UT_SRC}) IF(TD_LINUX_64 AND JEMALLOC_ENABLED) ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc) @@ -30,17 +15,13 @@ IF(TD_LINUX AND TD_WEBSOCKET) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include -ltaosws) SET(LINK_WEBSOCKET "-L${CMAKE_BINARY_DIR}/build/lib -ltaosws") ADD_DEPENDENCIES(shell taosws-rs) - ADD_DEPENDENCIES(shell_ut taosws-rs) ELSEIF(TD_DARWIN AND TD_WEBSOCKET) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include) SET(LINK_WEBSOCKET "${CMAKE_BINARY_DIR}/build/lib/libtaosws.dylib") - ADD_DEPENDENCIES(shell taosws-rs) - ADD_DEPENDENCIES(shell_ut taosws-rs) ELSEIF(TD_WINDOWS AND TD_WEBSOCKET) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include) SET(LINK_WEBSOCKET "${CMAKE_BINARY_DIR}/build/lib/taosws.lib") ADD_DEPENDENCIES(shell taosws-rs) - ADD_DEPENDENCIES(shell_ut taosws-rs) ELSE() SET(LINK_WEBSOCKET "") ENDIF() @@ -73,27 +54,27 @@ SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) # generator library shell_ut for uint test # -# link public -if(TD_WINDOWS) - target_link_libraries(shell_ut PUBLIC taos_static ${LINK_WEBSOCKET}) -else() +IF(TD_LINUX) + # include + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) + # shell_ut library + add_library(shell_ut STATIC ${SHELL_SRC}) + + IF(TD_WEBSOCKET) + ADD_DEPENDENCIES(shell_ut taosws-rs) + ENDIF() target_link_libraries(shell_ut PUBLIC taos ${LINK_WEBSOCKET} ${LINK_JEMALLOC} ${LINK_ARGP}) -endif() + target_link_libraries(shell_ut PRIVATE os common transport geometry util) -# link private -target_link_libraries( - shell_ut - PRIVATE os common transport geometry util -) + # util depends + target_link_directories( + shell_ut + PUBLIC "${TD_SOURCE_DIR}/contrib/lzma2" + PUBLIC "${TD_SOURCE_DIR}/contrib/pcre2" + ) -# util depends -target_link_directories( - shell_ut - PUBLIC "${TD_SOURCE_DIR}/contrib/lzma2" - PUBLIC "${TD_SOURCE_DIR}/contrib/pcre2" -) - -# unit test -if(${BUILD_TEST}) - ADD_SUBDIRECTORY(test) -endif(${BUILD_TEST}) \ No newline at end of file + # unit test + IF(${BUILD_TEST}) + ADD_SUBDIRECTORY(test) + ENDIF(${BUILD_TEST}) +ENDIF() From 4876bc4fb2ab7a8ff75e9808ba1118c32ba92727 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 27 Oct 2024 18:33:31 +0800 Subject: [PATCH 17/40] fix: restore shell origin code --- tools/shell/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 317fb69c62..4a8e0b9d34 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -2,7 +2,6 @@ aux_source_directory(src SHELL_SRC) add_executable(shell ${SHELL_SRC}) - IF(TD_LINUX_64 AND JEMALLOC_ENABLED) ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc) SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc") @@ -18,6 +17,7 @@ IF(TD_LINUX AND TD_WEBSOCKET) ELSEIF(TD_DARWIN AND TD_WEBSOCKET) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include) SET(LINK_WEBSOCKET "${CMAKE_BINARY_DIR}/build/lib/libtaosws.dylib") + ADD_DEPENDENCIES(shell taosws-rs) ELSEIF(TD_WINDOWS AND TD_WEBSOCKET) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include) SET(LINK_WEBSOCKET "${CMAKE_BINARY_DIR}/build/lib/taosws.lib") From db71fe49ed88342f91e161756b665519f1f11808 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 27 Oct 2024 19:04:58 +0800 Subject: [PATCH 18/40] add shell-test CMakefiles --- tools/shell/test/CMakeLists.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tools/shell/test/CMakeLists.txt diff --git a/tools/shell/test/CMakeLists.txt b/tools/shell/test/CMakeLists.txt new file mode 100644 index 0000000000..31ee70c202 --- /dev/null +++ b/tools/shell/test/CMakeLists.txt @@ -0,0 +1,25 @@ + +MESSAGE(STATUS "build catalog unit test") + +IF(NOT TD_DARWIN) + # GoogleTest requires at least C++11 + SET(CMAKE_CXX_STANDARD 11) + AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) + + ADD_EXECUTABLE(shellTest ${SOURCE_LIST}) + TARGET_LINK_LIBRARIES( + shellTest + PRIVATE shell_ut gtest os common transport geometry util + ) + + target_include_directories( + shell_ui + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inc" + ) + + + add_test( + NAME shellTest + COMMAND shellTest + ) +ENDIF() From 0e2ccadd2fea60af4afdba79f72e0363275943a8 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 27 Oct 2024 19:06:10 +0800 Subject: [PATCH 19/40] add shell-test CMakefiles --- tools/shell/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shell/test/CMakeLists.txt b/tools/shell/test/CMakeLists.txt index 31ee70c202..6f3b0474bd 100644 --- a/tools/shell/test/CMakeLists.txt +++ b/tools/shell/test/CMakeLists.txt @@ -1,5 +1,5 @@ -MESSAGE(STATUS "build catalog unit test") +MESSAGE(STATUS "build taos-CLI unit test") IF(NOT TD_DARWIN) # GoogleTest requires at least C++11 From 2803d51797ea190610dc405071ce66b562ff2602 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 27 Oct 2024 19:15:51 +0800 Subject: [PATCH 20/40] add shell-test CMakefiles shell-ut --- tools/shell/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shell/test/CMakeLists.txt b/tools/shell/test/CMakeLists.txt index 6f3b0474bd..1eb6c709ab 100644 --- a/tools/shell/test/CMakeLists.txt +++ b/tools/shell/test/CMakeLists.txt @@ -13,7 +13,7 @@ IF(NOT TD_DARWIN) ) target_include_directories( - shell_ui + shell_ut PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) From 90642f4dc2ddf01a7d51c36bd46c8dd04c1a5d53 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 27 Oct 2024 19:33:58 +0800 Subject: [PATCH 21/40] fix: add extern C support c++ --- tools/shell/inc/shellAuto.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/shell/inc/shellAuto.h b/tools/shell/inc/shellAuto.h index 7fe249251b..c9d631f4b2 100644 --- a/tools/shell/inc/shellAuto.h +++ b/tools/shell/inc/shellAuto.h @@ -16,6 +16,10 @@ #ifndef __SHELL_AUTO__ #define __SHELL_AUTO__ +#ifdef __cplusplus +extern "C" { +#endif + #include "shellInt.h" #define TAB_KEY 0x09 @@ -54,5 +58,8 @@ void showHelp(); bool fieldOptionsArea(char* p); bool isCreateFieldsArea(char* p); +#ifdef __cplusplus +} +#endif #endif From 92e7ba50dec8b05a27885caed41a902f9de2f18b Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 28 Oct 2024 08:41:52 +0800 Subject: [PATCH 22/40] docs/s3: new section for s3 interacting --- docs/zh/08-operation/12-multi.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/zh/08-operation/12-multi.md b/docs/zh/08-operation/12-multi.md index bb3326cf3e..ece590d6c8 100644 --- a/docs/zh/08-operation/12-multi.md +++ b/docs/zh/08-operation/12-multi.md @@ -109,9 +109,37 @@ s3migrate database ; | # | 参数 | 默认值 | 最小值 | 最大值 | 描述 | | :--- | :----------- | :----- | :----- | :------ | :----------------------------------------------------------- | | 1 | s3_keeplocal | 365 | 1 | 365000 | 数据在本地保留的天数,即 data 文件在本地磁盘保留多长时间后可以上传到 S3。默认单位:天,支持 m(分钟)、h(小时)和 d(天)三个单位 | -| 2 | s3_chunksize | 262144 | 131072 | 1048576 | 上传对象的大小阈值,与 TSDB_PAGESIZE 参数一样,不可修改,单位为 TSDB 页 | +| 2 | s3_chunksize | 262144 | 131072 | 1048576 | 上传对象的大小阈值,与 tsdb_pagesize 参数一样,不可修改,单位为 TSDB 页 | | 3 | s3_compact | 1 | 0 | 1 | TSDB 文件组首次上传 S3 时,是否自动进行 compact 操作。 | +### 对象存储交互 + +对象存储服务的使用成本与存储的数据量及请求次数相关,下面分别介绍数据的上传及下载过程。 + +#### 数据上传 + +当 TSDB 时序数据超过 `s3_keeplocal` 参数指定的时间,相关的数据文件会被切分成多个文件块,每个文件块的默认大小是 1G 字节 (`s3_chunksize * tsdb_pagesize`)。除了最后一个文件块保留在本地文件系统外,其余的文件块会被上 +传到对象存储服务。 + +```math +上传次数 = 数据文件大小 / 每个文件块大小 - 1 +``` + +在创建数据库时,可以通过 `s3_chunksize` 参数调整每个文件块的大小,从而控制每个数据文件的上传次数。 + +其它类型的文件如 head, stt, sma 等,保留在本地文件系统,以加速预计算相关查询。 + +#### 数据下载 + +在查询操作中,如果需要访问对象存储中的数据,TSDB 不会下载整个数据文件,而是计算所需数据在文件中的位置,只下载相应的数据块(请参考存储引擎部分)到 TSDB 页缓存中,然后将数据返回给查询执行引擎。后续查询首先检查页缓 +存,查看数据是否已被缓存。如果数据已缓存,则直接使用缓存中的数据,而无需重复从对象存储下载,从而有效降低从对象存储下载数据的次数。 + +```math +下载次数 = 查询需要的数据块数量 - 已缓存的数据块数量 +``` + +页缓存是内存缓存,节点重启后,再次查询需要重新下载数据。缓存采用 LRU (Least Recently Used) 策略,当缓存空间不足时,最近最少使用的数据将被淘汰。缓存的大小可以通过 `s3PageCacheSize` 参数进行调整,通常来说,缓存越>大,下载次数越少。 + ## Azure Blob 存储 本节介绍在 TDengine Enterprise 如何使用微软 Azure Blob 对象存储。本功能是上一小节‘对象存储’功能的扩展,需额外依赖 Flexify 服务提供的 S3 网关。通过适当的参数配置,可以把大部分较冷的时序数据存储到 Azure Blob 服务中。 From cee0626163c7481f8ebd350db98b7a0bb799f737 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 28 Oct 2024 08:48:19 +0800 Subject: [PATCH 23/40] docs/s3: fix incorrect line feed --- docs/zh/08-operation/12-multi.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/zh/08-operation/12-multi.md b/docs/zh/08-operation/12-multi.md index ece590d6c8..b8b231fbdb 100644 --- a/docs/zh/08-operation/12-multi.md +++ b/docs/zh/08-operation/12-multi.md @@ -118,8 +118,7 @@ s3migrate database ; #### 数据上传 -当 TSDB 时序数据超过 `s3_keeplocal` 参数指定的时间,相关的数据文件会被切分成多个文件块,每个文件块的默认大小是 1G 字节 (`s3_chunksize * tsdb_pagesize`)。除了最后一个文件块保留在本地文件系统外,其余的文件块会被上 -传到对象存储服务。 +当 TSDB 时序数据超过 `s3_keeplocal` 参数指定的时间,相关的数据文件会被切分成多个文件块,每个文件块的默认大小是 1G 字节 (`s3_chunksize * tsdb_pagesize`)。除了最后一个文件块保留在本地文件系统外,其余的文件块会被上传到对象存储服务。 ```math 上传次数 = 数据文件大小 / 每个文件块大小 - 1 From 4be0380e17944400fa3d26e23db10ff2acb42027 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 28 Oct 2024 08:51:39 +0800 Subject: [PATCH 24/40] fix typos --- docs/zh/08-operation/12-multi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/08-operation/12-multi.md b/docs/zh/08-operation/12-multi.md index b8b231fbdb..d4c869a27a 100644 --- a/docs/zh/08-operation/12-multi.md +++ b/docs/zh/08-operation/12-multi.md @@ -137,7 +137,7 @@ s3migrate database ; 下载次数 = 查询需要的数据块数量 - 已缓存的数据块数量 ``` -页缓存是内存缓存,节点重启后,再次查询需要重新下载数据。缓存采用 LRU (Least Recently Used) 策略,当缓存空间不足时,最近最少使用的数据将被淘汰。缓存的大小可以通过 `s3PageCacheSize` 参数进行调整,通常来说,缓存越>大,下载次数越少。 +页缓存是内存缓存,节点重启后,再次查询需要重新下载数据。缓存采用 LRU (Least Recently Used) 策略,当缓存空间不足时,最近最少使用的数据将被淘汰。缓存的大小可以通过 `s3PageCacheSize` 参数进行调整,通常来说,缓存越大,下载次数越少。 ## Azure Blob 存储 本节介绍在 TDengine Enterprise 如何使用微软 Azure Blob 对象存储。本功能是上一小节‘对象存储’功能的扩展,需额外依赖 Flexify 服务提供的 S3 网关。通过适当的参数配置,可以把大部分较冷的时序数据存储到 Azure Blob 服务中。 From 67a05c28600c6cd0a1da9b04858aa3d2002ef9b4 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 28 Oct 2024 08:53:33 +0800 Subject: [PATCH 25/40] fix line ending --- docs/zh/08-operation/12-multi.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/zh/08-operation/12-multi.md b/docs/zh/08-operation/12-multi.md index d4c869a27a..6237613223 100644 --- a/docs/zh/08-operation/12-multi.md +++ b/docs/zh/08-operation/12-multi.md @@ -130,8 +130,7 @@ s3migrate database ; #### 数据下载 -在查询操作中,如果需要访问对象存储中的数据,TSDB 不会下载整个数据文件,而是计算所需数据在文件中的位置,只下载相应的数据块(请参考存储引擎部分)到 TSDB 页缓存中,然后将数据返回给查询执行引擎。后续查询首先检查页缓 -存,查看数据是否已被缓存。如果数据已缓存,则直接使用缓存中的数据,而无需重复从对象存储下载,从而有效降低从对象存储下载数据的次数。 +在查询操作中,如果需要访问对象存储中的数据,TSDB 不会下载整个数据文件,而是计算所需数据在文件中的位置,只下载相应的数据块(请参考存储引擎部分)到 TSDB 页缓存中,然后将数据返回给查询执行引擎。后续查询首先检查页缓存,查看数据是否已被缓存。如果数据已缓存,则直接使用缓存中的数据,而无需重复从对象存储下载,从而有效降低从对象存储下载数据的次数。 ```math 下载次数 = 查询需要的数据块数量 - 已缓存的数据块数量 From b89d01a11f1b013e4cebd406d0d4305b32ee1bd1 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 28 Oct 2024 10:46:59 +0800 Subject: [PATCH 26/40] more detailed upload formular --- docs/zh/08-operation/12-multi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/08-operation/12-multi.md b/docs/zh/08-operation/12-multi.md index 6237613223..9b1e7fc7ba 100644 --- a/docs/zh/08-operation/12-multi.md +++ b/docs/zh/08-operation/12-multi.md @@ -121,7 +121,7 @@ s3migrate database ; 当 TSDB 时序数据超过 `s3_keeplocal` 参数指定的时间,相关的数据文件会被切分成多个文件块,每个文件块的默认大小是 1G 字节 (`s3_chunksize * tsdb_pagesize`)。除了最后一个文件块保留在本地文件系统外,其余的文件块会被上传到对象存储服务。 ```math -上传次数 = 数据文件大小 / 每个文件块大小 - 1 +上传次数 = 数据文件大小 / (s3_chunksize * tsdb_pagesize) - 1 ``` 在创建数据库时,可以通过 `s3_chunksize` 参数调整每个文件块的大小,从而控制每个数据文件的上传次数。 From 9fecac785013a4f847041ff73a1e22a0959b0ceb Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 28 Oct 2024 13:51:51 +0800 Subject: [PATCH 27/40] refactor desc. on data block --- docs/zh/08-operation/12-multi.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/zh/08-operation/12-multi.md b/docs/zh/08-operation/12-multi.md index 9b1e7fc7ba..128aab2174 100644 --- a/docs/zh/08-operation/12-multi.md +++ b/docs/zh/08-operation/12-multi.md @@ -112,7 +112,7 @@ s3migrate database ; | 2 | s3_chunksize | 262144 | 131072 | 1048576 | 上传对象的大小阈值,与 tsdb_pagesize 参数一样,不可修改,单位为 TSDB 页 | | 3 | s3_compact | 1 | 0 | 1 | TSDB 文件组首次上传 S3 时,是否自动进行 compact 操作。 | -### 对象存储交互 +### 对象存储读写次数估算 对象存储服务的使用成本与存储的数据量及请求次数相关,下面分别介绍数据的上传及下载过程。 @@ -130,7 +130,9 @@ s3migrate database ; #### 数据下载 -在查询操作中,如果需要访问对象存储中的数据,TSDB 不会下载整个数据文件,而是计算所需数据在文件中的位置,只下载相应的数据块(请参考存储引擎部分)到 TSDB 页缓存中,然后将数据返回给查询执行引擎。后续查询首先检查页缓存,查看数据是否已被缓存。如果数据已缓存,则直接使用缓存中的数据,而无需重复从对象存储下载,从而有效降低从对象存储下载数据的次数。 +在查询操作中,如果需要访问对象存储中的数据,TSDB 不会下载整个数据文件,而是计算所需数据在文件中的位置,只下载相应的数据到 TSDB 页缓存中,然后将数据返回给查询执行引擎。后续查询首先检查页缓存,查看数据是否已被缓存。如果数据已缓存,则直接使用缓存中的数据,而无需重复从对象存储下载,从而有效降低从对象存储下载数据的次数。 + +相邻的多个数据页(创建数据库时,通过 `tsdb_pagesize` 参数指定数据页大小,默认 4K 字节)会作为一个数据块从对象存储下载一次,以减少从对象存储下载的次数。 ```math 下载次数 = 查询需要的数据块数量 - 已缓存的数据块数量 From f114dfc529706c7f2628556ed4a0885fe8ac7e4d Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 28 Oct 2024 13:58:08 +0800 Subject: [PATCH 28/40] refact desc. for tsdb page size --- docs/zh/08-operation/12-multi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/08-operation/12-multi.md b/docs/zh/08-operation/12-multi.md index 128aab2174..e015e80cc8 100644 --- a/docs/zh/08-operation/12-multi.md +++ b/docs/zh/08-operation/12-multi.md @@ -132,7 +132,7 @@ s3migrate database ; 在查询操作中,如果需要访问对象存储中的数据,TSDB 不会下载整个数据文件,而是计算所需数据在文件中的位置,只下载相应的数据到 TSDB 页缓存中,然后将数据返回给查询执行引擎。后续查询首先检查页缓存,查看数据是否已被缓存。如果数据已缓存,则直接使用缓存中的数据,而无需重复从对象存储下载,从而有效降低从对象存储下载数据的次数。 -相邻的多个数据页(创建数据库时,通过 `tsdb_pagesize` 参数指定数据页大小,默认 4K 字节)会作为一个数据块从对象存储下载一次,以减少从对象存储下载的次数。 +相邻的多个数据页会作为一个数据块从对象存储下载一次,以减少从对象存储下载的次数。每个数据页的大小,在创建数据库时,通过 `tsdb_pagesize` 参数指定,默认 4K 字节。 ```math 下载次数 = 查询需要的数据块数量 - 已缓存的数据块数量 From d9ee12b8f6d1cc819fd4ca8b44c9e68a8b432c1f Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 28 Oct 2024 14:29:07 +0800 Subject: [PATCH 29/40] refact s3_chunksize's default value --- docs/zh/08-operation/12-multi.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh/08-operation/12-multi.md b/docs/zh/08-operation/12-multi.md index e015e80cc8..6afd642752 100644 --- a/docs/zh/08-operation/12-multi.md +++ b/docs/zh/08-operation/12-multi.md @@ -109,7 +109,7 @@ s3migrate database ; | # | 参数 | 默认值 | 最小值 | 最大值 | 描述 | | :--- | :----------- | :----- | :----- | :------ | :----------------------------------------------------------- | | 1 | s3_keeplocal | 365 | 1 | 365000 | 数据在本地保留的天数,即 data 文件在本地磁盘保留多长时间后可以上传到 S3。默认单位:天,支持 m(分钟)、h(小时)和 d(天)三个单位 | -| 2 | s3_chunksize | 262144 | 131072 | 1048576 | 上传对象的大小阈值,与 tsdb_pagesize 参数一样,不可修改,单位为 TSDB 页 | +| 2 | s3_chunksize | 131072 | 131072 | 1048576 | 上传对象的大小阈值,与 tsdb_pagesize 参数一样,不可修改,单位为 TSDB 页 | | 3 | s3_compact | 1 | 0 | 1 | TSDB 文件组首次上传 S3 时,是否自动进行 compact 操作。 | ### 对象存储读写次数估算 @@ -118,7 +118,7 @@ s3migrate database ; #### 数据上传 -当 TSDB 时序数据超过 `s3_keeplocal` 参数指定的时间,相关的数据文件会被切分成多个文件块,每个文件块的默认大小是 1G 字节 (`s3_chunksize * tsdb_pagesize`)。除了最后一个文件块保留在本地文件系统外,其余的文件块会被上传到对象存储服务。 +当 TSDB 时序数据超过 `s3_keeplocal` 参数指定的时间,相关的数据文件会被切分成多个文件块,每个文件块的默认大小是 500M 字节 (`s3_chunksize * tsdb_pagesize`)。除了最后一个文件块保留在本地文件系统外,其余的文件块会被上传到对象存储服务。 ```math 上传次数 = 数据文件大小 / (s3_chunksize * tsdb_pagesize) - 1 From 036b7ebefa0e4386fefa0e3ed370edb54086a323 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 28 Oct 2024 16:12:18 +0800 Subject: [PATCH 30/40] fix: replace unsafe str fun and check return value --- tools/shell/src/shellAuto.c | 54 ++++++------ tools/shell/test/shellTest.cpp | 145 +++++++++++++++++---------------- 2 files changed, 105 insertions(+), 94 deletions(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 201389f20b..8ad9e9072b 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -700,9 +700,9 @@ SWord* addWord(const char* p, int32_t len, bool pattern) { // check format if (pattern && len > 0) { - if (p[len-1] == ';') { + if (p[len - 1] == ';') { word->type = wordType(p, len - 1); - word->end = true; + word->end = true; } else { word->type = wordType(p, len); } @@ -1311,7 +1311,7 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) { // first tab press const char* str = NULL; int strLen = 0; - + SWord* word = MATCH_WORD(match); if (firstMatchIndex == curMatchIndex && lastWordBytes == -1) { // first press tab @@ -1331,14 +1331,18 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) { if (word->end && str[strLen - 1] != ';') { // append end ';' - char *p = taosMemoryMalloc(strLen + 8); - strcpy(p, str); - strcat(p, ";"); - shellInsertStr(cmd, (char *)p, strLen + 1); - taosMemoryFree(p); + char* p = taosMemoryCalloc(strLen + 8, 1); + if (p) { + tstrncpy(p, str, strLen); + tstrncpy(p + strLen, ";", 1); + shellInsertStr(cmd, (char*)p, strLen + 1); + taosMemoryFree(p); + } else { + shellInsertStr(cmd, (char*)str, strLen); + } } else { // insert new - shellInsertStr(cmd, (char *)str, strLen); + shellInsertStr(cmd, (char*)str, strLen); } } @@ -1722,27 +1726,27 @@ bool fieldOptionsArea(char* p) { } // find tags - if(strstr(p, " tags") != NULL) { + if (strstr(p, " tags") != NULL) { return false; } - if(p2 == NULL) { + if (p2 == NULL) { // first field area p2 = p1; } // find blank count int32_t cnt = 0; - while(p2) { + while (p2) { p2 = strchr(p2, ' '); if (p2) { // get prev char char prec = *(p2 - 1); if (prec != ',' && prec != '(') { // blank if before comma, not calc count. like st(ts timestamp, age int + BLANK + TAB only two blank - cnt ++; + cnt++; } - + // continue blank is one blank while (p2[1] != 0 && p2[1] == ' ') { // move next if blank again @@ -1758,18 +1762,18 @@ bool fieldOptionsArea(char* p) { // if is input create fields or tags area, return true bool isCreateFieldsArea(char* p) { - int32_t n = 0; // count - char *p1 = p; + int32_t n = 0; // count + char* p1 = p; while (*p1 != 0) { switch (*p1) { - case '(': - ++ n; - break; - case ')': - -- n; - break; - default: - break; + case '(': + ++n; + break; + case ')': + --n; + break; + default: + break; } // move next ++p1; @@ -1813,7 +1817,7 @@ bool matchCreateTable(TAOS* con, SShellCmd* cmd) { char* last = lastWord(ps); // check in create fields or tags input area - if (isCreateFieldsArea(ps)) { + if (isCreateFieldsArea(ps)) { if (fieldOptionsArea(ps)) { // fill field options ret = fillWithType(con, cmd, last, WT_VAR_FIELD_OPTIONS); diff --git a/tools/shell/test/shellTest.cpp b/tools/shell/test/shellTest.cpp index 1f3f1b1b2a..cf0ec503fe 100644 --- a/tools/shell/test/shellTest.cpp +++ b/tools/shell/test/shellTest.cpp @@ -17,56 +17,58 @@ #include #include "shellAuto.h" - TEST(fieldOptionsArea, autoTabTest) { printf("hellow world SHELL tab test\n"); // str false - const char *s0 [] = { - "create table st(ts ", - "create table st(ts timestamp, age ", - "create table st(ts timestamp, age", - "create table st(ts timestamp, age int , name ", - "create table st(ts timestamp, age int , name binary(16)", - "create table st(ts timestamp, age int , name binary(16) ) tags( ", - "create table st(ts timestamp, age int , name binary(16) ) tags( area int, addr ", - "create table st(ts timestamp, age int , name binary(16) ) tags( area int,addr varbinary", - "create table st(ts timestamp, age int, name binary(16)) tags(area int , addr varbinary(32)", - "create table st( ts timestamp, age int, name binary(16)) tags( area int, addr", - "create table st (ts timestamp , age int, name binary(16) , area int,", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int ,addr varbinary", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) level 'high' , no i", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) encode 'simple8b' level 'high', no in", + const char *s0[] = { + "create table st(ts ", + "create table st(ts timestamp, age ", + "create table st(ts timestamp, age", + "create table st(ts timestamp, age int , name ", + "create table st(ts timestamp, age int , name binary(16)", + "create table st(ts timestamp, age int , name binary(16) ) tags( ", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int, addr ", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int,addr varbinary", + "create table st(ts timestamp, age int, name binary(16)) tags(area int , addr varbinary(32)", + "create table st( ts timestamp, age int, name binary(16)) tags( area int, addr", + "create table st (ts timestamp , age int, name binary(16) , area int,", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int ,addr varbinary", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) level " + "'high' , no i", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) encode " + "'simple8b' level 'high', no in", }; // str true - const char *s1 [] = { - "create table st(ts timestamp ", - "create table st(ts timestamp, age int ", - "create table st(ts timestamp, age int ", - "create table st(ts timestamp, age int , name binary(16) ", - "create table st(ts timestamp, age int , name binary(16) ", - "create table st(ts timestamp, age int , name binary(16) , addr varbinary( 32 ) ", - "create table st(ts timestamp, age int , name binary(16) ,area int, addr varbinary(32) ", - "create table st(ts timestamp, age int , name binary(16), area int,addr varbinary(32) ", - "create table st(ts timestamp, age int, name binary(16) , area int,addr varbinary(32) ", - "create table st( ts timestamp, age int, name binary(16) ,area int,addr varbinary(32) ", - "create table st (ts timestamp , age int, name binary(16), area int,addr varbinary(32) ", - "create table st (ts timestamp , age int, name binary(16), area int , addr varbinary(32) compress 'zlib' ", - "create table st (ts timestamp , age int, name binary(16), area int , addr varbinary(32) level 'high' ", - "create table st (ts timestamp , age int, name binary(16) , area int , addr varbinary(32) encode 'simple8b' level 'high' ", + const char *s1[] = { + "create table st(ts timestamp ", + "create table st(ts timestamp, age int ", + "create table st(ts timestamp, age int ", + "create table st(ts timestamp, age int , name binary(16) ", + "create table st(ts timestamp, age int , name binary(16) ", + "create table st(ts timestamp, age int , name binary(16) , addr varbinary( 32 ) ", + "create table st(ts timestamp, age int , name binary(16) ,area int, addr varbinary(32) ", + "create table st(ts timestamp, age int , name binary(16), area int,addr varbinary(32) ", + "create table st(ts timestamp, age int, name binary(16) , area int,addr varbinary(32) ", + "create table st( ts timestamp, age int, name binary(16) ,area int,addr varbinary(32) ", + "create table st (ts timestamp , age int, name binary(16), area int,addr varbinary(32) ", + "create table st (ts timestamp , age int, name binary(16), area int , addr varbinary(32) compress 'zlib' ", + "create table st (ts timestamp , age int, name binary(16), area int , addr varbinary(32) level 'high' ", + "create table st (ts timestamp , age int, name binary(16) , area int , addr varbinary(32) encode 'simple8b' " + "level 'high' ", }; // s0 is false - for(int32_t i = 0; i < sizeof(s0)/sizeof(char*) ; i++) { + for (int32_t i = 0; i < sizeof(s0) / sizeof(char *); i++) { printf("s0 i=%d fieldOptionsArea %s expect false \n", i, s0[i]); - ASSERT (fieldOptionsArea((char *)s0[i]) == false); + ASSERT(fieldOptionsArea((char *)s0[i]) == false); } // s1 is true - for(int32_t i = 0; i < sizeof(s1)/sizeof(char*) ; i++) { + for (int32_t i = 0; i < sizeof(s1) / sizeof(char *); i++) { printf("s1 i=%d fieldOptionsArea %s expect true \n", i, s1[i]); - ASSERT (fieldOptionsArea((char *)s1[i]) == true); + ASSERT(fieldOptionsArea((char *)s1[i]) == true); } } @@ -74,51 +76,56 @@ TEST(isCreateFieldsArea, autoTabTest) { printf("hellow world SHELL tab test\n"); // str false - const char *s0 [] = { - "create table st(ts )", - "create table st(ts timestamp, age) ", - "create table st(ts timestamp, age)", - "create table st(ts timestamp, age int , name binary(16) )", - "create table st(ts timestamp, age int , name binary(16))", - "create table st(ts timestamp, age int , name binary(16) ) tags( )", - "create table st(ts timestamp, age int , name binary(16) ) tags( area int, addr )", - "create table st(ts timestamp, age int , name binary(16) ) tags( area int,addr varbinary)", - "create table st(ts timestamp, age int, name binary(16)) tags(area int , addr varbinary(32))", - "create table st( ts timestamp, age int, name binary(16)) tags( area int, addr int)", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int,addr varbinary(32) )", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int ,addr varbinary(14))", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) level 'high' )", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) encode 'simple8b' level 'high' ) ", + const char *s0[] = { + "create table st(ts )", + "create table st(ts timestamp, age) ", + "create table st(ts timestamp, age)", + "create table st(ts timestamp, age int , name binary(16) )", + "create table st(ts timestamp, age int , name binary(16))", + "create table st(ts timestamp, age int , name binary(16) ) tags( )", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int, addr )", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int,addr varbinary)", + "create table st(ts timestamp, age int, name binary(16)) tags(area int , addr varbinary(32))", + "create table st( ts timestamp, age int, name binary(16)) tags( area int, addr int)", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int,addr varbinary(32) )", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int ,addr varbinary(14))", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) level " + "'high' )", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) encode " + "'simple8b' level 'high' ) ", }; // str true - const char *s1 [] = { - "create table st(ts timestamp ", - "create table st(ts timestamp, age int ", - "create table st(ts timestamp, age int ,", - "create table st(ts timestamp, age int , name binary(16), ", - "create table st(ts timestamp, age int , name binary(16) ", - "create table st(ts timestamp, age int , name binary(16) ) tags( area int ", - "create table st(ts timestamp, age int , name binary(16) ) tags( area int, addr varbinary(32) ", - "create table st(ts timestamp, age int , name binary(16) ) tags( area int,addr varbinary(32)", - "create table st(ts timestamp, age int, name binary(16)) tags(area int,addr varbinary(32) ", - "create table st( ts timestamp, age int, name binary(16)) tags(area int,addr varbinary(32) ", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int, addr varbinary(32) ", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) compress 'zlib' ", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) level 'high' ", - "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) encode 'simple8b' level 'high' ", + const char *s1[] = { + "create table st(ts timestamp ", + "create table st(ts timestamp, age int ", + "create table st(ts timestamp, age int ,", + "create table st(ts timestamp, age int , name binary(16), ", + "create table st(ts timestamp, age int , name binary(16) ", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int ", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int, addr varbinary(32) ", + "create table st(ts timestamp, age int , name binary(16) ) tags( area int,addr varbinary(32)", + "create table st(ts timestamp, age int, name binary(16)) tags(area int,addr varbinary(32) ", + "create table st( ts timestamp, age int, name binary(16)) tags(area int,addr varbinary(32) ", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int, addr varbinary(32) ", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) compress " + "'zlib' ", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) level " + "'high' ", + "create table st (ts timestamp , age int, name binary(16) ) tags ( area int , addr varbinary(32) encode " + "'simple8b' level 'high' ", }; // s0 is false - for(int32_t i = 0; i < sizeof(s0)/sizeof(char*) ; i++) { + for (int32_t i = 0; i < sizeof(s0) / sizeof(char *); i++) { printf("s0 i=%d isCreateFieldsArea %s expect false. \n", i, s0[i]); - ASSERT (isCreateFieldsArea((char *)s0[i]) == false); + ASSERT(isCreateFieldsArea((char *)s0[i]) == false); } // s1 is true - for(int32_t i = 0; i < sizeof(s1)/sizeof(char*) ; i++) { + for (int32_t i = 0; i < sizeof(s1) / sizeof(char *); i++) { printf("s1 i=%d isCreateFieldsArea %s expect true. \n", i, s1[i]); - ASSERT (isCreateFieldsArea((char *)s1[i]) == true); + ASSERT(isCreateFieldsArea((char *)s1[i]) == true); } } From 6b6c9c884e4856f33099e33898252cf4ef3f2c1d Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 28 Oct 2024 16:21:15 +0800 Subject: [PATCH 31/40] fix: tstrncpy len must add 1 --- tools/shell/src/shellAuto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 8ad9e9072b..a3093237cb 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -1333,8 +1333,8 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) { // append end ';' char* p = taosMemoryCalloc(strLen + 8, 1); if (p) { - tstrncpy(p, str, strLen); - tstrncpy(p + strLen, ";", 1); + tstrncpy(p, str, strLen + 1); + tstrncpy(p + strLen, ";", 1 + 1); shellInsertStr(cmd, (char*)p, strLen + 1); taosMemoryFree(p); } else { From 462dc3362f2c88fe5428ceb43f700dc65d905024 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 28 Oct 2024 16:27:52 +0800 Subject: [PATCH 32/40] fix: lastWordBytes need add 1 --- tools/shell/src/shellAuto.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index a3093237cb..959e2d6d62 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -1335,6 +1335,7 @@ void printScreen(TAOS* con, SShellCmd* cmd, SWords* match) { if (p) { tstrncpy(p, str, strLen + 1); tstrncpy(p + strLen, ";", 1 + 1); + lastWordBytes += 1; shellInsertStr(cmd, (char*)p, strLen + 1); taosMemoryFree(p); } else { From 53826a320f260b481643a4e4e224373c48778810 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 28 Oct 2024 16:46:26 +0800 Subject: [PATCH 33/40] fix(s3/s3_chunksize): rename to s3_chunkpages & default to 128k pages --- include/common/ttokendef.h | 776 ++++++------ include/util/tdef.h | 2 +- source/common/src/systable.c | 2 +- source/libs/command/src/command.c | 146 +-- source/libs/parser/inc/parAst.h | 4 +- source/libs/parser/inc/sql.y | 2 +- source/libs/parser/src/parAstCreater.c | 28 +- source/libs/parser/src/parTokenizer.c | 14 +- source/libs/parser/src/parTranslater.c | 490 ++++---- source/libs/parser/src/sql.c | 1502 +++++++++++++++++++++++- 10 files changed, 2205 insertions(+), 761 deletions(-) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index b86830869c..3b2a0a0094 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -16,394 +16,394 @@ #ifndef _TD_COMMON_TOKEN_H_ #define _TD_COMMON_TOKEN_H_ -#define TK_OR 1 -#define TK_AND 2 -#define TK_UNION 3 -#define TK_ALL 4 -#define TK_MINUS 5 -#define TK_EXCEPT 6 -#define TK_INTERSECT 7 -#define TK_NK_BITAND 8 -#define TK_NK_BITOR 9 -#define TK_NK_LSHIFT 10 -#define TK_NK_RSHIFT 11 -#define TK_NK_PLUS 12 -#define TK_NK_MINUS 13 -#define TK_NK_STAR 14 -#define TK_NK_SLASH 15 -#define TK_NK_REM 16 -#define TK_NK_CONCAT 17 -#define TK_CREATE 18 -#define TK_ACCOUNT 19 -#define TK_NK_ID 20 -#define TK_PASS 21 -#define TK_NK_STRING 22 -#define TK_ALTER 23 -#define TK_PPS 24 -#define TK_TSERIES 25 -#define TK_STORAGE 26 -#define TK_STREAMS 27 -#define TK_QTIME 28 -#define TK_DBS 29 -#define TK_USERS 30 -#define TK_CONNS 31 -#define TK_STATE 32 -#define TK_NK_COMMA 33 -#define TK_HOST 34 -#define TK_IS_IMPORT 35 -#define TK_NK_INTEGER 36 -#define TK_CREATEDB 37 -#define TK_USER 38 -#define TK_ENABLE 39 -#define TK_SYSINFO 40 -#define TK_ADD 41 -#define TK_DROP 42 -#define TK_GRANT 43 -#define TK_ON 44 -#define TK_TO 45 -#define TK_REVOKE 46 -#define TK_FROM 47 -#define TK_SUBSCRIBE 48 -#define TK_READ 49 -#define TK_WRITE 50 -#define TK_NK_DOT 51 -#define TK_WITH 52 -#define TK_ENCRYPT_KEY 53 -#define TK_ANODE 54 -#define TK_UPDATE 55 -#define TK_ANODES 56 -#define TK_DNODE 57 -#define TK_PORT 58 -#define TK_DNODES 59 -#define TK_RESTORE 60 -#define TK_NK_IPTOKEN 61 -#define TK_FORCE 62 -#define TK_UNSAFE 63 -#define TK_CLUSTER 64 -#define TK_LOCAL 65 -#define TK_QNODE 66 -#define TK_BNODE 67 -#define TK_SNODE 68 -#define TK_MNODE 69 -#define TK_VNODE 70 -#define TK_DATABASE 71 -#define TK_USE 72 -#define TK_FLUSH 73 -#define TK_TRIM 74 -#define TK_S3MIGRATE 75 -#define TK_COMPACT 76 -#define TK_IF 77 -#define TK_NOT 78 -#define TK_EXISTS 79 -#define TK_BUFFER 80 -#define TK_CACHEMODEL 81 -#define TK_CACHESIZE 82 -#define TK_COMP 83 -#define TK_DURATION 84 -#define TK_NK_VARIABLE 85 -#define TK_MAXROWS 86 -#define TK_MINROWS 87 -#define TK_KEEP 88 -#define TK_PAGES 89 -#define TK_PAGESIZE 90 -#define TK_TSDB_PAGESIZE 91 -#define TK_PRECISION 92 -#define TK_REPLICA 93 -#define TK_VGROUPS 94 -#define TK_SINGLE_STABLE 95 -#define TK_RETENTIONS 96 -#define TK_SCHEMALESS 97 -#define TK_WAL_LEVEL 98 -#define TK_WAL_FSYNC_PERIOD 99 -#define TK_WAL_RETENTION_PERIOD 100 -#define TK_WAL_RETENTION_SIZE 101 -#define TK_WAL_ROLL_PERIOD 102 -#define TK_WAL_SEGMENT_SIZE 103 -#define TK_STT_TRIGGER 104 -#define TK_TABLE_PREFIX 105 -#define TK_TABLE_SUFFIX 106 -#define TK_S3_CHUNKSIZE 107 -#define TK_S3_KEEPLOCAL 108 -#define TK_S3_COMPACT 109 -#define TK_KEEP_TIME_OFFSET 110 -#define TK_ENCRYPT_ALGORITHM 111 -#define TK_NK_COLON 112 -#define TK_BWLIMIT 113 -#define TK_START 114 -#define TK_TIMESTAMP 115 -#define TK_END 116 -#define TK_TABLE 117 -#define TK_NK_LP 118 -#define TK_NK_RP 119 -#define TK_USING 120 -#define TK_FILE 121 -#define TK_STABLE 122 -#define TK_COLUMN 123 -#define TK_MODIFY 124 -#define TK_RENAME 125 -#define TK_TAG 126 -#define TK_SET 127 -#define TK_NK_EQ 128 -#define TK_TAGS 129 -#define TK_BOOL 130 -#define TK_TINYINT 131 -#define TK_SMALLINT 132 -#define TK_INT 133 -#define TK_INTEGER 134 -#define TK_BIGINT 135 -#define TK_FLOAT 136 -#define TK_DOUBLE 137 -#define TK_BINARY 138 -#define TK_NCHAR 139 -#define TK_UNSIGNED 140 -#define TK_JSON 141 -#define TK_VARCHAR 142 -#define TK_MEDIUMBLOB 143 -#define TK_BLOB 144 -#define TK_VARBINARY 145 -#define TK_GEOMETRY 146 -#define TK_DECIMAL 147 -#define TK_COMMENT 148 -#define TK_MAX_DELAY 149 -#define TK_WATERMARK 150 -#define TK_ROLLUP 151 -#define TK_TTL 152 -#define TK_SMA 153 -#define TK_DELETE_MARK 154 -#define TK_FIRST 155 -#define TK_LAST 156 -#define TK_SHOW 157 -#define TK_FULL 158 -#define TK_PRIVILEGES 159 -#define TK_DATABASES 160 -#define TK_TABLES 161 -#define TK_STABLES 162 -#define TK_MNODES 163 -#define TK_QNODES 164 -#define TK_ARBGROUPS 165 -#define TK_FUNCTIONS 166 -#define TK_INDEXES 167 -#define TK_ACCOUNTS 168 -#define TK_APPS 169 -#define TK_CONNECTIONS 170 -#define TK_LICENCES 171 -#define TK_GRANTS 172 -#define TK_LOGS 173 -#define TK_MACHINES 174 -#define TK_ENCRYPTIONS 175 -#define TK_QUERIES 176 -#define TK_SCORES 177 -#define TK_TOPICS 178 -#define TK_VARIABLES 179 -#define TK_BNODES 180 -#define TK_SNODES 181 -#define TK_TRANSACTIONS 182 -#define TK_DISTRIBUTED 183 -#define TK_CONSUMERS 184 -#define TK_SUBSCRIPTIONS 185 -#define TK_VNODES 186 -#define TK_ALIVE 187 -#define TK_VIEWS 188 -#define TK_VIEW 189 -#define TK_COMPACTS 190 -#define TK_NORMAL 191 -#define TK_CHILD 192 -#define TK_LIKE 193 -#define TK_TBNAME 194 -#define TK_QTAGS 195 -#define TK_AS 196 -#define TK_SYSTEM 197 -#define TK_TSMA 198 -#define TK_INTERVAL 199 -#define TK_RECURSIVE 200 -#define TK_TSMAS 201 -#define TK_FUNCTION 202 -#define TK_INDEX 203 -#define TK_COUNT 204 -#define TK_LAST_ROW 205 -#define TK_META 206 -#define TK_ONLY 207 -#define TK_TOPIC 208 -#define TK_CONSUMER 209 -#define TK_GROUP 210 -#define TK_DESC 211 -#define TK_DESCRIBE 212 -#define TK_RESET 213 -#define TK_QUERY 214 -#define TK_CACHE 215 -#define TK_EXPLAIN 216 -#define TK_ANALYZE 217 -#define TK_VERBOSE 218 -#define TK_NK_BOOL 219 -#define TK_RATIO 220 -#define TK_NK_FLOAT 221 -#define TK_OUTPUTTYPE 222 -#define TK_AGGREGATE 223 -#define TK_BUFSIZE 224 -#define TK_LANGUAGE 225 -#define TK_REPLACE 226 -#define TK_STREAM 227 -#define TK_INTO 228 -#define TK_PAUSE 229 -#define TK_RESUME 230 -#define TK_PRIMARY 231 -#define TK_KEY 232 -#define TK_TRIGGER 233 -#define TK_AT_ONCE 234 -#define TK_WINDOW_CLOSE 235 -#define TK_IGNORE 236 -#define TK_EXPIRED 237 -#define TK_FILL_HISTORY 238 -#define TK_SUBTABLE 239 -#define TK_UNTREATED 240 -#define TK_KILL 241 -#define TK_CONNECTION 242 -#define TK_TRANSACTION 243 -#define TK_BALANCE 244 -#define TK_VGROUP 245 -#define TK_LEADER 246 -#define TK_MERGE 247 -#define TK_REDISTRIBUTE 248 -#define TK_SPLIT 249 -#define TK_DELETE 250 -#define TK_INSERT 251 -#define TK_NK_BIN 252 -#define TK_NK_HEX 253 -#define TK_NULL 254 -#define TK_NK_QUESTION 255 -#define TK_NK_ALIAS 256 -#define TK_NK_ARROW 257 -#define TK_ROWTS 258 -#define TK_QSTART 259 -#define TK_QEND 260 -#define TK_QDURATION 261 -#define TK_WSTART 262 -#define TK_WEND 263 -#define TK_WDURATION 264 -#define TK_IROWTS 265 -#define TK_ISFILLED 266 -#define TK_FLOW 267 -#define TK_FHIGH 268 -#define TK_FROWTS 269 -#define TK_CAST 270 -#define TK_POSITION 271 -#define TK_IN 272 -#define TK_FOR 273 -#define TK_NOW 274 -#define TK_TODAY 275 -#define TK_RAND 276 -#define TK_SUBSTR 277 -#define TK_SUBSTRING 278 -#define TK_BOTH 279 -#define TK_TRAILING 280 -#define TK_LEADING 281 -#define TK_TIMEZONE 282 -#define TK_CLIENT_VERSION 283 -#define TK_SERVER_VERSION 284 -#define TK_SERVER_STATUS 285 -#define TK_CURRENT_USER 286 -#define TK_PI 287 -#define TK_CASE 288 -#define TK_WHEN 289 -#define TK_THEN 290 -#define TK_ELSE 291 -#define TK_BETWEEN 292 -#define TK_IS 293 -#define TK_NK_LT 294 -#define TK_NK_GT 295 -#define TK_NK_LE 296 -#define TK_NK_GE 297 -#define TK_NK_NE 298 -#define TK_MATCH 299 -#define TK_NMATCH 300 -#define TK_CONTAINS 301 -#define TK_JOIN 302 -#define TK_INNER 303 -#define TK_LEFT 304 -#define TK_RIGHT 305 -#define TK_OUTER 306 -#define TK_SEMI 307 -#define TK_ANTI 308 -#define TK_ASOF 309 -#define TK_WINDOW 310 -#define TK_WINDOW_OFFSET 311 -#define TK_JLIMIT 312 -#define TK_SELECT 313 -#define TK_NK_HINT 314 -#define TK_DISTINCT 315 -#define TK_WHERE 316 -#define TK_PARTITION 317 -#define TK_BY 318 -#define TK_SESSION 319 -#define TK_STATE_WINDOW 320 -#define TK_EVENT_WINDOW 321 -#define TK_COUNT_WINDOW 322 -#define TK_ANOMALY_WINDOW 323 -#define TK_SLIDING 324 -#define TK_FILL 325 -#define TK_VALUE 326 -#define TK_VALUE_F 327 -#define TK_NONE 328 -#define TK_PREV 329 -#define TK_NULL_F 330 -#define TK_LINEAR 331 -#define TK_NEXT 332 -#define TK_HAVING 333 -#define TK_RANGE 334 -#define TK_EVERY 335 -#define TK_ORDER 336 -#define TK_SLIMIT 337 -#define TK_SOFFSET 338 -#define TK_LIMIT 339 -#define TK_OFFSET 340 -#define TK_ASC 341 -#define TK_NULLS 342 -#define TK_ABORT 343 -#define TK_AFTER 344 -#define TK_ATTACH 345 -#define TK_BEFORE 346 -#define TK_BEGIN 347 -#define TK_BITAND 348 -#define TK_BITNOT 349 -#define TK_BITOR 350 -#define TK_BLOCKS 351 -#define TK_CHANGE 352 -#define TK_COMMA 353 -#define TK_CONCAT 354 -#define TK_CONFLICT 355 -#define TK_COPY 356 -#define TK_DEFERRED 357 -#define TK_DELIMITERS 358 -#define TK_DETACH 359 -#define TK_DIVIDE 360 -#define TK_DOT 361 -#define TK_EACH 362 -#define TK_FAIL 363 -#define TK_GLOB 364 -#define TK_ID 365 -#define TK_IMMEDIATE 366 -#define TK_IMPORT 367 -#define TK_INITIALLY 368 -#define TK_INSTEAD 369 -#define TK_ISNULL 370 -#define TK_MODULES 371 -#define TK_NK_BITNOT 372 -#define TK_NK_SEMI 373 -#define TK_NOTNULL 374 -#define TK_OF 375 -#define TK_PLUS 376 -#define TK_PRIVILEGE 377 -#define TK_RAISE 378 -#define TK_RESTRICT 379 -#define TK_ROW 380 -#define TK_STAR 381 -#define TK_STATEMENT 382 -#define TK_STRICT 383 -#define TK_STRING 384 -#define TK_TIMES 385 -#define TK_VALUES 386 -#define TK_VARIABLE 387 -#define TK_WAL 388 +#define TK_OR 1 +#define TK_AND 2 +#define TK_UNION 3 +#define TK_ALL 4 +#define TK_MINUS 5 +#define TK_EXCEPT 6 +#define TK_INTERSECT 7 +#define TK_NK_BITAND 8 +#define TK_NK_BITOR 9 +#define TK_NK_LSHIFT 10 +#define TK_NK_RSHIFT 11 +#define TK_NK_PLUS 12 +#define TK_NK_MINUS 13 +#define TK_NK_STAR 14 +#define TK_NK_SLASH 15 +#define TK_NK_REM 16 +#define TK_NK_CONCAT 17 +#define TK_CREATE 18 +#define TK_ACCOUNT 19 +#define TK_NK_ID 20 +#define TK_PASS 21 +#define TK_NK_STRING 22 +#define TK_ALTER 23 +#define TK_PPS 24 +#define TK_TSERIES 25 +#define TK_STORAGE 26 +#define TK_STREAMS 27 +#define TK_QTIME 28 +#define TK_DBS 29 +#define TK_USERS 30 +#define TK_CONNS 31 +#define TK_STATE 32 +#define TK_NK_COMMA 33 +#define TK_HOST 34 +#define TK_IS_IMPORT 35 +#define TK_NK_INTEGER 36 +#define TK_CREATEDB 37 +#define TK_USER 38 +#define TK_ENABLE 39 +#define TK_SYSINFO 40 +#define TK_ADD 41 +#define TK_DROP 42 +#define TK_GRANT 43 +#define TK_ON 44 +#define TK_TO 45 +#define TK_REVOKE 46 +#define TK_FROM 47 +#define TK_SUBSCRIBE 48 +#define TK_READ 49 +#define TK_WRITE 50 +#define TK_NK_DOT 51 +#define TK_WITH 52 +#define TK_ENCRYPT_KEY 53 +#define TK_ANODE 54 +#define TK_UPDATE 55 +#define TK_ANODES 56 +#define TK_DNODE 57 +#define TK_PORT 58 +#define TK_DNODES 59 +#define TK_RESTORE 60 +#define TK_NK_IPTOKEN 61 +#define TK_FORCE 62 +#define TK_UNSAFE 63 +#define TK_CLUSTER 64 +#define TK_LOCAL 65 +#define TK_QNODE 66 +#define TK_BNODE 67 +#define TK_SNODE 68 +#define TK_MNODE 69 +#define TK_VNODE 70 +#define TK_DATABASE 71 +#define TK_USE 72 +#define TK_FLUSH 73 +#define TK_TRIM 74 +#define TK_S3MIGRATE 75 +#define TK_COMPACT 76 +#define TK_IF 77 +#define TK_NOT 78 +#define TK_EXISTS 79 +#define TK_BUFFER 80 +#define TK_CACHEMODEL 81 +#define TK_CACHESIZE 82 +#define TK_COMP 83 +#define TK_DURATION 84 +#define TK_NK_VARIABLE 85 +#define TK_MAXROWS 86 +#define TK_MINROWS 87 +#define TK_KEEP 88 +#define TK_PAGES 89 +#define TK_PAGESIZE 90 +#define TK_TSDB_PAGESIZE 91 +#define TK_PRECISION 92 +#define TK_REPLICA 93 +#define TK_VGROUPS 94 +#define TK_SINGLE_STABLE 95 +#define TK_RETENTIONS 96 +#define TK_SCHEMALESS 97 +#define TK_WAL_LEVEL 98 +#define TK_WAL_FSYNC_PERIOD 99 +#define TK_WAL_RETENTION_PERIOD 100 +#define TK_WAL_RETENTION_SIZE 101 +#define TK_WAL_ROLL_PERIOD 102 +#define TK_WAL_SEGMENT_SIZE 103 +#define TK_STT_TRIGGER 104 +#define TK_TABLE_PREFIX 105 +#define TK_TABLE_SUFFIX 106 +#define TK_S3_CHUNKPAGES 107 +#define TK_S3_KEEPLOCAL 108 +#define TK_S3_COMPACT 109 +#define TK_KEEP_TIME_OFFSET 110 +#define TK_ENCRYPT_ALGORITHM 111 +#define TK_NK_COLON 112 +#define TK_BWLIMIT 113 +#define TK_START 114 +#define TK_TIMESTAMP 115 +#define TK_END 116 +#define TK_TABLE 117 +#define TK_NK_LP 118 +#define TK_NK_RP 119 +#define TK_USING 120 +#define TK_FILE 121 +#define TK_STABLE 122 +#define TK_COLUMN 123 +#define TK_MODIFY 124 +#define TK_RENAME 125 +#define TK_TAG 126 +#define TK_SET 127 +#define TK_NK_EQ 128 +#define TK_TAGS 129 +#define TK_BOOL 130 +#define TK_TINYINT 131 +#define TK_SMALLINT 132 +#define TK_INT 133 +#define TK_INTEGER 134 +#define TK_BIGINT 135 +#define TK_FLOAT 136 +#define TK_DOUBLE 137 +#define TK_BINARY 138 +#define TK_NCHAR 139 +#define TK_UNSIGNED 140 +#define TK_JSON 141 +#define TK_VARCHAR 142 +#define TK_MEDIUMBLOB 143 +#define TK_BLOB 144 +#define TK_VARBINARY 145 +#define TK_GEOMETRY 146 +#define TK_DECIMAL 147 +#define TK_COMMENT 148 +#define TK_MAX_DELAY 149 +#define TK_WATERMARK 150 +#define TK_ROLLUP 151 +#define TK_TTL 152 +#define TK_SMA 153 +#define TK_DELETE_MARK 154 +#define TK_FIRST 155 +#define TK_LAST 156 +#define TK_SHOW 157 +#define TK_FULL 158 +#define TK_PRIVILEGES 159 +#define TK_DATABASES 160 +#define TK_TABLES 161 +#define TK_STABLES 162 +#define TK_MNODES 163 +#define TK_QNODES 164 +#define TK_ARBGROUPS 165 +#define TK_FUNCTIONS 166 +#define TK_INDEXES 167 +#define TK_ACCOUNTS 168 +#define TK_APPS 169 +#define TK_CONNECTIONS 170 +#define TK_LICENCES 171 +#define TK_GRANTS 172 +#define TK_LOGS 173 +#define TK_MACHINES 174 +#define TK_ENCRYPTIONS 175 +#define TK_QUERIES 176 +#define TK_SCORES 177 +#define TK_TOPICS 178 +#define TK_VARIABLES 179 +#define TK_BNODES 180 +#define TK_SNODES 181 +#define TK_TRANSACTIONS 182 +#define TK_DISTRIBUTED 183 +#define TK_CONSUMERS 184 +#define TK_SUBSCRIPTIONS 185 +#define TK_VNODES 186 +#define TK_ALIVE 187 +#define TK_VIEWS 188 +#define TK_VIEW 189 +#define TK_COMPACTS 190 +#define TK_NORMAL 191 +#define TK_CHILD 192 +#define TK_LIKE 193 +#define TK_TBNAME 194 +#define TK_QTAGS 195 +#define TK_AS 196 +#define TK_SYSTEM 197 +#define TK_TSMA 198 +#define TK_INTERVAL 199 +#define TK_RECURSIVE 200 +#define TK_TSMAS 201 +#define TK_FUNCTION 202 +#define TK_INDEX 203 +#define TK_COUNT 204 +#define TK_LAST_ROW 205 +#define TK_META 206 +#define TK_ONLY 207 +#define TK_TOPIC 208 +#define TK_CONSUMER 209 +#define TK_GROUP 210 +#define TK_DESC 211 +#define TK_DESCRIBE 212 +#define TK_RESET 213 +#define TK_QUERY 214 +#define TK_CACHE 215 +#define TK_EXPLAIN 216 +#define TK_ANALYZE 217 +#define TK_VERBOSE 218 +#define TK_NK_BOOL 219 +#define TK_RATIO 220 +#define TK_NK_FLOAT 221 +#define TK_OUTPUTTYPE 222 +#define TK_AGGREGATE 223 +#define TK_BUFSIZE 224 +#define TK_LANGUAGE 225 +#define TK_REPLACE 226 +#define TK_STREAM 227 +#define TK_INTO 228 +#define TK_PAUSE 229 +#define TK_RESUME 230 +#define TK_PRIMARY 231 +#define TK_KEY 232 +#define TK_TRIGGER 233 +#define TK_AT_ONCE 234 +#define TK_WINDOW_CLOSE 235 +#define TK_IGNORE 236 +#define TK_EXPIRED 237 +#define TK_FILL_HISTORY 238 +#define TK_SUBTABLE 239 +#define TK_UNTREATED 240 +#define TK_KILL 241 +#define TK_CONNECTION 242 +#define TK_TRANSACTION 243 +#define TK_BALANCE 244 +#define TK_VGROUP 245 +#define TK_LEADER 246 +#define TK_MERGE 247 +#define TK_REDISTRIBUTE 248 +#define TK_SPLIT 249 +#define TK_DELETE 250 +#define TK_INSERT 251 +#define TK_NK_BIN 252 +#define TK_NK_HEX 253 +#define TK_NULL 254 +#define TK_NK_QUESTION 255 +#define TK_NK_ALIAS 256 +#define TK_NK_ARROW 257 +#define TK_ROWTS 258 +#define TK_QSTART 259 +#define TK_QEND 260 +#define TK_QDURATION 261 +#define TK_WSTART 262 +#define TK_WEND 263 +#define TK_WDURATION 264 +#define TK_IROWTS 265 +#define TK_ISFILLED 266 +#define TK_FLOW 267 +#define TK_FHIGH 268 +#define TK_FROWTS 269 +#define TK_CAST 270 +#define TK_POSITION 271 +#define TK_IN 272 +#define TK_FOR 273 +#define TK_NOW 274 +#define TK_TODAY 275 +#define TK_RAND 276 +#define TK_SUBSTR 277 +#define TK_SUBSTRING 278 +#define TK_BOTH 279 +#define TK_TRAILING 280 +#define TK_LEADING 281 +#define TK_TIMEZONE 282 +#define TK_CLIENT_VERSION 283 +#define TK_SERVER_VERSION 284 +#define TK_SERVER_STATUS 285 +#define TK_CURRENT_USER 286 +#define TK_PI 287 +#define TK_CASE 288 +#define TK_WHEN 289 +#define TK_THEN 290 +#define TK_ELSE 291 +#define TK_BETWEEN 292 +#define TK_IS 293 +#define TK_NK_LT 294 +#define TK_NK_GT 295 +#define TK_NK_LE 296 +#define TK_NK_GE 297 +#define TK_NK_NE 298 +#define TK_MATCH 299 +#define TK_NMATCH 300 +#define TK_CONTAINS 301 +#define TK_JOIN 302 +#define TK_INNER 303 +#define TK_LEFT 304 +#define TK_RIGHT 305 +#define TK_OUTER 306 +#define TK_SEMI 307 +#define TK_ANTI 308 +#define TK_ASOF 309 +#define TK_WINDOW 310 +#define TK_WINDOW_OFFSET 311 +#define TK_JLIMIT 312 +#define TK_SELECT 313 +#define TK_NK_HINT 314 +#define TK_DISTINCT 315 +#define TK_WHERE 316 +#define TK_PARTITION 317 +#define TK_BY 318 +#define TK_SESSION 319 +#define TK_STATE_WINDOW 320 +#define TK_EVENT_WINDOW 321 +#define TK_COUNT_WINDOW 322 +#define TK_ANOMALY_WINDOW 323 +#define TK_SLIDING 324 +#define TK_FILL 325 +#define TK_VALUE 326 +#define TK_VALUE_F 327 +#define TK_NONE 328 +#define TK_PREV 329 +#define TK_NULL_F 330 +#define TK_LINEAR 331 +#define TK_NEXT 332 +#define TK_HAVING 333 +#define TK_RANGE 334 +#define TK_EVERY 335 +#define TK_ORDER 336 +#define TK_SLIMIT 337 +#define TK_SOFFSET 338 +#define TK_LIMIT 339 +#define TK_OFFSET 340 +#define TK_ASC 341 +#define TK_NULLS 342 +#define TK_ABORT 343 +#define TK_AFTER 344 +#define TK_ATTACH 345 +#define TK_BEFORE 346 +#define TK_BEGIN 347 +#define TK_BITAND 348 +#define TK_BITNOT 349 +#define TK_BITOR 350 +#define TK_BLOCKS 351 +#define TK_CHANGE 352 +#define TK_COMMA 353 +#define TK_CONCAT 354 +#define TK_CONFLICT 355 +#define TK_COPY 356 +#define TK_DEFERRED 357 +#define TK_DELIMITERS 358 +#define TK_DETACH 359 +#define TK_DIVIDE 360 +#define TK_DOT 361 +#define TK_EACH 362 +#define TK_FAIL 363 +#define TK_GLOB 364 +#define TK_ID 365 +#define TK_IMMEDIATE 366 +#define TK_IMPORT 367 +#define TK_INITIALLY 368 +#define TK_INSTEAD 369 +#define TK_ISNULL 370 +#define TK_MODULES 371 +#define TK_NK_BITNOT 372 +#define TK_NK_SEMI 373 +#define TK_NOTNULL 374 +#define TK_OF 375 +#define TK_PLUS 376 +#define TK_PRIVILEGE 377 +#define TK_RAISE 378 +#define TK_RESTRICT 379 +#define TK_ROW 380 +#define TK_STAR 381 +#define TK_STATEMENT 382 +#define TK_STRICT 383 +#define TK_STRING 384 +#define TK_TIMES 385 +#define TK_VALUES 386 +#define TK_VARIABLE 387 +#define TK_WAL 388 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 diff --git a/include/util/tdef.h b/include/util/tdef.h index e15ec0b499..b924b377da 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -450,7 +450,7 @@ typedef enum ELogicConditionType { #define TSDB_MIN_S3_CHUNK_SIZE (128 * 1024) #define TSDB_MAX_S3_CHUNK_SIZE (1024 * 1024) -#define TSDB_DEFAULT_S3_CHUNK_SIZE (256 * 1024) +#define TSDB_DEFAULT_S3_CHUNK_SIZE (128 * 1024) #define TSDB_MIN_S3_KEEP_LOCAL (1 * 1440) // unit minute #define TSDB_MAX_S3_KEEP_LOCAL (365000 * 1440) #define TSDB_DEFAULT_S3_KEEP_LOCAL (365 * 1440) diff --git a/source/common/src/systable.c b/source/common/src/systable.c index eef38bf18e..02efb40f9f 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -118,7 +118,7 @@ static const SSysDbTableSchema userDBSchema[] = { {.name = "table_suffix", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, {.name = "tsdb_pagesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "keep_time_offset", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, - {.name = "s3_chunksize", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, + {.name = "s3_chunkpages", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "s3_keeplocal", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "s3_compact", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true}, {.name = "with_arbitrator", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true}, diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index b2417a8597..716296345f 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -50,7 +50,7 @@ static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRe (*pRsp)->numOfCols = htonl(numOfCols); int32_t len = blockEncode(pBlock, (*pRsp)->data + PAYLOAD_PREFIX_LEN, numOfCols); - if(len < 0) { + if (len < 0) { taosMemoryFree(*pRsp); return terrno; } @@ -292,7 +292,7 @@ static int32_t buildRetension(SArray* pRetension, char** ppRetentions) { } const int lMaxLen = 128; - char* p1 = taosMemoryCalloc(1, lMaxLen); + char* p1 = taosMemoryCalloc(1, lMaxLen); if (NULL == p1) { return terrno; } @@ -346,20 +346,20 @@ static const char* encryptAlgorithmStr(int8_t encryptAlgorithm) { } int32_t formatDurationOrKeep(char* buffer, int64_t bufSize, int32_t timeInMinutes) { - if (buffer == NULL || bufSize <= 0) { - return 0; - } - int32_t len = 0; - if (timeInMinutes % 1440 == 0) { - int32_t days = timeInMinutes / 1440; - len = tsnprintf(buffer, bufSize, "%dd", days); - } else if (timeInMinutes % 60 == 0) { - int32_t hours = timeInMinutes / 60; - len = tsnprintf(buffer, bufSize, "%dh", hours); - } else { - len = tsnprintf(buffer, bufSize, "%dm", timeInMinutes); - } - return len; + if (buffer == NULL || bufSize <= 0) { + return 0; + } + int32_t len = 0; + if (timeInMinutes % 1440 == 0) { + int32_t days = timeInMinutes / 1440; + len = tsnprintf(buffer, bufSize, "%dd", days); + } else if (timeInMinutes % 60 == 0) { + int32_t hours = timeInMinutes / 60; + len = tsnprintf(buffer, bufSize, "%dh", hours); + } else { + len = tsnprintf(buffer, bufSize, "%dm", timeInMinutes); + } + return len; } static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, char* dbFName, SDbCfgInfo* pCfg) { @@ -410,27 +410,27 @@ static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, int32_t lenKeep2 = formatDurationOrKeep(keep2Str, sizeof(keep2Str), pCfg->daysToKeep2); if (IS_SYS_DBNAME(dbName)) { - len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, "CREATE DATABASE `%s`", dbName); - } else { len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, - "CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %s " - "WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %s,%s,%s PAGES %d PAGESIZE %d " - "PRECISION '%s' REPLICA %d " - "WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d " - "WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64 - " KEEP_TIME_OFFSET %d ENCRYPT_ALGORITHM '%s' S3_CHUNKSIZE %d S3_KEEPLOCAL %dm S3_COMPACT %d", - dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, - durationStr, - pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger, - keep0Str, keep1Str, keep2Str, - pCfg->pages, pCfg->pageSize, prec, - pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups, 1 == pCfg->numOfStables, hashPrefix, - pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod, pCfg->walRetentionSize, - pCfg->keepTimeOffset, encryptAlgorithmStr(pCfg->encryptAlgorithm), pCfg->s3ChunkSize, - pCfg->s3KeepLocal, pCfg->s3Compact); + "CREATE DATABASE `%s`", dbName); + } else { + len += + tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, + "CREATE DATABASE `%s` BUFFER %d CACHESIZE %d CACHEMODEL '%s' COMP %d DURATION %s " + "WAL_FSYNC_PERIOD %d MAXROWS %d MINROWS %d STT_TRIGGER %d KEEP %s,%s,%s PAGES %d PAGESIZE %d " + "PRECISION '%s' REPLICA %d " + "WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d " + "WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64 + " KEEP_TIME_OFFSET %d ENCRYPT_ALGORITHM '%s' S3_CHUNKPAGES %d S3_KEEPLOCAL %dm S3_COMPACT %d", + dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, durationStr, + pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger, keep0Str, keep1Str, keep2Str, + pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups, + 1 == pCfg->numOfStables, hashPrefix, pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod, + pCfg->walRetentionSize, pCfg->keepTimeOffset, encryptAlgorithmStr(pCfg->encryptAlgorithm), + pCfg->s3ChunkSize, pCfg->s3KeepLocal, pCfg->s3Compact); if (pRetentions) { - len += tsnprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, " RETENTIONS %s", pRetentions); + len += tsnprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, + " RETENTIONS %s", pRetentions); } } @@ -510,30 +510,30 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) { #define LTYPE_LEN (32 + 60) // 60 byte for compress info char type[LTYPE_LEN]; snprintf(type, LTYPE_LEN, "%s", tDataTypes[pSchema->type].name); - int typeLen = strlen(type); + int typeLen = strlen(type); if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type || TSDB_DATA_TYPE_GEOMETRY == pSchema->type) { typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE)); } else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) { typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, "(%d)", - (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); + (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); } if (useCompress(pCfg->tableType) && pCfg->pSchemaExt) { typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " ENCODE \'%s\'", - columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress))); + columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress))); typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " COMPRESS \'%s\'", - columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress))); + columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress))); typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " LEVEL \'%s\'", - columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress))); + columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress))); } if (!(pSchema->flags & COL_IS_KEY)) { - *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s", - ((i > 0) ? ", " : ""), pSchema->name, type); + *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), + "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type); } else { char* pk = "PRIMARY KEY"; - *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s %s", - ((i > 0) ? ", " : ""), pSchema->name, type, pk); + *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), + "%s`%s` %s %s", ((i > 0) ? ", " : ""), pSchema->name, type, pk); } } } @@ -545,14 +545,15 @@ void appendTagFields(char* buf, int32_t* len, STableCfg* pCfg) { snprintf(type, sizeof(type), "%s", tDataTypes[pSchema->type].name); if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type || TSDB_DATA_TYPE_GEOMETRY == pSchema->type) { - snprintf(type + strlen(type), sizeof(type) - strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE)); + snprintf(type + strlen(type), sizeof(type) - strlen(type), "(%d)", + (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE)); } else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) { snprintf(type + strlen(type), sizeof(type) - strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); } - *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "%s`%s` %s", - ((i > 0) ? ", " : ""), pSchema->name, type); + *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), + "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type); } } @@ -560,7 +561,7 @@ void appendTagNameFields(char* buf, int32_t* len, STableCfg* pCfg) { for (int32_t i = 0; i < pCfg->numOfTags; ++i) { SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i; *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - "%s`%s`", ((i > 0) ? ", " : ""), pSchema->name); + "%s`%s`", ((i > 0) ? ", " : ""), pSchema->name); } } @@ -582,7 +583,7 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { return terrno; } *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - "%s", pJson); + "%s", pJson); taosMemoryFree(pJson); return TSDB_CODE_SUCCESS; @@ -596,12 +597,12 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i; if (i > 0) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - ", "); + ", "); } if (j >= valueNum) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - "NULL"); + "NULL"); continue; } @@ -624,14 +625,15 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { code = dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, leftSize, type, pTagVal->pData, pTagVal->nData, &tlen); TAOS_CHECK_ERRNO(code); } else { - code = dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, leftSize, type, &pTagVal->i64, tDataTypes[type].bytes, &tlen); + code = dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, leftSize, type, &pTagVal->i64, tDataTypes[type].bytes, + &tlen); TAOS_CHECK_ERRNO(code); } *len += tlen; j++; } else { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - "NULL"); + "NULL"); } } _exit: @@ -643,38 +645,38 @@ _exit: void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg* pCfg) { if (pCfg->commentLen > 0) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - " COMMENT '%s'", pCfg->pComment); + " COMMENT '%s'", pCfg->pComment); } else if (0 == pCfg->commentLen) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - " COMMENT ''"); + " COMMENT ''"); } if (NULL != pDbCfg->pRetensions && pCfg->watermark1 > 0) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - " WATERMARK %" PRId64 "a", pCfg->watermark1); + " WATERMARK %" PRId64 "a", pCfg->watermark1); if (pCfg->watermark2 > 0) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - ", %" PRId64 "a", pCfg->watermark2); + ", %" PRId64 "a", pCfg->watermark2); } } if (NULL != pDbCfg->pRetensions && pCfg->delay1 > 0) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - " MAX_DELAY %" PRId64 "a", pCfg->delay1); + " MAX_DELAY %" PRId64 "a", pCfg->delay1); if (pCfg->delay2 > 0) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - ", %" PRId64 "a", pCfg->delay2); + ", %" PRId64 "a", pCfg->delay2); } } int32_t funcNum = taosArrayGetSize(pCfg->pFuncs); if (NULL != pDbCfg->pRetensions && funcNum > 0) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - " ROLLUP("); + " ROLLUP("); for (int32_t i = 0; i < funcNum; ++i) { char* pFunc = taosArrayGet(pCfg->pFuncs, i); *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - "%s%s", ((i > 0) ? ", " : ""), pFunc); + "%s%s", ((i > 0) ? ", " : ""), pFunc); } *len += snprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), ")"); @@ -682,7 +684,7 @@ void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg* if (pCfg->ttl > 0) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - " TTL %d", pCfg->ttl); + " TTL %d", pCfg->ttl); } if (TSDB_SUPER_TABLE == pCfg->tableType || TSDB_NORMAL_TABLE == pCfg->tableType) { @@ -696,18 +698,18 @@ void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg* if (nSma < pCfg->numOfColumns && nSma > 0) { bool smaOn = false; *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), - " SMA("); + " SMA("); for (int32_t i = 0; i < pCfg->numOfColumns; ++i) { if (IS_BSMA_ON(pCfg->pSchemas + i)) { if (smaOn) { *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, - SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), ",`%s`", - (pCfg->pSchemas + i)->name); + SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), ",`%s`", + (pCfg->pSchemas + i)->name); } else { smaOn = true; *len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, - SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "`%s`", - (pCfg->pSchemas + i)->name); + SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len), "`%s`", + (pCfg->pSchemas + i)->name); } } } @@ -736,20 +738,20 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p if (TSDB_SUPER_TABLE == pCfg->tableType) { len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, - "CREATE STABLE `%s` (", tbName); + "CREATE STABLE `%s` (", tbName); appendColumnFields(buf2, &len, pCfg); len += tsnprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len), - ") TAGS ("); + ") TAGS ("); appendTagFields(buf2, &len, pCfg); len += snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len), ")"); appendTableOptions(buf2, &len, pDbCfg, pCfg); } else if (TSDB_CHILD_TABLE == pCfg->tableType) { len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, - "CREATE TABLE `%s` USING `%s` (", tbName, pCfg->stbName); + "CREATE TABLE `%s` USING `%s` (", tbName, pCfg->stbName); appendTagNameFields(buf2, &len, pCfg); len += tsnprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len), - ") TAGS ("); + ") TAGS ("); code = appendTagValues(buf2, &len, pCfg); TAOS_CHECK_ERRNO(code); len += @@ -757,7 +759,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p appendTableOptions(buf2, &len, pDbCfg, pCfg); } else { len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_TB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE, - "CREATE TABLE `%s` (", tbName); + "CREATE TABLE `%s` (", tbName); appendColumnFields(buf2, &len, pCfg); len += snprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + len), ")"); @@ -793,7 +795,7 @@ static int32_t setCreateViewResultIntoDataBlock(SSDataBlock* pBlock, SShowCreate } SViewMeta* pMeta = pStmt->pViewMeta; - if(NULL == pMeta) { + if (NULL == pMeta) { qError("exception: view meta is null"); return TSDB_CODE_APP_ERROR; } diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 28e867965f..597ee5f5d2 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -64,7 +64,7 @@ typedef enum EDatabaseOptionType { DB_OPTION_STT_TRIGGER, DB_OPTION_TABLE_PREFIX, DB_OPTION_TABLE_SUFFIX, - DB_OPTION_S3_CHUNKSIZE, + DB_OPTION_S3_CHUNKPAGES, DB_OPTION_S3_KEEPLOCAL, DB_OPTION_S3_COMPACT, DB_OPTION_KEEP_TIME_OFFSET, @@ -244,7 +244,7 @@ SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable SNode* createShowDnodeVariablesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pLikePattern); SNode* createShowVnodesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pDnodeEndpoint); SNode* createShowTableTagsStmt(SAstCreateContext* pCxt, SNode* pTbName, SNode* pDbName, SNodeList* pTags); -SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo, +SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo, int8_t createdb, int8_t is_import); SNode* addCreateUserStmtWhiteList(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pIpRangesNodeList); SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, void* pAlterInfo); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 99f301445a..067a8e3ccc 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -280,7 +280,7 @@ db_options(A) ::= db_options(B) WAL_SEGMENT_SIZE NK_INTEGER(C). db_options(A) ::= db_options(B) STT_TRIGGER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STT_TRIGGER, &C); } db_options(A) ::= db_options(B) TABLE_PREFIX signed(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_PREFIX, C); } db_options(A) ::= db_options(B) TABLE_SUFFIX signed(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_SUFFIX, C); } -db_options(A) ::= db_options(B) S3_CHUNKSIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_S3_CHUNKSIZE, &C); } +db_options(A) ::= db_options(B) S3_CHUNKPAGES NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_S3_CHUNKPAGES, &C); } db_options(A) ::= db_options(B) S3_KEEPLOCAL NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_S3_KEEPLOCAL, &C); } db_options(A) ::= db_options(B) S3_KEEPLOCAL NK_VARIABLE(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_S3_KEEPLOCAL, &C); } db_options(A) ::= db_options(B) S3_COMPACT NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_S3_COMPACT, &C); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index e031ee0fe1..8a148aa766 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -43,11 +43,11 @@ } \ } while (0) -#define CHECK_NAME(p) \ - do { \ - if (!p) { \ - goto _err; \ - } \ +#define CHECK_NAME(p) \ + do { \ + if (!p) { \ + goto _err; \ + } \ } while (0) #define COPY_STRING_FORM_ID_TOKEN(buf, pToken) strncpy(buf, (pToken)->z, TMIN((pToken)->n, sizeof(buf) - 1)) @@ -333,7 +333,7 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { // Len of pRawExpr->p could be larger than len of aliasName[TSDB_COL_NAME_LEN]. // If aliasName is truncated, hash value of aliasName could be the same. uint64_t hashVal = MurmurHash3_64(pRawExpr->p, pRawExpr->n); - sprintf(pExpr->aliasName, "%"PRIu64, hashVal); + sprintf(pExpr->aliasName, "%" PRIu64, hashVal); strncpy(pExpr->userAlias, pRawExpr->p, len); pExpr->userAlias[len] = '\0'; } @@ -405,7 +405,7 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pCxt->errCode = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&val); CHECK_MAKE_NODE(val); val->literal = taosStrndup(pLiteral->z, pLiteral->n); - if(!val->literal) { + if (!val->literal) { pCxt->errCode = terrno; nodesDestroyNode((SNode*)val); return NULL; @@ -586,8 +586,8 @@ SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral) { if (NULL == pLiteral || pLiteral->n <= 5) { return NULL; } - SNodeList* pHintList = NULL; - char* hint = taosStrndup(pLiteral->z + 3, pLiteral->n - 5); + SNodeList* pHintList = NULL; + char* hint = taosStrndup(pLiteral->z + 3, pLiteral->n - 5); if (!hint) return NULL; int32_t i = 0; bool quit = false; @@ -971,7 +971,7 @@ _err: } SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) { - SNode* pNew = NULL, *pGE = NULL, *pLE = NULL; + SNode *pNew = NULL, *pGE = NULL, *pLE = NULL; CHECK_PARSER_STATUS(pCxt); pCxt->errCode = nodesCloneNode(pExpr, &pNew); CHECK_PARSER_STATUS(pCxt); @@ -993,7 +993,7 @@ _err: } SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) { - SNode* pNew = NULL, *pLT = NULL, *pGT = NULL; + SNode *pNew = NULL, *pLT = NULL, *pGT = NULL; CHECK_PARSER_STATUS(pCxt); pCxt->errCode = nodesCloneNode(pExpr, &pNew); CHECK_PARSER_STATUS(pCxt); @@ -1959,7 +1959,7 @@ static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, ED nodesDestroyNode((SNode*)pNode); break; } - case DB_OPTION_S3_CHUNKSIZE: + case DB_OPTION_S3_CHUNKPAGES: pDbOptions->s3ChunkSize = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); break; case DB_OPTION_S3_KEEPLOCAL: { @@ -2210,7 +2210,7 @@ _err: SNode* setColumnOptions(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal1, void* pVal2) { CHECK_PARSER_STATUS(pCxt); - char optionType[TSDB_CL_OPTION_LEN]; + char optionType[TSDB_CL_OPTION_LEN]; memset(optionType, 0, TSDB_CL_OPTION_LEN); strncpy(optionType, pVal1->z, TMIN(pVal1->n, TSDB_CL_OPTION_LEN)); @@ -2807,7 +2807,7 @@ static int32_t getIpV4RangeFromWhitelistItem(char* ipRange, SIpV4Range* pIpRange int32_t code = TSDB_CODE_SUCCESS; char* ipCopy = taosStrdup(ipRange); if (!ipCopy) return terrno; - char* slash = strchr(ipCopy, '/'); + char* slash = strchr(ipCopy, '/'); if (slash) { *slash = '\0'; struct in_addr addr; diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 63121ec044..9b2815d2df 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -340,7 +340,7 @@ static SKeyword keywordTable[] = { {"_FROWTS", TK_FROWTS}, {"ALIVE", TK_ALIVE}, {"VARBINARY", TK_VARBINARY}, - {"S3_CHUNKSIZE", TK_S3_CHUNKSIZE}, + {"S3_CHUNKPAGES", TK_S3_CHUNKPAGES}, {"S3_KEEPLOCAL", TK_S3_KEEPLOCAL}, {"S3_COMPACT", TK_S3_COMPACT}, {"S3MIGRATE", TK_S3MIGRATE}, @@ -370,7 +370,7 @@ static int32_t doInitKeywordsTable(void) { keywordHashTable = taosHashInit(numOfEntries, MurmurHash3_32, true, false); for (int32_t i = 0; i < numOfEntries; i++) { keywordTable[i].len = (uint8_t)strlen(keywordTable[i].name); - void* ptr = &keywordTable[i]; + void* ptr = &keywordTable[i]; int32_t code = taosHashPut(keywordHashTable, keywordTable[i].name, keywordTable[i].len, (void*)&ptr, POINTER_BYTES); if (TSDB_CODE_SUCCESS != code) { taosHashCleanup(keywordHashTable); @@ -698,7 +698,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) { } } if (hasNonAsciiChars) { - *tokenId = TK_NK_ALIAS; // must be alias + *tokenId = TK_NK_ALIAS; // must be alias return i; } if (IS_TRUE_STR(z, i) || IS_FALSE_STR(z, i)) { @@ -713,10 +713,10 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) { break; } bool hasNonAsciiChars = false; - for (i = 1; ; i++) { + for (i = 1;; i++) { if ((z[i] & 0x80) != 0) { hasNonAsciiChars = true; - } else if (isIdChar[(uint8_t)z[i]]){ + } else if (isIdChar[(uint8_t)z[i]]) { } else { break; } @@ -834,9 +834,7 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr, bool* pIgnoreC bool taosIsKeyWordToken(const char* z, int32_t len) { return (tKeywordCode((char*)z, len) != TK_NK_ID); } -int32_t taosInitKeywordsTable() { - return doInitKeywordsTable(); -} +int32_t taosInitKeywordsTable() { return doInitKeywordsTable(); } void taosCleanupKeywordsTable() { void* m = keywordHashTable; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 636be7c5cc..395801e3dd 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -34,19 +34,19 @@ #define SYSTABLE_SHOW_TYPE_OFFSET QUERY_NODE_SHOW_DNODES_STMT -#define CHECK_RES_OUT_OF_MEM(p) \ - do { \ - int32_t code = (p); \ - if (TSDB_CODE_SUCCESS != code) { \ - return code; \ - } \ +#define CHECK_RES_OUT_OF_MEM(p) \ + do { \ + int32_t code = (p); \ + if (TSDB_CODE_SUCCESS != code) { \ + return code; \ + } \ } while (0) -#define CHECK_POINTER_OUT_OF_MEM(p) \ - do { \ - if (NULL == (p)) { \ - return code; \ - } \ +#define CHECK_POINTER_OUT_OF_MEM(p) \ + do { \ + if (NULL == (p)) { \ + return code; \ + } \ } while (0) typedef struct SRewriteTbNameContext { @@ -458,7 +458,7 @@ static int32_t collectUseDatabase(const SName* pName, SHashObj* pDbs) { } static int32_t collectUseTable(const SName* pName, SHashObj* pTable) { - char fullName[TSDB_TABLE_FNAME_LEN]; + char fullName[TSDB_TABLE_FNAME_LEN]; int32_t code = tNameExtractFullName(pName, fullName); if (TSDB_CODE_SUCCESS != code) { return code; @@ -709,7 +709,7 @@ static int32_t getDBVgInfoImpl(STranslateContext* pCxt, const SName* pName, SArr } static int32_t getDBVgInfo(STranslateContext* pCxt, const char* pDbName, SArray** pVgInfo) { - SName name; + SName name; int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pDbName, strlen(pDbName)); if (TSDB_CODE_SUCCESS != code) return code; char dbFname[TSDB_DB_FNAME_LEN] = {0}; @@ -725,7 +725,7 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam } if (TSDB_CODE_SUCCESS == code) { if (pParCxt->async) { - if(pCxt->withOpt) { + if (pCxt->withOpt) { code = getDbTableVgroupFromCache(pCxt->pMetaCache, pName, pInfo); } else { code = getTableVgroupFromCache(pCxt->pMetaCache, pName, pInfo); @@ -777,7 +777,7 @@ static int32_t getDBCfg(STranslateContext* pCxt, const char* pDbName, SDbCfgInfo SParseContext* pParCxt = pCxt->pParseCxt; SName name; - int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pDbName, strlen(pDbName)); + int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pDbName, strlen(pDbName)); if (TSDB_CODE_SUCCESS != code) return code; char dbFname[TSDB_DB_FNAME_LEN] = {0}; (void)tNameGetFullDbName(&name, dbFname); @@ -1019,8 +1019,7 @@ static uint8_t getPrecisionFromCurrStmt(SNode* pCurrStmt, uint8_t defaultVal) { if (isDeleteStmt(pCurrStmt)) { return ((SDeleteStmt*)pCurrStmt)->precision; } - if (pCurrStmt && nodeType(pCurrStmt) == QUERY_NODE_CREATE_TSMA_STMT) - return ((SCreateTSMAStmt*)pCurrStmt)->precision; + if (pCurrStmt && nodeType(pCurrStmt) == QUERY_NODE_CREATE_TSMA_STMT) return ((SCreateTSMAStmt*)pCurrStmt)->precision; return defaultVal; } @@ -1168,7 +1167,7 @@ static bool isBlockTimeLineAlignedQuery(SNode* pStmt) { return false; } -int32_t buildPartitionListFromOrderList(SNodeList* pOrderList, int32_t nodesNum, SNodeList**ppOut) { +int32_t buildPartitionListFromOrderList(SNodeList* pOrderList, int32_t nodesNum, SNodeList** ppOut) { *ppOut = NULL; SNodeList* pPartitionList = NULL; SNode* pNode = NULL; @@ -1194,8 +1193,7 @@ int32_t buildPartitionListFromOrderList(SNodeList* pOrderList, int32_t nodesNum, break; } } - if(TSDB_CODE_SUCCESS == code) - *ppOut = pPartitionList; + if (TSDB_CODE_SUCCESS == code) *ppOut = pPartitionList; return code; } @@ -1229,7 +1227,8 @@ static int32_t isTimeLineAlignedQuery(SNode* pStmt, bool* pRes) { } } } - if (TSDB_CODE_SUCCESS == code && QUERY_NODE_SET_OPERATOR == nodeType(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { + if (TSDB_CODE_SUCCESS == code && + QUERY_NODE_SET_OPERATOR == nodeType(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { SSetOperator* pSub = (SSetOperator*)((STempTableNode*)pSelect->pFromTable)->pSubquery; if (pSelect->pPartitionByList && pSub->timeLineFromOrderBy && pSub->pOrderByList->length > 1) { SNodeList* pPartitionList = NULL; @@ -1397,12 +1396,16 @@ static void setColumnPrimTs(STranslateContext* pCxt, SColumnNode* pCol, const ST } } -static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* pTable, bool igTags, SNodeList* pList, bool skipProjRef) { +static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* pTable, bool igTags, SNodeList* pList, + bool skipProjRef) { int32_t code = 0; if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) { const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta; int32_t nums = pMeta->tableInfo.numOfColumns + - (igTags ? 0 : ((TSDB_SUPER_TABLE == pMeta->tableType || ((SRealTableNode*)pTable)->stbRewrite) ? pMeta->tableInfo.numOfTags : 0)); + (igTags ? 0 + : ((TSDB_SUPER_TABLE == pMeta->tableType || ((SRealTableNode*)pTable)->stbRewrite) + ? pMeta->tableInfo.numOfTags + : 0)); for (int32_t i = 0; i < nums; ++i) { if (invisibleColumn(pCxt->pParseCxt->enableSysInfo, pMeta->tableType, pMeta->schema[i].flags)) { pCxt->pParseCxt->hasInvisibleCol = true; @@ -1433,7 +1436,8 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p code = setColumnInfoByExpr(pTempTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode); } if (TSDB_CODE_SUCCESS == code) { - if (!skipProjRef) pCol->projRefIdx = ((SExprNode*)pNode)->projIdx; // only set proj ref when select * from (select ...) + if (!skipProjRef) + pCol->projRefIdx = ((SExprNode*)pNode)->projIdx; // only set proj ref when select * from (select ...) } else { break; } @@ -1603,7 +1607,8 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p } } if (*pFound) { - if (QUERY_NODE_FUNCTION == nodeType(pFoundNode) && (SQL_CLAUSE_GROUP_BY == pCxt->currClause || SQL_CLAUSE_PARTITION_BY == pCxt->currClause)) { + if (QUERY_NODE_FUNCTION == nodeType(pFoundNode) && + (SQL_CLAUSE_GROUP_BY == pCxt->currClause || SQL_CLAUSE_PARTITION_BY == pCxt->currClause)) { pCxt->errCode = getFuncInfo(pCxt, (SFunctionNode*)pFoundNode); if (TSDB_CODE_SUCCESS == pCxt->errCode) { if (fmIsVectorFunc(((SFunctionNode*)pFoundNode)->funcId)) { @@ -1622,7 +1627,7 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p return DEAL_RES_ERROR; } } - SNode* pNew = NULL; + SNode* pNew = NULL; int32_t code = nodesCloneNode(pFoundNode, &pNew); if (NULL == pNew) { pCxt->errCode = code; @@ -1687,7 +1692,7 @@ static int32_t biMakeTbnameProjectAstNode(char* funcName, char* tableAlias, SNod } if (TSDB_CODE_SUCCESS == code) { snprintf(tbNameFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias), (tableAlias) ? "%s.tbname" : "%stbname", - (tableAlias) ? tableAlias : ""); + (tableAlias) ? tableAlias : ""); strncpy(tbNameFunc->node.aliasName, tbNameFunc->functionName, TSDB_COL_NAME_LEN); if (funcName == NULL) { *pOutNode = (SNode*)tbNameFunc; @@ -1705,13 +1710,13 @@ static int32_t biMakeTbnameProjectAstNode(char* funcName, char* tableAlias, SNod if (TSDB_CODE_SUCCESS == code) { if (tsKeepColumnName) { snprintf(multiResFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias), - (tableAlias) ? "%s.tbname" : "%stbname", (tableAlias) ? tableAlias : ""); + (tableAlias) ? "%s.tbname" : "%stbname", (tableAlias) ? tableAlias : ""); strcpy(multiResFunc->node.aliasName, tbNameFunc->functionName); } else { snprintf(multiResFunc->node.userAlias, sizeof(multiResFunc->node.userAlias), - tableAlias ? "%s(%s.tbname)" : "%s(%stbname)", funcName, tableAlias ? tableAlias : ""); + tableAlias ? "%s(%s.tbname)" : "%s(%stbname)", funcName, tableAlias ? tableAlias : ""); biMakeAliasNameInMD5(multiResFunc->node.userAlias, strlen(multiResFunc->node.userAlias), - multiResFunc->node.aliasName); + multiResFunc->node.aliasName); } *pOutNode = (SNode*)multiResFunc; } else { @@ -1726,7 +1731,7 @@ static int32_t biMakeTbnameProjectAstNode(char* funcName, char* tableAlias, SNod static int32_t biRewriteSelectFuncParamStar(STranslateContext* pCxt, SSelectStmt* pSelect, SNode* pNode, SListCell* pSelectListCell) { SNodeList* pTbnameNodeList = NULL; - int32_t code = nodesMakeList(&pTbnameNodeList); + int32_t code = nodesMakeList(&pTbnameNodeList); if (!pTbnameNodeList) return code; SFunctionNode* pFunc = (SFunctionNode*)pNode; @@ -1744,8 +1749,7 @@ static int32_t biRewriteSelectFuncParamStar(STranslateContext* pCxt, SSelectStmt ((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) { SNode* pTbnameNode = NULL; code = biMakeTbnameProjectAstNode(pFunc->functionName, NULL, &pTbnameNode); - if (TSDB_CODE_SUCCESS == code) - code = nodesListStrictAppend(pTbnameNodeList, pTbnameNode); + if (TSDB_CODE_SUCCESS == code) code = nodesListStrictAppend(pTbnameNodeList, pTbnameNode); } } if (TSDB_CODE_SUCCESS == code && LIST_LENGTH(pTbnameNodeList) > 0) { @@ -1761,8 +1765,7 @@ static int32_t biRewriteSelectFuncParamStar(STranslateContext* pCxt, SSelectStmt ((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) { SNode* pTbnameNode = NULL; code = biMakeTbnameProjectAstNode(pFunc->functionName, pTableAlias, &pTbnameNode); - if (TSDB_CODE_SUCCESS == code) - code = nodesListStrictAppend(pTbnameNodeList, pTbnameNode); + if (TSDB_CODE_SUCCESS == code) code = nodesListStrictAppend(pTbnameNodeList, pTbnameNode); } if (TSDB_CODE_SUCCESS == code && LIST_LENGTH(pTbnameNodeList) > 0) { nodesListInsertListAfterPos(pSelect->pProjectionList, pSelectListCell, pTbnameNodeList); @@ -1794,8 +1797,7 @@ int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect) { ((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) { SNode* pTbnameNode = NULL; code = biMakeTbnameProjectAstNode(NULL, NULL, &pTbnameNode); - if (TSDB_CODE_SUCCESS == code) - code = nodesListStrictAppend(pTbnameNodeList, pTbnameNode); + if (TSDB_CODE_SUCCESS == code) code = nodesListStrictAppend(pTbnameNodeList, pTbnameNode); } } if (TSDB_CODE_SUCCESS == code && LIST_LENGTH(pTbnameNodeList) > 0) { @@ -1810,8 +1812,7 @@ int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect) { ((SRealTableNode*)pTable)->pMeta != NULL && ((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) { SNode* pTbnameNode = NULL; code = biMakeTbnameProjectAstNode(NULL, pTableAlias, &pTbnameNode); - if (TSDB_CODE_SUCCESS ==code) - code = nodesListStrictAppend(pTbnameNodeList, pTbnameNode); + if (TSDB_CODE_SUCCESS == code) code = nodesListStrictAppend(pTbnameNodeList, pTbnameNode); } if (TSDB_CODE_SUCCESS == code && LIST_LENGTH(pTbnameNodeList) > 0) { nodesListInsertListAfterPos(pSelect->pProjectionList, cell, pTbnameNodeList); @@ -1877,9 +1878,7 @@ int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SCreateTableStmt* p } static bool clauseSupportAlias(ESqlClause clause) { - return SQL_CLAUSE_GROUP_BY == clause || - SQL_CLAUSE_PARTITION_BY == clause || - SQL_CLAUSE_ORDER_BY == clause; + return SQL_CLAUSE_GROUP_BY == clause || SQL_CLAUSE_PARTITION_BY == clause || SQL_CLAUSE_ORDER_BY == clause; } static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { @@ -1895,7 +1894,7 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { if (pCxt->pParseCxt->biMode) { SNode** ppNode = (SNode**)pCol; - bool ret; + bool ret; pCxt->errCode = biRewriteToTbnameFunc(pCxt, ppNode, &ret); if (TSDB_CODE_SUCCESS != pCxt->errCode) return DEAL_RES_ERROR; if (ret) { @@ -1908,8 +1907,7 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { res = translateColumnWithPrefix(pCxt, pCol); } else { bool found = false; - if ((pCxt->currClause == SQL_CLAUSE_ORDER_BY) && - !(*pCol)->node.asParam) { + if ((pCxt->currClause == SQL_CLAUSE_ORDER_BY) && !(*pCol)->node.asParam) { res = translateColumnUseAlias(pCxt, pCol, &found); } if (DEAL_RES_ERROR != res && !found) { @@ -1919,9 +1917,7 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { res = translateColumnWithoutPrefix(pCxt, pCol); } } - if (clauseSupportAlias(pCxt->currClause) && - !(*pCol)->node.asParam && - res != DEAL_RES_CONTINUE && + if (clauseSupportAlias(pCxt->currClause) && !(*pCol)->node.asParam && res != DEAL_RES_CONTINUE && res != DEAL_RES_END) { res = translateColumnUseAlias(pCxt, pCol, &found); } @@ -2478,8 +2474,8 @@ static int32_t translateIndefiniteRowsFunc(STranslateContext* pCxt, SFunctionNod return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); } if (pSelect->hasIndefiniteRowsFunc && - (FUNC_RETURN_ROWS_INDEFINITE == pSelect->returnRows || pSelect->returnRows != fmGetFuncReturnRows(pFunc)) && - (pSelect->lastProcessByRowFuncId == -1 || !fmIsProcessByRowFunc(pFunc->funcId))) { + (FUNC_RETURN_ROWS_INDEFINITE == pSelect->returnRows || pSelect->returnRows != fmGetFuncReturnRows(pFunc)) && + (pSelect->lastProcessByRowFuncId == -1 || !fmIsProcessByRowFunc(pFunc->funcId))) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); } if (pSelect->lastProcessByRowFuncId != -1 && pSelect->lastProcessByRowFuncId != pFunc->funcId) { @@ -2651,14 +2647,14 @@ static int32_t translateTimelineFunc(STranslateContext* pCxt, SFunctionNode* pFu "%s function must be used in select statements", pFunc->functionName); } SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt; - bool isTimelineAlignedQuery = false; + bool isTimelineAlignedQuery = false; if ((NULL != pSelect->pFromTable && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) && !isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery))) { int32_t code = isTimeLineAlignedQuery(pCxt->pCurrStmt, &isTimelineAlignedQuery); if (TSDB_CODE_SUCCESS != code) return code; if (!isTimelineAlignedQuery) return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, - "%s function requires valid time series input", pFunc->functionName); + "%s function requires valid time series input", pFunc->functionName); } if (NULL != pSelect->pFromTable && QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) && (TIME_LINE_GLOBAL != pSelect->timeLineCurMode && TIME_LINE_MULTI != pSelect->timeLineCurMode)) { @@ -2750,9 +2746,10 @@ static int32_t translateRepeatScanFunc(STranslateContext* pCxt, SFunctionNode* p } if (NULL != pSelect->pWindow) { - if (QUERY_NODE_EVENT_WINDOW == nodeType(pSelect->pWindow) || QUERY_NODE_COUNT_WINDOW == nodeType(pSelect->pWindow)) { - return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, - "%s function is not supported in count/event window", pFunc->functionName); + if (QUERY_NODE_EVENT_WINDOW == nodeType(pSelect->pWindow) || + QUERY_NODE_COUNT_WINDOW == nodeType(pSelect->pWindow)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, + "%s function is not supported in count/event window", pFunc->functionName); } } return TSDB_CODE_SUCCESS; @@ -2861,7 +2858,7 @@ static void setFuncClassification(STranslateContext* pCxt, SFunctionNode* pFunc) static int32_t rewriteFuncToValue(STranslateContext* pCxt, char** pLiteral, SNode** pNode) { SValueNode* pVal = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal); + int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -2970,7 +2967,7 @@ static int32_t rewriteSystemInfoFunc(STranslateContext* pCxt, SNode** pNode) { static int32_t replacePsedudoColumnFuncWithColumn(STranslateContext* pCxt, SNode** ppNode) { SColumnNode* pCol = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -3222,8 +3219,7 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode** pFunc pCxt->errCode = getFuncInfo(pCxt, *pFunc); if (TSDB_CODE_SUCCESS == pCxt->errCode) { - if ((SQL_CLAUSE_GROUP_BY == pCxt->currClause || - SQL_CLAUSE_PARTITION_BY == pCxt->currClause) && + if ((SQL_CLAUSE_GROUP_BY == pCxt->currClause || SQL_CLAUSE_PARTITION_BY == pCxt->currClause) && fmIsVectorFunc((*pFunc)->funcId)) { pCxt->errCode = TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION; } @@ -3246,7 +3242,7 @@ static EDealRes translateLogicCond(STranslateContext* pCxt, SLogicConditionNode* static int32_t createCastFunc(STranslateContext* pCxt, SNode* pExpr, SDataType dt, SNode** pCast) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -3281,7 +3277,7 @@ static bool isCondition(const SNode* pNode) { static int32_t rewriteIsTrue(SNode* pSrc, SNode** pIsTrue) { SOperatorNode* pOp = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp); + int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -3293,11 +3289,11 @@ static int32_t rewriteIsTrue(SNode* pSrc, SNode** pIsTrue) { return TSDB_CODE_SUCCESS; } -extern int8_t gDisplyTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX]; +extern int8_t gDisplyTypes[TSDB_DATA_TYPE_MAX][TSDB_DATA_TYPE_MAX]; static int32_t selectCommonType(SDataType* commonType, const SDataType* newType) { - if (commonType->type < TSDB_DATA_TYPE_NULL || commonType->type >= TSDB_DATA_TYPE_MAX || + if (commonType->type < TSDB_DATA_TYPE_NULL || commonType->type >= TSDB_DATA_TYPE_MAX || newType->type < TSDB_DATA_TYPE_NULL || newType->type >= TSDB_DATA_TYPE_MAX) { - return TSDB_CODE_INVALID_PARA; + return TSDB_CODE_INVALID_PARA; } int8_t type1 = commonType->type; int8_t type2 = newType->type; @@ -3308,26 +3304,25 @@ static int32_t selectCommonType(SDataType* commonType, const SDataType* newType) resultType = gDisplyTypes[type2][type1]; } if (resultType == -1) { - return TSDB_CODE_SCALAR_CONVERT_ERROR; + return TSDB_CODE_SCALAR_CONVERT_ERROR; } if (commonType->type == newType->type) { commonType->bytes = TMAX(commonType->bytes, newType->bytes); return TSDB_CODE_SUCCESS; } - if (resultType == commonType->type){ + if (resultType == commonType->type) { return TSDB_CODE_SUCCESS; } - if(resultType == newType->type) { + if (resultType == newType->type) { *commonType = *newType; return TSDB_CODE_SUCCESS; } commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), TYPE_BYTES[resultType]); - if(resultType == TSDB_DATA_TYPE_VARCHAR && (IS_FLOAT_TYPE(commonType->type) || IS_FLOAT_TYPE(newType->type))) { + if (resultType == TSDB_DATA_TYPE_VARCHAR && (IS_FLOAT_TYPE(commonType->type) || IS_FLOAT_TYPE(newType->type))) { commonType->bytes += TYPE_BYTES[TSDB_DATA_TYPE_DOUBLE]; } commonType->type = resultType; return TSDB_CODE_SUCCESS; - } static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseWhen) { @@ -3350,7 +3345,7 @@ static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseW } allNullThen = false; pCxt->errCode = selectCommonType(&pCaseWhen->node.resType, &pThenExpr->resType); - if(TSDB_CODE_SUCCESS != pCxt->errCode){ + if (TSDB_CODE_SUCCESS != pCxt->errCode) { return DEAL_RES_ERROR; } } @@ -3358,7 +3353,7 @@ static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseW SExprNode* pElseExpr = (SExprNode*)pCaseWhen->pElse; if (NULL != pElseExpr) { pCxt->errCode = selectCommonType(&pCaseWhen->node.resType, &pElseExpr->resType); - if(TSDB_CODE_SUCCESS != pCxt->errCode) { + if (TSDB_CODE_SUCCESS != pCxt->errCode) { return DEAL_RES_ERROR; } } @@ -3459,7 +3454,7 @@ static int32_t getGroupByErrorCode(STranslateContext* pCxt) { static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (TSDB_CODE_SUCCESS != code) { pCxt->errCode = code; return DEAL_RES_ERROR; @@ -3482,7 +3477,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode static EDealRes rewriteExprToGroupKeyFunc(STranslateContext* pCxt, SNode** pNode) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (TSDB_CODE_SUCCESS != code) { pCxt->errCode = code; return DEAL_RES_ERROR; @@ -3866,7 +3861,7 @@ static EDealRes doCheckAggColCoexist(SNode** pNode, void* pContext) { static EDealRes doCheckGetAggColCoexist(SNode** pNode, void* pContext) { CheckAggColCoexistCxt* pCxt = (CheckAggColCoexistCxt*)pContext; - int32_t code = 0; + int32_t code = 0; if (isVectorFunc(*pNode)) { return DEAL_RES_IGNORE_CHILD; } @@ -3893,7 +3888,7 @@ static int32_t resetSelectFuncNumWithoutDup(SSelectStmt* pSelect) { pSelect->selectFuncNum = 0; pSelect->lastProcessByRowFuncId = -1; SNodeList* pNodeList = NULL; - int32_t code = nodesMakeList(&pNodeList); + int32_t code = nodesMakeList(&pNodeList); if (TSDB_CODE_SUCCESS != code) return code; code = nodesCollectSelectFuncs(pSelect, SQL_CLAUSE_FROM, NULL, fmIsSelectFunc, pNodeList); if (TSDB_CODE_SUCCESS != code) { @@ -4278,8 +4273,8 @@ static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNo SVgroupInfo vgInfo = {0}; bool exists = false; toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName); - int32_t len = tsnprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name, - pRealTable->table.tableName); + int32_t len = tsnprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, + pTsma->name, pRealTable->table.tableName); len = taosCreateMD5Hash(buf, len); strncpy(tsmaTargetTbName.tname, buf, MD5_OUTPUT_LEN); code = collectUseTable(&tsmaTargetTbName, pCxt->pTargetTables); @@ -4364,7 +4359,7 @@ static EDealRes doTranslateTbName(SNode** pNode, void* pContext) { if (FUNCTION_TYPE_TBNAME == pFunc->funcType) { SRewriteTbNameContext* pCxt = (SRewriteTbNameContext*)pContext; SValueNode* pVal = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal); + int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal); if (TSDB_CODE_SUCCESS != code) { pCxt->errCode = code; return DEAL_RES_ERROR; @@ -4957,8 +4952,7 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare } code = translateAudit(pCxt, pRealTable, &name); #endif - if (TSDB_CODE_SUCCESS == code) - code = setTableVgroupList(pCxt, &name, pRealTable); + if (TSDB_CODE_SUCCESS == code) code = setTableVgroupList(pCxt, &name, pRealTable); if (TSDB_CODE_SUCCESS == code) { code = setTableIndex(pCxt, &name, pRealTable); } @@ -5063,7 +5057,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, bool igTags, SNodeList* static int32_t createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr, SNode** ppNodeOut) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -5153,12 +5147,12 @@ static int32_t createMultiResFuncsParas(STranslateContext* pCxt, SNodeList* pSrc static int32_t createMultiResFuncs(SFunctionNode* pSrcFunc, SNodeList* pExprs, SNodeList** pOutput) { SNodeList* pFuncs = NULL; - int32_t code = nodesMakeList(&pFuncs); + int32_t code = nodesMakeList(&pFuncs); if (NULL == pFuncs) { return code; } - SNode* pExpr = NULL; + SNode* pExpr = NULL; FOREACH(pExpr, pExprs) { SNode* pNode = NULL; code = createMultiResFunc(pSrcFunc, (SExprNode*)pExpr, &pNode); @@ -5205,7 +5199,7 @@ static int32_t createTags(STranslateContext* pCxt, SNodeList** pOutput) { SSchema* pTagsSchema = getTableTagSchema(pMeta); for (int32_t i = 0; i < pMeta->tableInfo.numOfTags; ++i) { SColumnNode* pCol = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); if (TSDB_CODE_SUCCESS != code) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); } @@ -5291,7 +5285,7 @@ static int32_t getPositionValue(const SValueNode* pVal) { } static int32_t translateClausePosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pClauseList, - bool* pOther) { + bool* pOther) { *pOther = false; SNode* pNode = NULL; WHERE_EACH(pNode, pClauseList) { @@ -5350,8 +5344,8 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) { } static EDealRes needFillImpl(SNode* pNode, void* pContext) { - if ((isAggFunc(pNode) || isInterpFunc(pNode)) && FUNCTION_TYPE_GROUP_KEY != ((SFunctionNode*)pNode)->funcType - && FUNCTION_TYPE_GROUP_CONST_VALUE != ((SFunctionNode*)pNode)->funcType) { + if ((isAggFunc(pNode) || isInterpFunc(pNode)) && FUNCTION_TYPE_GROUP_KEY != ((SFunctionNode*)pNode)->funcType && + FUNCTION_TYPE_GROUP_CONST_VALUE != ((SFunctionNode*)pNode)->funcType) { *(bool*)pContext = true; return DEAL_RES_END; } @@ -5435,8 +5429,8 @@ static int32_t checkProjectAlias(STranslateContext* pCxt, SNodeList* pProjection SHashObj* pUserAliasSet = taosHashInit(LIST_LENGTH(pProjectionList), taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); if (!pUserAliasSet) return terrno; - SNode* pProject = NULL; - int32_t code = TSDB_CODE_SUCCESS; + SNode* pProject = NULL; + int32_t code = TSDB_CODE_SUCCESS; FOREACH(pProject, pProjectionList) { SExprNode* pExpr = (SExprNode*)pProject; if (NULL != taosHashGet(pUserAliasSet, pExpr->userAlias, strlen(pExpr->userAlias))) { @@ -5458,11 +5452,9 @@ static int32_t translateProjectionList(STranslateContext* pCxt, SSelectStmt* pSe if (!pSelect->isSubquery) { return rewriteProjectAlias(pSelect->pProjectionList); } else { - SNode* pNode; + SNode* pNode; int32_t projIdx = 1; - FOREACH(pNode, pSelect->pProjectionList) { - ((SExprNode*)pNode)->projIdx = projIdx++; - } + FOREACH(pNode, pSelect->pProjectionList) { ((SExprNode*)pNode)->projIdx = projIdx++; } return TSDB_CODE_SUCCESS; } } @@ -5478,7 +5470,7 @@ static EDealRes replaceGroupByAliasImpl(SNode** pNode, void* pContext) { SNode* pProject = NULL; if (QUERY_NODE_VALUE == nodeType(*pNode)) { STranslateContext* pTransCxt = pCxt->pTranslateCxt; - SValueNode* pVal = (SValueNode*) *pNode; + SValueNode* pVal = (SValueNode*)*pNode; if (DEAL_RES_ERROR == translateValue(pTransCxt, pVal)) { return DEAL_RES_CONTINUE; } @@ -5487,7 +5479,7 @@ static EDealRes replaceGroupByAliasImpl(SNode** pNode, void* pContext) { } int32_t pos = getPositionValue(pVal); if (0 < pos && pos <= LIST_LENGTH(pProjectionList)) { - SNode* pNew = NULL; + SNode* pNew = NULL; int32_t code = nodesCloneNode(nodesListGetNode(pProjectionList, pos - 1), (SNode**)&pNew); if (TSDB_CODE_SUCCESS != code) { pCxt->pTranslateCxt->errCode = code; @@ -5511,8 +5503,7 @@ static int32_t replaceGroupByAlias(STranslateContext* pCxt, SSelectStmt* pSelect if (NULL == pSelect->pGroupByList) { return TSDB_CODE_SUCCESS; } - SReplaceGroupByAliasCxt cxt = { - .pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList}; + SReplaceGroupByAliasCxt cxt = {.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList}; nodesRewriteExprsPostOrder(pSelect->pGroupByList, replaceGroupByAliasImpl, &cxt); return pCxt->errCode; @@ -5522,8 +5513,7 @@ static int32_t replacePartitionByAlias(STranslateContext* pCxt, SSelectStmt* pSe if (NULL == pSelect->pPartitionByList) { return TSDB_CODE_SUCCESS; } - SReplaceGroupByAliasCxt cxt = { - .pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList}; + SReplaceGroupByAliasCxt cxt = {.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList}; nodesRewriteExprsPostOrder(pSelect->pPartitionByList, replaceGroupByAliasImpl, &cxt); return pCxt->errCode; @@ -5613,7 +5603,7 @@ static int32_t getQueryTimeRange(STranslateContext* pCxt, SNode* pWhere, STimeWi return TSDB_CODE_SUCCESS; } - SNode* pCond = NULL; + SNode* pCond = NULL; int32_t code = nodesCloneNode(pWhere, &pCond); if (NULL == pCond) { return code; @@ -5787,14 +5777,14 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG); } if (!fixed) { - double offsetMonth = 0, intervalMonth = 0; + double offsetMonth = 0, intervalMonth = 0; int32_t code = getMonthsFromTimeVal(pOffset->datum.i, precision, pOffset->unit, &offsetMonth); if (TSDB_CODE_SUCCESS != code) { - return code; + return code; } code = getMonthsFromTimeVal(pInter->datum.i, precision, pInter->unit, &intervalMonth); if (TSDB_CODE_SUCCESS != code) { - return code; + return code; } if (offsetMonth > intervalMonth) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG); @@ -5819,14 +5809,14 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL); } if (valInter) { - double slidingMonth = 0, intervalMonth = 0; + double slidingMonth = 0, intervalMonth = 0; int32_t code = getMonthsFromTimeVal(pSliding->datum.i, precision, pSliding->unit, &slidingMonth); if (TSDB_CODE_SUCCESS != code) { - return code; + return code; } code = getMonthsFromTimeVal(pInter->datum.i, precision, pInter->unit, &intervalMonth); if (TSDB_CODE_SUCCESS != code) { - return code; + return code; } if (slidingMonth > intervalMonth) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG); @@ -6055,7 +6045,7 @@ static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { int32_t code = 0; if (QUERY_NODE_INTERVAL_WINDOW != nodeType(pSelect->pWindow)) { if (NULL != pSelect->pFromTable && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) && - !isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { + !isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { bool isTimelineAlignedQuery = false; code = isTimeLineAlignedQuery(pCxt->pCurrStmt, &isTimelineAlignedQuery); if (TSDB_CODE_SUCCESS != code) return code; @@ -6094,7 +6084,7 @@ static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { static int32_t createDefaultFillNode(STranslateContext* pCxt, SNode** pOutput) { SFillNode* pFill = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FILL, (SNode**)&pFill); + int32_t code = nodesMakeNode(QUERY_NODE_FILL, (SNode**)&pFill); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -6117,7 +6107,7 @@ static int32_t createDefaultFillNode(STranslateContext* pCxt, SNode** pOutput) { static int32_t createDefaultEveryNode(STranslateContext* pCxt, SNode** pOutput) { SValueNode* pEvery = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pEvery); + int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pEvery); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -6308,7 +6298,7 @@ typedef struct SEqCondTbNameTableInfo { //[tableAlias.]tbname = tbNamVal static int32_t isOperatorEqTbnameCond(STranslateContext* pCxt, SOperatorNode* pOperator, char** ppTableAlias, - SArray** ppTabNames, bool* pRet) { + SArray** ppTabNames, bool* pRet) { if (pOperator->opType != OP_TYPE_EQUAL) { *pRet = false; return TSDB_CODE_SUCCESS; @@ -6359,7 +6349,7 @@ static int32_t isOperatorEqTbnameCond(STranslateContext* pCxt, SOperatorNode* pO //[tableAlias.]tbname in (value1, value2, ...) static int32_t isOperatorTbnameInCond(STranslateContext* pCxt, SOperatorNode* pOperator, char** ppTableAlias, - SArray** ppTbNames, bool* pRet) { + SArray** ppTbNames, bool* pRet) { if (pOperator->opType != OP_TYPE_IN) return false; if (nodeType(pOperator->pLeft) != QUERY_NODE_FUNCTION || ((SFunctionNode*)(pOperator->pLeft))->funcType != FUNCTION_TYPE_TBNAME || @@ -6383,8 +6373,8 @@ static int32_t isOperatorTbnameInCond(STranslateContext* pCxt, SOperatorNode* pO SNodeListNode* pValueListNode = (SNodeListNode*)pOperator->pRight; *ppTbNames = taosArrayInit(LIST_LENGTH(pValueListNode->pNodeList), sizeof(void*)); if (!*ppTbNames) return terrno; - SNodeList* pValueNodeList = pValueListNode->pNodeList; - SNode* pValNode = NULL; + SNodeList* pValueNodeList = pValueListNode->pNodeList; + SNode* pValNode = NULL; FOREACH(pValNode, pValueNodeList) { if (nodeType(pValNode) != QUERY_NODE_VALUE) { *pRet = false; @@ -6400,7 +6390,8 @@ static int32_t isOperatorTbnameInCond(STranslateContext* pCxt, SOperatorNode* pO return TSDB_CODE_SUCCESS; } -static int32_t findEqCondTbNameInOperatorNode(STranslateContext* pCxt, SNode* pWhere, SEqCondTbNameTableInfo* pInfo, bool* pRet) { +static int32_t findEqCondTbNameInOperatorNode(STranslateContext* pCxt, SNode* pWhere, SEqCondTbNameTableInfo* pInfo, + bool* pRet) { int32_t code = TSDB_CODE_SUCCESS; char* pTableAlias = NULL; bool eqTbnameCond = false, tbnameInCond = false; @@ -6467,7 +6458,7 @@ static int32_t findEqualCondTbnameInLogicCondAnd(STranslateContext* pCxt, SNode* static int32_t unionEqualCondTbnamesOfSameTable(SArray* aTableTbnames, SEqCondTbNameTableInfo* pInfo) { int32_t code = TSDB_CODE_SUCCESS; - bool bFoundTable = false; + bool bFoundTable = false; for (int i = 0; i < taosArrayGetSize(aTableTbnames); ++i) { SEqCondTbNameTableInfo* info = taosArrayGet(aTableTbnames, i); if (info->pRealTable == pInfo->pRealTable) { @@ -6547,7 +6538,7 @@ static int32_t findEqualCondTbname(STranslateContext* pCxt, SNode* pWhere, SArra } static void findVgroupsFromEqualTbname(STranslateContext* pCxt, SArray* aTbnames, const char* dbName, - int32_t numOfVgroups, SVgroupsInfo* vgsInfo) { + int32_t numOfVgroups, SVgroupsInfo* vgsInfo) { int32_t nVgroups = 0; int32_t nTbls = taosArrayGetSize(aTbnames); @@ -6584,10 +6575,10 @@ static void findVgroupsFromEqualTbname(STranslateContext* pCxt, SArray* aTbnames } static int32_t replaceToChildTableQuery(STranslateContext* pCxt, SEqCondTbNameTableInfo* pInfo) { - SName snameTb = {0}; - int32_t code = 0; + SName snameTb = {0}; + int32_t code = 0; SRealTableNode* pRealTable = pInfo->pRealTable; - char* tbName = taosArrayGetP(pInfo->aTbnames, 0); + char* tbName = taosArrayGetP(pInfo->aTbnames, 0); toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, tbName, &snameTb); STableMeta* pMeta = NULL; @@ -6604,14 +6595,14 @@ static int32_t replaceToChildTableQuery(STranslateContext* pCxt, SEqCondTbNameTa pRealTable->stbRewrite = true; if (pRealTable->pTsmas) { - // if select from a child table, fetch it's corresponding tsma target child table infos + // if select from a child table, fetch it's corresponding tsma target child table infos char buf[TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN + 1]; for (int32_t i = 0; i < pRealTable->pTsmas->size; ++i) { STableTSMAInfo* pTsma = taosArrayGetP(pRealTable->pTsmas, i); SName tsmaTargetTbName = {0}; toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName); int32_t len = tsnprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name, - pRealTable->table.tableName); + pRealTable->table.tableName); len = taosCreateMD5Hash(buf, len); strncpy(tsmaTargetTbName.tname, buf, MD5_OUTPUT_LEN); STsmaTargetTbInfo ctbInfo = {0}; @@ -6639,16 +6630,16 @@ _return: } static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* pSelect, SArray* aTables) { - int32_t code = TSDB_CODE_SUCCESS; - int32_t aTableNum = taosArrayGetSize(aTables); - int32_t nTbls = 0; - bool stableQuery = false; + int32_t code = TSDB_CODE_SUCCESS; + int32_t aTableNum = taosArrayGetSize(aTables); + int32_t nTbls = 0; + bool stableQuery = false; SEqCondTbNameTableInfo* pInfo = NULL; qDebug("start to update stable vg for tbname optimize, aTableNum:%d", aTableNum); for (int i = 0; i < aTableNum; ++i) { pInfo = taosArrayGet(aTables, i); - int32_t numOfVgs = pInfo->pRealTable->pVgroupList->numOfVgroups; + int32_t numOfVgs = pInfo->pRealTable->pVgroupList->numOfVgroups; nTbls = taosArrayGetSize(pInfo->aTbnames); SVgroupsInfo* vgsInfo = taosMemoryMalloc(sizeof(SVgroupsInfo) + nTbls * sizeof(SVgroupInfo)); @@ -6714,7 +6705,8 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* } } - qDebug("before ctbname optimize, code:%d, aTableNum:%d, nTbls:%d, stableQuery:%d", code, aTableNum, nTbls, stableQuery); + qDebug("before ctbname optimize, code:%d, aTableNum:%d, nTbls:%d, stableQuery:%d", code, aTableNum, nTbls, + stableQuery); if (TSDB_CODE_SUCCESS == code && 1 == aTableNum && 1 == nTbls && stableQuery && NULL == pInfo->pRealTable->pTsmas) { code = replaceToChildTableQuery(pCxt, pInfo); @@ -6770,13 +6762,13 @@ static int32_t checkLimit(STranslateContext* pCxt, SSelectStmt* pSelect) { static int32_t createPrimaryKeyColByTable(STranslateContext* pCxt, STableNode* pTable, SNode** pPrimaryKey) { SColumnNode* pCol = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); if (TSDB_CODE_SUCCESS != code) { return code; } pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; strcpy(pCol->colName, ROWTS_PSEUDO_COLUMN_NAME); - bool found = false; + bool found = false; code = findAndSetColumn(pCxt, &pCol, pTable, &found, true); if (TSDB_CODE_SUCCESS != code || !found) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_VALID_PRIM_TS_REQUIRED); @@ -6808,8 +6800,8 @@ static EDealRes collectTableAlias(SNode* pNode, void* pContext) { *(SSHashObj**)pContext = pHash; } - if (TSDB_CODE_SUCCESS != tSimpleHashPut(*(SSHashObj**)pContext, pCol->tableAlias, strlen(pCol->tableAlias), pCol->tableAlias, - sizeof(pCol->tableAlias))) { + if (TSDB_CODE_SUCCESS != tSimpleHashPut(*(SSHashObj**)pContext, pCol->tableAlias, strlen(pCol->tableAlias), + pCol->tableAlias, sizeof(pCol->tableAlias))) { return DEAL_RES_ERROR; } @@ -6869,13 +6861,13 @@ static int32_t appendTsForImplicitTsFunc(STranslateContext* pCxt, SSelectStmt* p static int32_t createPkColByTable(STranslateContext* pCxt, SRealTableNode* pTable, SNode** pPk) { SColumnNode* pCol = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); if (TSDB_CODE_SUCCESS != code) { return code; } pCol->colId = pTable->pMeta->schema[1].colId; strcpy(pCol->colName, pTable->pMeta->schema[1].name); - bool found = false; + bool found = false; code = findAndSetColumn(pCxt, &pCol, (STableNode*)pTable, &found, true); if (TSDB_CODE_SUCCESS != code || !found) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTERNAL_ERROR); @@ -6943,7 +6935,7 @@ static EDealRes replaceOrderByAliasImpl(SNode** pNode, void* pContext) { (QUERY_NODE_COLUMN == nodeType(pProject) && !nodesEqualNode(*pNode, pProject)))) { continue; } - SNode* pNew = NULL; + SNode* pNew = NULL; int32_t code = nodesCloneNode(pProject, &pNew); if (NULL == pNew) { pCxt->pTranslateCxt->errCode = code; @@ -6966,7 +6958,7 @@ static EDealRes replaceOrderByAliasImpl(SNode** pNode, void* pContext) { } int32_t pos = getPositionValue(pVal); if (0 < pos && pos <= LIST_LENGTH(pProjectionList)) { - SNode* pNew = NULL; + SNode* pNew = NULL; int32_t code = nodesCloneNode(nodesListGetNode(pProjectionList, pos - 1), &pNew); if (NULL == pNew) { pCxt->pTranslateCxt->errCode = code; @@ -7075,8 +7067,7 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect } if (TSDB_CODE_SUCCESS == code) { code = resetSelectFuncNumWithoutDup(pSelect); - if (TSDB_CODE_SUCCESS == code) - code = checkAggColCoexist(pCxt, pSelect); + if (TSDB_CODE_SUCCESS == code) code = checkAggColCoexist(pCxt, pSelect); } /* if (TSDB_CODE_SUCCESS == code) { @@ -7137,7 +7128,7 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) { SColumnNode* pCol = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); if (TSDB_CODE_SUCCESS != code) { return NULL; } @@ -7350,7 +7341,7 @@ static int32_t translateInsertQuery(STranslateContext* pCxt, SInsertStmt* pInser static int32_t addOrderByPrimaryKeyToQueryImpl(STranslateContext* pCxt, SNode* pPrimaryKeyExpr, SNodeList** pOrderByList) { SOrderByExprNode* pOrderByExpr = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR, (SNode**)&pOrderByExpr); + int32_t code = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR, (SNode**)&pOrderByExpr); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -7493,7 +7484,7 @@ static int32_t buildCreateDbRetentions(const SNodeList* pRetentions, SCreateDbRe } static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt, SCreateDbReq* pReq) { - SName name = {0}; + SName name = {0}; int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); if (TSDB_CODE_SUCCESS != code) return code; (void)tNameGetFullDbName(&name, pReq->db); @@ -8005,8 +7996,8 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName code = checkOptionsDependency(pCxt, pDbName, pOptions); } if (TSDB_CODE_SUCCESS == code) { - code = - checkDbRangeOption(pCxt, "s3_chunksize", pOptions->s3ChunkSize, TSDB_MIN_S3_CHUNK_SIZE, TSDB_MAX_S3_CHUNK_SIZE); + code = checkDbRangeOption(pCxt, "s3_chunkpages", pOptions->s3ChunkSize, TSDB_MIN_S3_CHUNK_SIZE, + TSDB_MAX_S3_CHUNK_SIZE); } if (TSDB_CODE_SUCCESS == code) { code = checkDbRangeOption(pCxt, "s3_compact", pOptions->s3Compact, TSDB_MIN_S3_COMPACT, TSDB_MAX_S3_COMPACT); @@ -8026,7 +8017,7 @@ static int32_t checkCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt* CMD_TYPE* pCmdReq = genericCmd; \ char* cmdSql = taosMemoryMalloc(sqlLen); \ if (cmdSql == NULL) { \ - return terrno; \ + return terrno; \ } \ memcpy(cmdSql, sql, sqlLen); \ pCmdReq->sqlLen = sqlLen; \ @@ -8210,7 +8201,7 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* pStmt) { SDropDbReq dropReq = {0}; SName name = {0}; - int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); + int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); if (TSDB_CODE_SUCCESS != code) return code; (void)tNameGetFullDbName(&name, dropReq.db); dropReq.ignoreNotExists = pStmt->ignoreNotExists; @@ -8292,7 +8283,7 @@ static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStm static int32_t translateTrimDatabase(STranslateContext* pCxt, STrimDatabaseStmt* pStmt) { STrimDbReq req = {.maxSpeed = pStmt->maxSpeed}; SName name = {0}; - int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); + int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); if (TSDB_CODE_SUCCESS != code) return code; (void)tNameGetFullDbName(&name, req.db); return buildCmdMsg(pCxt, TDMT_MND_TRIM_DB, (FSerializeFunc)tSerializeSTrimDbReq, &req); @@ -8329,7 +8320,7 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray, bool calB if (!pArray) return terrno; int32_t code = TSDB_CODE_SUCCESS; - SNode* pNode; + SNode* pNode; FOREACH(pNode, pList) { SColumnDefNode* pCol = (SColumnDefNode*)pNode; SFieldWithOptions field = {.type = pCol->dataType.type, .bytes = calcTypeBytes(pCol->dataType)}; @@ -8801,7 +8792,7 @@ typedef struct SSampleAstInfo { static int32_t buildTableForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) { SRealTableNode* pTable = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_REAL_TABLE, (SNode**)&pTable); + int32_t code = nodesMakeNode(QUERY_NODE_REAL_TABLE, (SNode**)&pTable); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -8815,7 +8806,7 @@ static int32_t buildTableForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) { static int32_t addWstartToSampleProjects(SNodeList* pProjectionList) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (NULL == pFunc) { return code; } @@ -8826,7 +8817,7 @@ static int32_t addWstartToSampleProjects(SNodeList* pProjectionList) { static int32_t addWendToSampleProjects(SNodeList* pProjectionList) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (NULL == pFunc) { return code; } @@ -8837,7 +8828,7 @@ static int32_t addWendToSampleProjects(SNodeList* pProjectionList) { static int32_t addWdurationToSampleProjects(SNodeList* pProjectionList) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (NULL == pFunc) { return code; } @@ -8874,7 +8865,7 @@ static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pLis static int32_t buildIntervalForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) { SIntervalWindowNode* pInterval = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW, (SNode**)&pInterval); + int32_t code = nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW, (SNode**)&pInterval); if (NULL == pInterval) { return code; } @@ -8896,7 +8887,7 @@ static int32_t buildIntervalForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, char** pAst, int32_t* pLen, char** pExpr, int32_t* pExprLen, int32_t* pProjectionTotalLen) { SSelectStmt* pSelect = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_SELECT_STMT, (SNode**)&pSelect); + int32_t code = nodesMakeNode(QUERY_NODE_SELECT_STMT, (SNode**)&pSelect); if (NULL == pSelect) { return code; } @@ -8937,7 +8928,7 @@ static void clearSampleAstInfo(SSampleAstInfo* pInfo) { static int32_t makeIntervalVal(SRetention* pRetension, int8_t precision, SNode** ppNode) { SValueNode* pVal = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal); + int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal); if (NULL == pVal) { return code; } @@ -8964,7 +8955,7 @@ static int32_t makeIntervalVal(SRetention* pRetension, int8_t precision, SNode** static int32_t createColumnFromDef(SColumnDefNode* pDef, SNode** ppCol) { SColumnNode* pCol = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); if (NULL == pCol) { return code; } @@ -8975,7 +8966,7 @@ static int32_t createColumnFromDef(SColumnDefNode* pDef, SNode** ppCol) { static int32_t createRollupFunc(SNode* pSrcFunc, SColumnDefNode* pColDef, SNode** ppRollupFunc) { SFunctionNode* pFunc = NULL; - int32_t code = nodesCloneNode(pSrcFunc, (SNode**)&pFunc); + int32_t code = nodesCloneNode(pSrcFunc, (SNode**)&pFunc); if (NULL == pFunc) { return code; } @@ -8995,7 +8986,7 @@ static int32_t createRollupFunc(SNode* pSrcFunc, SColumnDefNode* pColDef, SNode* static int32_t createRollupFuncs(SCreateTableStmt* pStmt, SNodeList** ppList) { SNodeList* pFuncs = NULL; - int32_t code = nodesMakeList(&pFuncs); + int32_t code = nodesMakeList(&pFuncs); if (NULL == pFuncs) { return code; } @@ -9024,7 +9015,8 @@ static int32_t createRollupFuncs(SCreateTableStmt* pStmt, SNodeList** ppList) { } *ppList = pFuncs; - return code;; + return code; + ; } static int32_t createRollupTableMeta(SCreateTableStmt* pStmt, int8_t precision, STableMeta** ppTbMeta) { @@ -9056,7 +9048,7 @@ static int32_t createRollupTableMeta(SCreateTableStmt* pStmt, int8_t precision, static int32_t createTbnameFunction(SFunctionNode** ppFunc) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (NULL == pFunc) { return code; } @@ -9153,8 +9145,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm // columnDefNodeToField(pStmt->pCols, &pReq->pColumns, true); // columnDefNodeToField(pStmt->pTags, &pReq->pTags, true); code = columnDefNodeToField(pStmt->pCols, &pReq->pColumns, true); - if (TSDB_CODE_SUCCESS == code) - code = tagDefNodeToField(pStmt->pTags, &pReq->pTags, true); + if (TSDB_CODE_SUCCESS == code) code = tagDefNodeToField(pStmt->pTags, &pReq->pTags, true); if (TSDB_CODE_SUCCESS == code) { pReq->numOfColumns = LIST_LENGTH(pStmt->pCols); pReq->numOfTags = LIST_LENGTH(pStmt->pTags); @@ -9174,8 +9165,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName); code = tNameExtractFullName(&tableName, pReq->name); } - if (TSDB_CODE_SUCCESS == code) - code = collectUseTable(&tableName, pCxt->pTables); + if (TSDB_CODE_SUCCESS == code) code = collectUseTable(&tableName, pCxt->pTables); if (TSDB_CODE_SUCCESS == code) { code = collectUseTable(&tableName, pCxt->pTargetTables); } @@ -9527,12 +9517,13 @@ static int32_t translateAlterSuperTable(STranslateContext* pCxt, SAlterTableStmt static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* pStmt) { SUseDbReq usedbReq = {0}; SName name = {0}; - int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); + int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); if (TSDB_CODE_SUCCESS == code) { code = tNameExtractFullName(&name, usedbReq.db); } if (TSDB_CODE_SUCCESS == code) - code = getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable, &usedbReq.stateTs); + code = + getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable, &usedbReq.stateTs); if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_USE_DB, (FSerializeFunc)tSerializeSUseDbReq, &usedbReq); } @@ -9801,9 +9792,9 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm pReq->intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit; pReq->offset = (NULL != pStmt->pOptions->pOffset ? ((SValueNode*)pStmt->pOptions->pOffset)->datum.i : 0); pReq->sliding = - (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval); + (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval); pReq->slidingUnit = - (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit); + (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit); } if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pOptions->pStreamOptions) { @@ -10112,8 +10103,7 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS } else if ('\0' != pStmt->subDbName[0]) { pReq->subType = TOPIC_SUB_TYPE__DB; code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->subDbName, strlen(pStmt->subDbName)); - if (TSDB_CODE_SUCCESS == code) - (void)tNameGetFullDbName(&name, pReq->subDbName); + if (TSDB_CODE_SUCCESS == code) (void)tNameGetFullDbName(&name, pReq->subDbName); } else { pReq->subType = TOPIC_SUB_TYPE__COLUMN; char* dbName = ((SRealTableNode*)(((SSelectStmt*)pStmt->pQuery)->pFromTable))->table.dbName; @@ -10202,7 +10192,7 @@ static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt* // for (int32_t i = 0; i < pMeta->tableInfo.numOfColumns; ++i) { SSchema* column = &pMeta->schema[0]; SColumnNode* col = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&col); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&col); if (NULL == col) { return code; } @@ -10239,7 +10229,7 @@ static int32_t buildQueryForTableTopic(STranslateContext* pCxt, SCreateTopicStmt return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Only supertable table can be used"); } - SNodeList* pProjection = NULL; + SNodeList* pProjection = NULL; SRealTableNode* realTable = NULL; code = checkCollectTopicTags(pCxt, pStmt, pMeta, &pProjection); if (TSDB_CODE_SUCCESS == code) { @@ -10518,7 +10508,7 @@ static int32_t setColumnDefNodePrimaryKey(SColumnDefNode* pNode, bool isPk) { if (!pNode->pOptions) { code = nodesMakeNode(QUERY_NODE_COLUMN_OPTIONS, &pNode->pOptions); } - if (TSDB_CODE_SUCCESS ==code) ((SColumnOptions*)pNode->pOptions)->bPrimaryKey = isPk; + if (TSDB_CODE_SUCCESS == code) ((SColumnOptions*)pNode->pOptions)->bPrimaryKey = isPk; return code; } @@ -10530,7 +10520,7 @@ static int32_t addWstartTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSele return TSDB_CODE_SUCCESS; } SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (NULL == pFunc) { return code; } @@ -10589,7 +10579,7 @@ static int32_t addTagsToCreateStreamQuery(STranslateContext* pCxt, SCreateStream SNode* pPart = NULL; FOREACH(pPart, pSelect->pPartitionByList) { if (0 == strcmp(getTagNameForCreateStreamTag(pTag), ((SExprNode*)pPart)->userAlias)) { - SNode* pNew = NULL; + SNode* pNew = NULL; int32_t code = nodesCloneNode(pPart, &pNew); if (TSDB_CODE_SUCCESS != code) return code; if (TSDB_CODE_SUCCESS != (code = nodesListMakeStrictAppend(&pSelect->pTags, pNew))) { @@ -10608,7 +10598,7 @@ static int32_t addTagsToCreateStreamQuery(STranslateContext* pCxt, SCreateStream static int32_t createNullValue(SNode** ppNode) { SValueNode* pValue = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pValue); + int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pValue); if (NULL == pValue) { return code; } @@ -10625,8 +10615,7 @@ static int32_t addNullTagsForExistTable(STranslateContext* pCxt, STableMeta* pMe for (int32_t i = 0; TSDB_CODE_SUCCESS == code && i < numOfTags; ++i) { SNode* pNull = NULL; code = createNullValue(&pNull); - if (TSDB_CODE_SUCCESS == code) - code = nodesListMakeStrictAppend(&pSelect->pTags, pNull); + if (TSDB_CODE_SUCCESS == code) code = nodesListMakeStrictAppend(&pSelect->pTags, pNull); } return code; } @@ -10643,7 +10632,7 @@ static EDealRes rewriteSubtable(SNode** pNode, void* pContext) { SNode* pPart = NULL; FOREACH(pPart, pCxt->pPartitionList) { if (0 == strcmp(((SColumnNode*)*pNode)->colName, ((SExprNode*)pPart)->userAlias)) { - SNode* pNew = NULL; + SNode* pNew = NULL; int32_t code = nodesCloneNode(pPart, &pNew); if (NULL == pNew) { pCxt->pCxt->errCode = code; @@ -10686,8 +10675,7 @@ static int32_t addNullTagsForCreateTable(STranslateContext* pCxt, SCreateStreamS for (int32_t i = 0; TSDB_CODE_SUCCESS == code && i < LIST_LENGTH(pStmt->pTags); ++i) { SNode* pNull = NULL; code = createNullValue(&pNull); - if (TSDB_CODE_SUCCESS == code) - code = nodesListMakeStrictAppend(&((SSelectStmt*)pStmt->pQuery)->pTags, pNull); + if (TSDB_CODE_SUCCESS == code) code = nodesListMakeStrictAppend(&((SSelectStmt*)pStmt->pQuery)->pTags, pNull); } return code; } @@ -10700,9 +10688,9 @@ static int32_t addNullTagsToCreateStreamQuery(STranslateContext* pCxt, STableMet } static int32_t addColDefNodeByProj(SNodeList** ppCols, const SNode* pProject, int8_t flags) { - const SExprNode* pExpr = (const SExprNode*)pProject; - SColumnDefNode* pColDef = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN_DEF, (SNode**)&pColDef); + const SExprNode* pExpr = (const SExprNode*)pProject; + SColumnDefNode* pColDef = NULL; + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN_DEF, (SNode**)&pColDef); if (TSDB_CODE_SUCCESS != code) return code; strcpy(pColDef->colName, pExpr->userAlias); pColDef->dataType = pExpr->resType; @@ -10872,10 +10860,11 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm if (NULL != pStmt->pOptions->pDelay) { SValueNode* pVal = (SValueNode*)pStmt->pOptions->pDelay; - int64_t minDelay = 0; - char* str = "5s"; - if (DEAL_RES_ERROR != translateValue(pCxt, pVal) && TSDB_CODE_SUCCESS == - parseNatualDuration(str, strlen(str), &minDelay, &pVal->unit, pVal->node.resType.precision, false)) { + int64_t minDelay = 0; + char* str = "5s"; + if (DEAL_RES_ERROR != translateValue(pCxt, pVal) && + TSDB_CODE_SUCCESS == + parseNatualDuration(str, strlen(str), &minDelay, &pVal->unit, pVal->node.resType.precision, false)) { if (pVal->datum.i < minDelay) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "stream max delay must be bigger than 5 session"); @@ -10907,7 +10896,7 @@ static int32_t adjustDataTypeOfProjections(STranslateContext* pCxt, const STable REPLACE_NODE(pFunc); } SColumnDefNode* pColDef = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN_DEF, (SNode**)&pColDef); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN_DEF, (SNode**)&pColDef); if (TSDB_CODE_SUCCESS != code) return code; strcpy(pColDef->colName, pSchema->name); pColDef->dataType = dt; @@ -10942,7 +10931,7 @@ static int32_t projColPosCompar(const void* l, const void* r) { static void projColPosDelete(void* p) { nodesDestroyNode(((SProjColPos*)p)->pProj); } static int32_t addProjToProjColPos(STranslateContext* pCxt, const SSchema* pSchema, SNode* pProj, SArray* pProjColPos) { - SNode* pNewProj = NULL; + SNode* pNewProj = NULL; int32_t code = nodesCloneNode(pProj, &pNewProj); if (NULL == pNewProj) { return code; @@ -11170,8 +11159,7 @@ static int32_t adjustOrderOfTags(STranslateContext* pCxt, SNodeList* pTags, cons } SNode* pNull = NULL; code = createNullValue(&pNull); - if (TSDB_CODE_SUCCESS == code) - code = nodesListStrictAppend(pNewTagExprs, pNull); + if (TSDB_CODE_SUCCESS == code) code = nodesListStrictAppend(pNewTagExprs, pNull); } } @@ -11275,7 +11263,7 @@ static int32_t translateStreamTargetTable(STranslateContext* pCxt, SCreateStream static int32_t createLastTsSelectStmt(char* pDb, const char* pTable, const char* pkColName, SNode** pQuery) { SColumnNode* col = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&col); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&col); if (NULL == col) { return code; } @@ -11623,7 +11611,7 @@ static int32_t createStreamReqVersionInfo(SSDataBlock* pBlock, SArray** pArray, for (int32_t i = 0; i < pBlock->info.rows; ++i) { SVgroupVer v = {.vgId = *(int32_t*)colDataGetData(pCol1, i), .ver = *(int64_t*)colDataGetData(pCol2, i)}; - if((taosArrayPush(*pArray, &v)) == NULL) { + if ((taosArrayPush(*pArray, &v)) == NULL) { taosArrayDestroy(*pArray); return terrno; } @@ -11678,7 +11666,7 @@ int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, SSDa static int32_t translateDropStream(STranslateContext* pCxt, SDropStreamStmt* pStmt) { SMDropStreamReq dropReq = {0}; SName name; - int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->streamName, strlen(pStmt->streamName)); + int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->streamName, strlen(pStmt->streamName)); if (TSDB_CODE_SUCCESS != code) return code; (void)tNameGetFullDbName(&name, dropReq.name); dropReq.igNotExists = pStmt->ignoreNotExists; @@ -11690,7 +11678,7 @@ static int32_t translateDropStream(STranslateContext* pCxt, SDropStreamStmt* pSt static int32_t translatePauseStream(STranslateContext* pCxt, SPauseStreamStmt* pStmt) { SMPauseStreamReq req = {0}; SName name; - int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->streamName, strlen(pStmt->streamName)); + int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->streamName, strlen(pStmt->streamName)); if (TSDB_CODE_SUCCESS != code) return code; (void)tNameGetFullDbName(&name, req.name); req.igNotExists = pStmt->ignoreNotExists; @@ -11700,7 +11688,7 @@ static int32_t translatePauseStream(STranslateContext* pCxt, SPauseStreamStmt* p static int32_t translateResumeStream(STranslateContext* pCxt, SResumeStreamStmt* pStmt) { SMResumeStreamReq req = {0}; SName name; - int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->streamName, strlen(pStmt->streamName)); + int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->streamName, strlen(pStmt->streamName)); if (TSDB_CODE_SUCCESS != code) return code; (void)tNameGetFullDbName(&name, req.name); req.igNotExists = pStmt->ignoreNotExists; @@ -11775,7 +11763,7 @@ static int32_t translateDropView(STranslateContext* pCxt, SDropViewStmt* pStmt) SCMDropViewReq dropReq = {0}; SName name = {0}; - int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); + int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); if (TSDB_CODE_SUCCESS == code) { (void)tNameGetFullDbName(&name, dropReq.dbFName); strncpy(dropReq.name, pStmt->viewName, sizeof(dropReq.name) - 1); @@ -11871,7 +11859,7 @@ static int32_t translateDropFunction(STranslateContext* pCxt, SDropFunctionStmt* static int32_t createRealTableForGrantTable(SGrantStmt* pStmt, SRealTableNode** pTable) { SRealTableNode* pRealTable = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_REAL_TABLE, (SNode**)&pRealTable); + int32_t code = nodesMakeNode(QUERY_NODE_REAL_TABLE, (SNode**)&pRealTable); if (NULL == pRealTable) { return code; } @@ -12074,11 +12062,10 @@ static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateD return terrno; } - SName name; + SName name; int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); (void)tNameGetFullDbName(&name, pStmt->dbFName); - if (TSDB_CODE_SUCCESS == code) - return getDBCfg(pCxt, pStmt->dbName, (SDbCfgInfo*)pStmt->pCfg); + if (TSDB_CODE_SUCCESS == code) return getDBCfg(pCxt, pStmt->dbName, (SDbCfgInfo*)pStmt->pCfg); return code; } @@ -12108,7 +12095,7 @@ static int32_t translateShowCreateView(STranslateContext* pCxt, SShowCreateViewS static int32_t createColumnNodeWithName(const char* name, SNode** ppCol) { SColumnNode* pCol = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); if (!pCol) return code; tstrncpy(pCol->colName, name, TSDB_COL_NAME_LEN); tstrncpy(pCol->node.aliasName, name, TSDB_COL_NAME_LEN); @@ -12170,7 +12157,7 @@ static int32_t buildTSMAAstStreamSubTable(SCreateTSMAStmt* pStmt, SMCreateSmaReq SFunctionNode* pConcatFunc = NULL; code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pConcatFunc); if (TSDB_CODE_SUCCESS != code) goto _end; - SValueNode* pVal = NULL; + SValueNode* pVal = NULL; code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal); if (TSDB_CODE_SUCCESS != code) goto _end; @@ -12218,8 +12205,7 @@ static int32_t buildTSMAAst(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMC info.pDbName = pStmt->dbName; info.pTableName = tbName; code = nodesCloneList(pStmt->pOptions->pFuncs, &info.pFuncs); - if (TSDB_CODE_SUCCESS == code) - code = nodesCloneNode(pStmt->pOptions->pInterval, &info.pInterval); + if (TSDB_CODE_SUCCESS == code) code = nodesCloneNode(pStmt->pOptions->pInterval, &info.pInterval); SFunctionNode* pTbnameFunc = NULL; if (TSDB_CODE_SUCCESS == code) { @@ -12244,10 +12230,9 @@ static int32_t buildTSMAAst(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMC } code = nodesListAppend(info.pPartitionByList, pTagCol); if (TSDB_CODE_SUCCESS == code) { - SNode*pNew = NULL; + SNode* pNew = NULL; code = nodesCloneNode(pTagCol, &pNew); - if (TSDB_CODE_SUCCESS == code) - code = nodesListMakeStrictAppend(&info.pTags, pNew); + if (TSDB_CODE_SUCCESS == code) code = nodesListMakeStrictAppend(&info.pTags, pNew); } } @@ -12394,7 +12379,7 @@ static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStm pReq->interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; pReq->intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit; -#define TSMA_MIN_INTERVAL_MS 1000 * 60 // 1m +#define TSMA_MIN_INTERVAL_MS 1000 * 60 // 1m #define TSMA_MAX_INTERVAL_MS (60UL * 60UL * 1000UL * 24UL * 365UL) // 1y if (!IS_CALENDAR_TIME_DURATION(pReq->intervalUnit)) { @@ -12405,8 +12390,7 @@ static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStm } else { if (pReq->intervalUnit == TIME_UNIT_MONTH && (pReq->interval < 1 || pReq->interval > 12)) return TSDB_CODE_TSMA_INVALID_INTERVAL; - if (pReq->intervalUnit == TIME_UNIT_YEAR && (pReq->interval != 1)) - return TSDB_CODE_TSMA_INVALID_INTERVAL; + if (pReq->intervalUnit == TIME_UNIT_YEAR && (pReq->interval != 1)) return TSDB_CODE_TSMA_INVALID_INTERVAL; } STableMeta* pTableMeta = NULL; @@ -12422,7 +12406,7 @@ static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStm if (TSDB_CODE_SUCCESS == code) { SValueNode* pInterval = (SValueNode*)pStmt->pOptions->pInterval; if (checkRecursiveTsmaInterval(pRecursiveTsma->interval, pRecursiveTsma->unit, pInterval->datum.i, - pInterval->unit, pDbInfo.precision, true)) { + pInterval->unit, pDbInfo.precision, true)) { } else { code = TSDB_CODE_TSMA_INVALID_RECURSIVE_INTERVAL; } @@ -13044,7 +13028,7 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS static int32_t createStarCol(SNode** ppNode) { SColumnNode* pCol = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); if (NULL == pCol) { return code; } @@ -13055,7 +13039,7 @@ static int32_t createStarCol(SNode** ppNode) { static int32_t createProjectCol(const char* pProjCol, SNode** ppNode) { SColumnNode* pCol = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); + int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol); if (NULL == pCol) { return code; } @@ -13098,7 +13082,7 @@ static int32_t createProjectCols(int32_t ncols, const char* const pCols[], SNode static int32_t createSimpleSelectStmtImpl(const char* pDb, const char* pTable, SNodeList* pProjectionList, SSelectStmt** pStmt) { SSelectStmt* pSelect = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_SELECT_STMT, (SNode**)&pSelect); + int32_t code = nodesMakeNode(QUERY_NODE_SELECT_STMT, (SNode**)&pSelect); if (NULL == pSelect) { return code; } @@ -13153,7 +13137,7 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, co } SOperatorNode* pOper = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOper); + int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOper); if (NULL == pOper) { return code; } @@ -13178,7 +13162,7 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, co static int32_t createParOperatorNode(EOperatorType opType, const char* pLeftCol, const char* pRightCol, SNode** ppResOp) { SOperatorNode* pOper = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOper); + int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOper); if (TSDB_CODE_SUCCESS != code) return code; pOper->opType = opType; @@ -13201,7 +13185,7 @@ static int32_t createParOperatorNode(EOperatorType opType, const char* pLeftCol, static int32_t createIsOperatorNode(EOperatorType opType, const char* pColName, SNode** pOp) { SOperatorNode* pOper = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOper); + int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOper); if (NULL == pOper) { return code; } @@ -13323,7 +13307,7 @@ static int32_t addShowUserDatabasesCond(SSelectStmt* pSelect) { SNode* pNameCond1 = NULL; SNode* pNameCond2 = NULL; SNode* pNameCond = NULL; - SValueNode* pValNode1 = NULL, *pValNode2 = NULL; + SValueNode *pValNode1 = NULL, *pValNode2 = NULL; code = nodesMakeValueNodeFromString(TSDB_INFORMATION_SCHEMA_DB, &pValNode1); if (TSDB_CODE_SUCCESS == code) { @@ -13337,11 +13321,9 @@ static int32_t addShowUserDatabasesCond(SSelectStmt* pSelect) { } nodesDestroyNode((SNode*)pValNode2); nodesDestroyNode((SNode*)pValNode1); - if (TSDB_CODE_SUCCESS == code) - code = createLogicCondNode(&pNameCond1, &pNameCond2, &pNameCond, LOGIC_COND_TYPE_AND); + if (TSDB_CODE_SUCCESS == code) code = createLogicCondNode(&pNameCond1, &pNameCond2, &pNameCond, LOGIC_COND_TYPE_AND); - if (TSDB_CODE_SUCCESS == code) - code = insertCondIntoSelectStmt(pSelect, &pNameCond); + if (TSDB_CODE_SUCCESS == code) code = insertCondIntoSelectStmt(pSelect, &pNameCond); if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode(pNameCond1); @@ -13355,8 +13337,8 @@ static int32_t addShowSystemDatabasesCond(SSelectStmt* pSelect) { int32_t code = TSDB_CODE_SUCCESS; SNode* pNameCond1 = NULL; SNode* pNameCond2 = NULL; - SValueNode* pValNode1 = NULL, * pValNode2 = NULL; - SNode* pNameCond = NULL; + SValueNode *pValNode1 = NULL, *pValNode2 = NULL; + SNode* pNameCond = NULL; code = nodesMakeValueNodeFromString(TSDB_INFORMATION_SCHEMA_DB, &pValNode1); if (TSDB_CODE_SUCCESS == code) { code = nodesMakeValueNodeFromString(TSDB_PERFORMANCE_SCHEMA_DB, &pValNode2); @@ -13373,8 +13355,7 @@ static int32_t addShowSystemDatabasesCond(SSelectStmt* pSelect) { code = createLogicCondNode(&pNameCond1, &pNameCond2, &pNameCond, LOGIC_COND_TYPE_OR); } - if (TSDB_CODE_SUCCESS == code) - code = insertCondIntoSelectStmt(pSelect, &pNameCond); + if (TSDB_CODE_SUCCESS == code) code = insertCondIntoSelectStmt(pSelect, &pNameCond); if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode(pNameCond1); @@ -13390,8 +13371,7 @@ static int32_t addShowNormalTablesCond(SSelectStmt* pSelect) { SValueNode* pValNode1 = NULL; code = nodesMakeValueNodeFromString("NORMAL_TABLE", &pValNode1); - if (TSDB_CODE_SUCCESS == code) - code = createOperatorNode(OP_TYPE_EQUAL, "type", (SNode*)pValNode1, &pTypeCond); + if (TSDB_CODE_SUCCESS == code) code = createOperatorNode(OP_TYPE_EQUAL, "type", (SNode*)pValNode1, &pTypeCond); nodesDestroyNode((SNode*)pValNode1); @@ -13406,8 +13386,7 @@ static int32_t addShowChildTablesCond(SSelectStmt* pSelect) { SValueNode* pValNode1 = NULL; code = nodesMakeValueNodeFromString("CHILD_TABLE", &pValNode1); - if (TSDB_CODE_SUCCESS == code) - code = createOperatorNode(OP_TYPE_EQUAL, "type", (SNode*)pValNode1, &pTypeCond); + if (TSDB_CODE_SUCCESS == code) code = createOperatorNode(OP_TYPE_EQUAL, "type", (SNode*)pValNode1, &pTypeCond); nodesDestroyNode((SNode*)pValNode1); @@ -13506,7 +13485,8 @@ static int32_t checkShowTags(STranslateContext* pCxt, const SShowStmt* pShow) { int32_t code = 0; SName name = {0}; STableMeta* pTableMeta = NULL; - toName(pCxt->pParseCxt->acctId, ((SValueNode*)pShow->pDbName)->literal, ((SValueNode*)pShow->pTbName)->literal, &name); + toName(pCxt->pParseCxt->acctId, ((SValueNode*)pShow->pDbName)->literal, ((SValueNode*)pShow->pTbName)->literal, + &name); code = getTargetMeta(pCxt, &name, &pTableMeta, true); if (TSDB_CODE_SUCCESS != code) { code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); @@ -13533,7 +13513,7 @@ static int32_t rewriteShowTags(STranslateContext* pCxt, SQuery* pQuery) { static int32_t createTagsFunction(SFunctionNode** ppNode) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (NULL == pFunc) { return code; } @@ -13548,7 +13528,7 @@ static int32_t createShowTableTagsProjections(SNodeList** pProjections, SNodeLis return TSDB_CODE_SUCCESS; } SFunctionNode* pTbNameFunc = NULL; - int32_t code = createTbnameFunction(&pTbNameFunc); + int32_t code = createTbnameFunction(&pTbNameFunc); if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(pProjections, (SNode*)pTbNameFunc); } @@ -13630,7 +13610,7 @@ static int32_t rewriteShowVnodes(STranslateContext* pCxt, SQuery* pQuery) { static int32_t createBlockDistInfoFunc(SFunctionNode** ppNode) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (NULL == pFunc) { return code; } @@ -13643,7 +13623,7 @@ static int32_t createBlockDistInfoFunc(SFunctionNode** ppNode) { static int32_t createBlockDistFunc(SFunctionNode** ppNode) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (NULL == pFunc) { return code; } @@ -13670,8 +13650,7 @@ static int32_t rewriteShowTableDist(STranslateContext* pCxt, SQuery* pQuery) { NODES_DESTORY_LIST(pStmt->pProjectionList); SFunctionNode* pFuncNew = NULL; code = createBlockDistFunc(&pFuncNew); - if (TSDB_CODE_SUCCESS == code) - code = nodesListMakeStrictAppend(&pStmt->pProjectionList, (SNode*)pFuncNew); + if (TSDB_CODE_SUCCESS == code) code = nodesListMakeStrictAppend(&pStmt->pProjectionList, (SNode*)pFuncNew); } if (TSDB_CODE_SUCCESS == code) { pCxt->showRewrite = true; @@ -13725,7 +13704,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* } SNode* pCol; col_id_t index = 0; - int32_t code = tInitDefaultSColCmprWrapperByCols(&req.colCmpr, req.ntb.schemaRow.nCols); + int32_t code = tInitDefaultSColCmprWrapperByCols(&req.colCmpr, req.ntb.schemaRow.nCols); if (TSDB_CODE_SUCCESS != code) { tdDestroySVCreateTbReq(&req); return code; @@ -13823,7 +13802,7 @@ static void destroyCreateTbReqBatch(void* data) { int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray) { SVnodeModifyOpStmt* pNewStmt = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&pNewStmt); + int32_t code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&pNewStmt); if (pNewStmt == NULL) { return code; } @@ -13952,7 +13931,7 @@ static int32_t addCreateTbReqIntoVgroup(SHashObj* pVgroupHashmap, const char* db } static int32_t createCastFuncForTag(STranslateContext* pCxt, SNode* pNode, SDataType dt, SNode** pCast) { - SNode* pExpr = NULL; + SNode* pExpr = NULL; int32_t code = nodesCloneNode(pNode, (SNode**)&pExpr); if (NULL == pExpr) { return code; @@ -14636,7 +14615,7 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery) static int32_t rewriteCreateTableFromFile(STranslateContext* pCxt, SQuery* pQuery) { SVnodeModifyOpStmt* pModifyStmt = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&pModifyStmt); + int32_t code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&pModifyStmt); if (pModifyStmt == NULL) { return code; } @@ -15535,7 +15514,7 @@ static int32_t rewriteShowCompactDetailsStmt(STranslateContext* pCxt, SQuery* pQ static int32_t createParWhenThenNode(SNode* pWhen, SNode* pThen, SNode** ppResWhenThen) { SWhenThenNode* pWThen = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_WHEN_THEN, (SNode**)&pWThen); + int32_t code = nodesMakeNode(QUERY_NODE_WHEN_THEN, (SNode**)&pWThen); if (TSDB_CODE_SUCCESS != code) return code; pWThen->pWhen = pWhen; @@ -15547,7 +15526,7 @@ static int32_t createParWhenThenNode(SNode* pWhen, SNode* pThen, SNode** ppResWh static int32_t createParCaseWhenNode(SNode* pCase, SNodeList* pWhenThenList, SNode* pElse, const char* pAias, SNode** ppResCaseWhen) { SCaseWhenNode* pCaseWhen = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_CASE_WHEN, (SNode**)&pCaseWhen); + int32_t code = nodesMakeNode(QUERY_NODE_CASE_WHEN, (SNode**)&pCaseWhen); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -15566,7 +15545,7 @@ static int32_t createParCaseWhenNode(SNode* pCase, SNodeList* pWhenThenList, SNo static int32_t createParFunctionNode(const char* pFunName, const char* pAias, SNodeList* pParameterList, SNode** ppResFunc) { SFunctionNode* pFunc = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); + int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -15580,7 +15559,7 @@ static int32_t createParFunctionNode(const char* pFunName, const char* pAias, SN static int32_t createParListNode(SNode* pItem, SNodeList** ppResList) { SNodeList* pList = NULL; - int32_t code = nodesMakeList(&pList); + int32_t code = nodesMakeList(&pList); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -15591,7 +15570,7 @@ static int32_t createParListNode(SNode* pItem, SNodeList** ppResList) { static int32_t createParTempTableNode(SSelectStmt* pSubquery, SNode** ppResTempTable) { STempTableNode* pTempTable = NULL; - int32_t code = nodesMakeNode(QUERY_NODE_TEMP_TABLE, (SNode**)&pTempTable); + int32_t code = nodesMakeNode(QUERY_NODE_TEMP_TABLE, (SNode**)&pTempTable); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -15623,12 +15602,9 @@ static int32_t rewriteShowAliveStmt(STranslateContext* pCxt, SQuery* pQuery) { SNode* pCond3 = NULL; SNode* pCond4 = NULL; code = createOperatorNode(OP_TYPE_EQUAL, "v1_status", (SNode*)pValNode, &pCond1); - if (TSDB_CODE_SUCCESS == code) - code = createOperatorNode(OP_TYPE_EQUAL, "v2_status", (SNode*)pValNode, &pCond2); - if (TSDB_CODE_SUCCESS == code) - code = createOperatorNode(OP_TYPE_EQUAL, "v3_status", (SNode*)pValNode, &pCond3); - if (TSDB_CODE_SUCCESS == code) - code = createOperatorNode(OP_TYPE_EQUAL, "v4_status", (SNode*)pValNode, &pCond4); + if (TSDB_CODE_SUCCESS == code) code = createOperatorNode(OP_TYPE_EQUAL, "v2_status", (SNode*)pValNode, &pCond2); + if (TSDB_CODE_SUCCESS == code) code = createOperatorNode(OP_TYPE_EQUAL, "v3_status", (SNode*)pValNode, &pCond3); + if (TSDB_CODE_SUCCESS == code) code = createOperatorNode(OP_TYPE_EQUAL, "v4_status", (SNode*)pValNode, &pCond4); nodesDestroyNode((SNode*)pValNode); if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode(pCond1); @@ -15643,10 +15619,8 @@ static int32_t rewriteShowAliveStmt(STranslateContext* pCxt, SQuery* pQuery) { SNode* pTemp2 = NULL; SNode* pFullCond = NULL; code = createLogicCondNode(&pCond1, &pCond2, &pTemp1, LOGIC_COND_TYPE_OR); - if (TSDB_CODE_SUCCESS == code) - code = createLogicCondNode(&pTemp1, &pCond3, &pTemp2, LOGIC_COND_TYPE_OR); - if (TSDB_CODE_SUCCESS == code) - code = createLogicCondNode(&pTemp2, &pCond4, &pFullCond, LOGIC_COND_TYPE_OR); + if (TSDB_CODE_SUCCESS == code) code = createLogicCondNode(&pTemp1, &pCond3, &pTemp2, LOGIC_COND_TYPE_OR); + if (TSDB_CODE_SUCCESS == code) code = createLogicCondNode(&pTemp2, &pCond4, &pFullCond, LOGIC_COND_TYPE_OR); if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode(pCond1); nodesDestroyNode(pCond2); @@ -15969,8 +15943,8 @@ static int32_t rewriteShowAliveStmt(STranslateContext* pCxt, SQuery* pQuery) { } // pSubSelect, pWhenThenlist need to free - // case when leader_col = count_col and leader_col > 0 then 1 when leader_col < count_col and leader_col > 0 then 2 else - // 0 end as status + // case when leader_col = count_col and leader_col > 0 then 1 when leader_col < count_col and leader_col > 0 then 2 + // else 0 end as status pElse = NULL; code = nodesMakeValueNodeFromInt32(0, &pElse); if (TSDB_CODE_SUCCESS != code) { diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 5849977a3a..9ddf50f7aa 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -1,3 +1,5 @@ +/* This file is automatically generated by Lemon from input grammar +** source file "sql.y". */ /* ** 2000-05-29 ** @@ -22,9 +24,8 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ -#include -#include /************ Begin %include sections from the grammar ************************/ +#line 11 "sql.y" #include #include @@ -41,12 +42,401 @@ #include "parAst.h" #define YYSTACKDEPTH 0 +#line 46 "sql.c" /**************** End of %include directives **********************************/ -/* These constants specify the various numeric values for terminal symbols -** in a format understandable to "makeheaders". This section is blank unless -** "lemon" is run with the "-m" command-line option. -***************** Begin makeheaders token definitions *************************/ -/**************** End makeheaders token definitions ***************************/ +/* These constants specify the various numeric values for terminal symbols. +***************** Begin token definitions *************************************/ +#ifndef TK_OR +#define TK_OR 1 +#define TK_AND 2 +#define TK_UNION 3 +#define TK_ALL 4 +#define TK_MINUS 5 +#define TK_EXCEPT 6 +#define TK_INTERSECT 7 +#define TK_NK_BITAND 8 +#define TK_NK_BITOR 9 +#define TK_NK_LSHIFT 10 +#define TK_NK_RSHIFT 11 +#define TK_NK_PLUS 12 +#define TK_NK_MINUS 13 +#define TK_NK_STAR 14 +#define TK_NK_SLASH 15 +#define TK_NK_REM 16 +#define TK_NK_CONCAT 17 +#define TK_CREATE 18 +#define TK_ACCOUNT 19 +#define TK_NK_ID 20 +#define TK_PASS 21 +#define TK_NK_STRING 22 +#define TK_ALTER 23 +#define TK_PPS 24 +#define TK_TSERIES 25 +#define TK_STORAGE 26 +#define TK_STREAMS 27 +#define TK_QTIME 28 +#define TK_DBS 29 +#define TK_USERS 30 +#define TK_CONNS 31 +#define TK_STATE 32 +#define TK_NK_COMMA 33 +#define TK_HOST 34 +#define TK_IS_IMPORT 35 +#define TK_NK_INTEGER 36 +#define TK_CREATEDB 37 +#define TK_USER 38 +#define TK_ENABLE 39 +#define TK_SYSINFO 40 +#define TK_ADD 41 +#define TK_DROP 42 +#define TK_GRANT 43 +#define TK_ON 44 +#define TK_TO 45 +#define TK_REVOKE 46 +#define TK_FROM 47 +#define TK_SUBSCRIBE 48 +#define TK_READ 49 +#define TK_WRITE 50 +#define TK_NK_DOT 51 +#define TK_WITH 52 +#define TK_ENCRYPT_KEY 53 +#define TK_ANODE 54 +#define TK_UPDATE 55 +#define TK_ANODES 56 +#define TK_DNODE 57 +#define TK_PORT 58 +#define TK_DNODES 59 +#define TK_RESTORE 60 +#define TK_NK_IPTOKEN 61 +#define TK_FORCE 62 +#define TK_UNSAFE 63 +#define TK_CLUSTER 64 +#define TK_LOCAL 65 +#define TK_QNODE 66 +#define TK_BNODE 67 +#define TK_SNODE 68 +#define TK_MNODE 69 +#define TK_VNODE 70 +#define TK_DATABASE 71 +#define TK_USE 72 +#define TK_FLUSH 73 +#define TK_TRIM 74 +#define TK_S3MIGRATE 75 +#define TK_COMPACT 76 +#define TK_IF 77 +#define TK_NOT 78 +#define TK_EXISTS 79 +#define TK_BUFFER 80 +#define TK_CACHEMODEL 81 +#define TK_CACHESIZE 82 +#define TK_COMP 83 +#define TK_DURATION 84 +#define TK_NK_VARIABLE 85 +#define TK_MAXROWS 86 +#define TK_MINROWS 87 +#define TK_KEEP 88 +#define TK_PAGES 89 +#define TK_PAGESIZE 90 +#define TK_TSDB_PAGESIZE 91 +#define TK_PRECISION 92 +#define TK_REPLICA 93 +#define TK_VGROUPS 94 +#define TK_SINGLE_STABLE 95 +#define TK_RETENTIONS 96 +#define TK_SCHEMALESS 97 +#define TK_WAL_LEVEL 98 +#define TK_WAL_FSYNC_PERIOD 99 +#define TK_WAL_RETENTION_PERIOD 100 +#define TK_WAL_RETENTION_SIZE 101 +#define TK_WAL_ROLL_PERIOD 102 +#define TK_WAL_SEGMENT_SIZE 103 +#define TK_STT_TRIGGER 104 +#define TK_TABLE_PREFIX 105 +#define TK_TABLE_SUFFIX 106 +#define TK_S3_CHUNKPAGES 107 +#define TK_S3_KEEPLOCAL 108 +#define TK_S3_COMPACT 109 +#define TK_KEEP_TIME_OFFSET 110 +#define TK_ENCRYPT_ALGORITHM 111 +#define TK_NK_COLON 112 +#define TK_BWLIMIT 113 +#define TK_START 114 +#define TK_TIMESTAMP 115 +#define TK_END 116 +#define TK_TABLE 117 +#define TK_NK_LP 118 +#define TK_NK_RP 119 +#define TK_USING 120 +#define TK_FILE 121 +#define TK_STABLE 122 +#define TK_COLUMN 123 +#define TK_MODIFY 124 +#define TK_RENAME 125 +#define TK_TAG 126 +#define TK_SET 127 +#define TK_NK_EQ 128 +#define TK_TAGS 129 +#define TK_BOOL 130 +#define TK_TINYINT 131 +#define TK_SMALLINT 132 +#define TK_INT 133 +#define TK_INTEGER 134 +#define TK_BIGINT 135 +#define TK_FLOAT 136 +#define TK_DOUBLE 137 +#define TK_BINARY 138 +#define TK_NCHAR 139 +#define TK_UNSIGNED 140 +#define TK_JSON 141 +#define TK_VARCHAR 142 +#define TK_MEDIUMBLOB 143 +#define TK_BLOB 144 +#define TK_VARBINARY 145 +#define TK_GEOMETRY 146 +#define TK_DECIMAL 147 +#define TK_COMMENT 148 +#define TK_MAX_DELAY 149 +#define TK_WATERMARK 150 +#define TK_ROLLUP 151 +#define TK_TTL 152 +#define TK_SMA 153 +#define TK_DELETE_MARK 154 +#define TK_FIRST 155 +#define TK_LAST 156 +#define TK_SHOW 157 +#define TK_FULL 158 +#define TK_PRIVILEGES 159 +#define TK_DATABASES 160 +#define TK_TABLES 161 +#define TK_STABLES 162 +#define TK_MNODES 163 +#define TK_QNODES 164 +#define TK_ARBGROUPS 165 +#define TK_FUNCTIONS 166 +#define TK_INDEXES 167 +#define TK_ACCOUNTS 168 +#define TK_APPS 169 +#define TK_CONNECTIONS 170 +#define TK_LICENCES 171 +#define TK_GRANTS 172 +#define TK_LOGS 173 +#define TK_MACHINES 174 +#define TK_ENCRYPTIONS 175 +#define TK_QUERIES 176 +#define TK_SCORES 177 +#define TK_TOPICS 178 +#define TK_VARIABLES 179 +#define TK_BNODES 180 +#define TK_SNODES 181 +#define TK_TRANSACTIONS 182 +#define TK_DISTRIBUTED 183 +#define TK_CONSUMERS 184 +#define TK_SUBSCRIPTIONS 185 +#define TK_VNODES 186 +#define TK_ALIVE 187 +#define TK_VIEWS 188 +#define TK_VIEW 189 +#define TK_COMPACTS 190 +#define TK_NORMAL 191 +#define TK_CHILD 192 +#define TK_LIKE 193 +#define TK_TBNAME 194 +#define TK_QTAGS 195 +#define TK_AS 196 +#define TK_SYSTEM 197 +#define TK_TSMA 198 +#define TK_INTERVAL 199 +#define TK_RECURSIVE 200 +#define TK_TSMAS 201 +#define TK_FUNCTION 202 +#define TK_INDEX 203 +#define TK_COUNT 204 +#define TK_LAST_ROW 205 +#define TK_META 206 +#define TK_ONLY 207 +#define TK_TOPIC 208 +#define TK_CONSUMER 209 +#define TK_GROUP 210 +#define TK_DESC 211 +#define TK_DESCRIBE 212 +#define TK_RESET 213 +#define TK_QUERY 214 +#define TK_CACHE 215 +#define TK_EXPLAIN 216 +#define TK_ANALYZE 217 +#define TK_VERBOSE 218 +#define TK_NK_BOOL 219 +#define TK_RATIO 220 +#define TK_NK_FLOAT 221 +#define TK_OUTPUTTYPE 222 +#define TK_AGGREGATE 223 +#define TK_BUFSIZE 224 +#define TK_LANGUAGE 225 +#define TK_REPLACE 226 +#define TK_STREAM 227 +#define TK_INTO 228 +#define TK_PAUSE 229 +#define TK_RESUME 230 +#define TK_PRIMARY 231 +#define TK_KEY 232 +#define TK_TRIGGER 233 +#define TK_AT_ONCE 234 +#define TK_WINDOW_CLOSE 235 +#define TK_IGNORE 236 +#define TK_EXPIRED 237 +#define TK_FILL_HISTORY 238 +#define TK_SUBTABLE 239 +#define TK_UNTREATED 240 +#define TK_KILL 241 +#define TK_CONNECTION 242 +#define TK_TRANSACTION 243 +#define TK_BALANCE 244 +#define TK_VGROUP 245 +#define TK_LEADER 246 +#define TK_MERGE 247 +#define TK_REDISTRIBUTE 248 +#define TK_SPLIT 249 +#define TK_DELETE 250 +#define TK_INSERT 251 +#define TK_NK_BIN 252 +#define TK_NK_HEX 253 +#define TK_NULL 254 +#define TK_NK_QUESTION 255 +#define TK_NK_ALIAS 256 +#define TK_NK_ARROW 257 +#define TK_ROWTS 258 +#define TK_QSTART 259 +#define TK_QEND 260 +#define TK_QDURATION 261 +#define TK_WSTART 262 +#define TK_WEND 263 +#define TK_WDURATION 264 +#define TK_IROWTS 265 +#define TK_ISFILLED 266 +#define TK_FLOW 267 +#define TK_FHIGH 268 +#define TK_FROWTS 269 +#define TK_CAST 270 +#define TK_POSITION 271 +#define TK_IN 272 +#define TK_FOR 273 +#define TK_NOW 274 +#define TK_TODAY 275 +#define TK_RAND 276 +#define TK_SUBSTR 277 +#define TK_SUBSTRING 278 +#define TK_BOTH 279 +#define TK_TRAILING 280 +#define TK_LEADING 281 +#define TK_TIMEZONE 282 +#define TK_CLIENT_VERSION 283 +#define TK_SERVER_VERSION 284 +#define TK_SERVER_STATUS 285 +#define TK_CURRENT_USER 286 +#define TK_PI 287 +#define TK_CASE 288 +#define TK_WHEN 289 +#define TK_THEN 290 +#define TK_ELSE 291 +#define TK_BETWEEN 292 +#define TK_IS 293 +#define TK_NK_LT 294 +#define TK_NK_GT 295 +#define TK_NK_LE 296 +#define TK_NK_GE 297 +#define TK_NK_NE 298 +#define TK_MATCH 299 +#define TK_NMATCH 300 +#define TK_CONTAINS 301 +#define TK_JOIN 302 +#define TK_INNER 303 +#define TK_LEFT 304 +#define TK_RIGHT 305 +#define TK_OUTER 306 +#define TK_SEMI 307 +#define TK_ANTI 308 +#define TK_ASOF 309 +#define TK_WINDOW 310 +#define TK_WINDOW_OFFSET 311 +#define TK_JLIMIT 312 +#define TK_SELECT 313 +#define TK_NK_HINT 314 +#define TK_DISTINCT 315 +#define TK_WHERE 316 +#define TK_PARTITION 317 +#define TK_BY 318 +#define TK_SESSION 319 +#define TK_STATE_WINDOW 320 +#define TK_EVENT_WINDOW 321 +#define TK_COUNT_WINDOW 322 +#define TK_ANOMALY_WINDOW 323 +#define TK_SLIDING 324 +#define TK_FILL 325 +#define TK_VALUE 326 +#define TK_VALUE_F 327 +#define TK_NONE 328 +#define TK_PREV 329 +#define TK_NULL_F 330 +#define TK_LINEAR 331 +#define TK_NEXT 332 +#define TK_HAVING 333 +#define TK_RANGE 334 +#define TK_EVERY 335 +#define TK_ORDER 336 +#define TK_SLIMIT 337 +#define TK_SOFFSET 338 +#define TK_LIMIT 339 +#define TK_OFFSET 340 +#define TK_ASC 341 +#define TK_NULLS 342 +#define TK_ABORT 343 +#define TK_AFTER 344 +#define TK_ATTACH 345 +#define TK_BEFORE 346 +#define TK_BEGIN 347 +#define TK_BITAND 348 +#define TK_BITNOT 349 +#define TK_BITOR 350 +#define TK_BLOCKS 351 +#define TK_CHANGE 352 +#define TK_COMMA 353 +#define TK_CONCAT 354 +#define TK_CONFLICT 355 +#define TK_COPY 356 +#define TK_DEFERRED 357 +#define TK_DELIMITERS 358 +#define TK_DETACH 359 +#define TK_DIVIDE 360 +#define TK_DOT 361 +#define TK_EACH 362 +#define TK_FAIL 363 +#define TK_GLOB 364 +#define TK_ID 365 +#define TK_IMMEDIATE 366 +#define TK_IMPORT 367 +#define TK_INITIALLY 368 +#define TK_INSTEAD 369 +#define TK_ISNULL 370 +#define TK_MODULES 371 +#define TK_NK_BITNOT 372 +#define TK_NK_SEMI 373 +#define TK_NOTNULL 374 +#define TK_OF 375 +#define TK_PLUS 376 +#define TK_PRIVILEGE 377 +#define TK_RAISE 378 +#define TK_RESTRICT 379 +#define TK_ROW 380 +#define TK_STAR 381 +#define TK_STATEMENT 382 +#define TK_STRICT 383 +#define TK_STRING 384 +#define TK_TIMES 385 +#define TK_VALUES 386 +#define TK_VARIABLE 387 +#define TK_WAL 388 +#endif +/**************** End token definitions ***************************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -1546,7 +1936,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* STT_TRIGGER => nothing */ 0, /* TABLE_PREFIX => nothing */ 0, /* TABLE_SUFFIX => nothing */ - 0, /* S3_CHUNKSIZE => nothing */ + 0, /* S3_CHUNKPAGES => nothing */ 0, /* S3_KEEPLOCAL => nothing */ 0, /* S3_COMPACT => nothing */ 0, /* KEEP_TIME_OFFSET => nothing */ @@ -1881,6 +2271,7 @@ typedef struct yyParser yyParser; #ifndef NDEBUG #include +#include static FILE *yyTraceFILE = 0; static char *yyTracePrompt = 0; #endif /* NDEBUG */ @@ -2022,7 +2413,7 @@ static const char *const yyTokenName[] = { /* 104 */ "STT_TRIGGER", /* 105 */ "TABLE_PREFIX", /* 106 */ "TABLE_SUFFIX", - /* 107 */ "S3_CHUNKSIZE", + /* 107 */ "S3_CHUNKPAGES", /* 108 */ "S3_KEEPLOCAL", /* 109 */ "S3_COMPACT", /* 110 */ "KEEP_TIME_OFFSET", @@ -2634,7 +3025,7 @@ static const char *const yyRuleName[] = { /* 136 */ "db_options ::= db_options STT_TRIGGER NK_INTEGER", /* 137 */ "db_options ::= db_options TABLE_PREFIX signed", /* 138 */ "db_options ::= db_options TABLE_SUFFIX signed", - /* 139 */ "db_options ::= db_options S3_CHUNKSIZE NK_INTEGER", + /* 139 */ "db_options ::= db_options S3_CHUNKPAGES NK_INTEGER", /* 140 */ "db_options ::= db_options S3_KEEPLOCAL NK_INTEGER", /* 141 */ "db_options ::= db_options S3_KEEPLOCAL NK_VARIABLE", /* 142 */ "db_options ::= db_options S3_COMPACT NK_INTEGER", @@ -3493,7 +3884,9 @@ static void yy_destructor( case 568: /* query_simple_or_subquery */ case 570: /* sort_specification */ { +#line 7 "sql.y" nodesDestroyNode((yypminor->yy974)); +#line 3889 "sql.c" } break; case 390: /* account_options */ @@ -3503,7 +3896,9 @@ static void yy_destructor( case 478: /* with_meta */ case 487: /* bufsize_opt */ { +#line 54 "sql.y" +#line 3901 "sql.c" } break; case 394: /* ip_range_list */ @@ -3543,14 +3938,18 @@ static void yy_destructor( case 564: /* order_by_clause_opt */ case 569: /* sort_specification_list */ { +#line 85 "sql.y" nodesDestroyList((yypminor->yy946)); +#line 3943 "sql.c" } break; case 397: /* is_import_opt */ case 398: /* is_createdb_opt */ case 400: /* sysinfo_opt */ { +#line 99 "sql.y" +#line 3952 "sql.c" } break; case 399: /* user_name */ @@ -3575,19 +3974,25 @@ static void yy_destructor( case 517: /* noarg_func */ case 535: /* alias_opt */ { +#line 1095 "sql.y" +#line 3979 "sql.c" } break; case 401: /* privileges */ case 404: /* priv_type_list */ case 405: /* priv_type */ { +#line 131 "sql.y" +#line 3988 "sql.c" } break; case 402: /* priv_level */ { +#line 148 "sql.y" +#line 3995 "sql.c" } break; case 411: /* force_opt */ @@ -3602,71 +4007,97 @@ static void yy_destructor( case 546: /* set_quantifier_opt */ case 547: /* tag_mode_opt */ { +#line 186 "sql.y" +#line 4012 "sql.c" } break; case 424: /* alter_db_option */ case 452: /* alter_table_option */ { +#line 294 "sql.y" +#line 4020 "sql.c" } break; case 438: /* type_name */ case 449: /* type_name_default_len */ { +#line 436 "sql.y" +#line 4028 "sql.c" } break; case 457: /* db_kind_opt */ case 463: /* table_kind */ { +#line 617 "sql.y" +#line 4036 "sql.c" } break; case 458: /* table_kind_db_name_cond_opt */ { +#line 582 "sql.y" +#line 4043 "sql.c" } break; case 467: /* tsma_func_list */ { +#line 636 "sql.y" nodesDestroyNode((yypminor->yy974)); +#line 4050 "sql.c" } break; case 514: /* trim_specification_type */ { +#line 1241 "sql.y" +#line 4057 "sql.c" } break; case 525: /* compare_op */ case 526: /* in_op */ { +#line 1328 "sql.y" +#line 4065 "sql.c" } break; case 538: /* join_type */ { +#line 1409 "sql.y" +#line 4072 "sql.c" } break; case 539: /* join_subtype */ { +#line 1417 "sql.y" +#line 4079 "sql.c" } break; case 560: /* fill_mode */ { +#line 1537 "sql.y" +#line 4086 "sql.c" } break; case 571: /* ordering_specification_opt */ { +#line 1622 "sql.y" +#line 4093 "sql.c" } break; case 572: /* null_ordering_opt */ { +#line 1628 "sql.y" +#line 4100 "sql.c" } break; /********* End destructor definitions *****************************************/ @@ -3833,7 +4264,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && i=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); return yy_action[i]; } }while(1); @@ -4094,7 +4525,7 @@ static const YYCODETYPE yyRuleInfoLhs[] = { 414, /* (136) db_options ::= db_options STT_TRIGGER NK_INTEGER */ 414, /* (137) db_options ::= db_options TABLE_PREFIX signed */ 414, /* (138) db_options ::= db_options TABLE_SUFFIX signed */ - 414, /* (139) db_options ::= db_options S3_CHUNKSIZE NK_INTEGER */ + 414, /* (139) db_options ::= db_options S3_CHUNKPAGES NK_INTEGER */ 414, /* (140) db_options ::= db_options S3_KEEPLOCAL NK_INTEGER */ 414, /* (141) db_options ::= db_options S3_KEEPLOCAL NK_VARIABLE */ 414, /* (142) db_options ::= db_options S3_COMPACT NK_INTEGER */ @@ -4883,7 +5314,7 @@ static const signed char yyRuleInfoNRhs[] = { -3, /* (136) db_options ::= db_options STT_TRIGGER NK_INTEGER */ -3, /* (137) db_options ::= db_options TABLE_PREFIX signed */ -3, /* (138) db_options ::= db_options TABLE_SUFFIX signed */ - -3, /* (139) db_options ::= db_options S3_CHUNKSIZE NK_INTEGER */ + -3, /* (139) db_options ::= db_options S3_CHUNKPAGES NK_INTEGER */ -3, /* (140) db_options ::= db_options S3_KEEPLOCAL NK_INTEGER */ -3, /* (141) db_options ::= db_options S3_KEEPLOCAL NK_VARIABLE */ -3, /* (142) db_options ::= db_options S3_COMPACT NK_INTEGER */ @@ -5557,8 +5988,9 @@ static YYACTIONTYPE yy_reduce( (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; + assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); #ifndef NDEBUG - if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ + if( yyTraceFILE ){ yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", @@ -5618,15 +6050,21 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ +#line 50 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +#line 6055 "sql.c" yy_destructor(yypParser,390,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ +#line 51 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +#line 6061 "sql.c" yy_destructor(yypParser,391,&yymsp[0].minor); break; case 2: /* account_options ::= */ +#line 55 "sql.y" { } +#line 6067 "sql.c" break; case 3: /* account_options ::= account_options PPS literal */ case 4: /* account_options ::= account_options TSERIES literal */ yytestcase(yyruleno==4); @@ -5638,18 +6076,24 @@ static YYACTIONTYPE yy_reduce( 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,390,&yymsp[-2].minor); +#line 56 "sql.y" { } +#line 6081 "sql.c" yy_destructor(yypParser,392,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ { yy_destructor(yypParser,393,&yymsp[0].minor); +#line 68 "sql.y" { } +#line 6089 "sql.c" } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ { yy_destructor(yypParser,391,&yymsp[-1].minor); +#line 69 "sql.y" { } +#line 6096 "sql.c" yy_destructor(yypParser,393,&yymsp[0].minor); } break; @@ -5663,19 +6107,27 @@ static YYACTIONTYPE yy_reduce( case 21: /* alter_account_option ::= USERS literal */ yytestcase(yyruleno==21); case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); +#line 73 "sql.y" { } +#line 6112 "sql.c" yy_destructor(yypParser,392,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ +#line 86 "sql.y" { yylhsminor.yy946 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 6118 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ +#line 87 "sql.y" { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 6124 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; case 26: /* white_list ::= HOST ip_range_list */ +#line 91 "sql.y" { yymsp[-1].minor.yy946 = yymsp[0].minor.yy946; } +#line 6130 "sql.c" break; case 27: /* white_list_opt ::= */ case 212: /* specific_cols_opt ::= */ yytestcase(yyruleno==212); @@ -5686,98 +6138,150 @@ static YYACTIONTYPE yy_reduce( case 707: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==707); case 739: /* group_by_clause_opt ::= */ yytestcase(yyruleno==739); case 759: /* order_by_clause_opt ::= */ yytestcase(yyruleno==759); +#line 95 "sql.y" { yymsp[1].minor.yy946 = NULL; } +#line 6143 "sql.c" break; case 28: /* white_list_opt ::= white_list */ case 251: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==251); case 424: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==424); case 615: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==615); +#line 96 "sql.y" { yylhsminor.yy946 = yymsp[0].minor.yy946; } +#line 6151 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 29: /* is_import_opt ::= */ case 31: /* is_createdb_opt ::= */ yytestcase(yyruleno==31); +#line 100 "sql.y" { yymsp[1].minor.yy815 = 0; } +#line 6158 "sql.c" break; case 30: /* is_import_opt ::= IS_IMPORT NK_INTEGER */ case 32: /* is_createdb_opt ::= CREATEDB NK_INTEGER */ yytestcase(yyruleno==32); case 42: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ yytestcase(yyruleno==42); +#line 101 "sql.y" { yymsp[-1].minor.yy815 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +#line 6165 "sql.c" break; case 33: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt is_createdb_opt is_import_opt white_list_opt */ +#line 109 "sql.y" { pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-6].minor.yy557, &yymsp[-4].minor.yy0, yymsp[-3].minor.yy815, yymsp[-1].minor.yy815, yymsp[-2].minor.yy815); pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy946); } +#line 6173 "sql.c" break; case 34: /* cmd ::= ALTER USER user_name PASS NK_STRING */ +#line 113 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +#line 6178 "sql.c" break; case 35: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ +#line 114 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +#line 6183 "sql.c" break; case 36: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ +#line 115 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +#line 6188 "sql.c" break; case 37: /* cmd ::= ALTER USER user_name CREATEDB NK_INTEGER */ +#line 116 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_CREATEDB, &yymsp[0].minor.yy0); } +#line 6193 "sql.c" break; case 38: /* cmd ::= ALTER USER user_name ADD white_list */ +#line 117 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy946); } +#line 6198 "sql.c" break; case 39: /* cmd ::= ALTER USER user_name DROP white_list */ +#line 118 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy557, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy946); } +#line 6203 "sql.c" break; case 40: /* cmd ::= DROP USER user_name */ +#line 119 "sql.y" { pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy557); } +#line 6208 "sql.c" break; case 41: /* sysinfo_opt ::= */ +#line 123 "sql.y" { yymsp[1].minor.yy815 = 1; } +#line 6213 "sql.c" break; case 43: /* cmd ::= GRANT privileges ON priv_level with_clause_opt TO user_name */ +#line 127 "sql.y" { pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy483, &yymsp[-3].minor.yy723, &yymsp[0].minor.yy557, yymsp[-2].minor.yy974); } +#line 6218 "sql.c" break; case 44: /* cmd ::= REVOKE privileges ON priv_level with_clause_opt FROM user_name */ +#line 128 "sql.y" { pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy483, &yymsp[-3].minor.yy723, &yymsp[0].minor.yy557, yymsp[-2].minor.yy974); } +#line 6223 "sql.c" break; case 45: /* privileges ::= ALL */ +#line 132 "sql.y" { yymsp[0].minor.yy483 = PRIVILEGE_TYPE_ALL; } +#line 6228 "sql.c" break; case 46: /* privileges ::= priv_type_list */ case 48: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==48); +#line 133 "sql.y" { yylhsminor.yy483 = yymsp[0].minor.yy483; } +#line 6234 "sql.c" yymsp[0].minor.yy483 = yylhsminor.yy483; break; case 47: /* privileges ::= SUBSCRIBE */ +#line 134 "sql.y" { yymsp[0].minor.yy483 = PRIVILEGE_TYPE_SUBSCRIBE; } +#line 6240 "sql.c" break; case 49: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ +#line 139 "sql.y" { yylhsminor.yy483 = yymsp[-2].minor.yy483 | yymsp[0].minor.yy483; } +#line 6245 "sql.c" yymsp[-2].minor.yy483 = yylhsminor.yy483; break; case 50: /* priv_type ::= READ */ +#line 143 "sql.y" { yymsp[0].minor.yy483 = PRIVILEGE_TYPE_READ; } +#line 6251 "sql.c" break; case 51: /* priv_type ::= WRITE */ +#line 144 "sql.y" { yymsp[0].minor.yy483 = PRIVILEGE_TYPE_WRITE; } +#line 6256 "sql.c" break; case 52: /* priv_type ::= ALTER */ +#line 145 "sql.y" { yymsp[0].minor.yy483 = PRIVILEGE_TYPE_ALTER; } +#line 6261 "sql.c" break; case 53: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ +#line 149 "sql.y" { yylhsminor.yy723.first = yymsp[-2].minor.yy0; yylhsminor.yy723.second = yymsp[0].minor.yy0; } +#line 6266 "sql.c" yymsp[-2].minor.yy723 = yylhsminor.yy723; break; case 54: /* priv_level ::= db_name NK_DOT NK_STAR */ +#line 150 "sql.y" { yylhsminor.yy723.first = yymsp[-2].minor.yy557; yylhsminor.yy723.second = yymsp[0].minor.yy0; } +#line 6272 "sql.c" yymsp[-2].minor.yy723 = yylhsminor.yy723; break; case 55: /* priv_level ::= db_name NK_DOT table_name */ +#line 151 "sql.y" { yylhsminor.yy723.first = yymsp[-2].minor.yy557; yylhsminor.yy723.second = yymsp[0].minor.yy557; } +#line 6278 "sql.c" yymsp[-2].minor.yy723 = yylhsminor.yy723; break; case 56: /* priv_level ::= topic_name */ +#line 152 "sql.y" { yylhsminor.yy723.first = yymsp[0].minor.yy557; yylhsminor.yy723.second = nil_token; } +#line 6284 "sql.c" yymsp[0].minor.yy723 = yylhsminor.yy723; break; case 57: /* with_clause_opt ::= */ @@ -5799,62 +6303,98 @@ static YYACTIONTYPE yy_reduce( case 748: /* every_opt ::= */ yytestcase(yyruleno==748); case 761: /* slimit_clause_opt ::= */ yytestcase(yyruleno==761); case 765: /* limit_clause_opt ::= */ yytestcase(yyruleno==765); +#line 154 "sql.y" { yymsp[1].minor.yy974 = NULL; } +#line 6308 "sql.c" break; case 58: /* with_clause_opt ::= WITH search_condition */ case 656: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==656); case 683: /* join_on_clause_opt ::= ON search_condition */ yytestcase(yyruleno==683); case 706: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==706); case 744: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==744); +#line 155 "sql.y" { yymsp[-1].minor.yy974 = yymsp[0].minor.yy974; } +#line 6317 "sql.c" break; case 59: /* cmd ::= CREATE ENCRYPT_KEY NK_STRING */ +#line 158 "sql.y" { pCxt->pRootNode = createEncryptKeyStmt(pCxt, &yymsp[0].minor.yy0); } +#line 6322 "sql.c" break; case 60: /* cmd ::= CREATE ANODE NK_STRING */ +#line 161 "sql.y" { pCxt->pRootNode = createCreateAnodeStmt(pCxt, &yymsp[0].minor.yy0); } +#line 6327 "sql.c" break; case 61: /* cmd ::= UPDATE ANODE NK_INTEGER */ +#line 162 "sql.y" { pCxt->pRootNode = createUpdateAnodeStmt(pCxt, &yymsp[0].minor.yy0, false); } +#line 6332 "sql.c" break; case 62: /* cmd ::= UPDATE ALL ANODES */ +#line 163 "sql.y" { pCxt->pRootNode = createUpdateAnodeStmt(pCxt, NULL, true); } +#line 6337 "sql.c" break; case 63: /* cmd ::= DROP ANODE NK_INTEGER */ +#line 164 "sql.y" { pCxt->pRootNode = createDropAnodeStmt(pCxt, &yymsp[0].minor.yy0); } +#line 6342 "sql.c" break; case 64: /* cmd ::= CREATE DNODE dnode_endpoint */ +#line 167 "sql.y" { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy557, NULL); } +#line 6347 "sql.c" break; case 65: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ +#line 168 "sql.y" { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0); } +#line 6352 "sql.c" break; case 66: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ +#line 169 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy569, false); } +#line 6357 "sql.c" break; case 67: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ +#line 170 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy557, yymsp[0].minor.yy569, false); } +#line 6362 "sql.c" break; case 68: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ +#line 171 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy569); } +#line 6367 "sql.c" break; case 69: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ +#line 172 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy557, false, yymsp[0].minor.yy569); } +#line 6372 "sql.c" break; case 70: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ +#line 173 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } +#line 6377 "sql.c" break; case 71: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ +#line 174 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 6382 "sql.c" break; case 72: /* cmd ::= ALTER ALL DNODES NK_STRING */ +#line 175 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } +#line 6387 "sql.c" break; case 73: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ +#line 176 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 6392 "sql.c" break; case 74: /* cmd ::= RESTORE DNODE NK_INTEGER */ +#line 177 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_DNODE_STMT, &yymsp[0].minor.yy0); } +#line 6397 "sql.c" break; case 75: /* dnode_endpoint ::= NK_STRING */ case 76: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==76); @@ -5893,7 +6433,9 @@ static YYACTIONTYPE yy_reduce( case 611: /* star_func ::= FIRST */ yytestcase(yyruleno==611); case 612: /* star_func ::= LAST */ yytestcase(yyruleno==612); case 613: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==613); +#line 181 "sql.y" { yylhsminor.yy557 = yymsp[0].minor.yy0; } +#line 6438 "sql.c" yymsp[0].minor.yy557 = yylhsminor.yy557; break; case 78: /* force_opt ::= */ @@ -5906,7 +6448,9 @@ static YYACTIONTYPE yy_reduce( case 437: /* ignore_opt ::= */ yytestcase(yyruleno==437); case 693: /* tag_mode_opt ::= */ yytestcase(yyruleno==693); case 695: /* set_quantifier_opt ::= */ yytestcase(yyruleno==695); +#line 187 "sql.y" { yymsp[1].minor.yy569 = false; } +#line 6453 "sql.c" break; case 79: /* force_opt ::= FORCE */ case 80: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==80); @@ -5915,318 +6459,486 @@ static YYACTIONTYPE yy_reduce( case 401: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==401); case 694: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==694); case 696: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==696); +#line 188 "sql.y" { yymsp[0].minor.yy569 = true; } +#line 6464 "sql.c" break; case 81: /* cmd ::= ALTER CLUSTER NK_STRING */ +#line 195 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 6469 "sql.c" break; case 82: /* cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ +#line 196 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 6474 "sql.c" break; case 83: /* cmd ::= ALTER LOCAL NK_STRING */ +#line 199 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 6479 "sql.c" break; case 84: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ +#line 200 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 6484 "sql.c" break; case 85: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ +#line 203 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 6489 "sql.c" break; case 86: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ +#line 204 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 6494 "sql.c" break; case 87: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ +#line 205 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 6499 "sql.c" break; case 88: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ +#line 208 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } +#line 6504 "sql.c" break; case 89: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ +#line 209 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } +#line 6509 "sql.c" break; case 90: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ +#line 212 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } +#line 6514 "sql.c" break; case 91: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ +#line 213 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } +#line 6519 "sql.c" break; case 92: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ +#line 216 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 6524 "sql.c" break; case 93: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ +#line 217 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 6529 "sql.c" break; case 94: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ +#line 218 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 6534 "sql.c" break; case 95: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ +#line 221 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } +#line 6539 "sql.c" break; case 96: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +#line 224 "sql.y" { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy569, &yymsp[-1].minor.yy557, yymsp[0].minor.yy974); } +#line 6544 "sql.c" break; case 97: /* cmd ::= DROP DATABASE exists_opt db_name */ +#line 225 "sql.y" { pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } +#line 6549 "sql.c" break; case 98: /* cmd ::= USE db_name */ +#line 226 "sql.y" { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy557); } +#line 6554 "sql.c" break; case 99: /* cmd ::= ALTER DATABASE db_name alter_db_options */ +#line 227 "sql.y" { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy557, yymsp[0].minor.yy974); } +#line 6559 "sql.c" break; case 100: /* cmd ::= FLUSH DATABASE db_name */ +#line 228 "sql.y" { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy557); } +#line 6564 "sql.c" break; case 101: /* cmd ::= TRIM DATABASE db_name speed_opt */ +#line 229 "sql.y" { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy557, yymsp[0].minor.yy904); } +#line 6569 "sql.c" break; case 102: /* cmd ::= S3MIGRATE DATABASE db_name */ +#line 230 "sql.y" { pCxt->pRootNode = createS3MigrateDatabaseStmt(pCxt, &yymsp[0].minor.yy557); } +#line 6574 "sql.c" break; case 103: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ +#line 231 "sql.y" { pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy557, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } +#line 6579 "sql.c" break; case 104: /* not_exists_opt ::= IF NOT EXISTS */ +#line 235 "sql.y" { yymsp[-2].minor.yy569 = true; } +#line 6584 "sql.c" break; case 106: /* exists_opt ::= IF EXISTS */ case 407: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==407); case 438: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==438); +#line 240 "sql.y" { yymsp[-1].minor.yy569 = true; } +#line 6591 "sql.c" break; case 108: /* db_options ::= */ +#line 243 "sql.y" { yymsp[1].minor.yy974 = createDefaultDatabaseOptions(pCxt); } +#line 6596 "sql.c" break; case 109: /* db_options ::= db_options BUFFER NK_INTEGER */ +#line 244 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } +#line 6601 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 110: /* db_options ::= db_options CACHEMODEL NK_STRING */ +#line 245 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } +#line 6607 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 111: /* db_options ::= db_options CACHESIZE NK_INTEGER */ +#line 246 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } +#line 6613 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 112: /* db_options ::= db_options COMP NK_INTEGER */ +#line 247 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_COMP, &yymsp[0].minor.yy0); } +#line 6619 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 113: /* db_options ::= db_options DURATION NK_INTEGER */ case 114: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==114); +#line 248 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } +#line 6626 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 115: /* db_options ::= db_options MAXROWS NK_INTEGER */ +#line 250 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } +#line 6632 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 116: /* db_options ::= db_options MINROWS NK_INTEGER */ +#line 251 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } +#line 6638 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 117: /* db_options ::= db_options KEEP integer_list */ case 118: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==118); +#line 252 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_KEEP, yymsp[0].minor.yy946); } +#line 6645 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 119: /* db_options ::= db_options PAGES NK_INTEGER */ +#line 254 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } +#line 6651 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 120: /* db_options ::= db_options PAGESIZE NK_INTEGER */ +#line 255 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } +#line 6657 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 121: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ +#line 256 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } +#line 6663 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 122: /* db_options ::= db_options PRECISION NK_STRING */ +#line 257 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } +#line 6669 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 123: /* db_options ::= db_options REPLICA NK_INTEGER */ +#line 258 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } +#line 6675 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 124: /* db_options ::= db_options VGROUPS NK_INTEGER */ +#line 260 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } +#line 6681 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 125: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +#line 261 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } +#line 6687 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 126: /* db_options ::= db_options RETENTIONS retention_list */ +#line 262 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_RETENTIONS, yymsp[0].minor.yy946); } +#line 6693 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 127: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ +#line 263 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } +#line 6699 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 128: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ +#line 264 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_WAL, &yymsp[0].minor.yy0); } +#line 6705 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 129: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ +#line 265 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } +#line 6711 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 130: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ +#line 266 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } +#line 6717 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 131: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ +#line 267 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-3].minor.yy974, DB_OPTION_WAL_RETENTION_PERIOD, &t); } +#line 6727 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 132: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ +#line 272 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } +#line 6733 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 133: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ +#line 273 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-3].minor.yy974, DB_OPTION_WAL_RETENTION_SIZE, &t); } +#line 6743 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 134: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ +#line 278 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } +#line 6749 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 135: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ +#line 279 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } +#line 6755 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 136: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ +#line 280 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } +#line 6761 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 137: /* db_options ::= db_options TABLE_PREFIX signed */ +#line 281 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy974); } +#line 6767 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 138: /* db_options ::= db_options TABLE_SUFFIX signed */ +#line 282 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy974); } +#line 6773 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; - case 139: /* db_options ::= db_options S3_CHUNKSIZE NK_INTEGER */ -{ yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_S3_CHUNKSIZE, &yymsp[0].minor.yy0); } + case 139: /* db_options ::= db_options S3_CHUNKPAGES NK_INTEGER */ +#line 283 "sql.y" +{ yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_S3_CHUNKPAGES, &yymsp[0].minor.yy0); } +#line 6779 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 140: /* db_options ::= db_options S3_KEEPLOCAL NK_INTEGER */ case 141: /* db_options ::= db_options S3_KEEPLOCAL NK_VARIABLE */ yytestcase(yyruleno==141); +#line 284 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_S3_KEEPLOCAL, &yymsp[0].minor.yy0); } +#line 6786 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 142: /* db_options ::= db_options S3_COMPACT NK_INTEGER */ +#line 286 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_S3_COMPACT, &yymsp[0].minor.yy0); } +#line 6792 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 143: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ +#line 287 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } +#line 6798 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 144: /* db_options ::= db_options ENCRYPT_ALGORITHM NK_STRING */ +#line 288 "sql.y" { yylhsminor.yy974 = setDatabaseOption(pCxt, yymsp[-2].minor.yy974, DB_OPTION_ENCRYPT_ALGORITHM, &yymsp[0].minor.yy0); } +#line 6804 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 145: /* alter_db_options ::= alter_db_option */ +#line 290 "sql.y" { yylhsminor.yy974 = createAlterDatabaseOptions(pCxt); yylhsminor.yy974 = setAlterDatabaseOption(pCxt, yylhsminor.yy974, &yymsp[0].minor.yy683); } +#line 6810 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 146: /* alter_db_options ::= alter_db_options alter_db_option */ +#line 291 "sql.y" { yylhsminor.yy974 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy974, &yymsp[0].minor.yy683); } +#line 6816 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 147: /* alter_db_option ::= BUFFER NK_INTEGER */ +#line 295 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6822 "sql.c" break; case 148: /* alter_db_option ::= CACHEMODEL NK_STRING */ +#line 296 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6827 "sql.c" break; case 149: /* alter_db_option ::= CACHESIZE NK_INTEGER */ +#line 297 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6832 "sql.c" break; case 150: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ +#line 298 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6837 "sql.c" break; case 151: /* alter_db_option ::= KEEP integer_list */ case 152: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==152); +#line 299 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_KEEP; yymsp[-1].minor.yy683.pList = yymsp[0].minor.yy946; } +#line 6843 "sql.c" break; case 153: /* alter_db_option ::= PAGES NK_INTEGER */ +#line 301 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_PAGES; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6848 "sql.c" break; case 154: /* alter_db_option ::= REPLICA NK_INTEGER */ +#line 302 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6853 "sql.c" break; case 155: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ +#line 304 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_WAL; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6858 "sql.c" break; case 156: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ +#line 305 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6863 "sql.c" break; case 157: /* alter_db_option ::= MINROWS NK_INTEGER */ +#line 306 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6868 "sql.c" break; case 158: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ +#line 307 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6873 "sql.c" break; case 159: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ +#line 308 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yymsp[-2].minor.yy683.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy683.val = t; } +#line 6882 "sql.c" break; case 160: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ +#line 313 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6887 "sql.c" break; case 161: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ +#line 314 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yymsp[-2].minor.yy683.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy683.val = t; } +#line 6896 "sql.c" break; case 162: /* alter_db_option ::= S3_KEEPLOCAL NK_INTEGER */ case 163: /* alter_db_option ::= S3_KEEPLOCAL NK_VARIABLE */ yytestcase(yyruleno==163); +#line 319 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_S3_KEEPLOCAL; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6902 "sql.c" break; case 164: /* alter_db_option ::= S3_COMPACT NK_INTEGER */ +#line 321 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_S3_COMPACT, yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6907 "sql.c" break; case 165: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ +#line 322 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6912 "sql.c" break; case 166: /* alter_db_option ::= ENCRYPT_ALGORITHM NK_STRING */ +#line 323 "sql.y" { yymsp[-1].minor.yy683.type = DB_OPTION_ENCRYPT_ALGORITHM; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 6917 "sql.c" break; case 167: /* integer_list ::= NK_INTEGER */ +#line 327 "sql.y" { yylhsminor.yy946 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6922 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 168: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ case 452: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==452); +#line 328 "sql.y" { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6929 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; case 169: /* variable_list ::= NK_VARIABLE */ +#line 332 "sql.y" { yylhsminor.yy946 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 6935 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 170: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ +#line 333 "sql.y" { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 6941 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; case 171: /* retention_list ::= retention */ @@ -6246,7 +6958,9 @@ static YYACTIONTYPE yy_reduce( case 698: /* select_list ::= select_item */ yytestcase(yyruleno==698); case 709: /* partition_list ::= partition_item */ yytestcase(yyruleno==709); case 772: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==772); +#line 337 "sql.y" { yylhsminor.yy946 = createNodeList(pCxt, yymsp[0].minor.yy974); } +#line 6963 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 172: /* retention_list ::= retention_list NK_COMMA retention */ @@ -6264,762 +6978,1198 @@ static YYACTIONTYPE yy_reduce( case 699: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==699); case 710: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==710); case 773: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==773); +#line 338 "sql.y" { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, yymsp[0].minor.yy974); } +#line 6983 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; case 173: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ case 174: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==174); +#line 340 "sql.y" { yylhsminor.yy974 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 6990 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 175: /* speed_opt ::= */ case 402: /* bufsize_opt ::= */ yytestcase(yyruleno==402); +#line 345 "sql.y" { yymsp[1].minor.yy904 = 0; } +#line 6997 "sql.c" break; case 176: /* speed_opt ::= BWLIMIT NK_INTEGER */ case 403: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==403); +#line 346 "sql.y" { yymsp[-1].minor.yy904 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +#line 7003 "sql.c" break; case 178: /* start_opt ::= START WITH NK_INTEGER */ case 182: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==182); +#line 349 "sql.y" { yymsp[-2].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +#line 7009 "sql.c" break; case 179: /* start_opt ::= START WITH NK_STRING */ case 183: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==183); +#line 350 "sql.y" { yymsp[-2].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 7015 "sql.c" break; case 180: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ case 184: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==184); +#line 351 "sql.y" { yymsp[-3].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 7021 "sql.c" break; case 185: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 188: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==188); +#line 360 "sql.y" { pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy569, yymsp[-5].minor.yy974, yymsp[-3].minor.yy946, yymsp[-1].minor.yy946, yymsp[0].minor.yy974); } +#line 7027 "sql.c" break; case 186: /* cmd ::= CREATE TABLE multi_create_clause */ +#line 361 "sql.y" { pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy946); } +#line 7032 "sql.c" break; case 187: /* cmd ::= CREATE TABLE not_exists_opt USING full_table_name NK_LP tag_list_opt NK_RP FILE NK_STRING */ +#line 363 "sql.y" { pCxt->pRootNode = createCreateSubTableFromFileClause(pCxt, yymsp[-7].minor.yy569, yymsp[-5].minor.yy974, yymsp[-3].minor.yy946, &yymsp[0].minor.yy0); } +#line 7037 "sql.c" break; case 189: /* cmd ::= DROP TABLE with_opt multi_drop_clause */ +#line 366 "sql.y" { pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[-1].minor.yy569, yymsp[0].minor.yy946); } +#line 7042 "sql.c" break; case 190: /* cmd ::= DROP STABLE with_opt exists_opt full_table_name */ +#line 367 "sql.y" { pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-2].minor.yy569, yymsp[-1].minor.yy569, yymsp[0].minor.yy974); } +#line 7047 "sql.c" break; case 191: /* cmd ::= ALTER TABLE alter_table_clause */ case 454: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==454); case 455: /* cmd ::= insert_query */ yytestcase(yyruleno==455); +#line 369 "sql.y" { pCxt->pRootNode = yymsp[0].minor.yy974; } +#line 7054 "sql.c" break; case 192: /* cmd ::= ALTER STABLE alter_table_clause */ +#line 370 "sql.y" { pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy974); } +#line 7059 "sql.c" break; case 193: /* alter_table_clause ::= full_table_name alter_table_options */ +#line 372 "sql.y" { yylhsminor.yy974 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } +#line 7064 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 194: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name column_options */ +#line 374 "sql.y" { yylhsminor.yy974 = createAlterTableAddModifyColOptions2(pCxt, yymsp[-5].minor.yy974, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-2].minor.yy557, yymsp[-1].minor.yy424, yymsp[0].minor.yy974); } +#line 7070 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; case 195: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +#line 375 "sql.y" { yylhsminor.yy974 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy974, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy557); } +#line 7076 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 196: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +#line 377 "sql.y" { yylhsminor.yy974 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy557, yymsp[0].minor.yy424); } +#line 7082 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; case 197: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name column_options */ +#line 379 "sql.y" { yylhsminor.yy974 = createAlterTableAddModifyColOptions(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS, &yymsp[-1].minor.yy557, yymsp[0].minor.yy974); } +#line 7088 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; case 198: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +#line 381 "sql.y" { yylhsminor.yy974 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy557, &yymsp[0].minor.yy557); } +#line 7094 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; case 199: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +#line 383 "sql.y" { yylhsminor.yy974 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy557, yymsp[0].minor.yy424); } +#line 7100 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; case 200: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +#line 384 "sql.y" { yylhsminor.yy974 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy974, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy557); } +#line 7106 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 201: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +#line 386 "sql.y" { yylhsminor.yy974 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy557, yymsp[0].minor.yy424); } +#line 7112 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; case 202: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +#line 388 "sql.y" { yylhsminor.yy974 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy974, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy557, &yymsp[0].minor.yy557); } +#line 7118 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; case 203: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ +#line 390 "sql.y" { yylhsminor.yy974 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy974, &yymsp[-2].minor.yy557, yymsp[0].minor.yy974); } +#line 7124 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; case 205: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 623: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==623); +#line 395 "sql.y" { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-1].minor.yy946, yymsp[0].minor.yy974); } +#line 7131 "sql.c" yymsp[-1].minor.yy946 = yylhsminor.yy946; break; case 206: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP tags_literal_list NK_RP table_options */ +#line 399 "sql.y" { yylhsminor.yy974 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy569, yymsp[-8].minor.yy974, yymsp[-6].minor.yy974, yymsp[-5].minor.yy946, yymsp[-2].minor.yy946, yymsp[0].minor.yy974); } +#line 7137 "sql.c" yymsp[-9].minor.yy974 = yylhsminor.yy974; break; case 209: /* drop_table_clause ::= exists_opt full_table_name */ +#line 406 "sql.y" { yylhsminor.yy974 = createDropTableClause(pCxt, yymsp[-1].minor.yy569, yymsp[0].minor.yy974); } +#line 7143 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 213: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ case 417: /* col_list_opt ::= NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==417); +#line 416 "sql.y" { yymsp[-2].minor.yy946 = yymsp[-1].minor.yy946; } +#line 7150 "sql.c" break; case 214: /* full_table_name ::= table_name */ case 358: /* full_tsma_name ::= tsma_name */ yytestcase(yyruleno==358); +#line 418 "sql.y" { yylhsminor.yy974 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy557, NULL); } +#line 7156 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 215: /* full_table_name ::= db_name NK_DOT table_name */ case 359: /* full_tsma_name ::= db_name NK_DOT tsma_name */ yytestcase(yyruleno==359); +#line 419 "sql.y" { yylhsminor.yy974 = createRealTableNode(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557, NULL); } +#line 7163 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 218: /* tag_def ::= column_name type_name */ +#line 425 "sql.y" { yylhsminor.yy974 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy557, yymsp[0].minor.yy424, NULL); } +#line 7169 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 221: /* column_def ::= column_name type_name column_options */ +#line 433 "sql.y" { yylhsminor.yy974 = createColumnDefNode(pCxt, &yymsp[-2].minor.yy557, yymsp[-1].minor.yy424, yymsp[0].minor.yy974); } +#line 7175 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 222: /* type_name ::= BOOL */ +#line 437 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_BOOL); } +#line 7181 "sql.c" break; case 223: /* type_name ::= TINYINT */ +#line 438 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_TINYINT); } +#line 7186 "sql.c" break; case 224: /* type_name ::= SMALLINT */ +#line 439 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +#line 7191 "sql.c" break; case 225: /* type_name ::= INT */ case 226: /* type_name ::= INTEGER */ yytestcase(yyruleno==226); +#line 440 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_INT); } +#line 7197 "sql.c" break; case 227: /* type_name ::= BIGINT */ +#line 442 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_BIGINT); } +#line 7202 "sql.c" break; case 228: /* type_name ::= FLOAT */ +#line 443 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_FLOAT); } +#line 7207 "sql.c" break; case 229: /* type_name ::= DOUBLE */ +#line 444 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +#line 7212 "sql.c" break; case 230: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +#line 445 "sql.y" { yymsp[-3].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +#line 7217 "sql.c" break; case 231: /* type_name ::= TIMESTAMP */ +#line 446 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +#line 7222 "sql.c" break; case 232: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +#line 447 "sql.y" { yymsp[-3].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +#line 7227 "sql.c" break; case 233: /* type_name ::= TINYINT UNSIGNED */ +#line 448 "sql.y" { yymsp[-1].minor.yy424 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +#line 7232 "sql.c" break; case 234: /* type_name ::= SMALLINT UNSIGNED */ +#line 449 "sql.y" { yymsp[-1].minor.yy424 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +#line 7237 "sql.c" break; case 235: /* type_name ::= INT UNSIGNED */ +#line 450 "sql.y" { yymsp[-1].minor.yy424 = createDataType(TSDB_DATA_TYPE_UINT); } +#line 7242 "sql.c" break; case 236: /* type_name ::= BIGINT UNSIGNED */ +#line 451 "sql.y" { yymsp[-1].minor.yy424 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +#line 7247 "sql.c" break; case 237: /* type_name ::= JSON */ +#line 452 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_JSON); } +#line 7252 "sql.c" break; case 238: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +#line 453 "sql.y" { yymsp[-3].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +#line 7257 "sql.c" break; case 239: /* type_name ::= MEDIUMBLOB */ +#line 454 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +#line 7262 "sql.c" break; case 240: /* type_name ::= BLOB */ +#line 455 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_BLOB); } +#line 7267 "sql.c" break; case 241: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +#line 456 "sql.y" { yymsp[-3].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +#line 7272 "sql.c" break; case 242: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ +#line 457 "sql.y" { yymsp[-3].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +#line 7277 "sql.c" break; case 243: /* type_name ::= DECIMAL */ +#line 458 "sql.y" { yymsp[0].minor.yy424 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 7282 "sql.c" break; case 244: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +#line 459 "sql.y" { yymsp[-3].minor.yy424 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 7287 "sql.c" break; case 245: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +#line 460 "sql.y" { yymsp[-5].minor.yy424 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 7292 "sql.c" break; case 246: /* type_name_default_len ::= BINARY */ +#line 464 "sql.y" { yymsp[0].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, NULL); } +#line 7297 "sql.c" break; case 247: /* type_name_default_len ::= NCHAR */ +#line 465 "sql.y" { yymsp[0].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, NULL); } +#line 7302 "sql.c" break; case 248: /* type_name_default_len ::= VARCHAR */ +#line 466 "sql.y" { yymsp[0].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, NULL); } +#line 7307 "sql.c" break; case 249: /* type_name_default_len ::= VARBINARY */ +#line 467 "sql.y" { yymsp[0].minor.yy424 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, NULL); } +#line 7312 "sql.c" break; case 252: /* tags_def ::= TAGS NK_LP tag_def_list NK_RP */ case 425: /* tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==425); +#line 476 "sql.y" { yymsp[-3].minor.yy946 = yymsp[-1].minor.yy946; } +#line 7318 "sql.c" break; case 253: /* table_options ::= */ +#line 478 "sql.y" { yymsp[1].minor.yy974 = createDefaultTableOptions(pCxt); } +#line 7323 "sql.c" break; case 254: /* table_options ::= table_options COMMENT NK_STRING */ +#line 479 "sql.y" { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-2].minor.yy974, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } +#line 7328 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 255: /* table_options ::= table_options MAX_DELAY duration_list */ +#line 480 "sql.y" { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-2].minor.yy974, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy946); } +#line 7334 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 256: /* table_options ::= table_options WATERMARK duration_list */ +#line 481 "sql.y" { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-2].minor.yy974, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy946); } +#line 7340 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 257: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ +#line 482 "sql.y" { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-4].minor.yy974, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy946); } +#line 7346 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; case 258: /* table_options ::= table_options TTL NK_INTEGER */ +#line 483 "sql.y" { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-2].minor.yy974, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } +#line 7352 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 259: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +#line 484 "sql.y" { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-4].minor.yy974, TABLE_OPTION_SMA, yymsp[-1].minor.yy946); } +#line 7358 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; case 260: /* table_options ::= table_options DELETE_MARK duration_list */ +#line 485 "sql.y" { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-2].minor.yy974, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy946); } +#line 7364 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 261: /* alter_table_options ::= alter_table_option */ +#line 487 "sql.y" { yylhsminor.yy974 = createAlterTableOptions(pCxt); yylhsminor.yy974 = setTableOption(pCxt, yylhsminor.yy974, yymsp[0].minor.yy683.type, &yymsp[0].minor.yy683.val); } +#line 7370 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 262: /* alter_table_options ::= alter_table_options alter_table_option */ +#line 488 "sql.y" { yylhsminor.yy974 = setTableOption(pCxt, yymsp[-1].minor.yy974, yymsp[0].minor.yy683.type, &yymsp[0].minor.yy683.val); } +#line 7376 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 263: /* alter_table_option ::= COMMENT NK_STRING */ +#line 492 "sql.y" { yymsp[-1].minor.yy683.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 7382 "sql.c" break; case 264: /* alter_table_option ::= TTL NK_INTEGER */ +#line 493 "sql.y" { yymsp[-1].minor.yy683.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy683.val = yymsp[0].minor.yy0; } +#line 7387 "sql.c" break; case 265: /* duration_list ::= duration_literal */ case 554: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==554); +#line 497 "sql.y" { yylhsminor.yy946 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } +#line 7393 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 266: /* duration_list ::= duration_list NK_COMMA duration_literal */ case 555: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==555); +#line 498 "sql.y" { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } +#line 7400 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; case 269: /* rollup_func_name ::= function_name */ +#line 505 "sql.y" { yylhsminor.yy974 = createFunctionNode(pCxt, &yymsp[0].minor.yy557, NULL); } +#line 7406 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 270: /* rollup_func_name ::= FIRST */ case 271: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==271); case 347: /* tag_item ::= QTAGS */ yytestcase(yyruleno==347); +#line 506 "sql.y" { yylhsminor.yy974 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 7414 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 274: /* col_name ::= column_name */ case 348: /* tag_item ::= column_name */ yytestcase(yyruleno==348); +#line 514 "sql.y" { yylhsminor.yy974 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy557); } +#line 7421 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 275: /* cmd ::= SHOW DNODES */ +#line 517 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } +#line 7427 "sql.c" break; case 276: /* cmd ::= SHOW USERS */ +#line 518 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } +#line 7432 "sql.c" break; case 277: /* cmd ::= SHOW USERS FULL */ +#line 519 "sql.y" { pCxt->pRootNode = createShowStmtWithFull(pCxt, QUERY_NODE_SHOW_USERS_FULL_STMT); } +#line 7437 "sql.c" break; case 278: /* cmd ::= SHOW USER PRIVILEGES */ +#line 520 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } +#line 7442 "sql.c" break; case 279: /* cmd ::= SHOW db_kind_opt DATABASES */ +#line 521 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); (void)setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy741); } +#line 7450 "sql.c" break; case 280: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ +#line 525 "sql.y" { pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy595, yymsp[0].minor.yy974, OP_TYPE_LIKE); } +#line 7457 "sql.c" break; case 281: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +#line 528 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy974, yymsp[0].minor.yy974, OP_TYPE_LIKE); } +#line 7462 "sql.c" break; case 282: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +#line 529 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy974, NULL, OP_TYPE_LIKE); } +#line 7467 "sql.c" break; case 283: /* cmd ::= SHOW MNODES */ +#line 530 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } +#line 7472 "sql.c" break; case 284: /* cmd ::= SHOW QNODES */ +#line 532 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } +#line 7477 "sql.c" break; case 285: /* cmd ::= SHOW ANODES */ +#line 533 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ANODES_STMT); } +#line 7482 "sql.c" break; case 286: /* cmd ::= SHOW ANODES FULL */ +#line 534 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ANODES_FULL_STMT); } +#line 7487 "sql.c" break; case 287: /* cmd ::= SHOW ARBGROUPS */ +#line 535 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ARBGROUPS_STMT); } +#line 7492 "sql.c" break; case 288: /* cmd ::= SHOW FUNCTIONS */ +#line 536 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } +#line 7497 "sql.c" break; case 289: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +#line 537 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy974, yymsp[-1].minor.yy974, OP_TYPE_EQUAL); } +#line 7502 "sql.c" break; case 290: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ +#line 538 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy557), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy557), OP_TYPE_EQUAL); } +#line 7507 "sql.c" break; case 291: /* cmd ::= SHOW STREAMS */ +#line 539 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } +#line 7512 "sql.c" break; case 292: /* cmd ::= SHOW ACCOUNTS */ +#line 540 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +#line 7517 "sql.c" break; case 293: /* cmd ::= SHOW APPS */ +#line 541 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } +#line 7522 "sql.c" break; case 294: /* cmd ::= SHOW CONNECTIONS */ +#line 542 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } +#line 7527 "sql.c" break; case 295: /* cmd ::= SHOW LICENCES */ case 296: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==296); +#line 543 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } +#line 7533 "sql.c" break; case 297: /* cmd ::= SHOW GRANTS FULL */ +#line 545 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_FULL_STMT); } +#line 7538 "sql.c" break; case 298: /* cmd ::= SHOW GRANTS LOGS */ +#line 546 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_LOGS_STMT); } +#line 7543 "sql.c" break; case 299: /* cmd ::= SHOW CLUSTER MACHINES */ +#line 547 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); } +#line 7548 "sql.c" break; case 300: /* cmd ::= SHOW CREATE DATABASE db_name */ +#line 548 "sql.y" { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy557); } +#line 7553 "sql.c" break; case 301: /* cmd ::= SHOW CREATE TABLE full_table_name */ +#line 549 "sql.y" { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy974); } +#line 7558 "sql.c" break; case 302: /* cmd ::= SHOW CREATE STABLE full_table_name */ +#line 550 "sql.y" { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy974); } +#line 7564 "sql.c" break; case 303: /* cmd ::= SHOW ENCRYPTIONS */ +#line 552 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ENCRYPTIONS_STMT); } +#line 7569 "sql.c" break; case 304: /* cmd ::= SHOW QUERIES */ +#line 553 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } +#line 7574 "sql.c" break; case 305: /* cmd ::= SHOW SCORES */ +#line 554 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } +#line 7579 "sql.c" break; case 306: /* cmd ::= SHOW TOPICS */ +#line 555 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } +#line 7584 "sql.c" break; case 307: /* cmd ::= SHOW VARIABLES */ case 308: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==308); +#line 556 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } +#line 7590 "sql.c" break; case 309: /* cmd ::= SHOW LOCAL VARIABLES */ +#line 558 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } +#line 7595 "sql.c" break; case 310: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ +#line 559 "sql.y" { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy974); } +#line 7600 "sql.c" break; case 311: /* cmd ::= SHOW BNODES */ +#line 560 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } +#line 7605 "sql.c" break; case 312: /* cmd ::= SHOW SNODES */ +#line 561 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } +#line 7610 "sql.c" break; case 313: /* cmd ::= SHOW CLUSTER */ +#line 562 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } +#line 7615 "sql.c" break; case 314: /* cmd ::= SHOW TRANSACTIONS */ +#line 563 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } +#line 7620 "sql.c" break; case 315: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +#line 564 "sql.y" { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy974); } +#line 7625 "sql.c" break; case 316: /* cmd ::= SHOW CONSUMERS */ +#line 565 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } +#line 7630 "sql.c" break; case 317: /* cmd ::= SHOW SUBSCRIPTIONS */ +#line 566 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } +#line 7635 "sql.c" break; case 318: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ +#line 567 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy974, yymsp[-1].minor.yy974, OP_TYPE_EQUAL); } +#line 7640 "sql.c" break; case 319: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ +#line 568 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy557), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy557), OP_TYPE_EQUAL); } +#line 7645 "sql.c" break; case 320: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ +#line 569 "sql.y" { pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy974, yymsp[0].minor.yy974, yymsp[-3].minor.yy946); } +#line 7650 "sql.c" break; case 321: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ +#line 570 "sql.y" { pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy557), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy557), yymsp[-4].minor.yy946); } +#line 7655 "sql.c" break; case 322: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ +#line 571 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } +#line 7660 "sql.c" break; case 323: /* cmd ::= SHOW VNODES */ +#line 572 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } +#line 7665 "sql.c" break; case 324: /* cmd ::= SHOW db_name_cond_opt ALIVE */ +#line 574 "sql.y" { pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy974, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +#line 7670 "sql.c" break; case 325: /* cmd ::= SHOW CLUSTER ALIVE */ +#line 575 "sql.y" { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } +#line 7675 "sql.c" break; case 326: /* cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ +#line 576 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy974, yymsp[0].minor.yy974, OP_TYPE_LIKE); } +#line 7680 "sql.c" break; case 327: /* cmd ::= SHOW CREATE VIEW full_table_name */ +#line 577 "sql.y" { pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy974); } +#line 7685 "sql.c" break; case 328: /* cmd ::= SHOW COMPACTS */ +#line 578 "sql.y" { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } +#line 7690 "sql.c" break; case 329: /* cmd ::= SHOW COMPACT NK_INTEGER */ +#line 579 "sql.y" { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 7695 "sql.c" break; case 330: /* table_kind_db_name_cond_opt ::= */ +#line 583 "sql.y" { yymsp[1].minor.yy595.kind = SHOW_KIND_ALL; yymsp[1].minor.yy595.dbName = nil_token; } +#line 7700 "sql.c" break; case 331: /* table_kind_db_name_cond_opt ::= table_kind */ +#line 584 "sql.y" { yylhsminor.yy595.kind = yymsp[0].minor.yy741; yylhsminor.yy595.dbName = nil_token; } +#line 7705 "sql.c" yymsp[0].minor.yy595 = yylhsminor.yy595; break; case 332: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ +#line 585 "sql.y" { yylhsminor.yy595.kind = SHOW_KIND_ALL; yylhsminor.yy595.dbName = yymsp[-1].minor.yy557; } +#line 7711 "sql.c" yymsp[-1].minor.yy595 = yylhsminor.yy595; break; case 333: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ +#line 586 "sql.y" { yylhsminor.yy595.kind = yymsp[-2].minor.yy741; yylhsminor.yy595.dbName = yymsp[-1].minor.yy557; } +#line 7717 "sql.c" yymsp[-2].minor.yy595 = yylhsminor.yy595; break; case 334: /* table_kind ::= NORMAL */ +#line 590 "sql.y" { yymsp[0].minor.yy741 = SHOW_KIND_TABLES_NORMAL; } +#line 7723 "sql.c" break; case 335: /* table_kind ::= CHILD */ +#line 591 "sql.y" { yymsp[0].minor.yy741 = SHOW_KIND_TABLES_CHILD; } +#line 7728 "sql.c" break; case 336: /* db_name_cond_opt ::= */ case 341: /* from_db_opt ::= */ yytestcase(yyruleno==341); +#line 593 "sql.y" { yymsp[1].minor.yy974 = createDefaultDatabaseCondValue(pCxt); } +#line 7734 "sql.c" break; case 337: /* db_name_cond_opt ::= db_name NK_DOT */ +#line 594 "sql.y" { yylhsminor.yy974 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy557); } +#line 7739 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 339: /* like_pattern_opt ::= LIKE NK_STRING */ +#line 597 "sql.y" { yymsp[-1].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 7745 "sql.c" break; case 340: /* table_name_cond ::= table_name */ +#line 599 "sql.y" { yylhsminor.yy974 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy557); } +#line 7750 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 342: /* from_db_opt ::= FROM db_name */ +#line 602 "sql.y" { yymsp[-1].minor.yy974 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy557); } +#line 7756 "sql.c" break; case 346: /* tag_item ::= TBNAME */ +#line 610 "sql.y" { yylhsminor.yy974 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } +#line 7761 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 349: /* tag_item ::= column_name column_alias */ +#line 613 "sql.y" { yylhsminor.yy974 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy557), &yymsp[0].minor.yy557); } +#line 7767 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 350: /* tag_item ::= column_name AS column_alias */ +#line 614 "sql.y" { yylhsminor.yy974 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy557), &yymsp[0].minor.yy557); } +#line 7773 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 351: /* db_kind_opt ::= */ +#line 618 "sql.y" { yymsp[1].minor.yy741 = SHOW_KIND_ALL; } +#line 7779 "sql.c" break; case 352: /* db_kind_opt ::= USER */ +#line 619 "sql.y" { yymsp[0].minor.yy741 = SHOW_KIND_DATABASES_USER; } +#line 7784 "sql.c" break; case 353: /* db_kind_opt ::= SYSTEM */ +#line 620 "sql.y" { yymsp[0].minor.yy741 = SHOW_KIND_DATABASES_SYSTEM; } +#line 7789 "sql.c" break; case 354: /* cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP */ +#line 626 "sql.y" { pCxt->pRootNode = createCreateTSMAStmt(pCxt, yymsp[-8].minor.yy569, &yymsp[-7].minor.yy557, yymsp[-4].minor.yy974, yymsp[-5].minor.yy974, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } +#line 7794 "sql.c" break; case 355: /* cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP */ +#line 628 "sql.y" { pCxt->pRootNode = createCreateTSMAStmt(pCxt, yymsp[-7].minor.yy569, &yymsp[-6].minor.yy557, NULL, yymsp[-4].minor.yy974, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } +#line 7799 "sql.c" break; case 356: /* cmd ::= DROP TSMA exists_opt full_tsma_name */ +#line 629 "sql.y" { pCxt->pRootNode = createDropTSMAStmt(pCxt, yymsp[-1].minor.yy569, yymsp[0].minor.yy974); } +#line 7804 "sql.c" break; case 357: /* cmd ::= SHOW db_name_cond_opt TSMAS */ +#line 630 "sql.y" { pCxt->pRootNode = createShowTSMASStmt(pCxt, yymsp[-1].minor.yy974); } +#line 7809 "sql.c" break; case 360: /* tsma_func_list ::= FUNCTION NK_LP func_list NK_RP */ +#line 637 "sql.y" { yymsp[-3].minor.yy974 = createTSMAOptions(pCxt, yymsp[-1].minor.yy946); } +#line 7814 "sql.c" break; case 361: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ +#line 641 "sql.y" { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy569, yymsp[-3].minor.yy974, yymsp[-1].minor.yy974, NULL, yymsp[0].minor.yy974); } +#line 7819 "sql.c" break; case 362: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ +#line 643 "sql.y" { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy569, yymsp[-5].minor.yy974, yymsp[-3].minor.yy974, yymsp[-1].minor.yy946, NULL); } +#line 7824 "sql.c" break; case 363: /* cmd ::= DROP INDEX exists_opt full_index_name */ +#line 644 "sql.y" { pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy569, yymsp[0].minor.yy974); } +#line 7829 "sql.c" break; case 364: /* full_index_name ::= index_name */ +#line 646 "sql.y" { yylhsminor.yy974 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy557); } +#line 7834 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 365: /* full_index_name ::= db_name NK_DOT index_name */ +#line 647 "sql.y" { yylhsminor.yy974 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557); } +#line 7840 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 366: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +#line 650 "sql.y" { yymsp[-9].minor.yy974 = createIndexOption(pCxt, yymsp[-7].minor.yy946, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), NULL, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } +#line 7846 "sql.c" break; case 367: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +#line 653 "sql.y" { yymsp[-11].minor.yy974 = createIndexOption(pCxt, yymsp[-9].minor.yy946, releaseRawExprNode(pCxt, yymsp[-5].minor.yy974), releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } +#line 7851 "sql.c" break; case 370: /* func ::= sma_func_name NK_LP expression_list NK_RP */ +#line 660 "sql.y" { yylhsminor.yy974 = createFunctionNode(pCxt, &yymsp[-3].minor.yy557, yymsp[-1].minor.yy946); } +#line 7856 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 371: /* sma_func_name ::= function_name */ case 666: /* alias_opt ::= table_alias */ yytestcase(yyruleno==666); +#line 664 "sql.y" { yylhsminor.yy557 = yymsp[0].minor.yy557; } +#line 7863 "sql.c" yymsp[0].minor.yy557 = yylhsminor.yy557; break; case 376: /* sma_stream_opt ::= */ case 426: /* stream_options ::= */ yytestcase(yyruleno==426); +#line 670 "sql.y" { yymsp[1].minor.yy974 = createStreamOptions(pCxt); } +#line 7870 "sql.c" break; case 377: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ +#line 671 "sql.y" { ((SStreamOptions*)yymsp[-2].minor.yy974)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = yymsp[-2].minor.yy974; } +#line 7875 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 378: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +#line 672 "sql.y" { ((SStreamOptions*)yymsp[-2].minor.yy974)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = yymsp[-2].minor.yy974; } +#line 7881 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 379: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +#line 673 "sql.y" { ((SStreamOptions*)yymsp[-2].minor.yy974)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = yymsp[-2].minor.yy974; } +#line 7887 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 380: /* with_meta ::= AS */ +#line 678 "sql.y" { yymsp[0].minor.yy904 = 0; } +#line 7893 "sql.c" break; case 381: /* with_meta ::= WITH META AS */ +#line 679 "sql.y" { yymsp[-2].minor.yy904 = 1; } +#line 7898 "sql.c" break; case 382: /* with_meta ::= ONLY META AS */ +#line 680 "sql.y" { yymsp[-2].minor.yy904 = 2; } +#line 7903 "sql.c" break; case 383: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +#line 682 "sql.y" { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy569, &yymsp[-2].minor.yy557, yymsp[0].minor.yy974); } +#line 7908 "sql.c" break; case 384: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ +#line 684 "sql.y" { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy569, &yymsp[-3].minor.yy557, &yymsp[0].minor.yy557, yymsp[-2].minor.yy904); } +#line 7913 "sql.c" break; case 385: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ +#line 686 "sql.y" { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy569, &yymsp[-4].minor.yy557, yymsp[-1].minor.yy974, yymsp[-3].minor.yy904, yymsp[0].minor.yy974); } +#line 7918 "sql.c" break; case 386: /* cmd ::= DROP TOPIC exists_opt topic_name */ +#line 688 "sql.y" { pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } +#line 7923 "sql.c" break; case 387: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +#line 689 "sql.y" { pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy569, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557); } +#line 7928 "sql.c" break; case 388: /* cmd ::= DESC full_table_name */ case 389: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==389); +#line 692 "sql.y" { pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy974); } +#line 7934 "sql.c" break; case 390: /* cmd ::= RESET QUERY CACHE */ +#line 696 "sql.y" { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } +#line 7939 "sql.c" break; case 391: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ case 392: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==392); +#line 699 "sql.y" { pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy569, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } +#line 7945 "sql.c" break; case 395: /* explain_options ::= */ +#line 707 "sql.y" { yymsp[1].minor.yy974 = createDefaultExplainOptions(pCxt); } +#line 7950 "sql.c" break; case 396: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +#line 708 "sql.y" { yylhsminor.yy974 = setExplainVerbose(pCxt, yymsp[-2].minor.yy974, &yymsp[0].minor.yy0); } +#line 7955 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 397: /* explain_options ::= explain_options RATIO NK_FLOAT */ +#line 709 "sql.y" { yylhsminor.yy974 = setExplainRatio(pCxt, yymsp[-2].minor.yy974, &yymsp[0].minor.yy0); } +#line 7961 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 398: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ +#line 714 "sql.y" { pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy569, yymsp[-9].minor.yy569, &yymsp[-6].minor.yy557, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy424, yymsp[-1].minor.yy904, &yymsp[0].minor.yy557, yymsp[-10].minor.yy569); } +#line 7967 "sql.c" break; case 399: /* cmd ::= DROP FUNCTION exists_opt function_name */ +#line 715 "sql.y" { pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } +#line 7972 "sql.c" break; case 404: /* language_opt ::= */ case 449: /* on_vgroup_id ::= */ yytestcase(yyruleno==449); +#line 729 "sql.y" { yymsp[1].minor.yy557 = nil_token; } +#line 7978 "sql.c" break; case 405: /* language_opt ::= LANGUAGE NK_STRING */ case 450: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==450); +#line 730 "sql.y" { yymsp[-1].minor.yy557 = yymsp[0].minor.yy0; } +#line 7984 "sql.c" break; case 408: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ +#line 739 "sql.y" { pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy569, yymsp[-2].minor.yy974, &yymsp[-1].minor.yy0, yymsp[0].minor.yy974); } +#line 7989 "sql.c" break; case 409: /* cmd ::= DROP VIEW exists_opt full_view_name */ +#line 740 "sql.y" { pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy569, yymsp[0].minor.yy974); } +#line 7994 "sql.c" break; case 410: /* full_view_name ::= view_name */ +#line 742 "sql.y" { yylhsminor.yy974 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy557); } +#line 7999 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 411: /* full_view_name ::= db_name NK_DOT view_name */ +#line 743 "sql.y" { yylhsminor.yy974 = createViewNode(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557); } +#line 8005 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 412: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ +#line 748 "sql.y" { pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy569, &yymsp[-8].minor.yy557, yymsp[-5].minor.yy974, yymsp[-7].minor.yy974, yymsp[-3].minor.yy946, yymsp[-2].minor.yy974, yymsp[0].minor.yy974, yymsp[-4].minor.yy946); } +#line 8011 "sql.c" break; case 413: /* cmd ::= DROP STREAM exists_opt stream_name */ +#line 749 "sql.y" { pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } +#line 8016 "sql.c" break; case 414: /* cmd ::= PAUSE STREAM exists_opt stream_name */ +#line 750 "sql.y" { pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } +#line 8021 "sql.c" break; case 415: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ +#line 751 "sql.y" { pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy569, yymsp[-1].minor.yy569, &yymsp[0].minor.yy557); } +#line 8026 "sql.c" break; case 420: /* column_stream_def ::= column_name stream_col_options */ +#line 764 "sql.y" { yylhsminor.yy974 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy557, createDataType(TSDB_DATA_TYPE_NULL), yymsp[0].minor.yy974); } +#line 8031 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 421: /* stream_col_options ::= */ case 781: /* column_options ::= */ yytestcase(yyruleno==781); +#line 765 "sql.y" { yymsp[1].minor.yy974 = createDefaultColumnOptions(pCxt); } +#line 8038 "sql.c" break; case 422: /* stream_col_options ::= stream_col_options PRIMARY KEY */ case 782: /* column_options ::= column_options PRIMARY KEY */ yytestcase(yyruleno==782); +#line 766 "sql.y" { yylhsminor.yy974 = setColumnOptionsPK(pCxt, yymsp[-2].minor.yy974); } +#line 8044 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 427: /* stream_options ::= stream_options TRIGGER AT_ONCE */ case 428: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==428); +#line 776 "sql.y" { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-2].minor.yy974, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } +#line 8051 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 429: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +#line 778 "sql.y" { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-3].minor.yy974, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } +#line 8057 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 430: /* stream_options ::= stream_options WATERMARK duration_literal */ +#line 779 "sql.y" { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-2].minor.yy974, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } +#line 8063 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 431: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +#line 780 "sql.y" { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-3].minor.yy974, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } +#line 8069 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 432: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +#line 781 "sql.y" { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-2].minor.yy974, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } +#line 8075 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 433: /* stream_options ::= stream_options DELETE_MARK duration_literal */ +#line 782 "sql.y" { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-2].minor.yy974, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } +#line 8081 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 434: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ +#line 783 "sql.y" { yylhsminor.yy974 = setStreamOptions(pCxt, yymsp[-3].minor.yy974, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } +#line 8087 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 436: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ case 725: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==725); case 749: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==749); +#line 786 "sql.y" { yymsp[-3].minor.yy974 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy974); } +#line 8095 "sql.c" break; case 439: /* cmd ::= KILL CONNECTION NK_INTEGER */ +#line 794 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } +#line 8100 "sql.c" break; case 440: /* cmd ::= KILL QUERY NK_STRING */ +#line 795 "sql.y" { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } +#line 8105 "sql.c" break; case 441: /* cmd ::= KILL TRANSACTION NK_INTEGER */ +#line 796 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } +#line 8110 "sql.c" break; case 442: /* cmd ::= KILL COMPACT NK_INTEGER */ +#line 797 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_COMPACT_STMT, &yymsp[0].minor.yy0); } +#line 8115 "sql.c" break; case 443: /* cmd ::= BALANCE VGROUP */ +#line 800 "sql.y" { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } +#line 8120 "sql.c" break; case 444: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ +#line 801 "sql.y" { pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy557); } +#line 8125 "sql.c" break; case 445: /* cmd ::= BALANCE VGROUP LEADER DATABASE db_name */ +#line 802 "sql.y" { pCxt->pRootNode = createBalanceVgroupLeaderDBNameStmt(pCxt, &yymsp[0].minor.yy557); } +#line 8130 "sql.c" break; case 446: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ +#line 803 "sql.y" { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 8135 "sql.c" break; case 447: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +#line 804 "sql.y" { pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy946); } +#line 8140 "sql.c" break; case 448: /* cmd ::= SPLIT VGROUP NK_INTEGER */ +#line 805 "sql.y" { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } +#line 8145 "sql.c" break; case 451: /* dnode_list ::= DNODE NK_INTEGER */ +#line 814 "sql.y" { yymsp[-1].minor.yy946 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 8150 "sql.c" break; case 453: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +#line 821 "sql.y" { pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } +#line 8155 "sql.c" break; case 456: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +#line 830 "sql.y" { yymsp[-6].minor.yy974 = createInsertStmt(pCxt, yymsp[-4].minor.yy974, yymsp[-2].minor.yy946, yymsp[0].minor.yy974); } +#line 8160 "sql.c" break; case 457: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ +#line 831 "sql.y" { yymsp[-3].minor.yy974 = createInsertStmt(pCxt, yymsp[-1].minor.yy974, NULL, yymsp[0].minor.yy974); } +#line 8165 "sql.c" break; case 458: /* tags_literal ::= NK_INTEGER */ case 470: /* tags_literal ::= NK_BIN */ yytestcase(yyruleno==470); case 479: /* tags_literal ::= NK_HEX */ yytestcase(yyruleno==479); +#line 834 "sql.y" { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0, NULL); } +#line 8172 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 459: /* tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ @@ -7030,12 +8180,14 @@ yymsp[0].minor.yy974); } case 481: /* tags_literal ::= NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==481); case 489: /* tags_literal ::= NK_STRING NK_PLUS duration_literal */ yytestcase(yyruleno==489); case 490: /* tags_literal ::= NK_STRING NK_MINUS duration_literal */ yytestcase(yyruleno==490); +#line 835 "sql.y" { SToken l = yymsp[-2].minor.yy0; SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); l.n = (r.z + r.n) - l.z; yylhsminor.yy974 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy974); } +#line 8190 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 461: /* tags_literal ::= NK_PLUS NK_INTEGER */ @@ -7044,11 +8196,13 @@ yymsp[0].minor.yy974); } case 476: /* tags_literal ::= NK_MINUS NK_BIN */ yytestcase(yyruleno==476); case 482: /* tags_literal ::= NK_PLUS NK_HEX */ yytestcase(yyruleno==482); case 485: /* tags_literal ::= NK_MINUS NK_HEX */ yytestcase(yyruleno==485); +#line 847 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); } +#line 8205 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 462: /* tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ @@ -7063,71 +8217,97 @@ yymsp[0].minor.yy974); } case 484: /* tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==484); case 486: /* tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==486); case 487: /* tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==487); +#line 852 "sql.y" { SToken l = yymsp[-3].minor.yy0; SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); l.n = (r.z + r.n) - l.z; yylhsminor.yy974 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy974); } +#line 8227 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 467: /* tags_literal ::= NK_FLOAT */ +#line 881 "sql.y" { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0, NULL); } +#line 8233 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 468: /* tags_literal ::= NK_PLUS NK_FLOAT */ case 469: /* tags_literal ::= NK_MINUS NK_FLOAT */ yytestcase(yyruleno==469); +#line 882 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); } +#line 8244 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 488: /* tags_literal ::= NK_STRING */ +#line 988 "sql.y" { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0, NULL); } +#line 8250 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 491: /* tags_literal ::= NK_BOOL */ +#line 1001 "sql.y" { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0, NULL); } +#line 8256 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 492: /* tags_literal ::= NULL */ +#line 1002 "sql.y" { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0, NULL); } +#line 8262 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 493: /* tags_literal ::= literal_func */ +#line 1004 "sql.y" { yylhsminor.yy974 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, yymsp[0].minor.yy974); } +#line 8268 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 494: /* tags_literal ::= literal_func NK_PLUS duration_literal */ case 495: /* tags_literal ::= literal_func NK_MINUS duration_literal */ yytestcase(yyruleno==495); +#line 1005 "sql.y" { SToken l = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); l.n = (r.z + r.n) - l.z; yylhsminor.yy974 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, yymsp[-2].minor.yy974, yymsp[0].minor.yy974); } +#line 8280 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 498: /* literal ::= NK_INTEGER */ +#line 1024 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } +#line 8286 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 499: /* literal ::= NK_FLOAT */ +#line 1025 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } +#line 8292 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 500: /* literal ::= NK_STRING */ +#line 1026 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 8298 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 501: /* literal ::= NK_BOOL */ +#line 1027 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } +#line 8304 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 502: /* literal ::= TIMESTAMP NK_STRING */ +#line 1028 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } +#line 8310 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 503: /* literal ::= duration_literal */ @@ -7151,64 +8331,90 @@ yymsp[0].minor.yy974); } case 752: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==752); case 755: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==755); case 757: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==757); +#line 1029 "sql.y" { yylhsminor.yy974 = yymsp[0].minor.yy974; } +#line 8336 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 504: /* literal ::= NULL */ +#line 1030 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } +#line 8342 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 505: /* literal ::= NK_QUESTION */ +#line 1031 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 8348 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 506: /* duration_literal ::= NK_VARIABLE */ case 726: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==726); case 727: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==727); case 728: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==728); +#line 1033 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 8357 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 507: /* signed ::= NK_INTEGER */ +#line 1035 "sql.y" { yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 8363 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 508: /* signed ::= NK_PLUS NK_INTEGER */ +#line 1036 "sql.y" { yymsp[-1].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 8369 "sql.c" break; case 509: /* signed ::= NK_MINUS NK_INTEGER */ +#line 1037 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } +#line 8378 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 510: /* signed ::= NK_FLOAT */ +#line 1042 "sql.y" { yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 8384 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 511: /* signed ::= NK_PLUS NK_FLOAT */ +#line 1043 "sql.y" { yymsp[-1].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 8390 "sql.c" break; case 512: /* signed ::= NK_MINUS NK_FLOAT */ +#line 1044 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } +#line 8399 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 514: /* signed_literal ::= NK_STRING */ +#line 1051 "sql.y" { yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 8405 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 515: /* signed_literal ::= NK_BOOL */ +#line 1052 "sql.y" { yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } +#line 8411 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 516: /* signed_literal ::= TIMESTAMP NK_STRING */ +#line 1053 "sql.y" { yymsp[-1].minor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 8417 "sql.c" break; case 517: /* signed_literal ::= duration_literal */ case 519: /* signed_literal ::= literal_func */ yytestcase(yyruleno==519); @@ -7218,118 +8424,156 @@ yymsp[0].minor.yy974); } case 756: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==756); case 758: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==758); case 771: /* search_condition ::= common_expression */ yytestcase(yyruleno==771); +#line 1054 "sql.y" { yylhsminor.yy974 = releaseRawExprNode(pCxt, yymsp[0].minor.yy974); } +#line 8429 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 518: /* signed_literal ::= NULL */ +#line 1055 "sql.y" { yylhsminor.yy974 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } +#line 8435 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 520: /* signed_literal ::= NK_QUESTION */ +#line 1057 "sql.y" { yylhsminor.yy974 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } +#line 8441 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 539: /* expression ::= pseudo_column */ +#line 1123 "sql.y" { yylhsminor.yy974 = yymsp[0].minor.yy974; (void)setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy974, true); } +#line 8447 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 543: /* expression ::= NK_LP expression NK_RP */ case 652: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==652); case 770: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==770); +#line 1127 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } +#line 8455 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 544: /* expression ::= NK_PLUS expr_or_subquery */ +#line 1128 "sql.y" { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } +#line 8464 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 545: /* expression ::= NK_MINUS expr_or_subquery */ +#line 1132 "sql.y" { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy974), NULL)); } +#line 8473 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 546: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ +#line 1136 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8483 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 547: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ +#line 1141 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8493 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 548: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ +#line 1146 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8503 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 549: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ +#line 1151 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8513 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 550: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ +#line 1156 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8523 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 551: /* expression ::= column_reference NK_ARROW NK_STRING */ +#line 1161 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } +#line 8532 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 552: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ +#line 1165 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8542 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 553: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ +#line 1170 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8552 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 556: /* column_reference ::= column_name */ +#line 1181 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy557, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy557)); } +#line 8558 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 557: /* column_reference ::= table_name NK_DOT column_name */ +#line 1182 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557, createColumnNode(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy557)); } +#line 8564 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 558: /* column_reference ::= NK_ALIAS */ +#line 1183 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 8570 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 559: /* column_reference ::= table_name NK_DOT NK_ALIAS */ +#line 1184 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0)); } +#line 8576 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 560: /* pseudo_column ::= ROWTS */ @@ -7348,290 +8592,427 @@ yymsp[0].minor.yy974); } case 574: /* pseudo_column ::= FROWTS */ yytestcase(yyruleno==574); case 591: /* literal_func ::= NOW */ yytestcase(yyruleno==591); case 592: /* literal_func ::= TODAY */ yytestcase(yyruleno==592); +#line 1186 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } +#line 8597 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 562: /* pseudo_column ::= table_name NK_DOT TBNAME */ +#line 1188 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy557)))); } +#line 8603 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 575: /* function_expression ::= function_name NK_LP expression_list NK_RP */ case 576: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==576); case 584: /* function_expression ::= substr_func NK_LP expression_list NK_RP */ yytestcase(yyruleno==584); +#line 1202 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy557, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy557, yymsp[-1].minor.yy946)); } +#line 8611 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 577: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ case 578: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ yytestcase(yyruleno==578); +#line 1205 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), yymsp[-1].minor.yy424)); } +#line 8618 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; case 579: /* function_expression ::= POSITION NK_LP expr_or_subquery IN expr_or_subquery NK_RP */ +#line 1209 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createPositionFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974))); } +#line 8624 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; case 580: /* function_expression ::= TRIM NK_LP expr_or_subquery NK_RP */ +#line 1211 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createTrimFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), TRIM_TYPE_BOTH)); } +#line 8630 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 581: /* function_expression ::= TRIM NK_LP trim_specification_type FROM expr_or_subquery NK_RP */ +#line 1213 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createTrimFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), yymsp[-3].minor.yy300)); } +#line 8636 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; case 582: /* function_expression ::= TRIM NK_LP expr_or_subquery FROM expr_or_subquery NK_RP */ +#line 1215 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createTrimFunctionNodeExt(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), TRIM_TYPE_BOTH)); } +#line 8642 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; case 583: /* function_expression ::= TRIM NK_LP trim_specification_type expr_or_subquery FROM expr_or_subquery NK_RP */ +#line 1217 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-6].minor.yy0, &yymsp[0].minor.yy0, createTrimFunctionNodeExt(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), yymsp[-4].minor.yy300)); } +#line 8648 "sql.c" yymsp[-6].minor.yy974 = yylhsminor.yy974; break; case 585: /* function_expression ::= substr_func NK_LP expr_or_subquery FROM expr_or_subquery NK_RP */ +#line 1221 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy557, &yymsp[0].minor.yy0, createSubstrFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974))); } +#line 8654 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; case 586: /* function_expression ::= substr_func NK_LP expr_or_subquery FROM expr_or_subquery FOR expr_or_subquery NK_RP */ +#line 1223 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-7].minor.yy557, &yymsp[0].minor.yy0, createSubstrFunctionNodeExt(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy974), releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974))); } +#line 8660 "sql.c" yymsp[-7].minor.yy974 = yylhsminor.yy974; break; case 587: /* function_expression ::= REPLACE NK_LP expression_list NK_RP */ case 594: /* rand_func ::= RAND NK_LP expression_list NK_RP */ yytestcase(yyruleno==594); +#line 1224 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy946)); } +#line 8667 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 590: /* literal_func ::= noarg_func NK_LP NK_RP */ +#line 1228 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy557, NULL)); } +#line 8673 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 593: /* rand_func ::= RAND NK_LP NK_RP */ +#line 1232 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy0, NULL)); } +#line 8679 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 597: /* trim_specification_type ::= BOTH */ +#line 1242 "sql.y" { yymsp[0].minor.yy300 = TRIM_TYPE_BOTH; } +#line 8685 "sql.c" break; case 598: /* trim_specification_type ::= TRAILING */ +#line 1243 "sql.y" { yymsp[0].minor.yy300 = TRIM_TYPE_TRAILING; } +#line 8690 "sql.c" break; case 599: /* trim_specification_type ::= LEADING */ +#line 1244 "sql.y" { yymsp[0].minor.yy300 = TRIM_TYPE_LEADING; } +#line 8695 "sql.c" break; case 614: /* star_func_para_list ::= NK_STAR */ +#line 1268 "sql.y" { yylhsminor.yy946 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 8700 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 619: /* star_func_para ::= table_name NK_DOT NK_STAR */ case 704: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==704); +#line 1277 "sql.y" { yylhsminor.yy974 = createColumnNode(pCxt, &yymsp[-2].minor.yy557, &yymsp[0].minor.yy0); } +#line 8707 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 620: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +#line 1280 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy946, yymsp[-1].minor.yy974)); } +#line 8713 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 621: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +#line 1282 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), yymsp[-2].minor.yy946, yymsp[-1].minor.yy974)); } +#line 8719 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; case 624: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +#line 1289 "sql.y" { yymsp[-3].minor.yy974 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974)); } +#line 8725 "sql.c" break; case 626: /* case_when_else_opt ::= ELSE common_expression */ +#line 1292 "sql.y" { yymsp[-1].minor.yy974 = releaseRawExprNode(pCxt, yymsp[0].minor.yy974); } +#line 8730 "sql.c" break; case 627: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ case 632: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==632); +#line 1295 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy140, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8740 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 628: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ +#line 1302 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy974), releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8750 "sql.c" yymsp[-4].minor.yy974 = yylhsminor.yy974; break; case 629: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ +#line 1308 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy974), releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8760 "sql.c" yymsp[-5].minor.yy974 = yylhsminor.yy974; break; case 630: /* predicate ::= expr_or_subquery IS NULL */ +#line 1313 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), NULL)); } +#line 8769 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 631: /* predicate ::= expr_or_subquery IS NOT NULL */ +#line 1317 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), NULL)); } +#line 8778 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 633: /* compare_op ::= NK_LT */ +#line 1329 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_LOWER_THAN; } +#line 8784 "sql.c" break; case 634: /* compare_op ::= NK_GT */ +#line 1330 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_GREATER_THAN; } +#line 8789 "sql.c" break; case 635: /* compare_op ::= NK_LE */ +#line 1331 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_LOWER_EQUAL; } +#line 8794 "sql.c" break; case 636: /* compare_op ::= NK_GE */ +#line 1332 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_GREATER_EQUAL; } +#line 8799 "sql.c" break; case 637: /* compare_op ::= NK_NE */ +#line 1333 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_NOT_EQUAL; } +#line 8804 "sql.c" break; case 638: /* compare_op ::= NK_EQ */ +#line 1334 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_EQUAL; } +#line 8809 "sql.c" break; case 639: /* compare_op ::= LIKE */ +#line 1335 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_LIKE; } +#line 8814 "sql.c" break; case 640: /* compare_op ::= NOT LIKE */ +#line 1336 "sql.y" { yymsp[-1].minor.yy140 = OP_TYPE_NOT_LIKE; } +#line 8819 "sql.c" break; case 641: /* compare_op ::= MATCH */ +#line 1337 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_MATCH; } +#line 8824 "sql.c" break; case 642: /* compare_op ::= NMATCH */ +#line 1338 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_NMATCH; } +#line 8829 "sql.c" break; case 643: /* compare_op ::= CONTAINS */ +#line 1339 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_JSON_CONTAINS; } +#line 8834 "sql.c" break; case 644: /* in_op ::= IN */ +#line 1343 "sql.y" { yymsp[0].minor.yy140 = OP_TYPE_IN; } +#line 8839 "sql.c" break; case 645: /* in_op ::= NOT IN */ +#line 1344 "sql.y" { yymsp[-1].minor.yy140 = OP_TYPE_NOT_IN; } +#line 8844 "sql.c" break; case 646: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +#line 1346 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy946)); } +#line 8849 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 648: /* boolean_value_expression ::= NOT boolean_primary */ +#line 1350 "sql.y" { SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy974), NULL)); } +#line 8858 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 649: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ +#line 1355 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8868 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 650: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ +#line 1361 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy974); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy974); yylhsminor.yy974 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 8878 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 658: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +#line 1379 "sql.y" { yylhsminor.yy974 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, JOIN_STYPE_NONE, yymsp[-2].minor.yy974, yymsp[0].minor.yy974, NULL); } +#line 8884 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 661: /* table_primary ::= table_name alias_opt */ +#line 1385 "sql.y" { yylhsminor.yy974 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy557, &yymsp[0].minor.yy557); } +#line 8890 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 662: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +#line 1386 "sql.y" { yylhsminor.yy974 = createRealTableNode(pCxt, &yymsp[-3].minor.yy557, &yymsp[-1].minor.yy557, &yymsp[0].minor.yy557); } +#line 8896 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 663: /* table_primary ::= subquery alias_opt */ +#line 1387 "sql.y" { yylhsminor.yy974 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), &yymsp[0].minor.yy557); } +#line 8902 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 665: /* alias_opt ::= */ +#line 1392 "sql.y" { yymsp[1].minor.yy557 = nil_token; } +#line 8908 "sql.c" break; case 667: /* alias_opt ::= AS table_alias */ +#line 1394 "sql.y" { yymsp[-1].minor.yy557 = yymsp[0].minor.yy557; } +#line 8913 "sql.c" break; case 668: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ case 669: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==669); +#line 1396 "sql.y" { yymsp[-2].minor.yy974 = yymsp[-1].minor.yy974; } +#line 8919 "sql.c" break; case 670: /* joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ +#line 1402 "sql.y" { yylhsminor.yy974 = createJoinTableNode(pCxt, yymsp[-6].minor.yy792, yymsp[-5].minor.yy744, yymsp[-7].minor.yy974, yymsp[-3].minor.yy974, yymsp[-2].minor.yy974); yylhsminor.yy974 = addWindowOffsetClause(pCxt, yylhsminor.yy974, yymsp[-1].minor.yy974); yylhsminor.yy974 = addJLimitClause(pCxt, yylhsminor.yy974, yymsp[0].minor.yy974); } +#line 8928 "sql.c" yymsp[-7].minor.yy974 = yylhsminor.yy974; break; case 671: /* join_type ::= */ +#line 1410 "sql.y" { yymsp[1].minor.yy792 = JOIN_TYPE_INNER; } +#line 8934 "sql.c" break; case 672: /* join_type ::= INNER */ +#line 1411 "sql.y" { yymsp[0].minor.yy792 = JOIN_TYPE_INNER; } +#line 8939 "sql.c" break; case 673: /* join_type ::= LEFT */ +#line 1412 "sql.y" { yymsp[0].minor.yy792 = JOIN_TYPE_LEFT; } +#line 8944 "sql.c" break; case 674: /* join_type ::= RIGHT */ +#line 1413 "sql.y" { yymsp[0].minor.yy792 = JOIN_TYPE_RIGHT; } +#line 8949 "sql.c" break; case 675: /* join_type ::= FULL */ +#line 1414 "sql.y" { yymsp[0].minor.yy792 = JOIN_TYPE_FULL; } +#line 8954 "sql.c" break; case 676: /* join_subtype ::= */ +#line 1418 "sql.y" { yymsp[1].minor.yy744 = JOIN_STYPE_NONE; } +#line 8959 "sql.c" break; case 677: /* join_subtype ::= OUTER */ +#line 1419 "sql.y" { yymsp[0].minor.yy744 = JOIN_STYPE_OUTER; } +#line 8964 "sql.c" break; case 678: /* join_subtype ::= SEMI */ +#line 1420 "sql.y" { yymsp[0].minor.yy744 = JOIN_STYPE_SEMI; } +#line 8969 "sql.c" break; case 679: /* join_subtype ::= ANTI */ +#line 1421 "sql.y" { yymsp[0].minor.yy744 = JOIN_STYPE_ANTI; } +#line 8974 "sql.c" break; case 680: /* join_subtype ::= ASOF */ +#line 1422 "sql.y" { yymsp[0].minor.yy744 = JOIN_STYPE_ASOF; } +#line 8979 "sql.c" break; case 681: /* join_subtype ::= WINDOW */ +#line 1423 "sql.y" { yymsp[0].minor.yy744 = JOIN_STYPE_WIN; } +#line 8984 "sql.c" break; case 685: /* window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ +#line 1430 "sql.y" { yymsp[-5].minor.yy974 = createWindowOffsetNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } +#line 8989 "sql.c" break; case 686: /* window_offset_literal ::= NK_VARIABLE */ +#line 1432 "sql.y" { yylhsminor.yy974 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createTimeOffsetValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 8994 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 687: /* window_offset_literal ::= NK_MINUS NK_VARIABLE */ +#line 1433 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy974 = createRawExprNode(pCxt, &t, createTimeOffsetValueNode(pCxt, &t)); } +#line 9004 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 689: /* jlimit_clause_opt ::= JLIMIT NK_INTEGER */ case 762: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ yytestcase(yyruleno==762); case 766: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==766); +#line 1440 "sql.y" { yymsp[-1].minor.yy974 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 9012 "sql.c" break; case 690: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ +#line 1446 "sql.y" { yymsp[-13].minor.yy974 = createSelectStmt(pCxt, yymsp[-11].minor.yy569, yymsp[-9].minor.yy946, yymsp[-8].minor.yy974, yymsp[-12].minor.yy946); yymsp[-13].minor.yy974 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy974, yymsp[-10].minor.yy569); @@ -7644,156 +9025,243 @@ yymsp[0].minor.yy974); } yymsp[-13].minor.yy974 = addEveryClause(pCxt, yymsp[-13].minor.yy974, yymsp[-4].minor.yy974); yymsp[-13].minor.yy974 = addFillClause(pCxt, yymsp[-13].minor.yy974, yymsp[-3].minor.yy974); } +#line 9028 "sql.c" break; case 691: /* hint_list ::= */ +#line 1461 "sql.y" { yymsp[1].minor.yy946 = createHintNodeList(pCxt, NULL); } +#line 9033 "sql.c" break; case 692: /* hint_list ::= NK_HINT */ +#line 1462 "sql.y" { yylhsminor.yy946 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } +#line 9038 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 697: /* set_quantifier_opt ::= ALL */ +#line 1473 "sql.y" { yymsp[0].minor.yy569 = false; } +#line 9044 "sql.c" break; case 700: /* select_item ::= NK_STAR */ +#line 1480 "sql.y" { yylhsminor.yy974 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } +#line 9049 "sql.c" yymsp[0].minor.yy974 = yylhsminor.yy974; break; case 702: /* select_item ::= common_expression column_alias */ case 712: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==712); +#line 1482 "sql.y" { yylhsminor.yy974 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), &yymsp[0].minor.yy557); } +#line 9056 "sql.c" yymsp[-1].minor.yy974 = yylhsminor.yy974; break; case 703: /* select_item ::= common_expression AS column_alias */ case 713: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==713); +#line 1483 "sql.y" { yylhsminor.yy974 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), &yymsp[0].minor.yy557); } +#line 9063 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 708: /* partition_by_clause_opt ::= PARTITION BY partition_list */ case 740: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==740); case 760: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==760); +#line 1492 "sql.y" { yymsp[-2].minor.yy946 = yymsp[0].minor.yy946; } +#line 9071 "sql.c" break; case 715: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ +#line 1505 "sql.y" { yymsp[-5].minor.yy974 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } +#line 9076 "sql.c" break; case 716: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +#line 1506 "sql.y" { yymsp[-3].minor.yy974 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } +#line 9081 "sql.c" break; case 717: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +#line 1508 "sql.y" { yymsp[-5].minor.yy974 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), NULL, yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } +#line 9086 "sql.c" break; case 718: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +#line 1512 "sql.y" { yymsp[-7].minor.yy974 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy974), releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), yymsp[-1].minor.yy974, yymsp[0].minor.yy974); } +#line 9091 "sql.c" break; case 719: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +#line 1514 "sql.y" { yymsp[-6].minor.yy974 = createEventWindowNode(pCxt, yymsp[-3].minor.yy974, yymsp[0].minor.yy974); } +#line 9096 "sql.c" break; case 720: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ +#line 1516 "sql.y" { yymsp[-3].minor.yy974 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } +#line 9101 "sql.c" break; case 721: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +#line 1518 "sql.y" { yymsp[-5].minor.yy974 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } +#line 9106 "sql.c" break; case 722: /* twindow_clause_opt ::= ANOMALY_WINDOW NK_LP expr_or_subquery NK_RP */ +#line 1520 "sql.y" { yymsp[-3].minor.yy974 = createAnomalyWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974), NULL); } +#line 9111 "sql.c" break; case 723: /* twindow_clause_opt ::= ANOMALY_WINDOW NK_LP expr_or_subquery NK_COMMA NK_STRING NK_RP */ +#line 1522 "sql.y" { yymsp[-5].minor.yy974 = createAnomalyWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), &yymsp[-1].minor.yy0); } +#line 9116 "sql.c" break; case 730: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +#line 1532 "sql.y" { yymsp[-3].minor.yy974 = createFillNode(pCxt, yymsp[-1].minor.yy102, NULL); } +#line 9121 "sql.c" break; case 731: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ +#line 1533 "sql.y" { yymsp[-5].minor.yy974 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy946)); } +#line 9126 "sql.c" break; case 732: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ +#line 1534 "sql.y" { yymsp[-5].minor.yy974 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy946)); } +#line 9131 "sql.c" break; case 733: /* fill_mode ::= NONE */ +#line 1538 "sql.y" { yymsp[0].minor.yy102 = FILL_MODE_NONE; } +#line 9136 "sql.c" break; case 734: /* fill_mode ::= PREV */ +#line 1539 "sql.y" { yymsp[0].minor.yy102 = FILL_MODE_PREV; } +#line 9141 "sql.c" break; case 735: /* fill_mode ::= NULL */ +#line 1540 "sql.y" { yymsp[0].minor.yy102 = FILL_MODE_NULL; } +#line 9146 "sql.c" break; case 736: /* fill_mode ::= NULL_F */ +#line 1541 "sql.y" { yymsp[0].minor.yy102 = FILL_MODE_NULL_F; } +#line 9151 "sql.c" break; case 737: /* fill_mode ::= LINEAR */ +#line 1542 "sql.y" { yymsp[0].minor.yy102 = FILL_MODE_LINEAR; } +#line 9156 "sql.c" break; case 738: /* fill_mode ::= NEXT */ +#line 1543 "sql.y" { yymsp[0].minor.yy102 = FILL_MODE_NEXT; } +#line 9161 "sql.c" break; case 741: /* group_by_list ::= expr_or_subquery */ +#line 1552 "sql.y" { yylhsminor.yy946 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 9166 "sql.c" yymsp[0].minor.yy946 = yylhsminor.yy946; break; case 742: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +#line 1553 "sql.y" { yylhsminor.yy946 = addNodeToList(pCxt, yymsp[-2].minor.yy946, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy974))); } +#line 9172 "sql.c" yymsp[-2].minor.yy946 = yylhsminor.yy946; break; case 746: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +#line 1560 "sql.y" { yymsp[-5].minor.yy974 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy974), releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } +#line 9178 "sql.c" break; case 747: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ +#line 1562 "sql.y" { yymsp[-3].minor.yy974 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy974)); } +#line 9183 "sql.c" break; case 750: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ +#line 1569 "sql.y" { yylhsminor.yy974 = addOrderByClause(pCxt, yymsp[-3].minor.yy974, yymsp[-2].minor.yy946); yylhsminor.yy974 = addSlimitClause(pCxt, yylhsminor.yy974, yymsp[-1].minor.yy974); yylhsminor.yy974 = addLimitClause(pCxt, yylhsminor.yy974, yymsp[0].minor.yy974); } +#line 9192 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 753: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +#line 1579 "sql.y" { yylhsminor.yy974 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy974, yymsp[0].minor.yy974); } +#line 9198 "sql.c" yymsp[-3].minor.yy974 = yylhsminor.yy974; break; case 754: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +#line 1581 "sql.y" { yylhsminor.yy974 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy974, yymsp[0].minor.yy974); } +#line 9204 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 763: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ case 767: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==767); +#line 1596 "sql.y" { yymsp[-3].minor.yy974 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } +#line 9211 "sql.c" break; case 764: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ case 768: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==768); +#line 1597 "sql.y" { yymsp[-3].minor.yy974 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } +#line 9217 "sql.c" break; case 769: /* subquery ::= NK_LP query_expression NK_RP */ +#line 1605 "sql.y" { yylhsminor.yy974 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy974); } +#line 9222 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 774: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +#line 1619 "sql.y" { yylhsminor.yy974 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy974), yymsp[-1].minor.yy410, yymsp[0].minor.yy307); } +#line 9228 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; case 775: /* ordering_specification_opt ::= */ +#line 1623 "sql.y" { yymsp[1].minor.yy410 = ORDER_ASC; } +#line 9234 "sql.c" break; case 776: /* ordering_specification_opt ::= ASC */ +#line 1624 "sql.y" { yymsp[0].minor.yy410 = ORDER_ASC; } +#line 9239 "sql.c" break; case 777: /* ordering_specification_opt ::= DESC */ +#line 1625 "sql.y" { yymsp[0].minor.yy410 = ORDER_DESC; } +#line 9244 "sql.c" break; case 778: /* null_ordering_opt ::= */ +#line 1629 "sql.y" { yymsp[1].minor.yy307 = NULL_ORDER_DEFAULT; } +#line 9249 "sql.c" break; case 779: /* null_ordering_opt ::= NULLS FIRST */ +#line 1630 "sql.y" { yymsp[-1].minor.yy307 = NULL_ORDER_FIRST; } +#line 9254 "sql.c" break; case 780: /* null_ordering_opt ::= NULLS LAST */ +#line 1631 "sql.y" { yymsp[-1].minor.yy307 = NULL_ORDER_LAST; } +#line 9259 "sql.c" break; case 783: /* column_options ::= column_options NK_ID NK_STRING */ +#line 1639 "sql.y" { yylhsminor.yy974 = setColumnOptions(pCxt, yymsp[-2].minor.yy974, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 9264 "sql.c" yymsp[-2].minor.yy974 = yylhsminor.yy974; break; default: @@ -7856,6 +9324,7 @@ static void yy_syntax_error( ParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ +#line 29 "sql.y" if (TSDB_CODE_SUCCESS == pCxt->errCode) { if(TOKEN.z) { @@ -7866,6 +9335,7 @@ static void yy_syntax_error( } else if (TSDB_CODE_PAR_DB_NOT_SPECIFIED == pCxt->errCode && TK_NK_FLOAT == TOKEN.type) { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); } +#line 9338 "sql.c" /************ End %syntax_error code ******************************************/ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ ParseCTX_STORE From 481ceefcdf8b294a4862afd4b97d1814406b10ba Mon Sep 17 00:00:00 2001 From: Pan Wei <72057773+dapan1121@users.noreply.github.com> Date: Mon, 28 Oct 2024 18:26:34 +0800 Subject: [PATCH 34/40] Update in.sim --- tests/script/tsim/scalar/in.sim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/script/tsim/scalar/in.sim b/tests/script/tsim/scalar/in.sim index f7fa2bcd2d..a2164675f0 100644 --- a/tests/script/tsim/scalar/in.sim +++ b/tests/script/tsim/scalar/in.sim @@ -100,7 +100,7 @@ sql explain verbose true select * from tb1 where fts in ('2022-07-10 16:31:00', if $rows != 4 then return -1 endi -if $data20 != @ Time Range: [0, 1657441980000]@ then +if $data20 != @ Time Range: [1, 1657441980000]@ then return -1 endi @@ -108,7 +108,7 @@ sql explain verbose true select * from tb1 where fts in ('2022-07-10 16:31:00', if $rows != 4 then return -1 endi -if $data20 != @ Time Range: [1, 1657441980000]@ then +if $data20 != @ Time Range: [0, 1657441980000]@ then return -1 endi From 969400616851162a5ff368c71b810a9ff78ab4e3 Mon Sep 17 00:00:00 2001 From: Pan Wei <72057773+dapan1121@users.noreply.github.com> Date: Mon, 28 Oct 2024 18:27:12 +0800 Subject: [PATCH 35/40] Update filter.c --- source/libs/scalar/src/filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 2c449fced6..d8622d93ee 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -4133,7 +4133,7 @@ int32_t fltSclBuildDatumFromValueNode(SFltSclDatum *datum, SValueNode *valNode) } case TSDB_DATA_TYPE_BOOL: { datum->kind = FLT_SCL_DATUM_KIND_INT64; - datum->i = (valNode->datum.b) ? 0 : 1; + datum->i = (valNode->datum.b) ? 1 : 0; break; } case TSDB_DATA_TYPE_TINYINT: From 8694eb99bee9a3e7a281b9afead7f0798b5e6c57 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 28 Oct 2024 18:34:43 +0800 Subject: [PATCH 36/40] s3/chunksize tests: rename chunksize in cases --- tests/army/storage/s3/s3Basic.json | 2 +- tests/army/storage/s3/s3Basic.py | 10 +++++----- tests/army/storage/s3/s3Basic1.json | 2 +- tests/army/storage/s3/s3azure.py | 10 +++++----- tests/develop-test/2-query/show_create_db.py | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/army/storage/s3/s3Basic.json b/tests/army/storage/s3/s3Basic.json index ee341b2096..2b911a989f 100644 --- a/tests/army/storage/s3/s3Basic.json +++ b/tests/army/storage/s3/s3Basic.json @@ -20,7 +20,7 @@ "replica": 1, "duration":"10d", "s3_keeplocal":"30d", - "s3_chunksize":"131072", + "s3_chunkpages":"131072", "tsdb_pagesize":"1", "s3_compact":"1", "wal_retention_size":"1", diff --git a/tests/army/storage/s3/s3Basic.py b/tests/army/storage/s3/s3Basic.py index bc55fe6f5c..273a6129e1 100644 --- a/tests/army/storage/s3/s3Basic.py +++ b/tests/army/storage/s3/s3Basic.py @@ -168,13 +168,13 @@ class TDTestCase(TBase): if keepLocal is not None: kw1 = f"s3_keeplocal {keepLocal}" if chunkSize is not None: - kw2 = f"s3_chunksize {chunkSize}" + kw2 = f"s3_chunkpages {chunkSize}" if compact is not None: kw3 = f"s3_compact {compact}" sql = f" create database db1 vgroups 1 duration 1h {kw1} {kw2} {kw3}" tdSql.execute(sql, show=True) - #sql = f"select name,s3_keeplocal,s3_chunksize,s3_compact from information_schema.ins_databases where name='db1';" + #sql = f"select name,s3_keeplocal,s3_chunkpages,s3_compact from information_schema.ins_databases where name='db1';" sql = f"select * from information_schema.ins_databases where name='db1';" tdSql.query(sql) # 29 30 31 -> chunksize keeplocal compact @@ -194,9 +194,9 @@ class TDTestCase(TBase): f"create database db2 s3_keeplocal -1", f"create database db2 s3_keeplocal 0", f"create database db2 s3_keeplocal 365001", - f"create database db2 s3_chunksize -1", - f"create database db2 s3_chunksize 0", - f"create database db2 s3_chunksize 900000000", + f"create database db2 s3_chunkpages -1", + f"create database db2 s3_chunkpages 0", + f"create database db2 s3_chunkpages 900000000", f"create database db2 s3_compact -1", f"create database db2 s3_compact 100", f"create database db2 duration 1d s3_keeplocal 1d" diff --git a/tests/army/storage/s3/s3Basic1.json b/tests/army/storage/s3/s3Basic1.json index 02be308443..087f89edec 100644 --- a/tests/army/storage/s3/s3Basic1.json +++ b/tests/army/storage/s3/s3Basic1.json @@ -20,7 +20,7 @@ "replica": 1, "duration":"10d", "s3_keeplocal":"30d", - "s3_chunksize":"131072", + "s3_chunkpages":"131072", "tsdb_pagesize":"1", "s3_compact":"1", "wal_retention_size":"1", diff --git a/tests/army/storage/s3/s3azure.py b/tests/army/storage/s3/s3azure.py index 43857cb7ca..e0226b0aa4 100644 --- a/tests/army/storage/s3/s3azure.py +++ b/tests/army/storage/s3/s3azure.py @@ -202,13 +202,13 @@ class TDTestCase(TBase): if keepLocal is not None: kw1 = f"s3_keeplocal {keepLocal}" if chunkSize is not None: - kw2 = f"s3_chunksize {chunkSize}" + kw2 = f"s3_chunkpages {chunkSize}" if compact is not None: kw3 = f"s3_compact {compact}" sql = f" create database db1 vgroups 1 duration 1h {kw1} {kw2} {kw3}" tdSql.execute(sql, show=True) - # sql = f"select name,s3_keeplocal,s3_chunksize,s3_compact from information_schema.ins_databases where name='db1';" + # sql = f"select name,s3_keeplocal,s3_chunkpages,s3_compact from information_schema.ins_databases where name='db1';" sql = f"select * from information_schema.ins_databases where name='db1';" tdSql.query(sql) # 29 30 31 -> chunksize keeplocal compact @@ -228,9 +228,9 @@ class TDTestCase(TBase): f"create database db2 s3_keeplocal -1", f"create database db2 s3_keeplocal 0", f"create database db2 s3_keeplocal 365001", - f"create database db2 s3_chunksize -1", - f"create database db2 s3_chunksize 0", - f"create database db2 s3_chunksize 900000000", + f"create database db2 s3_chunkpages -1", + f"create database db2 s3_chunkpages 0", + f"create database db2 s3_chunkpages 900000000", f"create database db2 s3_compact -1", f"create database db2 s3_compact 100", f"create database db2 duration 1d s3_keeplocal 1d" diff --git a/tests/develop-test/2-query/show_create_db.py b/tests/develop-test/2-query/show_create_db.py index b77e744df2..a698a3e92e 100644 --- a/tests/develop-test/2-query/show_create_db.py +++ b/tests/develop-test/2-query/show_create_db.py @@ -42,17 +42,17 @@ class TDTestCase: tdSql.query('show create database scd;') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd') - tdSql.checkData(0, 1, "CREATE DATABASE `scd` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 2 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKSIZE 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 2 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") tdSql.query('show create database scd2;') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd2') - tdSql.checkData(0, 1, "CREATE DATABASE `scd2` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 3 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKSIZE 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd2` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 3 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") tdSql.query('show create database scd4') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd4') - tdSql.checkData(0, 1, "CREATE DATABASE `scd4` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 13 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKSIZE 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd4` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 13 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") self.restartTaosd(1, dbname='scd') @@ -60,16 +60,16 @@ class TDTestCase: tdSql.query('show create database scd;') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd') - tdSql.checkData(0, 1, "CREATE DATABASE `scd` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 2 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKSIZE 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 2 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") tdSql.query('show create database scd2;') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd2') - tdSql.checkData(0, 1, "CREATE DATABASE `scd2` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 3 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKSIZE 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd2` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 3 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") tdSql.query('show create database scd4') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd4') - tdSql.checkData(0, 1, "CREATE DATABASE `scd4` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 13 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKSIZE 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd4` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 13 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") tdSql.execute('drop database scd') From 2a1bb79206651887766ed81c1ac3702abfd26a79 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Tue, 29 Oct 2024 08:33:53 +0800 Subject: [PATCH 37/40] fix default values for s3_chunkpages in test cases --- tests/develop-test/2-query/show_create_db.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/develop-test/2-query/show_create_db.py b/tests/develop-test/2-query/show_create_db.py index a698a3e92e..9589b6dc6f 100644 --- a/tests/develop-test/2-query/show_create_db.py +++ b/tests/develop-test/2-query/show_create_db.py @@ -42,17 +42,17 @@ class TDTestCase: tdSql.query('show create database scd;') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd') - tdSql.checkData(0, 1, "CREATE DATABASE `scd` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 2 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 2 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 131072 S3_KEEPLOCAL 525600m S3_COMPACT 1") tdSql.query('show create database scd2;') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd2') - tdSql.checkData(0, 1, "CREATE DATABASE `scd2` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 3 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd2` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 3 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 131072 S3_KEEPLOCAL 525600m S3_COMPACT 1") tdSql.query('show create database scd4') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd4') - tdSql.checkData(0, 1, "CREATE DATABASE `scd4` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 13 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd4` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 13 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 131072 S3_KEEPLOCAL 525600m S3_COMPACT 1") self.restartTaosd(1, dbname='scd') @@ -60,16 +60,16 @@ class TDTestCase: tdSql.query('show create database scd;') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd') - tdSql.checkData(0, 1, "CREATE DATABASE `scd` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 2 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 2 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 131072 S3_KEEPLOCAL 525600m S3_COMPACT 1") tdSql.query('show create database scd2;') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd2') - tdSql.checkData(0, 1, "CREATE DATABASE `scd2` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 3 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd2` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 3 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 131072 S3_KEEPLOCAL 525600m S3_COMPACT 1") tdSql.query('show create database scd4') tdSql.checkRows(1) tdSql.checkData(0, 0, 'scd4') - tdSql.checkData(0, 1, "CREATE DATABASE `scd4` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 13 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 262144 S3_KEEPLOCAL 525600m S3_COMPACT 1") + tdSql.checkData(0, 1, "CREATE DATABASE `scd4` BUFFER 256 CACHESIZE 1 CACHEMODEL 'none' COMP 2 DURATION 10d WAL_FSYNC_PERIOD 3000 MAXROWS 4096 MINROWS 100 STT_TRIGGER 13 KEEP 3650d,3650d,3650d PAGES 256 PAGESIZE 4 PRECISION 'ms' REPLICA 1 WAL_LEVEL 1 VGROUPS 2 SINGLE_STABLE 0 TABLE_PREFIX 0 TABLE_SUFFIX 0 TSDB_PAGESIZE 4 WAL_RETENTION_PERIOD 3600 WAL_RETENTION_SIZE 0 KEEP_TIME_OFFSET 0 ENCRYPT_ALGORITHM 'none' S3_CHUNKPAGES 131072 S3_KEEPLOCAL 525600m S3_COMPACT 1") tdSql.execute('drop database scd') From fb16e4912e7ae093f9e8072acd8c1fd9fbcf1743 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Tue, 29 Oct 2024 08:49:11 +0800 Subject: [PATCH 38/40] rename s3_chunksize to s3_chunkpages & fix default value --- docs/zh/08-operation/12-multi.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/zh/08-operation/12-multi.md b/docs/zh/08-operation/12-multi.md index 6afd642752..5489226ce1 100644 --- a/docs/zh/08-operation/12-multi.md +++ b/docs/zh/08-operation/12-multi.md @@ -109,7 +109,7 @@ s3migrate database ; | # | 参数 | 默认值 | 最小值 | 最大值 | 描述 | | :--- | :----------- | :----- | :----- | :------ | :----------------------------------------------------------- | | 1 | s3_keeplocal | 365 | 1 | 365000 | 数据在本地保留的天数,即 data 文件在本地磁盘保留多长时间后可以上传到 S3。默认单位:天,支持 m(分钟)、h(小时)和 d(天)三个单位 | -| 2 | s3_chunksize | 131072 | 131072 | 1048576 | 上传对象的大小阈值,与 tsdb_pagesize 参数一样,不可修改,单位为 TSDB 页 | +| 2 | s3_chunkpages | 131072 | 131072 | 1048576 | 上传对象的大小阈值,与 tsdb_pagesize 参数一样,不可修改,单位为 TSDB 页 | | 3 | s3_compact | 1 | 0 | 1 | TSDB 文件组首次上传 S3 时,是否自动进行 compact 操作。 | ### 对象存储读写次数估算 @@ -118,13 +118,13 @@ s3migrate database ; #### 数据上传 -当 TSDB 时序数据超过 `s3_keeplocal` 参数指定的时间,相关的数据文件会被切分成多个文件块,每个文件块的默认大小是 500M 字节 (`s3_chunksize * tsdb_pagesize`)。除了最后一个文件块保留在本地文件系统外,其余的文件块会被上传到对象存储服务。 +当 TSDB 时序数据超过 `s3_keeplocal` 参数指定的时间,相关的数据文件会被切分成多个文件块,每个文件块的默认大小是 512M 字节 (`s3_chunkpages * tsdb_pagesize`)。除了最后一个文件块保留在本地文件系统外,其余的文件块会被上传到对象存储服务。 ```math -上传次数 = 数据文件大小 / (s3_chunksize * tsdb_pagesize) - 1 +上传次数 = 数据文件大小 / (s3_chunkpages * tsdb_pagesize) - 1 ``` -在创建数据库时,可以通过 `s3_chunksize` 参数调整每个文件块的大小,从而控制每个数据文件的上传次数。 +在创建数据库时,可以通过 `s3_chunkpages` 参数调整每个文件块的大小,从而控制每个数据文件的上传次数。 其它类型的文件如 head, stt, sma 等,保留在本地文件系统,以加速预计算相关查询。 From b0c1e79f3a9facc99f268898ad31b99b58c49946 Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Tue, 29 Oct 2024 09:52:50 +0800 Subject: [PATCH 39/40] test: execute balancing vgroup in a loop --- tests/system-test/7-tmq/ts-4674.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/system-test/7-tmq/ts-4674.py b/tests/system-test/7-tmq/ts-4674.py index 0b3dc1b077..c4ba99b725 100644 --- a/tests/system-test/7-tmq/ts-4674.py +++ b/tests/system-test/7-tmq/ts-4674.py @@ -35,10 +35,11 @@ class TDTestCase: def balance_vnode(self): leader_before = self.get_leader() - tdSql.query("balance vgroup leader") + while True: leader_after = -1 tdLog.debug("balancing vgroup leader") + tdSql.query("balance vgroup leader") while True: tdLog.debug("get new vgroup leader") leader_after = self.get_leader() @@ -51,6 +52,7 @@ class TDTestCase: break else : time.sleep(1) + tdLog.debug("leader not changed") def consume_TS_4674_Test(self): From 316f96fb405cfa729d421da5796ebb4a42bd4c65 Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Tue, 29 Oct 2024 09:57:44 +0800 Subject: [PATCH 40/40] test: execute balancing vgroup in a loop --- tests/system-test/7-tmq/ts-4674.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/7-tmq/ts-4674.py b/tests/system-test/7-tmq/ts-4674.py index c4ba99b725..79379aaaed 100644 --- a/tests/system-test/7-tmq/ts-4674.py +++ b/tests/system-test/7-tmq/ts-4674.py @@ -39,7 +39,7 @@ class TDTestCase: while True: leader_after = -1 tdLog.debug("balancing vgroup leader") - tdSql.query("balance vgroup leader") + tdSql.execute("balance vgroup leader") while True: tdLog.debug("get new vgroup leader") leader_after = self.get_leader()