From 50b612082fc89db0655148c02c1a7b57dc48d311 Mon Sep 17 00:00:00 2001 From: cpwu Date: Wed, 22 Jun 2022 14:47:15 +0800 Subject: [PATCH 01/73] fix case --- .../system-test/1-insert/create_retentions.py | 74 ++++++------ tests/system-test/1-insert/time_range_wise.py | 112 ++++++++++++------ tests/system-test/2-query/join.py | 2 +- tests/system-test/2-query/join2.py | 2 +- tests/system-test/2-query/substr.py | 2 +- 5 files changed, 115 insertions(+), 77 deletions(-) diff --git a/tests/system-test/1-insert/create_retentions.py b/tests/system-test/1-insert/create_retentions.py index 5a0684e2ee..bf3c8d8309 100644 --- a/tests/system-test/1-insert/create_retentions.py +++ b/tests/system-test/1-insert/create_retentions.py @@ -51,12 +51,28 @@ class DataSet: binary_data : List[str] = None nchar_data : List[str] = None + def __post_init__(self): + self.ts_data = [] + self.int_data = [] + self.bint_data = [] + self.sint_data = [] + self.tint_data = [] + self.int_un_data = [] + self.bint_un_data = [] + self.sint_un_data = [] + self.tint_un_data = [] + self.float_data = [] + self.double_data = [] + self.bool_data = [] + self.binary_data = [] + self.nchar_data = [] + class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), True) + tdSql.init(conn.cursor(), False) @property def create_databases_sql_err(self): @@ -87,28 +103,28 @@ class TDTestCase: @property def create_stable_sql_err(self): return [ - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) watermark 1s maxdelay 1m", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) watermark 1s max_delay 1m", f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) watermark 1min", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay -1s", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay -1s", f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark -1m", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 1m ", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) maxdelay 1m ", + # f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 1m ", + # f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) max_delay 1m ", f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) watermark 1s", - f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) rollup(avg) maxdelay 1m", - # f"create table ntb_1 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) rollup(avg) watermark 1s maxdelay 1s", + f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) rollup(avg) max_delay 1m", + # f"create table ntb_1 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) rollup(avg) watermark 1s max_delay 1s", # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) " , # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) " , # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) " , # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) " , - # watermark, maxdelay: [0, 900000], [ms, s, m, ?] - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 1u", + # watermark, max_delay: [0, 900000], [ms, s, m, ?] + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1u", f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 1b", f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 900001ms", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 16m", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 901s", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 1h", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 0.2h", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 16m", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 901s", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1h", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 0.2h", f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 0.002d", ] @@ -117,11 +133,11 @@ class TDTestCase: def create_stable_sql_current(self): return [ f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(avg)", - f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 5s maxdelay 1m", - f"create stable stb3 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(max) watermark 5s maxdelay 1m", - f"create stable stb4 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(sum) watermark 5s maxdelay 1m", - # f"create stable stb5 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(last) watermark 5s maxdelay 1m", - # f"create stable stb6 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s maxdelay 1m", + f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 5s max_delay 1m", + f"create stable stb3 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(max) watermark 5s max_delay 1m", + f"create stable stb4 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(sum) watermark 5s max_delay 1m", + # f"create stable stb5 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(last) watermark 5s max_delay 1m", + # f"create stable stb6 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m", ] def test_create_stb(self): @@ -135,7 +151,7 @@ class TDTestCase: tdSql.checkRows(len(self.create_stable_sql_current)) # tdSql.execute("use db") # because db is a noraml database, not a rollup database, should not be able to create a rollup database - # tdSql.error(f"create stable nor_db_rollup_stb ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) file_factor 5.0") + # tdSql.error(f"create stable nor_db_rollup_stb ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 5s max_delay 1m") def test_create_databases(self): @@ -177,21 +193,6 @@ class TDTestCase: def __data_set(self, rows): data_set = DataSet() - # neg_data_set = DataSet() - data_set.ts_data = [] - data_set.int_data = [] - data_set.bint_data = [] - data_set.sint_data = [] - data_set.tint_data = [] - data_set.int_un_data = [] - data_set.bint_un_data = [] - data_set.sint_un_data = [] - data_set.tint_un_data = [] - data_set.float_data = [] - data_set.double_data = [] - data_set.bool_data = [] - data_set.binary_data = [] - data_set.nchar_data = [] for i in range(rows): data_set.ts_data.append(NOW + 1 * (rows - i)) @@ -226,6 +227,7 @@ class TDTestCase: return data_set def __insert_data(self): + tdLog.printNoPrefix("==========step: start inser data into tables now.....") data = self.__data_set(rows=self.rows) # now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) @@ -264,10 +266,10 @@ class TDTestCase: def run(self): self.rows = 10 - + tdSql.prepare() tdLog.printNoPrefix("==========step0:all check") - # self.all_test() + self.all_test() tdLog.printNoPrefix("==========step1:create table in normal database") tdSql.prepare() diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index 5387970d56..4f84856dd9 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -7,6 +7,7 @@ from util.sql import * from util.cases import * from util.dnodes import * from util.constant import * +from ...pytest.util.sql import * PRIMARY_COL = "ts" @@ -25,8 +26,6 @@ BINARY_COL = "c_binary" NCHAR_COL = "c_nchar" TS_COL = "c_ts" - - NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ] CHAR_COL = [BINARY_COL, NCHAR_COL, ] BOOLEAN_COL = [BOOL_COL, ] @@ -36,6 +35,12 @@ TS_TYPE_COL = [TS_COL, ] TIME_STEP = 10000 NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) +# init db/table +DBNAME = "db" +STBNAME = "stb1" +CTBNAME = "ct1" +NTBNAME = "nt1" + @dataclass class DataSet: @@ -73,19 +78,20 @@ class DataSet: @dataclass class SMAschema: - creation : str = "CREATE" - index_name : str = "sma_index_1" - index_flag : str = "SMA INDEX" - operator : str = "ON" - tbname : str = None - watermark : str = None - maxdelay : str = None - func : Tuple[str] = None - interval : Tuple[str] = None - sliding : str = None - other : Any = None - drop : str = "DROP" - drop_flag : str = "INDEX" + creation : str = "CREATE" + index_name : str = "sma_index_1" + index_flag : str = "SMA INDEX" + operator : str = "ON" + tbname : str = None + watermark : str = "5s" + max_delay : str = "6m" + func : Tuple[str] = None + interval : Tuple[str] = ("6m", "10s") + sliding : str = "6m" + other : Any = None + drop : str = "DROP" + drop_flag : str = "INDEX" + querySmaOptimize : int = 1 def __post_init__(self): if isinstance(self.other, dict): @@ -111,8 +117,8 @@ class SMAschema: self.watermark = v del self.other[k] - if k.lower() == "maxdelay" and isinstance(v, str) and not self.maxdelay: - self.maxdelay = v + if k.lower() == "max_delay" and isinstance(v, str) and not self.max_delay: + self.max_delay = v del self.other[k] if k.lower() == "functions" and isinstance(v, tuple) and not self.func: @@ -133,6 +139,7 @@ class SMAschema: class TDTestCase: + updatecfgDict = {"querySmaOptimize": 1} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") @@ -160,8 +167,8 @@ class TDTestCase: sql += f" sliding({sma.sliding})" if sma.watermark: sql += f" watermark {sma.watermark}" - if sma.maxdelay: - sql += f" maxdelay {sma.maxdelay}" + if sma.max_delay: + sql += f" max_delay {sma.max_delay}" if isinstance(sma.other, dict): for k,v in sma.other.items(): if isinstance(v,tuple) or isinstance(v, list): @@ -171,26 +178,36 @@ class TDTestCase: if isinstance(sma.other, tuple) or isinstance(sma.other, list): sql += " ".join(sma.other) if isinstance(sma.other, int) or isinstance(sma.other, float) or isinstance(sma.other, str): - sql += sma.other + sql += f" {sma.other}" return sql + def __check_sma_func(self, func:tuple): + sma_func_support = ["min", "max","avg"] + if not isinstance(func, str) or not isinstance(func, tuple) or not isinstance(func, list): + return False + if isinstance(func, str) : + if func.split("(")[0] not in sma_func_support: + return False + + def sma_create_check(self, sma:SMAschema): + if self.updatecfgDict["querySmaOptimize"] == 0: + tdSql.error(self.__create_sma_index(sma)) tdSql.query("show stables") stb_in_list = False for row in tdSql.queryResult: if sma.tbname == row[0]: stb_in_list = True - break if not stb_in_list: tdSql.error(self.__create_sma_index(sma)) - if not sma.creation: + if not sma.creation or not isinstance(sma.creation, str) or sma.creation.upper() != "CREATE": tdSql.error(self.__create_sma_index(sma)) - if not sma.index_flag: + if not sma.index_flag or not isinstance(sma.index_flag, str) or sma.index_flag.upper() != "SMA INDEX" : tdSql.error(self.__create_sma_index(sma)) - if not sma.index_name: + if not sma.index_name or not isinstance(sma.index_name, str): tdSql.error(self.__create_sma_index(sma)) - if not sma.operator: + if not sma.operator or not isinstance(sma.operator, str) or sma.operator.upper() != "ON": tdSql.error(self.__create_sma_index(sma)) if not sma.tbname: tdSql.error(self.__create_sma_index(sma)) @@ -203,13 +220,36 @@ class TDTestCase: if sma.other: tdSql.error(self.__create_sma_index(sma)) + @property + def __create_sma_sql(self): + err_sqls = [] + cur_sqls = [] + # err_set + # case 1: required fields check + err_sqls.append( SMAschema(creation="", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(index_name="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(operator="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(tbname="", func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(func="",tbname=STBNAME ) ) + err_sqls.append( SMAschema(interval="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(sliding="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + + return err_sqls, cur_sqls + + def test_create_sma(self): + err_sqls , cur_sqls = self.__create_sma_sql + for err_sql in err_sqls: + self.sma_create_check(err_sql) def all_test(self): + self.test_create_sma() + pass def __create_tb(self): tdLog.printNoPrefix("==========step: create table") - create_stb_sql = f'''create table stb1( + create_stb_sql = f'''create table {STBNAME}( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, @@ -217,7 +257,7 @@ class TDTestCase: {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned ) tags (tag1 int) ''' - create_ntb_sql = f'''create table t1( + create_ntb_sql = f'''create table {NTBNAME}( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, @@ -253,6 +293,7 @@ class TDTestCase: return data_set def __insert_data(self): + tdLog.printNoPrefix("==========step: start inser data into tables now.....") data = self.__data_set(rows=self.rows) # now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) @@ -278,7 +319,7 @@ class TDTestCase: tdSql.execute( f"insert into ct4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )") tdSql.execute( - f"insert into t1 values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )") + f"insert into {NTBNAME} values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )") tdSql.execute( f"insert into ct2 values ( {NOW + int(TIME_STEP * 0.6)}, {null_data} )") @@ -295,28 +336,23 @@ class TDTestCase: f"insert into ct4 values ( {NOW - self.rows * int(TIME_STEP * 0.39)}, {null_data} )") tdSql.execute( - f"insert into t1 values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )") + f"insert into {NTBNAME} values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )") tdSql.execute( - f"insert into t1 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )") + f"insert into {NTBNAME} values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )") tdSql.execute( - f"insert into t1 values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )") + f"insert into {NTBNAME} values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )") def run(self): - sma1 = SMAschema(func=("min(c1)","max(c2)")) - sql1 = self.__create_sma_index(sma1) - print("================") - print(sql1) - # a = DataSet() - # return self.rows = 10 tdLog.printNoPrefix("==========step0:all check") - # self.all_test() tdLog.printNoPrefix("==========step1:create table in normal database") tdSql.prepare() self.__create_tb() self.__insert_data() + self.all_test() + return tdLog.printNoPrefix("==========step2:create table in rollup database") diff --git a/tests/system-test/2-query/join.py b/tests/system-test/2-query/join.py index 5ff11c84dd..df6390f59c 100644 --- a/tests/system-test/2-query/join.py +++ b/tests/system-test/2-query/join.py @@ -28,7 +28,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), True) + tdSql.init(conn.cursor(), False) def __query_condition(self,tbname): query_condition = [] diff --git a/tests/system-test/2-query/join2.py b/tests/system-test/2-query/join2.py index 40da41eee7..5533cb840e 100644 --- a/tests/system-test/2-query/join2.py +++ b/tests/system-test/2-query/join2.py @@ -28,7 +28,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), True) + tdSql.init(conn.cursor(), False) def __query_condition(self,tbname): query_condition = [] diff --git a/tests/system-test/2-query/substr.py b/tests/system-test/2-query/substr.py index 79b5ac515b..f833a42b57 100644 --- a/tests/system-test/2-query/substr.py +++ b/tests/system-test/2-query/substr.py @@ -31,7 +31,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(),False) def __substr_condition(self): # sourcery skip: extract-method substr_condition = [] From 86fd683c3a3da1b0a377556d8be2cf1a1b668347 Mon Sep 17 00:00:00 2001 From: cpwu Date: Wed, 22 Jun 2022 19:38:30 +0800 Subject: [PATCH 02/73] add create case --- tests/system-test/2-query/createdb.py | 149 ++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 tests/system-test/2-query/createdb.py diff --git a/tests/system-test/2-query/createdb.py b/tests/system-test/2-query/createdb.py new file mode 100644 index 0000000000..dd1a907dc9 --- /dev/null +++ b/tests/system-test/2-query/createdb.py @@ -0,0 +1,149 @@ +import datetime + +from dataclasses import dataclass +from typing import List +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * + +COL_SCHEMA = "INT" +PRIMARY_COL = "tS" +STBNAME = "stb1" +NTBNAME = "ntb1" + +TAG_SCHEMA = "INT" +NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) + +@dataclass +class DataSet: + ts_data : List[int] = None + int_data : List[int] = None + bint_data : List[int] = None + sint_data : List[int] = None + tint_data : List[int] = None + int_un_data : List[int] = None + bint_un_data: List[int] = None + sint_un_data: List[int] = None + tint_un_data: List[int] = None + float_data : List[float] = None + double_data : List[float] = None + bool_data : List[int] = None + binary_data : List[str] = None + nchar_data : List[str] = None + + def __post_init__(self): + self.ts_data = [] + self.int_data = [] + self.bint_data = [] + self.sint_data = [] + self.tint_data = [] + self.int_un_data = [] + self.bint_un_data = [] + self.sint_un_data = [] + self.tint_un_data = [] + self.float_data = [] + self.double_data = [] + self.bool_data = [] + self.binary_data = [] + self.nchar_data = [] + + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + + def __create_tb(self): + tdLog.printNoPrefix("==========step1:create table") + + cols = f"{PRIMARY_COL} timestamp " + tags = f"tag_0 {TAG_SCHEMA}" + + for i in range(4095): + cols += f", col_{i} {COL_SCHEMA}" + + for i in range(127): + tags += f", tag_{i+1} {TAG_SCHEMA}" + + create_stb_sql = f"create table {STBNAME}({cols}) tags ({tags})" + create_ntb_sql = f"create table {NTBNAME}({cols})" + + # tdSql.execute(create_stb_sql) + + # tag_row = "" + # for i in range(128): + # if tag_row: + # tag_row += f", {i}" + + # for i in range(4): + # tag_row = f"{i+1}" + # for j in range(127): + # tag_row += f", {i+1}" + # tdSql.execute(f'create table ct{i+1} using stb1 tags ( {tag_row} )') + + # return + tdSql.execute(create_ntb_sql) + + + def __data_set(self, rows): + data_set = DataSet() + + for i in range(rows): + data_set.ts_data.append(NOW + 1 * (rows - i)) + data_set.int_data.append(rows - i) + data_set.bint_data.append(11111 * (rows - i)) + data_set.sint_data.append(111 * (rows - i) % 32767) + data_set.tint_data.append(11 * (rows - i) % 127) + data_set.int_un_data.append(rows - i) + data_set.bint_un_data.append(11111 * (rows - i)) + data_set.sint_un_data.append(111 * (rows - i) % 32767) + data_set.tint_un_data.append(11 * (rows - i) % 127) + data_set.float_data.append(1.11 * (rows - i)) + data_set.double_data.append(1100.0011 * (rows - i)) + data_set.bool_data.append((rows - i) % 2) + data_set.binary_data.append(f'binary{(rows - i)}') + data_set.nchar_data.append(f'nchar_测试_{(rows - i)}') + + return data_set + + def __insert_data(self, rows): + tdLog.printNoPrefix("==========step: start inser data into tables now.....") + data = self.__data_set(rows=self.rows) + + for i in range(rows): + rows_data = f"{NOW - i * 1000}" + for j in range(4095): + rows_data += f", {data.int_data[i]} " + tdSql.execute( + f"insert into ct1 values ({rows_data})") + + + def run(self): + tdSql.prepare() + + tdLog.printNoPrefix("==========step1:create table") + self.__create_tb() + + tdLog.printNoPrefix("==========step2:insert data") + self.rows = 10 + # self.__insert_data(self.rows) + + tdLog.printNoPrefix("==========step3:all check") + # self.all_test() + + # tdDnodes.stop(1) + # tdDnodes.start(1) + + # tdSql.execute("use db") + + tdLog.printNoPrefix("==========step4:after wal, all check again ") + # self.all_test() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) From 3ddcfe3b3576af68980a14046adf1b340aa73fc4 Mon Sep 17 00:00:00 2001 From: cpwu Date: Wed, 22 Jun 2022 19:38:42 +0800 Subject: [PATCH 03/73] fix case --- tests/pytest/util/constant.py | 22 +++++- tests/system-test/1-insert/time_range_wise.py | 79 ++++++++++++++----- 2 files changed, 80 insertions(+), 21 deletions(-) diff --git a/tests/pytest/util/constant.py b/tests/pytest/util/constant.py index e5095c74dc..40522b76e7 100644 --- a/tests/pytest/util/constant.py +++ b/tests/pytest/util/constant.py @@ -66,4 +66,24 @@ MNODE_SHM_SIZE_DEFAULT = 6292480 VNODE_SHM_SIZE_MAX = 2147483647 VNODE_SHM_SIZE_MIN = 6292480 -VNODE_SHM_SIZE_DEFAULT = 31458304 \ No newline at end of file +VNODE_SHM_SIZE_DEFAULT = 31458304 + +# time_init +TIME_MS = 1 +TIME_US = TIME_MS/1000 +TIME_NS = TIME_US/1000 + +TIME_S = 1000 * TIME_MS +TIME_M = 60 * TIME_S +TIME_H = 60 * TIME_M +TIME_D = 24 * TIME_H +TIME_W = 7 * TIME_D +TIME_N = 30 * TIME_D +TIME_Y = 365 * TIME_D + + + +# streams and related agg-function +SMA_INDEX_FUNCTIONS = ["MIN", "MAX"] +ROLLUP_FUNCTIONS = ["AVG", "SUM", "MIN", "MAX", "LAST", "FIRST"] +SMA_WATMARK_MAXDELAY_INIT = ['a', "s", "m"] \ No newline at end of file diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index 4f84856dd9..58303fce42 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -7,7 +7,8 @@ from util.sql import * from util.cases import * from util.dnodes import * from util.constant import * -from ...pytest.util.sql import * +# from ...pytest.util.sql import * +# from ...pytest.util.constant import * PRIMARY_COL = "ts" @@ -31,6 +32,11 @@ CHAR_COL = [BINARY_COL, NCHAR_COL, ] BOOLEAN_COL = [BOOL_COL, ] TS_TYPE_COL = [TS_COL, ] +INT_TAG = "t_int" + +ALL_COL = [PRIMARY_COL, INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, BINARY_COL, NCHAR_COL, BOOL_COL, TS_COL] +TAG_COL = [INT_TAG] + # insert data args: TIME_STEP = 10000 NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) @@ -183,49 +189,80 @@ class TDTestCase: return sql def __check_sma_func(self, func:tuple): - sma_func_support = ["min", "max","avg"] - if not isinstance(func, str) or not isinstance(func, tuple) or not isinstance(func, list): + if not isinstance(func, str) and not isinstance(func, tuple) and not isinstance(func, list): return False if isinstance(func, str) : - if func.split("(")[0] not in sma_func_support: + if "(" not in func or ")" not in func: return False + if func.split("(")[0].upper() not in SMA_INDEX_FUNCTIONS: + return False + if func.split("(")[1].split(")")[0] not in ALL_COL and func.split("(")[1].split(")")[0] not in TAG_COL : + return False + if isinstance(func, tuple) or isinstance(func, list): + for arg in func: + if not isinstance(arg, str): + return False + if "(" not in arg or ")" not in arg: + return False + if arg.split("(")[0].upper() not in SMA_INDEX_FUNCTIONS: + return False + if arg.split("(")[1].split(")")[0] not in ALL_COL and arg.split("(")[1].split(")")[0] not in TAG_COL : + return False + return True + + def __check_sma_watermark_max_dealy(self, arg): + if not isinstance(arg, str): + return False + if arg[-1] not in SMA_WATMARK_MAXDELAY_INIT: + return False - def sma_create_check(self, sma:SMAschema): + + + def __sma_create_check(self, sma:SMAschema): if self.updatecfgDict["querySmaOptimize"] == 0: - tdSql.error(self.__create_sma_index(sma)) + return False tdSql.query("show stables") stb_in_list = False for row in tdSql.queryResult: if sma.tbname == row[0]: stb_in_list = True if not stb_in_list: - tdSql.error(self.__create_sma_index(sma)) + return False if not sma.creation or not isinstance(sma.creation, str) or sma.creation.upper() != "CREATE": - tdSql.error(self.__create_sma_index(sma)) + return False if not sma.index_flag or not isinstance(sma.index_flag, str) or sma.index_flag.upper() != "SMA INDEX" : - tdSql.error(self.__create_sma_index(sma)) + return False if not sma.index_name or not isinstance(sma.index_name, str): - tdSql.error(self.__create_sma_index(sma)) + return False if not sma.operator or not isinstance(sma.operator, str) or sma.operator.upper() != "ON": - tdSql.error(self.__create_sma_index(sma)) + return False if not sma.tbname: - tdSql.error(self.__create_sma_index(sma)) - if not sma.func: - tdSql.error(self.__create_sma_index(sma)) + return False + if not sma.func or not self.__check_sma_func(sma.func): + return False if not sma.interval: - tdSql.error(self.__create_sma_index(sma)) - if not sma.sliding: - tdSql.error(self.__create_sma_index(sma)) + return False + if not sma.sliding : + return False + if not sma.watermark: + return False + if not sma.max_delay: + return False if sma.other: - tdSql.error(self.__create_sma_index(sma)) + return False + + return True + + def sma_create_check(self, sma:SMAschema): + tdSql.query(self.__create_sma_index(sma)) if self.__sma_create_check(sma) else tdSql.error(self.__create_sma_index(sma)) @property def __create_sma_sql(self): err_sqls = [] cur_sqls = [] # err_set - # case 1: required fields check + # # case 1: required fields check err_sqls.append( SMAschema(creation="", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) err_sqls.append( SMAschema(index_name="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) @@ -234,6 +271,8 @@ class TDTestCase: err_sqls.append( SMAschema(func="",tbname=STBNAME ) ) err_sqls.append( SMAschema(interval="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) err_sqls.append( SMAschema(sliding="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(watermark="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) return err_sqls, cur_sqls @@ -255,7 +294,7 @@ class TDTestCase: {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned - ) tags (tag1 int) + ) tags ({INT_TAG} int) ''' create_ntb_sql = f'''create table {NTBNAME}( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, From ab2a07ef60eb07d48d372c939dec631ef33a2ef6 Mon Sep 17 00:00:00 2001 From: cpwu Date: Thu, 23 Jun 2022 09:25:07 +0800 Subject: [PATCH 04/73] fix : fix constant boundary --- tests/pytest/util/constant.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/pytest/util/constant.py b/tests/pytest/util/constant.py index 40522b76e7..cfbdc4ded0 100644 --- a/tests/pytest/util/constant.py +++ b/tests/pytest/util/constant.py @@ -1,5 +1,29 @@ # -*- coding: utf-8 -*- +# basic type +TAOS_DATA_TYPE = [ + "INT", "BIGINT", "SMALLINT", "TINYINT", "INT UNSIGNED", "BIGINT UNSIGNED", "SMALLINT UNSIGNED", "TINYINT UNSIGNED", + "FLOAT", "DOUBLE", + "BOOL", + "BINARY", "NCHAR", "VARCHAR", + "TIMESTAMP", + # "MEDIUMBLOB", "BLOB", # add in 3.x + # "DECIMAL", "NUMERIC", # add in 3.x +] + +TAOS_NUM_TYPE = [ + "INT", "BIGINT", "SMALLINT", "TINYINT", "INT UNSIGNED", "BIGINT UNSIGNED", "SMALLINT UNSIGNED", "TINYINT UNSIGNED", "FLOAT", "DOUBLE", + # "DECIMAL", "NUMERIC", # add in 3.x +] +TAOS_CHAR_TYPE = [ + "BINARY", "NCHAR", "VARCHAR", +] +TAOS_BOOL_TYPE = ["BOOL",] +TAOS_TS_TYPE = ["TIMESTAMP",] +TAOS_BIN_TYPE = [ + "MEDIUMBLOB", "BLOB", # add in 3.x +] + # basic data type boundary TINYINT_MAX = 127 TINYINT_MIN = -128 From bf3af717e7a1e88099a86deb969859716f7ccc7a Mon Sep 17 00:00:00 2001 From: cpwu Date: Thu, 23 Jun 2022 10:37:57 +0800 Subject: [PATCH 05/73] fix case --- tests/system-test/2-query/createdb.py | 52 +++++++++++++++++++-------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/tests/system-test/2-query/createdb.py b/tests/system-test/2-query/createdb.py index dd1a907dc9..59ff756c08 100644 --- a/tests/system-test/2-query/createdb.py +++ b/tests/system-test/2-query/createdb.py @@ -70,22 +70,42 @@ class TDTestCase: create_stb_sql = f"create table {STBNAME}({cols}) tags ({tags})" create_ntb_sql = f"create table {NTBNAME}({cols})" - # tdSql.execute(create_stb_sql) + tdSql.execute(create_stb_sql) - # tag_row = "" - # for i in range(128): - # if tag_row: - # tag_row += f", {i}" + tag_row = "" + for i in range(128): + if tag_row: + tag_row += f", {i}" - # for i in range(4): - # tag_row = f"{i+1}" - # for j in range(127): - # tag_row += f", {i+1}" - # tdSql.execute(f'create table ct{i+1} using stb1 tags ( {tag_row} )') + for i in range(4): + tag_row = f"{i+1}" + for j in range(127): + tag_row += f", {i+1}" + tdSql.execute(f'create table ct{i+1} using stb1 tags ( {tag_row} )') - # return + return tdSql.execute(create_ntb_sql) + def query_data(self): + cols = f"{PRIMARY_COL} " + tags = f"tag_0 " + + for i in range(4095): + cols += f", col_{i} " + + for i in range(127): + tags += f", tag_{i+1} " + tdSql.query(f'select {cols} from stb1') + tdSql.checkRows(self.rows) + tdSql.query(f'select {cols} from ct1') + tdSql.checkRows(self.rows) + tdSql.query(f'select {cols} from ct2') + tdSql.checkRows(0) + tdSql.query(f'select {tags} from ct1') + tdSql.checkRows(1) + tdSql.query(f'select {tags} from stb1') + tdSql.checkRows(4) + def __data_set(self, rows): data_set = DataSet() @@ -128,17 +148,19 @@ class TDTestCase: tdLog.printNoPrefix("==========step2:insert data") self.rows = 10 - # self.__insert_data(self.rows) + self.__insert_data(self.rows) tdLog.printNoPrefix("==========step3:all check") + self.query_data() # self.all_test() - # tdDnodes.stop(1) - # tdDnodes.start(1) + tdDnodes.stop(1) + tdDnodes.start(1) - # tdSql.execute("use db") + tdSql.execute("use db") tdLog.printNoPrefix("==========step4:after wal, all check again ") + self.query_data() # self.all_test() def stop(self): From 57696bd3e19f6c1cbbbb4cf09aed8134c42c7e6e Mon Sep 17 00:00:00 2001 From: cpwu Date: Thu, 23 Jun 2022 12:59:05 +0800 Subject: [PATCH 06/73] fix case --- tests/pytest/util/constant.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pytest/util/constant.py b/tests/pytest/util/constant.py index cfbdc4ded0..eadc30d2df 100644 --- a/tests/pytest/util/constant.py +++ b/tests/pytest/util/constant.py @@ -9,6 +9,7 @@ TAOS_DATA_TYPE = [ "TIMESTAMP", # "MEDIUMBLOB", "BLOB", # add in 3.x # "DECIMAL", "NUMERIC", # add in 3.x + "JSON", # only for tag ] TAOS_NUM_TYPE = [ From beea5581dbbdc2484b3c80745dd0fcaf43b6eaf8 Mon Sep 17 00:00:00 2001 From: cpwu Date: Thu, 23 Jun 2022 15:47:41 +0800 Subject: [PATCH 07/73] fix case --- tests/system-test/2-query/createdb.py | 171 -------------------------- 1 file changed, 171 deletions(-) delete mode 100644 tests/system-test/2-query/createdb.py diff --git a/tests/system-test/2-query/createdb.py b/tests/system-test/2-query/createdb.py deleted file mode 100644 index 59ff756c08..0000000000 --- a/tests/system-test/2-query/createdb.py +++ /dev/null @@ -1,171 +0,0 @@ -import datetime - -from dataclasses import dataclass -from typing import List -from util.log import * -from util.sql import * -from util.cases import * -from util.dnodes import * - -COL_SCHEMA = "INT" -PRIMARY_COL = "tS" -STBNAME = "stb1" -NTBNAME = "ntb1" - -TAG_SCHEMA = "INT" -NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) - -@dataclass -class DataSet: - ts_data : List[int] = None - int_data : List[int] = None - bint_data : List[int] = None - sint_data : List[int] = None - tint_data : List[int] = None - int_un_data : List[int] = None - bint_un_data: List[int] = None - sint_un_data: List[int] = None - tint_un_data: List[int] = None - float_data : List[float] = None - double_data : List[float] = None - bool_data : List[int] = None - binary_data : List[str] = None - nchar_data : List[str] = None - - def __post_init__(self): - self.ts_data = [] - self.int_data = [] - self.bint_data = [] - self.sint_data = [] - self.tint_data = [] - self.int_un_data = [] - self.bint_un_data = [] - self.sint_un_data = [] - self.tint_un_data = [] - self.float_data = [] - self.double_data = [] - self.bool_data = [] - self.binary_data = [] - self.nchar_data = [] - - -class TDTestCase: - - def init(self, conn, logSql): - tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), True) - - def __create_tb(self): - tdLog.printNoPrefix("==========step1:create table") - - cols = f"{PRIMARY_COL} timestamp " - tags = f"tag_0 {TAG_SCHEMA}" - - for i in range(4095): - cols += f", col_{i} {COL_SCHEMA}" - - for i in range(127): - tags += f", tag_{i+1} {TAG_SCHEMA}" - - create_stb_sql = f"create table {STBNAME}({cols}) tags ({tags})" - create_ntb_sql = f"create table {NTBNAME}({cols})" - - tdSql.execute(create_stb_sql) - - tag_row = "" - for i in range(128): - if tag_row: - tag_row += f", {i}" - - for i in range(4): - tag_row = f"{i+1}" - for j in range(127): - tag_row += f", {i+1}" - tdSql.execute(f'create table ct{i+1} using stb1 tags ( {tag_row} )') - - return - tdSql.execute(create_ntb_sql) - - def query_data(self): - cols = f"{PRIMARY_COL} " - tags = f"tag_0 " - - for i in range(4095): - cols += f", col_{i} " - - for i in range(127): - tags += f", tag_{i+1} " - tdSql.query(f'select {cols} from stb1') - tdSql.checkRows(self.rows) - tdSql.query(f'select {cols} from ct1') - tdSql.checkRows(self.rows) - tdSql.query(f'select {cols} from ct2') - tdSql.checkRows(0) - tdSql.query(f'select {tags} from ct1') - tdSql.checkRows(1) - tdSql.query(f'select {tags} from stb1') - tdSql.checkRows(4) - - - def __data_set(self, rows): - data_set = DataSet() - - for i in range(rows): - data_set.ts_data.append(NOW + 1 * (rows - i)) - data_set.int_data.append(rows - i) - data_set.bint_data.append(11111 * (rows - i)) - data_set.sint_data.append(111 * (rows - i) % 32767) - data_set.tint_data.append(11 * (rows - i) % 127) - data_set.int_un_data.append(rows - i) - data_set.bint_un_data.append(11111 * (rows - i)) - data_set.sint_un_data.append(111 * (rows - i) % 32767) - data_set.tint_un_data.append(11 * (rows - i) % 127) - data_set.float_data.append(1.11 * (rows - i)) - data_set.double_data.append(1100.0011 * (rows - i)) - data_set.bool_data.append((rows - i) % 2) - data_set.binary_data.append(f'binary{(rows - i)}') - data_set.nchar_data.append(f'nchar_测试_{(rows - i)}') - - return data_set - - def __insert_data(self, rows): - tdLog.printNoPrefix("==========step: start inser data into tables now.....") - data = self.__data_set(rows=self.rows) - - for i in range(rows): - rows_data = f"{NOW - i * 1000}" - for j in range(4095): - rows_data += f", {data.int_data[i]} " - tdSql.execute( - f"insert into ct1 values ({rows_data})") - - - def run(self): - tdSql.prepare() - - tdLog.printNoPrefix("==========step1:create table") - self.__create_tb() - - tdLog.printNoPrefix("==========step2:insert data") - self.rows = 10 - self.__insert_data(self.rows) - - tdLog.printNoPrefix("==========step3:all check") - self.query_data() - # self.all_test() - - tdDnodes.stop(1) - tdDnodes.start(1) - - tdSql.execute("use db") - - tdLog.printNoPrefix("==========step4:after wal, all check again ") - self.query_data() - # self.all_test() - - def stop(self): - tdSql.close() - tdLog.success(f"{__file__} successfully executed") - -tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) From f000a2df96715e0818f5b4f00268fd9092357553 Mon Sep 17 00:00:00 2001 From: cpwu Date: Thu, 23 Jun 2022 19:53:48 +0800 Subject: [PATCH 08/73] fix case --- tests/pytest/util/constant.py | 11 +++- tests/pytest/util/sql.py | 36 +++++++++++ tests/system-test/1-insert/time_range_wise.py | 63 ++++++++++++++----- 3 files changed, 94 insertions(+), 16 deletions(-) diff --git a/tests/pytest/util/constant.py b/tests/pytest/util/constant.py index eadc30d2df..b6af49737c 100644 --- a/tests/pytest/util/constant.py +++ b/tests/pytest/util/constant.py @@ -25,6 +25,9 @@ TAOS_BIN_TYPE = [ "MEDIUMBLOB", "BLOB", # add in 3.x ] +TAOS_TIME_INIT = ["b", "u", "a", "s", "m", "h", "d", "w", "n", "y"] +TAOS_PRECISION = ["ms", "us", "ns"] + # basic data type boundary TINYINT_MAX = 127 TINYINT_MIN = -128 @@ -108,7 +111,13 @@ TIME_Y = 365 * TIME_D + # streams and related agg-function SMA_INDEX_FUNCTIONS = ["MIN", "MAX"] ROLLUP_FUNCTIONS = ["AVG", "SUM", "MIN", "MAX", "LAST", "FIRST"] -SMA_WATMARK_MAXDELAY_INIT = ['a', "s", "m"] \ No newline at end of file +SMA_WATMARK_MAXDELAY_INIT = ['a', "s", "m"] +WATERMARK_MAX = 900000 +WATERMARK_MIN = 0 + +MAX_DELAY_MAX = 900000 +MAX_DELAY_MIN = 1 \ No newline at end of file diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 580fc8ee47..d417551cce 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -21,6 +21,7 @@ import psutil import shutil import pandas as pd from util.log import * +from util.constant import * def _parse_datetime(timestr): try: @@ -301,6 +302,41 @@ class TDSql: args = (caller.filename, caller.lineno, self.sql, elm, expect_elm) tdLog.exit("%s(%d) failed: sql:%s, elm:%s == expect_elm:%s" % args) + def get_times(self, time_str, precision="ms"): + caller = inspect.getframeinfo(inspect.stack()[1][0]) + if time_str[-1] not in TAOS_TIME_INIT: + tdLog.exit(f"{caller.filename}({caller.lineno}) failed: {time_str} not a standard taos time init") + if precision not in TAOS_PRECISION: + tdLog.exit(f"{caller.filename}({caller.lineno}) failed: {precision} not a standard taos time precision") + + if time_str[-1] == TAOS_TIME_INIT[0]: + times = int(time_str[:-1]) * TIME_NS + if time_str[-1] == TAOS_TIME_INIT[1]: + times = int(time_str[:-1]) * TIME_US + if time_str[-1] == TAOS_TIME_INIT[2]: + times = int(time_str[:-1]) * TIME_MS + if time_str[-1] == TAOS_TIME_INIT[3]: + times = int(time_str[:-1]) * TIME_S + if time_str[-1] == TAOS_TIME_INIT[4]: + times = int(time_str[:-1]) * TIME_M + if time_str[-1] == TAOS_TIME_INIT[5]: + times = int(time_str[:-1]) * TIME_H + if time_str[-1] == TAOS_TIME_INIT[6]: + times = int(time_str[:-1]) * TIME_D + if time_str[-1] == TAOS_TIME_INIT[7]: + times = int(time_str[:-1]) * TIME_W + if time_str[-1] == TAOS_TIME_INIT[8]: + times = int(time_str[:-1]) * TIME_N + if time_str[-1] == TAOS_TIME_INIT[9]: + times = int(time_str[:-1]) * TIME_Y + + if precision == "ms": + return int(times) + elif precision == "us": + return int(times*1000) + elif precision == "ns": + return int(times*1000*1000) + def taosdStatus(self, state): tdLog.sleep(5) pstate = 0 diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index 58303fce42..76fee51e16 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -7,8 +7,6 @@ from util.sql import * from util.cases import * from util.dnodes import * from util.constant import * -# from ...pytest.util.sql import * -# from ...pytest.util.constant import * PRIMARY_COL = "ts" @@ -144,12 +142,16 @@ class SMAschema: del self.other[k] +from ...pytest.util.sql import * +from ...pytest.util.constant import * + class TDTestCase: updatecfgDict = {"querySmaOptimize": 1} def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) + self.precision = "ms" """ create sma index : @@ -210,14 +212,43 @@ class TDTestCase: return False return True - def __check_sma_watermark_max_dealy(self, arg): + def __check_sma_watermark(self, arg): if not isinstance(arg, str): return False if arg[-1] not in SMA_WATMARK_MAXDELAY_INIT: return False + if len(arg) == 1: + return False + if not arg[:-1].isdecimal(): + return False + if tdSql.get_times(arg) > WATERMARK_MAX: + return False + if tdSql.get_times(arg) < WATERMARK_MIN: + return False + + return True + + def __check_sma_max_delay(self, arg): + self.__check_sma_watermark(arg) + if tdSql.get_times(arg) < MAX_DELAY_MIN: + return False + + return True + + def __check_sliding(self, arg): + if not isinstance(arg, str): + return False + if arg[-1] not in TAOS_TIME_INIT: + return False + if len(arg) == 1: + return False + if not arg[:-1].isdecimal(): + return False - + def __check_interval(self, arg): + if not isinstance(arg, tuple): + return False def __sma_create_check(self, sma:SMAschema): if self.updatecfgDict["querySmaOptimize"] == 0: @@ -245,9 +276,9 @@ class TDTestCase: return False if not sma.sliding : return False - if not sma.watermark: + if not sma.watermark or not self.__check_sma_watermark(sma.watermark): return False - if not sma.max_delay: + if not sma.max_delay or not self.__check_sma_max_delay(sma.max_delay): return False if sma.other: return False @@ -263,22 +294,24 @@ class TDTestCase: cur_sqls = [] # err_set # # case 1: required fields check - err_sqls.append( SMAschema(creation="", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - err_sqls.append( SMAschema(index_name="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - err_sqls.append( SMAschema(operator="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - err_sqls.append( SMAschema(tbname="", func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - err_sqls.append( SMAschema(func="",tbname=STBNAME ) ) - err_sqls.append( SMAschema(interval="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - err_sqls.append( SMAschema(sliding="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - err_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + # err_sqls.append( SMAschema(creation="", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + # err_sqls.append( SMAschema(index_name="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + # err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + # err_sqls.append( SMAschema(operator="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + # err_sqls.append( SMAschema(tbname="", func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + # err_sqls.append( SMAschema(func="",tbname=STBNAME ) ) + # err_sqls.append( SMAschema(interval="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + # err_sqls.append( SMAschema(sliding="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + # err_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) err_sqls.append( SMAschema(watermark="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) return err_sqls, cur_sqls + def test_create_sma(self): err_sqls , cur_sqls = self.__create_sma_sql for err_sql in err_sqls: + print(type(err_sql.watermark)) self.sma_create_check(err_sql) def all_test(self): From d8440475da8ee133f0bda1032339d9c3f168e18c Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 24 Jun 2022 14:59:29 +0800 Subject: [PATCH 09/73] fix case --- tests/pytest/util/constant.py | 4 ++ tests/system-test/1-insert/time_range_wise.py | 61 +++++++++++++++---- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/tests/pytest/util/constant.py b/tests/pytest/util/constant.py index b6af49737c..49aa35996a 100644 --- a/tests/pytest/util/constant.py +++ b/tests/pytest/util/constant.py @@ -27,6 +27,8 @@ TAOS_BIN_TYPE = [ TAOS_TIME_INIT = ["b", "u", "a", "s", "m", "h", "d", "w", "n", "y"] TAOS_PRECISION = ["ms", "us", "ns"] +PRECISION_DEFAULT = "ms" +PRECISION = PRECISION_DEFAULT # basic data type boundary TINYINT_MAX = 127 @@ -110,6 +112,8 @@ TIME_N = 30 * TIME_D TIME_Y = 365 * TIME_D +# session parameters +INTERVAL_MIN = 1 * TIME_MS if PRECISION == PRECISION_DEFAULT else 1 * TIME_US # streams and related agg-function diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index 76fee51e16..2fb9b17220 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -142,8 +142,8 @@ class SMAschema: del self.other[k] -from ...pytest.util.sql import * -from ...pytest.util.constant import * +# from ...pytest.util.sql import * +# from ...pytest.util.constant import * class TDTestCase: updatecfgDict = {"querySmaOptimize": 1} @@ -170,7 +170,11 @@ class TDTestCase: if sma.func: sql += f" function({', '.join(sma.func)})" if sma.interval: - sql += f" interval({', '.join(sma.interval)})" + interval, offset = self.__get_interval_offset(sma.interval) + if offset: + sql += f" interval({interval}, {offset})" + else: + sql += f" interval({interval})" if sma.sliding: sql += f" sliding({sma.sliding})" if sma.watermark: @@ -213,6 +217,8 @@ class TDTestCase: return True def __check_sma_watermark(self, arg): + if not arg: + return False if not isinstance(arg, str): return False if arg[-1] not in SMA_WATMARK_MAXDELAY_INIT: @@ -229,13 +235,14 @@ class TDTestCase: return True def __check_sma_max_delay(self, arg): - self.__check_sma_watermark(arg) + if not self.__check_sma_watermark(arg): + return False if tdSql.get_times(arg) < MAX_DELAY_MIN: return False return True - def __check_sliding(self, arg): + def __check_sma_sliding(self, arg): if not isinstance(arg, str): return False if arg[-1] not in TAOS_TIME_INIT: @@ -245,10 +252,40 @@ class TDTestCase: if not arg[:-1].isdecimal(): return False + return True - def __check_interval(self, arg): - if not isinstance(arg, tuple): + def __get_interval_offset(self, args): + if isinstance(args, str): + interval, offset = args, None + elif isinstance(args,tuple) or isinstance(args, list): + if len(args) == 1: + interval, offset = args[0], None + elif len(args) == 2: + interval, offset = args + else: + interval, offset = False, False + else: + interval, offset = False, False + + return interval, offset + + def __check_sma_interval(self, args): + if not isinstance(args, tuple) and not isinstance(args,str): return False + interval, offset = self.__get_interval_offset(args) + if not interval: + return False + if not self.__check_sma_sliding(interval): + return False + if tdSql.get_times(interval) < INTERVAL_MIN: + return False + if offset: + if not self.__check_sma_sliding(offset): + return False + if tdSql.get_times(interval) <= tdSql.get_times(offset) : + return False + + return True def __sma_create_check(self, sma:SMAschema): if self.updatecfgDict["querySmaOptimize"] == 0: @@ -272,9 +309,10 @@ class TDTestCase: return False if not sma.func or not self.__check_sma_func(sma.func): return False - if not sma.interval: + if not sma.sliding or not self.__check_sma_sliding(sma.sliding): return False - if not sma.sliding : + interval, _ = self.__get_interval_offset(sma.interval) + if not sma.interval or not self.__check_sma_interval(sma.interval) or tdSql.get_times(interval) < tdSql.get_times(sma.sliding): return False if not sma.watermark or not self.__check_sma_watermark(sma.watermark): return False @@ -300,10 +338,10 @@ class TDTestCase: # err_sqls.append( SMAschema(operator="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) # err_sqls.append( SMAschema(tbname="", func=(f"min({INT_COL})",f"max({INT_COL})") ) ) # err_sqls.append( SMAschema(func="",tbname=STBNAME ) ) - # err_sqls.append( SMAschema(interval="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(interval=("6m"),tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) # err_sqls.append( SMAschema(sliding="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) # err_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - err_sqls.append( SMAschema(watermark="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + # err_sqls.append( SMAschema(watermark="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) return err_sqls, cur_sqls @@ -311,7 +349,6 @@ class TDTestCase: def test_create_sma(self): err_sqls , cur_sqls = self.__create_sma_sql for err_sql in err_sqls: - print(type(err_sql.watermark)) self.sma_create_check(err_sql) def all_test(self): From 23fc7ee8ebce0ff2d1718349312fb392791aabd2 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 22 Jun 2022 17:34:16 +0800 Subject: [PATCH 10/73] refactor: nodesClone interface refactor --- source/libs/nodes/src/nodesCloneFuncs.c | 329 ++++++++++++------------ 1 file changed, 163 insertions(+), 166 deletions(-) diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 05eaa88a83..7e35a7d097 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -41,8 +41,7 @@ } \ (pDst)->fldname = strdup((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ + return TSDB_CODE_OUT_OF_MEMORY; \ } \ } while (0) @@ -53,8 +52,7 @@ } \ (pDst)->fldname = nodesCloneNode((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ + return TSDB_CODE_OUT_OF_MEMORY; \ } \ } while (0) @@ -65,8 +63,7 @@ } \ (pDst)->fldname = (nodePtrType)nodesCloneNode((SNode*)(pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ + return TSDB_CODE_OUT_OF_MEMORY; \ } \ } while (0) @@ -77,8 +74,7 @@ } \ (pDst)->fldname = nodesCloneList((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ + return TSDB_CODE_OUT_OF_MEMORY; \ } \ } while (0) @@ -89,27 +85,25 @@ } \ (pDst)->fldname = cloneFunc((pSrc)->fldname); \ if (NULL == (pDst)->fldname) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ + return TSDB_CODE_OUT_OF_MEMORY; \ } \ } while (0) -#define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \ - do { \ - if (NULL == copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \ - nodesDestroyNode((SNode*)pDst); \ - return NULL; \ - } \ +#define COPY_BASE_OBJECT_FIELD(fldname, copyFunc) \ + do { \ + if (TSDB_CODE_SUCCESS != copyFunc(&((pSrc)->fldname), &((pDst)->fldname))) { \ + return TSDB_CODE_OUT_OF_MEMORY; \ + } \ } while (0) -static SNode* exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) { +static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) { COPY_OBJECT_FIELD(resType, sizeof(SDataType)); COPY_CHAR_ARRAY_FIELD(aliasName); COPY_CHAR_ARRAY_FIELD(userAlias); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) { +static int32_t columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_SCALAR_FIELD(tableId); COPY_SCALAR_FIELD(tableType); @@ -122,10 +116,10 @@ static SNode* columnNodeCopy(const SColumnNode* pSrc, SColumnNode* pDst) { COPY_CHAR_ARRAY_FIELD(colName); COPY_SCALAR_FIELD(dataBlockId); COPY_SCALAR_FIELD(slotId); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { +static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_CHAR_POINT_FIELD(literal); COPY_SCALAR_FIELD(isDuration); @@ -135,7 +129,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { COPY_SCALAR_FIELD(typeData); COPY_SCALAR_FIELD(unit); if (!pSrc->translate) { - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } switch (pSrc->node.resType.type) { case TSDB_DATA_TYPE_BOOL: @@ -164,8 +158,7 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { int32_t len = varDataTLen(pSrc->datum.p) + 1; pDst->datum.p = taosMemoryCalloc(1, len); if (NULL == pDst->datum.p) { - nodesDestroyNode((SNode*)pDst); - return NULL; + return TSDB_CODE_OUT_OF_MEMORY; } memcpy(pDst->datum.p, pSrc->datum.p, len); break; @@ -177,42 +170,42 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { default: break; } - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* operatorNodeCopy(const SOperatorNode* pSrc, SOperatorNode* pDst) { +static int32_t operatorNodeCopy(const SOperatorNode* pSrc, SOperatorNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_SCALAR_FIELD(opType); CLONE_NODE_FIELD(pLeft); CLONE_NODE_FIELD(pRight); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicConditionNodeCopy(const SLogicConditionNode* pSrc, SLogicConditionNode* pDst) { +static int32_t logicConditionNodeCopy(const SLogicConditionNode* pSrc, SLogicConditionNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_SCALAR_FIELD(condType); CLONE_NODE_LIST_FIELD(pParameterList); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) { +static int32_t functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_CHAR_ARRAY_FIELD(functionName); COPY_SCALAR_FIELD(funcId); COPY_SCALAR_FIELD(funcType); CLONE_NODE_LIST_FIELD(pParameterList); COPY_SCALAR_FIELD(udfBufSize); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* tableNodeCopy(const STableNode* pSrc, STableNode* pDst) { +static int32_t tableNodeCopy(const STableNode* pSrc, STableNode* pDst) { COPY_BASE_OBJECT_FIELD(node, exprNodeCopy); COPY_CHAR_ARRAY_FIELD(dbName); COPY_CHAR_ARRAY_FIELD(tableName); COPY_CHAR_ARRAY_FIELD(tableAlias); COPY_SCALAR_FIELD(precision); COPY_SCALAR_FIELD(singleTable); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } static STableMeta* tableMetaClone(const STableMeta* pSrc) { @@ -235,101 +228,101 @@ static SVgroupsInfo* vgroupsInfoClone(const SVgroupsInfo* pSrc) { return pDst; } -static SNode* realTableNodeCopy(const SRealTableNode* pSrc, SRealTableNode* pDst) { +static int32_t realTableNodeCopy(const SRealTableNode* pSrc, SRealTableNode* pDst) { COPY_BASE_OBJECT_FIELD(table, tableNodeCopy); CLONE_OBJECT_FIELD(pMeta, tableMetaClone); CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone); COPY_CHAR_ARRAY_FIELD(qualDbName); COPY_SCALAR_FIELD(ratio); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* tempTableNodeCopy(const STempTableNode* pSrc, STempTableNode* pDst) { +static int32_t tempTableNodeCopy(const STempTableNode* pSrc, STempTableNode* pDst) { COPY_BASE_OBJECT_FIELD(table, tableNodeCopy); CLONE_NODE_FIELD(pSubquery); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDst) { +static int32_t joinTableNodeCopy(const SJoinTableNode* pSrc, SJoinTableNode* pDst) { COPY_BASE_OBJECT_FIELD(table, tableNodeCopy); COPY_SCALAR_FIELD(joinType); CLONE_NODE_FIELD(pLeft); CLONE_NODE_FIELD(pRight); CLONE_NODE_FIELD(pOnCond); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* targetNodeCopy(const STargetNode* pSrc, STargetNode* pDst) { +static int32_t targetNodeCopy(const STargetNode* pSrc, STargetNode* pDst) { COPY_SCALAR_FIELD(dataBlockId); COPY_SCALAR_FIELD(slotId); CLONE_NODE_FIELD(pExpr); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode* pDst) { +static int32_t groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode* pDst) { COPY_SCALAR_FIELD(groupingSetType); CLONE_NODE_LIST_FIELD(pParameterList); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* orderByExprNodeCopy(const SOrderByExprNode* pSrc, SOrderByExprNode* pDst) { +static int32_t orderByExprNodeCopy(const SOrderByExprNode* pSrc, SOrderByExprNode* pDst) { CLONE_NODE_FIELD(pExpr); COPY_SCALAR_FIELD(order); COPY_SCALAR_FIELD(nullOrder); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* limitNodeCopy(const SLimitNode* pSrc, SLimitNode* pDst) { +static int32_t limitNodeCopy(const SLimitNode* pSrc, SLimitNode* pDst) { COPY_SCALAR_FIELD(limit); COPY_SCALAR_FIELD(offset); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode* pDst) { +static int32_t stateWindowNodeCopy(const SStateWindowNode* pSrc, SStateWindowNode* pDst) { CLONE_NODE_FIELD(pCol); CLONE_NODE_FIELD(pExpr); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) { +static int32_t sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) { CLONE_NODE_FIELD_EX(pCol, SColumnNode*); CLONE_NODE_FIELD_EX(pGap, SValueNode*); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SIntervalWindowNode* pDst) { +static int32_t intervalWindowNodeCopy(const SIntervalWindowNode* pSrc, SIntervalWindowNode* pDst) { CLONE_NODE_FIELD(pCol); CLONE_NODE_FIELD(pInterval); CLONE_NODE_FIELD(pOffset); CLONE_NODE_FIELD(pSliding); CLONE_NODE_FIELD(pFill); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) { +static int32_t nodeListNodeCopy(const SNodeListNode* pSrc, SNodeListNode* pDst) { COPY_OBJECT_FIELD(dataType, sizeof(SDataType)); CLONE_NODE_LIST_FIELD(pNodeList); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) { +static int32_t fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) { COPY_SCALAR_FIELD(mode); CLONE_NODE_FIELD(pValues); CLONE_NODE_FIELD(pWStartTs); COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow)); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) { +static int32_t logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) { CLONE_NODE_LIST_FIELD(pTargets); CLONE_NODE_FIELD(pConditions); CLONE_NODE_LIST_FIELD(pChildren); COPY_SCALAR_FIELD(optimizedFlag); COPY_SCALAR_FIELD(precision); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { +static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pScanCols); CLONE_NODE_LIST_FIELD(pScanPseudoCols); @@ -357,25 +350,25 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { COPY_SCALAR_FIELD(tsColId); COPY_SCALAR_FIELD(filesFactor); CLONE_NODE_LIST_FIELD(pPartTags); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) { +static int32_t logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); COPY_SCALAR_FIELD(joinType); CLONE_NODE_FIELD(pOnConditions); COPY_SCALAR_FIELD(isSingleTableJoin); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) { +static int32_t logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pGroupKeys); CLONE_NODE_LIST_FIELD(pAggFuncs); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode* pDst) { +static int32_t logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pProjections); COPY_CHAR_ARRAY_FIELD(stmtName); @@ -383,10 +376,10 @@ static SNode* logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode* COPY_SCALAR_FIELD(offset); COPY_SCALAR_FIELD(slimit); COPY_SCALAR_FIELD(soffset); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModifyLogicNode* pDst) { +static int32_t logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModifyLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); COPY_SCALAR_FIELD(modifyType); COPY_SCALAR_FIELD(msgType); @@ -395,25 +388,25 @@ static SNode* logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModif COPY_SCALAR_FIELD(tableType); COPY_CHAR_ARRAY_FIELD(tableFName); COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow)); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNode* pDst) { +static int32_t logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); COPY_SCALAR_FIELD(srcGroupId); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst) { +static int32_t logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pMergeKeys); CLONE_NODE_LIST_FIELD(pInputs); COPY_SCALAR_FIELD(numOfChannels); COPY_SCALAR_FIELD(srcGroupId); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) { +static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); COPY_SCALAR_FIELD(winType); CLONE_NODE_LIST_FIELD(pFuncs); @@ -430,37 +423,37 @@ static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pD COPY_SCALAR_FIELD(watermark); COPY_SCALAR_FIELD(filesFactor); COPY_SCALAR_FIELD(windowAlgo); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) { +static int32_t logicFillCopy(const SFillLogicNode* pSrc, SFillLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); COPY_SCALAR_FIELD(mode); CLONE_NODE_FIELD(pWStartTs); CLONE_NODE_FIELD(pValues); COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow)); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicSortCopy(const SSortLogicNode* pSrc, SSortLogicNode* pDst) { +static int32_t logicSortCopy(const SSortLogicNode* pSrc, SSortLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pSortKeys); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogicNode* pDst) { +static int32_t logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pPartitionKeys); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndefRowsFuncLogicNode* pDst) { +static int32_t logicIndefRowsFuncCopy(const SIndefRowsFuncLogicNode* pSrc, SIndefRowsFuncLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pFuncs); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncLogicNode* pDst) { +static int32_t logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncLogicNode* pDst) { COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pFuncs); COPY_OBJECT_FIELD(timeRange, sizeof(STimeWindow)); @@ -468,26 +461,26 @@ static SNode* logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncL COPY_SCALAR_FIELD(fillMode); CLONE_NODE_FIELD(pFillValues); CLONE_NODE_FIELD(pTimeSeries); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) { +static int32_t logicSubplanCopy(const SLogicSubplan* pSrc, SLogicSubplan* pDst) { COPY_OBJECT_FIELD(id, sizeof(SSubplanId)); CLONE_NODE_FIELD_EX(pNode, SLogicNode*); COPY_SCALAR_FIELD(subplanType); COPY_SCALAR_FIELD(level); COPY_SCALAR_FIELD(splitFlag); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) { +static int32_t physiNodeCopy(const SPhysiNode* pSrc, SPhysiNode* pDst) { CLONE_NODE_FIELD_EX(pOutputDataBlockDesc, SDataBlockDescNode*); CLONE_NODE_FIELD(pConditions); CLONE_NODE_LIST_FIELD(pChildren); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) { +static int32_t physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(node, physiNodeCopy); CLONE_NODE_LIST_FIELD(pScanCols); CLONE_NODE_LIST_FIELD(pScanPseudoCols); @@ -495,14 +488,14 @@ static SNode* physiScanCopy(const SScanPhysiNode* pSrc, SScanPhysiNode* pDst) { COPY_SCALAR_FIELD(suid); COPY_SCALAR_FIELD(tableType); COPY_OBJECT_FIELD(tableName, sizeof(SName)); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiTagScanCopy(const STagScanPhysiNode* pSrc, STagScanPhysiNode* pDst) { +static int32_t physiTagScanCopy(const STagScanPhysiNode* pSrc, STagScanPhysiNode* pDst) { return physiScanCopy(pSrc, pDst); } -static SNode* physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhysiNode* pDst) { +static int32_t physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(scan, physiScanCopy); COPY_OBJECT_FIELD(scanSeq[0], sizeof(uint8_t) * 2); COPY_OBJECT_FIELD(scanRange, sizeof(STimeWindow)); @@ -519,18 +512,18 @@ static SNode* physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhys COPY_SCALAR_FIELD(watermark); COPY_SCALAR_FIELD(tsColId); COPY_SCALAR_FIELD(filesFactor); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSystemTableScanPhysiNode* pDst) { +static int32_t physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSystemTableScanPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(scan, physiScanCopy); COPY_OBJECT_FIELD(mgmtEpSet, sizeof(SEpSet)); COPY_SCALAR_FIELD(showRewrite); COPY_SCALAR_FIELD(accountId); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pDst) { +static int32_t physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(node, physiNodeCopy); CLONE_NODE_LIST_FIELD(pExprs); CLONE_NODE_LIST_FIELD(pFuncs); @@ -539,59 +532,59 @@ static SNode* physiWindowCopy(const SWinodwPhysiNode* pSrc, SWinodwPhysiNode* pD COPY_SCALAR_FIELD(triggerType); COPY_SCALAR_FIELD(watermark); COPY_SCALAR_FIELD(filesFactor); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiIntervalCopy(const SIntervalPhysiNode* pSrc, SIntervalPhysiNode* pDst) { +static int32_t physiIntervalCopy(const SIntervalPhysiNode* pSrc, SIntervalPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(window, physiWindowCopy); COPY_SCALAR_FIELD(interval); COPY_SCALAR_FIELD(offset); COPY_SCALAR_FIELD(sliding); COPY_SCALAR_FIELD(intervalUnit); COPY_SCALAR_FIELD(slidingUnit); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiSessionCopy(const SSessionWinodwPhysiNode* pSrc, SSessionWinodwPhysiNode* pDst) { +static int32_t physiSessionCopy(const SSessionWinodwPhysiNode* pSrc, SSessionWinodwPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(window, physiWindowCopy); COPY_SCALAR_FIELD(gap); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* physiPartitionCopy(const SPartitionPhysiNode* pSrc, SPartitionPhysiNode* pDst) { +static int32_t physiPartitionCopy(const SPartitionPhysiNode* pSrc, SPartitionPhysiNode* pDst) { COPY_BASE_OBJECT_FIELD(node, physiNodeCopy); CLONE_NODE_LIST_FIELD(pExprs); CLONE_NODE_LIST_FIELD(pPartitionKeys); CLONE_NODE_LIST_FIELD(pTargets); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) { +static int32_t dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) { COPY_SCALAR_FIELD(dataBlockId); CLONE_NODE_LIST_FIELD(pSlots); COPY_SCALAR_FIELD(totalRowSize); COPY_SCALAR_FIELD(outputRowSize); COPY_SCALAR_FIELD(precision); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* slotDescCopy(const SSlotDescNode* pSrc, SSlotDescNode* pDst) { +static int32_t slotDescCopy(const SSlotDescNode* pSrc, SSlotDescNode* pDst) { COPY_SCALAR_FIELD(slotId); COPY_OBJECT_FIELD(dataType, sizeof(SDataType)); COPY_SCALAR_FIELD(reserve); COPY_SCALAR_FIELD(output); COPY_SCALAR_FIELD(tag); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstreamSourceNode* pDst) { +static int32_t downstreamSourceCopy(const SDownstreamSourceNode* pSrc, SDownstreamSourceNode* pDst) { COPY_OBJECT_FIELD(addr, sizeof(SQueryNodeAddr)); COPY_SCALAR_FIELD(taskId); COPY_SCALAR_FIELD(schedId); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } -static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { +static int32_t selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { COPY_SCALAR_FIELD(isDistinct); CLONE_NODE_LIST_FIELD(pProjectionList); CLONE_NODE_FIELD(pFromTable); @@ -609,116 +602,124 @@ static SNode* selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) { COPY_SCALAR_FIELD(isTimeOrderQuery); COPY_SCALAR_FIELD(hasAggFuncs); COPY_SCALAR_FIELD(hasRepeatScanFuncs); - return (SNode*)pDst; + return TSDB_CODE_SUCCESS; } SNode* nodesCloneNode(const SNode* pNode) { if (NULL == pNode) { return NULL; } + SNode* pDst = nodesMakeNode(nodeType(pNode)); if (NULL == pDst) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } + + int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { case QUERY_NODE_COLUMN: - return columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst); + code = columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst); case QUERY_NODE_VALUE: - return valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst); + code = valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst); case QUERY_NODE_OPERATOR: - return operatorNodeCopy((const SOperatorNode*)pNode, (SOperatorNode*)pDst); + code = operatorNodeCopy((const SOperatorNode*)pNode, (SOperatorNode*)pDst); case QUERY_NODE_LOGIC_CONDITION: - return logicConditionNodeCopy((const SLogicConditionNode*)pNode, (SLogicConditionNode*)pDst); + code = logicConditionNodeCopy((const SLogicConditionNode*)pNode, (SLogicConditionNode*)pDst); case QUERY_NODE_FUNCTION: - return functionNodeCopy((const SFunctionNode*)pNode, (SFunctionNode*)pDst); + code = functionNodeCopy((const SFunctionNode*)pNode, (SFunctionNode*)pDst); case QUERY_NODE_REAL_TABLE: - return realTableNodeCopy((const SRealTableNode*)pNode, (SRealTableNode*)pDst); + code = realTableNodeCopy((const SRealTableNode*)pNode, (SRealTableNode*)pDst); case QUERY_NODE_TEMP_TABLE: - return tempTableNodeCopy((const STempTableNode*)pNode, (STempTableNode*)pDst); + code = tempTableNodeCopy((const STempTableNode*)pNode, (STempTableNode*)pDst); case QUERY_NODE_JOIN_TABLE: - return joinTableNodeCopy((const SJoinTableNode*)pNode, (SJoinTableNode*)pDst); + code = joinTableNodeCopy((const SJoinTableNode*)pNode, (SJoinTableNode*)pDst); case QUERY_NODE_GROUPING_SET: - return groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst); + code = groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst); case QUERY_NODE_ORDER_BY_EXPR: - return orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst); + code = orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst); case QUERY_NODE_LIMIT: - return limitNodeCopy((const SLimitNode*)pNode, (SLimitNode*)pDst); + code = limitNodeCopy((const SLimitNode*)pNode, (SLimitNode*)pDst); case QUERY_NODE_STATE_WINDOW: - return stateWindowNodeCopy((const SStateWindowNode*)pNode, (SStateWindowNode*)pDst); + code = stateWindowNodeCopy((const SStateWindowNode*)pNode, (SStateWindowNode*)pDst); case QUERY_NODE_SESSION_WINDOW: - return sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst); + code = sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst); case QUERY_NODE_INTERVAL_WINDOW: - return intervalWindowNodeCopy((const SIntervalWindowNode*)pNode, (SIntervalWindowNode*)pDst); + code = intervalWindowNodeCopy((const SIntervalWindowNode*)pNode, (SIntervalWindowNode*)pDst); case QUERY_NODE_NODE_LIST: - return nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst); + code = nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst); case QUERY_NODE_FILL: - return fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst); + code = fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst); case QUERY_NODE_TARGET: - return targetNodeCopy((const STargetNode*)pNode, (STargetNode*)pDst); + code = targetNodeCopy((const STargetNode*)pNode, (STargetNode*)pDst); case QUERY_NODE_DATABLOCK_DESC: - return dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst); + code = dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst); case QUERY_NODE_SLOT_DESC: - return slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst); + code = slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst); case QUERY_NODE_DOWNSTREAM_SOURCE: - return downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst); + code = downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst); case QUERY_NODE_LEFT_VALUE: - return pDst; + code = TSDB_CODE_SUCCESS; case QUERY_NODE_SELECT_STMT: - return selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst); + code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst); case QUERY_NODE_LOGIC_PLAN_SCAN: - return logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst); + code = logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_JOIN: - return logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst); + code = logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_AGG: - return logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst); + code = logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_PROJECT: - return logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst); + code = logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY: - return logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst); + code = logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_EXCHANGE: - return logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst); + code = logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_MERGE: - return logicMergeCopy((const SMergeLogicNode*)pNode, (SMergeLogicNode*)pDst); + code = logicMergeCopy((const SMergeLogicNode*)pNode, (SMergeLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_WINDOW: - return logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst); + code = logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_FILL: - return logicFillCopy((const SFillLogicNode*)pNode, (SFillLogicNode*)pDst); + code = logicFillCopy((const SFillLogicNode*)pNode, (SFillLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_SORT: - return logicSortCopy((const SSortLogicNode*)pNode, (SSortLogicNode*)pDst); + code = logicSortCopy((const SSortLogicNode*)pNode, (SSortLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_PARTITION: - return logicPartitionCopy((const SPartitionLogicNode*)pNode, (SPartitionLogicNode*)pDst); + code = logicPartitionCopy((const SPartitionLogicNode*)pNode, (SPartitionLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC: - return logicIndefRowsFuncCopy((const SIndefRowsFuncLogicNode*)pNode, (SIndefRowsFuncLogicNode*)pDst); + code = logicIndefRowsFuncCopy((const SIndefRowsFuncLogicNode*)pNode, (SIndefRowsFuncLogicNode*)pDst); case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC: - return logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst); + code = logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst); case QUERY_NODE_LOGIC_SUBPLAN: - return logicSubplanCopy((const SLogicSubplan*)pNode, (SLogicSubplan*)pDst); + code = logicSubplanCopy((const SLogicSubplan*)pNode, (SLogicSubplan*)pDst); case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: - return physiTagScanCopy((const STagScanPhysiNode*)pNode, (STagScanPhysiNode*)pDst); + code = physiTagScanCopy((const STagScanPhysiNode*)pNode, (STagScanPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: - return physiTableScanCopy((const STableScanPhysiNode*)pNode, (STableScanPhysiNode*)pDst); + code = physiTableScanCopy((const STableScanPhysiNode*)pNode, (STableScanPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: - return physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst); + code = physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: - return physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst); + code = physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION: - return physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst); + code = physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: - return physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst); + code = physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst); default: break; } - nodesDestroyNode(pDst); - nodesError("nodesCloneNode unknown node = %s", nodesNodeName(nodeType(pNode))); - return NULL; + + if (TSDB_CODE_SUCCESS != code) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + nodesDestroyNode(pDst); + nodesError("nodesCloneNode failed node = %s", nodesNodeName(nodeType(pNode))); + return NULL; + } + return pDst; } SNodeList* nodesCloneList(const SNodeList* pList) { @@ -726,19 +727,15 @@ SNodeList* nodesCloneList(const SNodeList* pList) { return NULL; } - SNodeList* pDst = nodesMakeList(); - if (NULL == pDst) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; - } - SNode* pNode; + SNodeList* pDst = NULL; + SNode* pNode; FOREACH(pNode, pList) { - SNode* pNewNode = nodesCloneNode(pNode); - if (NULL == pNewNode) { + int32_t code = nodesListMakeStrictAppend(&pDst, nodesCloneNode(pNode)); + if (TSDB_CODE_SUCCESS != code) { + terrno = TSDB_CODE_OUT_OF_MEMORY; nodesDestroyList(pDst); return NULL; } - nodesListAppend(pDst, pNewNode); } return pDst; } From e342240e4cc7d5afb5ec493731478af6dd144756 Mon Sep 17 00:00:00 2001 From: cpwu Date: Sat, 25 Jun 2022 10:36:16 +0800 Subject: [PATCH 11/73] merge conflict --- include/common/tmsg.h | 2 + include/common/ttokendef.h | 204 +- include/libs/function/functionMgt.h | 1 + include/libs/nodes/cmdnodes.h | 14 +- include/libs/nodes/nodes.h | 1 + include/libs/nodes/plannodes.h | 14 +- source/common/src/tmsg.c | 24 +- source/libs/executor/src/executorimpl.c | 8 +- source/libs/function/src/builtins.c | 12 +- source/libs/nodes/src/nodesCloneFuncs.c | 48 +- source/libs/nodes/src/nodesCodeFuncs.c | 113 +- source/libs/nodes/src/nodesUtilFuncs.c | 4 +- source/libs/parser/inc/parAst.h | 3 +- source/libs/parser/inc/sql.y | 12 +- source/libs/parser/src/parAstCreater.c | 5 +- source/libs/parser/src/parAstParser.c | 14 + source/libs/parser/src/parCalcConst.c | 19 + source/libs/parser/src/parTokenizer.c | 2 + source/libs/parser/src/parTranslater.c | 45 +- source/libs/parser/src/sql.c | 4915 +++++++++-------- source/libs/parser/test/mockCatalog.cpp | 149 +- source/libs/parser/test/parSelectTest.cpp | 18 +- source/libs/parser/test/parShowToUse.cpp | 18 + source/libs/planner/src/planLogicCreater.c | 91 +- source/libs/planner/src/planOptimizer.c | 3 +- source/libs/planner/src/planPhysiCreater.c | 8 +- source/libs/planner/src/planSpliter.c | 1 + source/libs/planner/test/planBasicTest.cpp | 7 - source/libs/planner/test/planOrderByTest.cpp | 2 + source/libs/planner/test/planSetOpTest.cpp | 16 + source/libs/planner/test/planSubqueryTest.cpp | 4 +- 31 files changed, 2983 insertions(+), 2794 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index d289ff13ae..e9ee8b5955 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -2463,6 +2463,8 @@ typedef struct { int64_t interval; int64_t offset; int64_t sliding; + int64_t maxDelay; + int64_t watermark; int32_t exprLen; // strlen + 1 int32_t tagsFilterLen; // strlen + 1 int32_t sqlLen; // strlen + 1 diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 8e00119876..6ace51f58e 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -158,107 +158,109 @@ #define TK_CLUSTER 140 #define TK_TRANSACTIONS 141 #define TK_DISTRIBUTED 142 -#define TK_LIKE 143 -#define TK_INDEX 144 -#define TK_FUNCTION 145 -#define TK_INTERVAL 146 -#define TK_TOPIC 147 -#define TK_AS 148 -#define TK_WITH 149 -#define TK_META 150 -#define TK_CONSUMER 151 -#define TK_GROUP 152 -#define TK_DESC 153 -#define TK_DESCRIBE 154 -#define TK_RESET 155 -#define TK_QUERY 156 -#define TK_CACHE 157 -#define TK_EXPLAIN 158 -#define TK_ANALYZE 159 -#define TK_VERBOSE 160 -#define TK_NK_BOOL 161 -#define TK_RATIO 162 -#define TK_NK_FLOAT 163 -#define TK_COMPACT 164 -#define TK_VNODES 165 -#define TK_IN 166 -#define TK_OUTPUTTYPE 167 -#define TK_AGGREGATE 168 -#define TK_BUFSIZE 169 -#define TK_STREAM 170 -#define TK_INTO 171 -#define TK_TRIGGER 172 -#define TK_AT_ONCE 173 -#define TK_WINDOW_CLOSE 174 -#define TK_KILL 175 -#define TK_CONNECTION 176 -#define TK_TRANSACTION 177 -#define TK_BALANCE 178 -#define TK_VGROUP 179 -#define TK_MERGE 180 -#define TK_REDISTRIBUTE 181 -#define TK_SPLIT 182 -#define TK_SYNCDB 183 -#define TK_DELETE 184 -#define TK_NULL 185 -#define TK_NK_QUESTION 186 -#define TK_NK_ARROW 187 -#define TK_ROWTS 188 -#define TK_TBNAME 189 -#define TK_QSTARTTS 190 -#define TK_QENDTS 191 -#define TK_WSTARTTS 192 -#define TK_WENDTS 193 -#define TK_WDURATION 194 -#define TK_CAST 195 -#define TK_NOW 196 -#define TK_TODAY 197 -#define TK_TIMEZONE 198 -#define TK_COUNT 199 -#define TK_LAST_ROW 200 -#define TK_BETWEEN 201 -#define TK_IS 202 -#define TK_NK_LT 203 -#define TK_NK_GT 204 -#define TK_NK_LE 205 -#define TK_NK_GE 206 -#define TK_NK_NE 207 -#define TK_MATCH 208 -#define TK_NMATCH 209 -#define TK_CONTAINS 210 -#define TK_JOIN 211 -#define TK_INNER 212 -#define TK_SELECT 213 -#define TK_DISTINCT 214 -#define TK_WHERE 215 -#define TK_PARTITION 216 -#define TK_BY 217 -#define TK_SESSION 218 -#define TK_STATE_WINDOW 219 -#define TK_SLIDING 220 -#define TK_FILL 221 -#define TK_VALUE 222 -#define TK_NONE 223 -#define TK_PREV 224 -#define TK_LINEAR 225 -#define TK_NEXT 226 -#define TK_HAVING 227 -#define TK_RANGE 228 -#define TK_EVERY 229 -#define TK_ORDER 230 -#define TK_SLIMIT 231 -#define TK_SOFFSET 232 -#define TK_LIMIT 233 -#define TK_OFFSET 234 -#define TK_ASC 235 -#define TK_NULLS 236 -#define TK_ID 237 -#define TK_NK_BITNOT 238 -#define TK_INSERT 239 -#define TK_VALUES 240 -#define TK_IMPORT 241 -#define TK_NK_SEMI 242 -#define TK_FILE 243 +#define TK_CONSUMERS 143 +#define TK_SUBSCRIPTIONS 144 +#define TK_LIKE 145 +#define TK_INDEX 146 +#define TK_FUNCTION 147 +#define TK_INTERVAL 148 +#define TK_TOPIC 149 +#define TK_AS 150 +#define TK_WITH 151 +#define TK_META 152 +#define TK_CONSUMER 153 +#define TK_GROUP 154 +#define TK_DESC 155 +#define TK_DESCRIBE 156 +#define TK_RESET 157 +#define TK_QUERY 158 +#define TK_CACHE 159 +#define TK_EXPLAIN 160 +#define TK_ANALYZE 161 +#define TK_VERBOSE 162 +#define TK_NK_BOOL 163 +#define TK_RATIO 164 +#define TK_NK_FLOAT 165 +#define TK_COMPACT 166 +#define TK_VNODES 167 +#define TK_IN 168 +#define TK_OUTPUTTYPE 169 +#define TK_AGGREGATE 170 +#define TK_BUFSIZE 171 +#define TK_STREAM 172 +#define TK_INTO 173 +#define TK_TRIGGER 174 +#define TK_AT_ONCE 175 +#define TK_WINDOW_CLOSE 176 +#define TK_KILL 177 +#define TK_CONNECTION 178 +#define TK_TRANSACTION 179 +#define TK_BALANCE 180 +#define TK_VGROUP 181 +#define TK_MERGE 182 +#define TK_REDISTRIBUTE 183 +#define TK_SPLIT 184 +#define TK_SYNCDB 185 +#define TK_DELETE 186 +#define TK_NULL 187 +#define TK_NK_QUESTION 188 +#define TK_NK_ARROW 189 +#define TK_ROWTS 190 +#define TK_TBNAME 191 +#define TK_QSTARTTS 192 +#define TK_QENDTS 193 +#define TK_WSTARTTS 194 +#define TK_WENDTS 195 +#define TK_WDURATION 196 +#define TK_CAST 197 +#define TK_NOW 198 +#define TK_TODAY 199 +#define TK_TIMEZONE 200 +#define TK_COUNT 201 +#define TK_LAST_ROW 202 +#define TK_BETWEEN 203 +#define TK_IS 204 +#define TK_NK_LT 205 +#define TK_NK_GT 206 +#define TK_NK_LE 207 +#define TK_NK_GE 208 +#define TK_NK_NE 209 +#define TK_MATCH 210 +#define TK_NMATCH 211 +#define TK_CONTAINS 212 +#define TK_JOIN 213 +#define TK_INNER 214 +#define TK_SELECT 215 +#define TK_DISTINCT 216 +#define TK_WHERE 217 +#define TK_PARTITION 218 +#define TK_BY 219 +#define TK_SESSION 220 +#define TK_STATE_WINDOW 221 +#define TK_SLIDING 222 +#define TK_FILL 223 +#define TK_VALUE 224 +#define TK_NONE 225 +#define TK_PREV 226 +#define TK_LINEAR 227 +#define TK_NEXT 228 +#define TK_HAVING 229 +#define TK_RANGE 230 +#define TK_EVERY 231 +#define TK_ORDER 232 +#define TK_SLIMIT 233 +#define TK_SOFFSET 234 +#define TK_LIMIT 235 +#define TK_OFFSET 236 +#define TK_ASC 237 +#define TK_NULLS 238 +#define TK_ID 239 +#define TK_NK_BITNOT 240 +#define TK_INSERT 241 +#define TK_VALUES 242 +#define TK_IMPORT 243 +#define TK_NK_SEMI 244 +#define TK_FILE 245 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 1f314d19e7..1ca51b3043 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -123,6 +123,7 @@ typedef enum EFunctionType { FUNCTION_TYPE_SELECT_VALUE, FUNCTION_TYPE_BLOCK_DIST, // block distribution aggregate function FUNCTION_TYPE_BLOCK_DIST_INFO, // block distribution pseudo column function + FUNCTION_TYPE_TO_COLUMN, // distributed splitting functions FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000, diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 4f18cb19c2..b66dff31c1 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -28,11 +28,11 @@ extern "C" { #define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE) #define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE) -#define SHOW_CREATE_DB_RESULT_COLS 2 +#define SHOW_CREATE_DB_RESULT_COLS 2 #define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE) #define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE) -#define SHOW_CREATE_TB_RESULT_COLS 2 +#define SHOW_CREATE_TB_RESULT_COLS 2 #define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE) #define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE) @@ -40,7 +40,6 @@ extern "C" { #define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE) #define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE) - #define PRIVILEGE_TYPE_MASK(n) (1 << n) #define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0) @@ -234,10 +233,10 @@ typedef struct SShowCreateDatabaseStmt { } SShowCreateDatabaseStmt; typedef struct SShowCreateTableStmt { - ENodeType type; - char dbName[TSDB_DB_NAME_LEN]; - char tableName[TSDB_TABLE_NAME_LEN]; - void* pCfg; // STableCfg + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; + void* pCfg; // STableCfg } SShowCreateTableStmt; typedef struct SShowTableDistributedStmt { @@ -259,6 +258,7 @@ typedef struct SIndexOptions { SNode* pInterval; SNode* pOffset; SNode* pSliding; + SNode* pStreamOptions; } SIndexOptions; typedef struct SCreateIndexStmt { diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 5f89d1f665..777e67769f 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -188,6 +188,7 @@ typedef enum ENodeType { QUERY_NODE_SHOW_CREATE_STABLE_STMT, QUERY_NODE_SHOW_TRANSACTIONS_STMT, QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT, + QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT, QUERY_NODE_KILL_CONNECTION_STMT, QUERY_NODE_KILL_QUERY_STMT, QUERY_NODE_KILL_TRANSACTION_STMT, diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 5559cb8060..f8cf58d8cb 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -32,6 +32,8 @@ typedef struct SLogicNode { struct SLogicNode* pParent; int32_t optimizedFlag; uint8_t precision; + SNode* pLimit; + SNode* pSlimit; } SLogicNode; typedef enum EScanType { @@ -92,10 +94,6 @@ typedef struct SProjectLogicNode { SLogicNode node; SNodeList* pProjections; char stmtName[TSDB_TABLE_NAME_LEN]; - int64_t limit; - int64_t offset; - int64_t slimit; - int64_t soffset; } SProjectLogicNode; typedef struct SIndefRowsFuncLogicNode { @@ -248,6 +246,8 @@ typedef struct SPhysiNode { SNode* pConditions; SNodeList* pChildren; struct SPhysiNode* pParent; + SNode* pLimit; + SNode* pSlimit; } SPhysiNode; typedef struct SScanPhysiNode { @@ -297,10 +297,6 @@ typedef STableScanPhysiNode SStreamScanPhysiNode; typedef struct SProjectPhysiNode { SPhysiNode node; SNodeList* pProjections; - int64_t limit; - int64_t offset; - int64_t slimit; - int64_t soffset; } SProjectPhysiNode; typedef struct SIndefRowsFuncPhysiNode { @@ -378,7 +374,7 @@ typedef struct SIntervalPhysiNode { int8_t slidingUnit; } SIntervalPhysiNode; -typedef SIntervalPhysiNode SMergeIntervalPhysiNode; +typedef SIntervalPhysiNode SMergeIntervalPhysiNode; typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode; typedef SIntervalPhysiNode SStreamIntervalPhysiNode; typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 4ad11f2998..dde282c4e3 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -539,7 +539,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq const char *pFunc = taosArrayGet(pReq->pFuncs, i); if (tEncodeCStr(&encoder, pFunc) < 0) return -1; } - + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -621,7 +621,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR if (NULL == pReq->pFuncs) return -1; } for (int32_t i = 0; i < numOfFuncs; ++i) { - char* pFunc = NULL; + char *pFunc = NULL; if (tDecodeCStrAlloc(&decoder, &pFunc) < 0) return -1; if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -783,6 +783,8 @@ int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq if (tEncodeI64(&encoder, pReq->interval) < 0) return -1; if (tEncodeI64(&encoder, pReq->offset) < 0) return -1; if (tEncodeI64(&encoder, pReq->sliding) < 0) return -1; + if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1; + if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1; if (tEncodeI32(&encoder, pReq->exprLen) < 0) return -1; if (tEncodeI32(&encoder, pReq->tagsFilterLen) < 0) return -1; if (tEncodeI32(&encoder, pReq->sqlLen) < 0) return -1; @@ -821,6 +823,8 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR if (tDecodeI64(&decoder, &pReq->interval) < 0) return -1; if (tDecodeI64(&decoder, &pReq->offset) < 0) return -1; if (tDecodeI64(&decoder, &pReq->sliding) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1; if (tDecodeI32(&decoder, &pReq->exprLen) < 0) return -1; if (tDecodeI32(&decoder, &pReq->tagsFilterLen) < 0) return -1; if (tDecodeI32(&decoder, &pReq->sqlLen) < 0) return -1; @@ -1868,7 +1872,7 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) { if (tEncodeI64(&encoder, pRsp->watermark1) < 0) return -1; if (tEncodeI64(&encoder, pRsp->watermark2) < 0) return -1; if (tEncodeI32(&encoder, pRsp->ttl) < 0) return -1; - + int32_t numOfFuncs = taosArrayGetSize(pRsp->pFuncs); if (tEncodeI32(&encoder, numOfFuncs) < 0) return -1; for (int32_t i = 0; i < numOfFuncs; ++i) { @@ -1876,19 +1880,19 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) { if (tEncodeCStr(&encoder, pFunc) < 0) return -1; } - if (tEncodeI32(&encoder, pRsp->commentLen) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->commentLen) < 0) return -1; if (pRsp->commentLen > 0) { if (tEncodeCStr(&encoder, pRsp->pComment) < 0) return -1; } - + for (int32_t i = 0; i < pRsp->numOfColumns + pRsp->numOfTags; ++i) { SSchema *pSchema = &pRsp->pSchemas[i]; if (tEncodeSSchema(&encoder, pSchema) < 0) return -1; } - if (tEncodeI32(&encoder, pRsp->tagsLen) < 0) return -1; - if (tEncodeBinary(&encoder, pRsp->pTags, pRsp->tagsLen) < 0) return -1; - + if (tEncodeI32(&encoder, pRsp->tagsLen) < 0) return -1; + if (tEncodeBinary(&encoder, pRsp->pTags, pRsp->tagsLen) < 0) return -1; + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1945,7 +1949,7 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) } if (tDecodeI32(&decoder, &pRsp->tagsLen) < 0) return -1; - if (tDecodeBinaryAlloc(&decoder, (void**)&pRsp->pTags, NULL) < 0) return -1; + if (tDecodeBinaryAlloc(&decoder, (void **)&pRsp->pTags, NULL) < 0) return -1; tEndDecode(&decoder); @@ -1961,7 +1965,7 @@ void tFreeSTableCfgRsp(STableCfgRsp *pRsp) { taosMemoryFreeClear(pRsp->pComment); taosMemoryFreeClear(pRsp->pSchemas); taosMemoryFreeClear(pRsp->pTags); - + taosArrayDestroy(pRsp->pFuncs); } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index afe0a1f8fa..1105cb3156 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3581,6 +3581,10 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols) return pList; } +static int64_t getLimit(SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->limit; } + +static int64_t getOffset(SNode* pLimit) { return NULL == pLimit ? -1 : ((SLimitNode*)pLimit)->offset; } + SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode, SExecTaskInfo* pTaskInfo) { SProjectOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SProjectOperatorInfo)); @@ -3593,8 +3597,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &numOfCols); SSDataBlock* pResBlock = createResDataBlock(pProjPhyNode->node.pOutputDataBlockDesc); - SLimit limit = {.limit = pProjPhyNode->limit, .offset = pProjPhyNode->offset}; - SLimit slimit = {.limit = pProjPhyNode->slimit, .offset = pProjPhyNode->soffset}; + SLimit limit = {.limit = getLimit(pProjPhyNode->node.pLimit), .offset = getOffset(pProjPhyNode->node.pLimit)}; + SLimit slimit = {.limit = getLimit(pProjPhyNode->node.pSlimit), .offset = getOffset(pProjPhyNode->node.pSlimit)}; pInfo->limit = limit; pInfo->slimit = slimit; diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 69fff2ad18..6516a10795 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1857,7 +1857,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_TIMELINE_FUNC, .translateFunc = translateLastRow, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minmaxFunctionSetup, @@ -2024,7 +2024,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "diff", .type = FUNCTION_TYPE_DIFF, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateDiff, .getEnvFunc = getDiffFuncEnv, .initFunc = diffFunctionSetup, @@ -2034,7 +2034,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "statecount", .type = FUNCTION_TYPE_STATE_COUNT, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateStateCount, .getEnvFunc = getStateFuncEnv, .initFunc = functionSetup, @@ -2044,7 +2044,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "stateduration", .type = FUNCTION_TYPE_STATE_DURATION, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateStateDuration, .getEnvFunc = getStateFuncEnv, .initFunc = functionSetup, @@ -2054,7 +2054,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "csum", .type = FUNCTION_TYPE_CSUM, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateCsum, .getEnvFunc = getCsumFuncEnv, .initFunc = functionSetup, @@ -2064,7 +2064,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "mavg", .type = FUNCTION_TYPE_MAVG, - .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC, .translateFunc = translateMavg, .getEnvFunc = getMavgFuncEnv, .initFunc = mavgFunctionSetup, diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 7e35a7d097..ac197912cf 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -319,6 +319,8 @@ static int32_t logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) { CLONE_NODE_LIST_FIELD(pChildren); COPY_SCALAR_FIELD(optimizedFlag); COPY_SCALAR_FIELD(precision); + CLONE_NODE_FIELD(pLimit); + CLONE_NODE_FIELD(pSlimit); return TSDB_CODE_SUCCESS; } @@ -372,10 +374,6 @@ static int32_t logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode COPY_BASE_OBJECT_FIELD(node, logicNodeCopy); CLONE_NODE_LIST_FIELD(pProjections); COPY_CHAR_ARRAY_FIELD(stmtName); - COPY_SCALAR_FIELD(limit); - COPY_SCALAR_FIELD(offset); - COPY_SCALAR_FIELD(slimit); - COPY_SCALAR_FIELD(soffset); return TSDB_CODE_SUCCESS; } @@ -620,95 +618,137 @@ SNode* nodesCloneNode(const SNode* pNode) { switch (nodeType(pNode)) { case QUERY_NODE_COLUMN: code = columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst); + break; case QUERY_NODE_VALUE: code = valueNodeCopy((const SValueNode*)pNode, (SValueNode*)pDst); + break; case QUERY_NODE_OPERATOR: code = operatorNodeCopy((const SOperatorNode*)pNode, (SOperatorNode*)pDst); + break; case QUERY_NODE_LOGIC_CONDITION: code = logicConditionNodeCopy((const SLogicConditionNode*)pNode, (SLogicConditionNode*)pDst); + break; case QUERY_NODE_FUNCTION: code = functionNodeCopy((const SFunctionNode*)pNode, (SFunctionNode*)pDst); + break; case QUERY_NODE_REAL_TABLE: code = realTableNodeCopy((const SRealTableNode*)pNode, (SRealTableNode*)pDst); + break; case QUERY_NODE_TEMP_TABLE: code = tempTableNodeCopy((const STempTableNode*)pNode, (STempTableNode*)pDst); + break; case QUERY_NODE_JOIN_TABLE: code = joinTableNodeCopy((const SJoinTableNode*)pNode, (SJoinTableNode*)pDst); + break; case QUERY_NODE_GROUPING_SET: code = groupingSetNodeCopy((const SGroupingSetNode*)pNode, (SGroupingSetNode*)pDst); + break; case QUERY_NODE_ORDER_BY_EXPR: code = orderByExprNodeCopy((const SOrderByExprNode*)pNode, (SOrderByExprNode*)pDst); + break; case QUERY_NODE_LIMIT: code = limitNodeCopy((const SLimitNode*)pNode, (SLimitNode*)pDst); + break; case QUERY_NODE_STATE_WINDOW: code = stateWindowNodeCopy((const SStateWindowNode*)pNode, (SStateWindowNode*)pDst); + break; case QUERY_NODE_SESSION_WINDOW: code = sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst); + break; case QUERY_NODE_INTERVAL_WINDOW: code = intervalWindowNodeCopy((const SIntervalWindowNode*)pNode, (SIntervalWindowNode*)pDst); + break; case QUERY_NODE_NODE_LIST: code = nodeListNodeCopy((const SNodeListNode*)pNode, (SNodeListNode*)pDst); + break; case QUERY_NODE_FILL: code = fillNodeCopy((const SFillNode*)pNode, (SFillNode*)pDst); + break; case QUERY_NODE_TARGET: code = targetNodeCopy((const STargetNode*)pNode, (STargetNode*)pDst); + break; case QUERY_NODE_DATABLOCK_DESC: code = dataBlockDescCopy((const SDataBlockDescNode*)pNode, (SDataBlockDescNode*)pDst); + break; case QUERY_NODE_SLOT_DESC: code = slotDescCopy((const SSlotDescNode*)pNode, (SSlotDescNode*)pDst); + break; case QUERY_NODE_DOWNSTREAM_SOURCE: code = downstreamSourceCopy((const SDownstreamSourceNode*)pNode, (SDownstreamSourceNode*)pDst); + break; case QUERY_NODE_LEFT_VALUE: code = TSDB_CODE_SUCCESS; + break; case QUERY_NODE_SELECT_STMT: code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_SCAN: code = logicScanCopy((const SScanLogicNode*)pNode, (SScanLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_JOIN: code = logicJoinCopy((const SJoinLogicNode*)pNode, (SJoinLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_AGG: code = logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_PROJECT: code = logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY: code = logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_EXCHANGE: code = logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_MERGE: code = logicMergeCopy((const SMergeLogicNode*)pNode, (SMergeLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_WINDOW: code = logicWindowCopy((const SWindowLogicNode*)pNode, (SWindowLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_FILL: code = logicFillCopy((const SFillLogicNode*)pNode, (SFillLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_SORT: code = logicSortCopy((const SSortLogicNode*)pNode, (SSortLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_PARTITION: code = logicPartitionCopy((const SPartitionLogicNode*)pNode, (SPartitionLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC: code = logicIndefRowsFuncCopy((const SIndefRowsFuncLogicNode*)pNode, (SIndefRowsFuncLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_PLAN_INTERP_FUNC: code = logicInterpFuncCopy((const SInterpFuncLogicNode*)pNode, (SInterpFuncLogicNode*)pDst); + break; case QUERY_NODE_LOGIC_SUBPLAN: code = logicSubplanCopy((const SLogicSubplan*)pNode, (SLogicSubplan*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: code = physiTagScanCopy((const STagScanPhysiNode*)pNode, (STagScanPhysiNode*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: code = physiTableScanCopy((const STableScanPhysiNode*)pNode, (STableScanPhysiNode*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: code = physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: code = physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION: code = physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst); + break; case QUERY_NODE_PHYSICAL_PLAN_PARTITION: code = physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst); + break; default: break; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 5c5c62d915..1858918e4a 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -491,6 +491,8 @@ static int32_t jsonToTableMeta(const SJson* pJson, void* pObj) { static const char* jkLogicPlanTargets = "Targets"; static const char* jkLogicPlanConditions = "Conditions"; static const char* jkLogicPlanChildren = "Children"; +static const char* jkLogicPlanLimit = "Limit"; +static const char* jkLogicPlanSlimit = "SLimit"; static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) { const SLogicNode* pNode = (const SLogicNode*)pObj; @@ -502,6 +504,12 @@ static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkLogicPlanChildren, pNode->pChildren); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkLogicPlanLimit, nodeToJson, pNode->pLimit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkLogicPlanSlimit, nodeToJson, pNode->pSlimit); + } return code; } @@ -516,6 +524,12 @@ static int32_t jsonToLogicPlanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkLogicPlanChildren, &pNode->pChildren); } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkLogicPlanLimit, &pNode->pLimit); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkLogicPlanSlimit, &pNode->pSlimit); + } return code; } @@ -581,10 +595,6 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) { } static const char* jkProjectLogicPlanProjections = "Projections"; -static const char* jkProjectLogicPlanLimit = "Limit"; -static const char* jkProjectLogicPlanOffset = "Offset"; -static const char* jkProjectLogicPlanSlimit = "SLimit"; -static const char* jkProjectLogicPlanSoffset = "SOffset"; static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) { const SProjectLogicNode* pNode = (const SProjectLogicNode*)pObj; @@ -593,18 +603,6 @@ static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkProjectLogicPlanProjections, pNode->pProjections); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanLimit, pNode->limit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanOffset, pNode->offset); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSlimit, pNode->slimit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSoffset, pNode->soffset); - } return code; } @@ -616,18 +614,6 @@ static int32_t jsonToLogicProjectNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkProjectLogicPlanProjections, &pNode->pProjections); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanLimit, &pNode->limit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanOffset, &pNode->offset); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSlimit, &pNode->slimit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSoffset, &pNode->soffset); - } return code; } @@ -1283,6 +1269,8 @@ static int32_t logicJoinNodeToJson(const void* pObj, SJson* pJson) { static const char* jkPhysiPlanOutputDataBlockDesc = "OutputDataBlockDesc"; static const char* jkPhysiPlanConditions = "Conditions"; static const char* jkPhysiPlanChildren = "Children"; +static const char* jkPhysiPlanLimit = "Limit"; +static const char* jkPhysiPlanSlimit = "SLimit"; static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) { const SPhysiNode* pNode = (const SPhysiNode*)pObj; @@ -1294,6 +1282,12 @@ static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkPhysiPlanChildren, pNode->pChildren); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkPhysiPlanLimit, nodeToJson, pNode->pLimit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkPhysiPlanSlimit, nodeToJson, pNode->pSlimit); + } return code; } @@ -1308,6 +1302,12 @@ static int32_t jsonToPhysicPlanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkPhysiPlanChildren, &pNode->pChildren); } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkPhysiPlanLimit, &pNode->pLimit); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkPhysiPlanSlimit, &pNode->pSlimit); + } return code; } @@ -1590,10 +1590,6 @@ static int32_t jsonToPhysiSysTableScanNode(const SJson* pJson, void* pObj) { } static const char* jkProjectPhysiPlanProjections = "Projections"; -static const char* jkProjectPhysiPlanLimit = "Limit"; -static const char* jkProjectPhysiPlanOffset = "Offset"; -static const char* jkProjectPhysiPlanSlimit = "SLimit"; -static const char* jkProjectPhysiPlanSoffset = "SOffset"; static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) { const SProjectPhysiNode* pNode = (const SProjectPhysiNode*)pObj; @@ -1602,18 +1598,6 @@ static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkProjectPhysiPlanProjections, pNode->pProjections); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanLimit, pNode->limit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanOffset, pNode->offset); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanSlimit, pNode->slimit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddIntegerToObject(pJson, jkProjectPhysiPlanSoffset, pNode->soffset); - } return code; } @@ -1625,18 +1609,6 @@ static int32_t jsonToPhysiProjectNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkProjectPhysiPlanProjections, &pNode->pProjections); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanLimit, &pNode->limit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanOffset, &pNode->offset); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanSlimit, &pNode->slimit); - } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetBigIntValue(pJson, jkProjectPhysiPlanSoffset, &pNode->soffset); - } return code; } @@ -3165,6 +3137,31 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) { return code; } +static const char* jkLimitLimit = "Limit"; +static const char* jkLimitOffset = "Offset"; + +static int32_t limitNodeToJson(const void* pObj, SJson* pJson) { + const SLimitNode* pNode = (const SLimitNode*)pObj; + + int32_t code = tjsonAddIntegerToObject(pJson, jkLimitLimit, pNode->limit); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkLimitOffset, pNode->offset); + } + + return code; +} + +static int32_t jsonToLimitNode(const SJson* pJson, void* pObj) { + SLimitNode* pNode = (SLimitNode*)pObj; + + int32_t code = tjsonGetBigIntValue(pJson, jkLimitLimit, &pNode->limit); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBigIntValue(pJson, jkLimitOffset, &pNode->offset); + } + + return code; +} + static const char* jkStateWindowCol = "StateWindowCol"; static const char* jkStateWindowExpr = "StateWindowExpr"; @@ -4031,7 +4028,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_ORDER_BY_EXPR: return orderByExprNodeToJson(pObj, pJson); case QUERY_NODE_LIMIT: - break; + return limitNodeToJson(pObj, pJson); case QUERY_NODE_STATE_WINDOW: return stateWindowNodeToJson(pObj, pJson); case QUERY_NODE_SESSION_WINDOW: @@ -4191,6 +4188,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToTempTableNode(pJson, pObj); case QUERY_NODE_ORDER_BY_EXPR: return jsonToOrderByExprNode(pJson, pObj); + case QUERY_NODE_LIMIT: + return jsonToLimitNode(pJson, pObj); case QUERY_NODE_STATE_WINDOW: return jsonToStateWindowNode(pJson, pObj); case QUERY_NODE_SESSION_WINDOW: diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 13628f85db..57ead2d2ae 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -210,6 +210,7 @@ SNode* nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_VARIABLES_STMT: case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: case QUERY_NODE_SHOW_TRANSACTIONS_STMT: + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: return makeNode(type, sizeof(SShowDnodeVariablesStmt)); @@ -644,7 +645,8 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_SHOW_SCORES_STMT: case QUERY_NODE_SHOW_VARIABLES_STMT: case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: - case QUERY_NODE_SHOW_TRANSACTIONS_STMT: { + case QUERY_NODE_SHOW_TRANSACTIONS_STMT: + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: { SShowStmt* pStmt = (SShowStmt*)pNode; nodesDestroyNode(pStmt->pDbName); nodesDestroyNode(pStmt->pTbName); diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 213e21cdcf..4585a59612 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -170,7 +170,8 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName, SToken* pTableName, SNodeList* pCols, SNode* pOptions); -SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); +SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding, + SNode* pStreamOptions); SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName); SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId); SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 08199c4f37..a27d0e9164 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -388,6 +388,8 @@ cmd ::= SHOW SNODES. cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } cmd ::= SHOW TRANSACTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } cmd ::= SHOW TABLE DISTRIBUTED full_table_name(A). { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, A); } +cmd ::= SHOW CONSUMERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } +cmd ::= SHOW SUBSCRIPTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); } db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } @@ -407,11 +409,11 @@ cmd ::= CREATE SMA INDEX not_exists_opt(D) // index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); } cmd ::= DROP INDEX exists_opt(B) index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, &A); } -index_options(A) ::= . { A = NULL; } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL - NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D); } + NK_LP duration_literal(C) NK_RP sliding_opt(D) sma_stream_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D, E); } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL - NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E); } + NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E) + sma_stream_opt(F). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E, F); } %type func_list { SNodeList* } %destructor func_list { nodesDestroyList($$); } @@ -420,6 +422,10 @@ func_list(A) ::= func_list(B) NK_COMMA func(C). func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); } +sma_stream_opt(A) ::= . { A = createStreamOptions(pCxt); } +sma_stream_opt(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; } +sma_stream_opt(A) ::= stream_options(B) MAX_DELAY duration_literal(C). { ((SStreamOptions*)B)->pDelay = releaseRawExprNode(pCxt, C); A = B; } + /************************************************ create/drop topic ***************************************************/ cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); } cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, false); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index ef7f17a460..9709a8b1ea 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1317,8 +1317,8 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno return (SNode*)pStmt; } -SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, - SNode* pSliding) { +SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding, + SNode* pStreamOptions) { CHECK_PARSER_STATUS(pCxt); SIndexOptions* pOptions = (SIndexOptions*)nodesMakeNode(QUERY_NODE_INDEX_OPTIONS); CHECK_OUT_OF_MEM(pOptions); @@ -1326,6 +1326,7 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt pOptions->pInterval = pInterval; pOptions->pOffset = pOffset; pOptions->pSliding = pSliding; + pOptions->pStreamOptions = pStreamOptions; return (SNode*)pOptions; } diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index d9c4551400..80ca411e0e 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -380,6 +380,11 @@ static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt* pCxt->pMetaCache); } +static int32_t collectMetaKeyFromShowConsumers(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONSUMERS, + pCxt->pMetaCache); +} + static int32_t collectMetaKeyFromShowConnections(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONNECTIONS, pCxt->pMetaCache); @@ -456,6 +461,11 @@ static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTa return code; } +static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, + pCxt->pMetaCache); +} + static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { pCxt->pStmt = pStmt; switch (nodeType(pStmt)) { @@ -517,6 +527,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromShowVgroups(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_TOPICS_STMT: return collectMetaKeyFromShowTopics(pCxt, (SShowStmt*)pStmt); + case QUERY_NODE_SHOW_CONSUMERS_STMT: + return collectMetaKeyFromShowConsumers(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_CONNECTIONS_STMT: return collectMetaKeyFromShowConnections(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_QUERIES_STMT: @@ -538,6 +550,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromDelete(pCxt, (SDeleteStmt*)pStmt); case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: return collectMetaKeyFromShowBlockDist(pCxt, (SShowTableDistributedStmt*)pStmt); + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: + return collectMetaKeyFromShowSubscriptions(pCxt, (SShowStmt*)pStmt); default: break; } diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 0dfc79269e..495950f35c 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -175,8 +175,11 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) { } } + char aliasName[TSDB_COL_NAME_LEN] = {0}; + strcpy(aliasName, ((SExprNode*)pProject)->aliasName); int32_t code = scalarCalculateConstants(pProject, pNew); if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) { + strcpy(((SExprNode*)*pNew)->aliasName, aliasName); int32_t size = taosArrayGetSize(pAssociation); for (int32_t i = 0; i < size; ++i) { SNode** pCol = taosArrayGetP(pAssociation, i); @@ -196,6 +199,19 @@ static bool isUselessCol(bool hasSelectValFunc, SExprNode* pProj) { return NULL == ((SExprNode*)pProj)->pAssociation; } +static SNode* createConstantValue() { + SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + if (NULL == pVal) { + return NULL; + } + pVal->node.resType.type = TSDB_DATA_TYPE_INT; + pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes; + const int32_t val = 1; + nodesSetValueNodeValue(pVal, (void*)&val); + pVal->translate = true; + return (SNode*)pVal; +} + static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { SNode* pProj = NULL; WHERE_EACH(pProj, pSelect->pProjectionList) { @@ -212,6 +228,9 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec } WHERE_NEXT; } + if (0 == LIST_LENGTH(pSelect->pProjectionList)) { + return nodesListStrictAppend(pSelect->pProjectionList, createConstantValue()); + } return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 12b717e56a..6726bb7dfd 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -63,6 +63,7 @@ static SKeyword keywordTable[] = { {"CONNECTION", TK_CONNECTION}, {"CONNECTIONS", TK_CONNECTIONS}, {"CONSUMER", TK_CONSUMER}, + {"CONSUMERS", TK_CONSUMERS}, {"COUNT", TK_COUNT}, {"CREATE", TK_CREATE}, {"CONTAINS", TK_CONTAINS}, @@ -188,6 +189,7 @@ static SKeyword keywordTable[] = { {"STREAM", TK_STREAM}, {"STREAMS", TK_STREAMS}, {"STRICT", TK_STRICT}, + {"SUBSCRIPTIONS", TK_SUBSCRIPTIONS}, {"SYNCDB", TK_SYNCDB}, {"SYSINFO", TK_SYSINFO}, {"TABLE", TK_TABLE}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 7b5c30d3cb..eb767ffa61 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -707,7 +707,11 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { res = translateColumnUseAlias(pCxt, pCol, &found); } if (DEAL_RES_ERROR != res && !found) { - res = translateColumnWithoutPrefix(pCxt, pCol); + if (NULL != pCxt->pCurrSetOperator) { + res = generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, (*pCol)->colName); + } else { + res = translateColumnWithoutPrefix(pCxt, pCol); + } } } return res; @@ -2656,6 +2660,13 @@ static int32_t translateSetOperOrderBy(STranslateContext* pCxt, SSetOperator* pS return code; } +static int32_t checkSetOperLimit(STranslateContext* pCxt, SLimitNode* pLimit) { + if ((NULL != pLimit && pLimit->offset < 0)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_OFFSET_LESS_ZERO); + } + return TSDB_CODE_SUCCESS; +} + static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetOperator) { int32_t code = translateQuery(pCxt, pSetOperator->pLeft); if (TSDB_CODE_SUCCESS == code) { @@ -2671,6 +2682,9 @@ static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetO if (TSDB_CODE_SUCCESS == code) { code = translateSetOperOrderBy(pCxt, pSetOperator); } + if (TSDB_CODE_SUCCESS == code) { + code = checkSetOperLimit(pCxt, (SLimitNode*)pSetOperator->pLimit); + } return code; } @@ -3566,9 +3580,7 @@ static int32_t buildRollupFuncs(SNodeList* pFuncs, SArray** pArray) { } *pArray = taosArrayInit(LIST_LENGTH(pFuncs), TSDB_FUNC_NAME_LEN); SNode* pNode; - FOREACH(pNode, pFuncs) { - taosArrayPush(*pArray, ((SFunctionNode*)pNode)->functionName); - } + FOREACH(pNode, pFuncs) { taosArrayPush(*pArray, ((SFunctionNode*)pNode)->functionName); } return TSDB_CODE_SUCCESS; } @@ -3867,6 +3879,11 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm (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); + if (NULL != pStmt->pOptions->pStreamOptions) { + SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions; + pReq->maxDelay = (NULL != pStreamOpt->pDelay ? ((SValueNode*)pStreamOpt->pDelay)->datum.i : 0); + pReq->watermark = (NULL != pStreamOpt->pWatermark ? ((SValueNode*)pStreamOpt->pWatermark)->datum.i : 0); + } int32_t code = getSmaIndexDstVgId(pCxt, pStmt->tableName, &pReq->dstVgId); if (TSDB_CODE_SUCCESS == code) { @@ -3888,6 +3905,18 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt return pCxt->errCode; } + if (NULL != pStmt->pOptions->pStreamOptions) { + SStreamOptions* pStreamOpt = (SStreamOptions*)pStmt->pOptions->pStreamOptions; + if (NULL != pStreamOpt->pWatermark && + (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pWatermark))) { + return pCxt->errCode; + } + + if (NULL != pStreamOpt->pDelay && (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStreamOpt->pDelay))) { + return pCxt->errCode; + } + } + SMCreateSmaReq createSmaReq = {0}; int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); if (TSDB_CODE_SUCCESS == code) { @@ -4683,6 +4712,8 @@ static const char* getSysDbName(ENodeType type) { case QUERY_NODE_SHOW_STREAMS_STMT: case QUERY_NODE_SHOW_TRANSACTIONS_STMT: case QUERY_NODE_SHOW_APPS_STMT: + case QUERY_NODE_SHOW_CONSUMERS_STMT: + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: return TSDB_PERFORMANCE_SCHEMA_DB; default: break; @@ -4738,6 +4769,10 @@ static const char* getSysTableName(ENodeType type) { return TSDB_PERFS_TABLE_APPS; case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: return TSDB_INS_TABLE_DNODE_VARIABLES; + case QUERY_NODE_SHOW_CONSUMERS_STMT: + return TSDB_PERFS_TABLE_CONSUMERS; + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: + return TSDB_PERFS_TABLE_SUBSCRIPTIONS; default: break; } @@ -5876,6 +5911,8 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_TRANSACTIONS_STMT: case QUERY_NODE_SHOW_VARIABLES_STMT: case QUERY_NODE_SHOW_APPS_STMT: + case QUERY_NODE_SHOW_CONSUMERS_STMT: + case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: code = rewriteShow(pCxt, pQuery); break; case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index b632f2eb32..225d163f53 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,26 +104,26 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 367 +#define YYNOCODE 370 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - bool yy197; - EJoinType yy208; - SToken yy241; - SAlterOption yy301; - EOrder yy362; - SNodeList* yy368; - EFillMode yy388; - SDataType yy392; - EOperatorType yy412; - ENullOrder yy417; - SNode* yy442; - int32_t yy578; - int8_t yy629; - int64_t yy683; + ENullOrder yy77; + SAlterOption yy85; + int32_t yy100; + SToken yy109; + EOrder yy178; + int64_t yy209; + int8_t yy323; + SNodeList* yy404; + bool yy437; + EOperatorType yy440; + SNode* yy452; + SDataType yy504; + EJoinType yy532; + EFillMode yy614; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 645 -#define YYNRULE 473 -#define YYNTOKEN 244 -#define YY_MAX_SHIFT 644 -#define YY_MIN_SHIFTREDUCE 938 -#define YY_MAX_SHIFTREDUCE 1410 -#define YY_ERROR_ACTION 1411 -#define YY_ACCEPT_ACTION 1412 -#define YY_NO_ACTION 1413 -#define YY_MIN_REDUCE 1414 -#define YY_MAX_REDUCE 1886 +#define YYNSTATE 653 +#define YYNRULE 477 +#define YYNTOKEN 246 +#define YY_MAX_SHIFT 652 +#define YY_MIN_SHIFTREDUCE 947 +#define YY_MAX_SHIFTREDUCE 1423 +#define YY_ERROR_ACTION 1424 +#define YY_ACCEPT_ACTION 1425 +#define YY_NO_ACTION 1426 +#define YY_MIN_REDUCE 1427 +#define YY_MAX_REDUCE 1903 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,631 +216,623 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2260) +#define YY_ACTTAB_COUNT (2208) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 78, 415, 1726, 416, 1449, 30, 239, 423, 61, 416, - /* 10 */ 1449, 1864, 39, 37, 1864, 40, 38, 36, 35, 34, - /* 20 */ 321, 1541, 1217, 333, 69, 1863, 1593, 1595, 155, 1861, - /* 30 */ 1744, 1713, 1861, 1600, 312, 1215, 558, 115, 522, 519, - /* 40 */ 326, 26, 1710, 1696, 971, 542, 1543, 33, 32, 1598, - /* 50 */ 28, 40, 38, 36, 35, 34, 33, 32, 1744, 14, - /* 60 */ 40, 38, 36, 35, 34, 1223, 512, 119, 1706, 1712, - /* 70 */ 1757, 368, 1726, 88, 1727, 545, 1729, 1730, 541, 562, - /* 80 */ 562, 84, 1, 1797, 975, 976, 60, 314, 1793, 150, - /* 90 */ 1684, 33, 32, 1864, 120, 40, 38, 36, 35, 34, - /* 100 */ 1744, 231, 1540, 511, 641, 432, 117, 1862, 543, 498, - /* 110 */ 1825, 1861, 1864, 1696, 558, 542, 149, 60, 1288, 1289, - /* 120 */ 521, 151, 1805, 1806, 559, 1810, 154, 559, 523, 1587, - /* 130 */ 1861, 39, 37, 1347, 1726, 159, 1217, 347, 372, 321, - /* 140 */ 1757, 1217, 296, 87, 1727, 545, 1729, 1730, 541, 1215, - /* 150 */ 562, 513, 1548, 1797, 1215, 1548, 508, 295, 1793, 467, - /* 160 */ 466, 1218, 1744, 1216, 465, 1242, 1255, 116, 462, 1864, - /* 170 */ 522, 461, 460, 459, 1308, 1696, 43, 542, 14, 1223, - /* 180 */ 1241, 11, 10, 156, 1223, 1221, 1222, 1861, 1270, 1271, - /* 190 */ 1273, 1274, 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, - /* 200 */ 1290, 2, 1757, 1240, 305, 88, 1727, 545, 1729, 1730, - /* 210 */ 541, 186, 562, 157, 546, 1797, 374, 157, 641, 314, - /* 220 */ 1793, 150, 324, 641, 1644, 142, 1309, 1371, 514, 509, - /* 230 */ 449, 445, 441, 437, 185, 1354, 1223, 1288, 1289, 33, - /* 240 */ 32, 1241, 1826, 40, 38, 36, 35, 34, 157, 1314, - /* 250 */ 39, 37, 306, 292, 304, 303, 596, 455, 321, 70, - /* 260 */ 1217, 457, 183, 1322, 505, 1369, 1370, 1372, 1373, 1594, - /* 270 */ 1595, 39, 37, 1215, 22, 1218, 599, 1216, 519, 321, - /* 280 */ 1218, 1217, 1216, 456, 29, 319, 1303, 1304, 1305, 1306, - /* 290 */ 1307, 1311, 1312, 1313, 1215, 1242, 1296, 14, 414, 1221, - /* 300 */ 1222, 418, 1241, 1223, 1221, 1222, 119, 1270, 1271, 1273, - /* 310 */ 1274, 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, - /* 320 */ 2, 519, 182, 175, 1223, 180, 523, 101, 1539, 428, - /* 330 */ 100, 99, 98, 97, 96, 95, 94, 93, 92, 1710, - /* 340 */ 139, 8, 641, 1726, 1505, 117, 33, 32, 173, 119, - /* 350 */ 40, 38, 36, 35, 34, 481, 1288, 1289, 1714, 588, - /* 360 */ 228, 1805, 518, 641, 517, 1706, 1712, 1864, 479, 1710, - /* 370 */ 477, 1744, 988, 138, 987, 1426, 562, 1288, 1289, 543, - /* 380 */ 600, 156, 1520, 420, 1696, 1861, 542, 451, 117, 1239, - /* 390 */ 39, 37, 1291, 1120, 1121, 1706, 1712, 499, 321, 1218, - /* 400 */ 1217, 1216, 989, 152, 1805, 1806, 562, 1810, 1526, 422, - /* 410 */ 1272, 1757, 418, 1215, 284, 1727, 545, 1729, 1730, 541, - /* 420 */ 1218, 562, 1216, 1221, 1222, 1537, 1270, 1271, 1273, 1274, - /* 430 */ 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 519, - /* 440 */ 1437, 558, 594, 1223, 1221, 1222, 69, 1270, 1271, 1273, - /* 450 */ 1274, 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, - /* 460 */ 9, 127, 126, 591, 590, 589, 432, 119, 1544, 33, - /* 470 */ 32, 1272, 157, 40, 38, 36, 35, 34, 988, 200, - /* 480 */ 987, 1696, 641, 1436, 33, 32, 135, 523, 40, 38, - /* 490 */ 36, 35, 34, 359, 33, 32, 1288, 1289, 40, 38, - /* 500 */ 36, 35, 34, 42, 60, 1812, 117, 559, 989, 39, - /* 510 */ 37, 464, 463, 361, 357, 559, 559, 321, 373, 1217, - /* 520 */ 296, 228, 1805, 518, 1696, 517, 111, 111, 1864, 1809, - /* 530 */ 39, 37, 1215, 453, 458, 1548, 71, 294, 321, 1218, - /* 540 */ 1217, 1216, 154, 1548, 1548, 1243, 1861, 36, 35, 34, - /* 550 */ 33, 32, 1308, 1215, 40, 38, 36, 35, 34, 1381, - /* 560 */ 612, 610, 1223, 1221, 1222, 1415, 1270, 1271, 1273, 1274, - /* 570 */ 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 9, - /* 580 */ 1524, 490, 367, 1223, 366, 405, 101, 1533, 1636, 100, - /* 590 */ 99, 98, 97, 96, 95, 94, 93, 92, 1600, 166, - /* 600 */ 2, 641, 33, 32, 1309, 332, 40, 38, 36, 35, - /* 610 */ 34, 325, 559, 331, 1598, 1288, 1289, 1414, 1435, 136, - /* 620 */ 1427, 136, 641, 375, 1455, 1361, 164, 1314, 1550, 208, - /* 630 */ 1550, 168, 167, 1434, 157, 157, 1288, 1289, 596, 201, - /* 640 */ 1548, 110, 109, 108, 107, 106, 105, 104, 103, 102, - /* 650 */ 559, 67, 1812, 7, 66, 60, 519, 73, 1218, 1696, - /* 660 */ 1216, 390, 29, 319, 1303, 1304, 1305, 1306, 1307, 1311, - /* 670 */ 1312, 1313, 636, 230, 1696, 1310, 1808, 1255, 1548, 1218, - /* 680 */ 1433, 1216, 1221, 1222, 119, 1270, 1271, 1273, 1274, 1275, - /* 690 */ 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 1315, 1199, - /* 700 */ 1200, 1535, 497, 1221, 1222, 1476, 1270, 1271, 1273, 1274, - /* 710 */ 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 334, - /* 720 */ 136, 1696, 291, 117, 1239, 137, 1040, 136, 1812, 1551, - /* 730 */ 269, 398, 592, 27, 410, 1591, 1550, 58, 153, 1805, - /* 740 */ 1806, 457, 1810, 1864, 267, 57, 1600, 1432, 56, 1479, - /* 750 */ 546, 383, 1807, 411, 1412, 385, 1042, 154, 1241, 559, - /* 760 */ 1645, 1861, 1599, 456, 169, 527, 618, 617, 616, 336, - /* 770 */ 391, 615, 614, 613, 121, 608, 607, 606, 605, 604, - /* 780 */ 603, 602, 601, 129, 597, 376, 157, 1548, 1696, 60, - /* 790 */ 1078, 585, 584, 583, 1082, 582, 1084, 1085, 581, 1087, - /* 800 */ 578, 1525, 1093, 575, 1095, 1096, 572, 569, 1523, 593, - /* 810 */ 467, 466, 1591, 338, 483, 465, 1531, 263, 116, 462, - /* 820 */ 1578, 204, 461, 460, 459, 409, 1342, 86, 404, 403, - /* 830 */ 402, 401, 400, 397, 396, 395, 394, 393, 389, 388, - /* 840 */ 387, 386, 380, 379, 378, 377, 975, 976, 559, 1244, - /* 850 */ 537, 1431, 1430, 559, 1864, 1864, 1429, 328, 327, 431, - /* 860 */ 64, 63, 371, 1428, 1545, 163, 559, 1231, 154, 154, - /* 870 */ 1726, 365, 1861, 1861, 1346, 559, 1548, 1673, 1425, 1466, - /* 880 */ 1224, 1548, 290, 1817, 1342, 355, 556, 353, 349, 345, - /* 890 */ 160, 340, 1696, 1696, 1548, 594, 1424, 1696, 1744, 1423, - /* 900 */ 530, 468, 594, 1548, 1696, 191, 543, 1506, 189, 1422, - /* 910 */ 1223, 1696, 1421, 542, 127, 126, 591, 590, 589, 1696, - /* 920 */ 157, 127, 126, 591, 590, 589, 523, 1272, 1420, 1726, - /* 930 */ 1419, 207, 1418, 1417, 52, 494, 193, 1696, 1757, 192, - /* 940 */ 1696, 87, 1727, 545, 1729, 1730, 541, 472, 562, 563, - /* 950 */ 1696, 1797, 559, 1696, 528, 295, 1793, 1744, 195, 72, - /* 960 */ 535, 194, 482, 491, 525, 543, 1461, 1864, 559, 1696, - /* 970 */ 1696, 1696, 542, 1696, 1696, 1713, 199, 211, 329, 495, - /* 980 */ 1548, 154, 11, 10, 197, 1861, 1710, 196, 470, 1226, - /* 990 */ 475, 611, 1726, 587, 469, 1459, 1548, 1757, 559, 198, - /* 1000 */ 88, 1727, 545, 1729, 1730, 541, 1232, 562, 1227, 557, - /* 1010 */ 1797, 559, 1706, 1712, 314, 1793, 1877, 473, 50, 215, - /* 1020 */ 1744, 41, 252, 562, 55, 1832, 1548, 54, 543, 559, - /* 1030 */ 1235, 362, 41, 1696, 83, 542, 1409, 1410, 1716, 1548, - /* 1040 */ 335, 560, 1285, 1286, 80, 41, 1225, 241, 506, 234, - /* 1050 */ 123, 450, 124, 1726, 222, 125, 1745, 1548, 1368, 217, - /* 1060 */ 1757, 1316, 50, 88, 1727, 545, 1729, 1730, 541, 1012, - /* 1070 */ 562, 484, 1278, 1797, 1718, 1726, 337, 314, 1793, 1877, - /* 1080 */ 567, 1744, 124, 125, 1345, 1170, 1300, 243, 1855, 543, - /* 1090 */ 551, 531, 249, 1450, 1696, 1071, 542, 112, 1588, 1013, - /* 1100 */ 1828, 124, 262, 1744, 520, 233, 236, 238, 3, 5, - /* 1110 */ 339, 543, 1239, 342, 346, 301, 1696, 1229, 542, 1040, - /* 1120 */ 1099, 1757, 1103, 1110, 89, 1727, 545, 1729, 1730, 541, - /* 1130 */ 302, 562, 1183, 392, 1797, 259, 1726, 1108, 1796, 1793, - /* 1140 */ 1638, 128, 165, 1757, 399, 406, 88, 1727, 545, 1729, - /* 1150 */ 1730, 541, 408, 562, 412, 1245, 1797, 407, 413, 421, - /* 1160 */ 314, 1793, 1877, 1248, 1744, 424, 172, 425, 1247, 426, - /* 1170 */ 174, 1816, 543, 1249, 1228, 427, 177, 1696, 429, 542, - /* 1180 */ 179, 1246, 430, 181, 68, 433, 184, 452, 454, 1726, - /* 1190 */ 1538, 188, 523, 1678, 1534, 190, 293, 130, 131, 91, - /* 1200 */ 1677, 1536, 260, 1726, 1757, 485, 1532, 276, 1727, 545, - /* 1210 */ 1729, 1730, 541, 492, 562, 132, 133, 1744, 202, 489, - /* 1220 */ 205, 209, 486, 496, 502, 543, 1244, 507, 6, 516, - /* 1230 */ 1696, 1744, 542, 1864, 311, 549, 213, 1839, 504, 543, - /* 1240 */ 1838, 313, 144, 510, 1696, 523, 542, 156, 216, 1819, - /* 1250 */ 1829, 1861, 221, 503, 224, 1726, 501, 1757, 500, 226, - /* 1260 */ 276, 1727, 545, 1729, 1730, 541, 118, 562, 1342, 1243, - /* 1270 */ 44, 1757, 529, 1726, 89, 1727, 545, 1729, 1730, 541, - /* 1280 */ 532, 562, 225, 1744, 1797, 1813, 1864, 315, 534, 1793, - /* 1290 */ 18, 540, 227, 1643, 223, 1860, 1696, 1642, 542, 232, - /* 1300 */ 154, 1744, 1778, 552, 1861, 547, 548, 553, 323, 543, - /* 1310 */ 245, 79, 554, 1549, 1696, 261, 542, 1880, 247, 77, - /* 1320 */ 526, 533, 235, 1757, 565, 1726, 283, 1727, 545, 1729, - /* 1330 */ 1730, 541, 539, 562, 536, 1769, 1592, 237, 1521, 255, - /* 1340 */ 264, 1757, 1726, 637, 140, 1727, 545, 1729, 1730, 541, - /* 1350 */ 640, 562, 638, 1744, 266, 51, 143, 285, 287, 286, - /* 1360 */ 268, 543, 1690, 1689, 62, 1688, 1696, 341, 542, 1685, - /* 1370 */ 1744, 343, 344, 1210, 1211, 161, 348, 1683, 543, 350, - /* 1380 */ 351, 352, 1682, 1696, 354, 542, 1681, 356, 1680, 524, - /* 1390 */ 1878, 1726, 358, 1757, 1679, 360, 89, 1727, 545, 1729, - /* 1400 */ 1730, 541, 1663, 562, 363, 162, 1797, 364, 1186, 1185, - /* 1410 */ 1757, 1794, 1657, 279, 1727, 545, 1729, 1730, 541, 1744, - /* 1420 */ 562, 1656, 369, 370, 1655, 1654, 1157, 543, 1631, 65, - /* 1430 */ 1630, 1629, 1696, 1628, 542, 1627, 1626, 381, 382, 1625, - /* 1440 */ 384, 1624, 1623, 1622, 1621, 1620, 1619, 1618, 1617, 1616, - /* 1450 */ 1615, 1726, 515, 1614, 1613, 1612, 1611, 122, 1610, 1757, - /* 1460 */ 1726, 170, 140, 1727, 545, 1729, 1730, 541, 113, 562, - /* 1470 */ 1609, 1608, 1607, 1606, 1605, 1604, 33, 32, 1603, 1744, - /* 1480 */ 40, 38, 36, 35, 34, 1159, 1602, 543, 1744, 1601, - /* 1490 */ 1478, 1446, 1696, 978, 542, 977, 540, 417, 1445, 171, - /* 1500 */ 148, 1696, 1671, 542, 114, 318, 419, 1665, 1879, 1726, - /* 1510 */ 178, 1652, 1640, 1527, 1477, 176, 1475, 1473, 434, 1757, - /* 1520 */ 1653, 1726, 284, 1727, 545, 1729, 1730, 541, 1757, 562, - /* 1530 */ 438, 283, 1727, 545, 1729, 1730, 541, 1744, 562, 435, - /* 1540 */ 1770, 439, 1006, 436, 440, 543, 1471, 443, 444, 1744, - /* 1550 */ 1696, 1469, 542, 442, 446, 447, 1458, 543, 1457, 1442, - /* 1560 */ 448, 1529, 1696, 320, 542, 1114, 1113, 1528, 49, 187, - /* 1570 */ 1039, 1038, 644, 1037, 1726, 322, 1036, 1757, 1033, 1467, - /* 1580 */ 284, 1727, 545, 1729, 1730, 541, 258, 562, 609, 1757, - /* 1590 */ 1726, 611, 284, 1727, 545, 1729, 1730, 541, 1032, 562, - /* 1600 */ 147, 1031, 1744, 307, 1462, 634, 630, 626, 622, 256, - /* 1610 */ 543, 308, 1460, 471, 309, 1696, 1441, 542, 1744, 474, - /* 1620 */ 476, 1407, 1440, 478, 1439, 480, 543, 90, 1670, 1193, - /* 1630 */ 1664, 1696, 53, 542, 85, 487, 134, 250, 493, 1726, - /* 1640 */ 1651, 488, 1757, 1649, 206, 270, 1727, 545, 1729, 1730, - /* 1650 */ 541, 310, 562, 1650, 1648, 1647, 23, 4, 1757, 1383, - /* 1660 */ 41, 271, 1727, 545, 1729, 1730, 541, 1744, 562, 214, - /* 1670 */ 555, 220, 212, 141, 47, 543, 1367, 218, 24, 15, - /* 1680 */ 1696, 1360, 542, 1716, 219, 25, 10, 74, 46, 1339, - /* 1690 */ 229, 1338, 145, 1400, 17, 1395, 1394, 316, 45, 1726, - /* 1700 */ 210, 1389, 16, 1406, 1399, 1398, 317, 1757, 1726, 1301, - /* 1710 */ 272, 1727, 545, 1729, 1730, 541, 19, 562, 13, 1280, - /* 1720 */ 146, 1191, 1279, 203, 158, 1263, 544, 1744, 550, 31, - /* 1730 */ 12, 20, 1639, 246, 21, 543, 1744, 1715, 251, 240, - /* 1740 */ 1696, 1365, 542, 248, 543, 242, 1233, 244, 75, 1696, - /* 1750 */ 76, 542, 564, 566, 1760, 330, 570, 1726, 1282, 80, - /* 1760 */ 1100, 561, 48, 568, 573, 1097, 1094, 1757, 571, 1726, - /* 1770 */ 278, 1727, 545, 1729, 1730, 541, 1757, 562, 574, 280, - /* 1780 */ 1727, 545, 1729, 1730, 541, 1744, 562, 1088, 576, 577, - /* 1790 */ 579, 1086, 580, 543, 1092, 1091, 1090, 1744, 1696, 1089, - /* 1800 */ 542, 1077, 1109, 586, 81, 543, 253, 82, 59, 1105, - /* 1810 */ 1696, 1004, 542, 595, 1046, 1028, 598, 254, 1026, 1025, - /* 1820 */ 1726, 1024, 1021, 1023, 1022, 1757, 1020, 1019, 273, 1727, - /* 1830 */ 545, 1729, 1730, 541, 1726, 562, 1043, 1757, 1041, 1016, - /* 1840 */ 281, 1727, 545, 1729, 1730, 541, 1015, 562, 1744, 1014, - /* 1850 */ 1011, 1010, 1009, 1474, 619, 620, 543, 621, 1472, 623, - /* 1860 */ 624, 1696, 1744, 542, 625, 1470, 627, 628, 629, 1468, - /* 1870 */ 543, 631, 633, 632, 1456, 1696, 635, 542, 968, 1438, - /* 1880 */ 643, 257, 639, 1413, 1219, 1726, 265, 642, 1757, 1413, - /* 1890 */ 1413, 274, 1727, 545, 1729, 1730, 541, 1726, 562, 1413, - /* 1900 */ 1413, 1413, 1757, 1413, 1413, 282, 1727, 545, 1729, 1730, - /* 1910 */ 541, 1726, 562, 1744, 1413, 1413, 1413, 1413, 1413, 1413, - /* 1920 */ 1413, 543, 1413, 1413, 1413, 1744, 1696, 1413, 542, 1413, - /* 1930 */ 1413, 1413, 1413, 543, 1413, 1413, 1413, 1413, 1696, 1744, - /* 1940 */ 542, 1413, 1413, 1413, 1413, 1413, 1413, 543, 1413, 1413, - /* 1950 */ 1413, 1413, 1696, 1757, 542, 1413, 275, 1727, 545, 1729, - /* 1960 */ 1730, 541, 1726, 562, 1413, 1757, 1413, 1413, 288, 1727, - /* 1970 */ 545, 1729, 1730, 541, 1413, 562, 1413, 1413, 1413, 1757, - /* 1980 */ 1413, 1413, 289, 1727, 545, 1729, 1730, 541, 1726, 562, - /* 1990 */ 1744, 1413, 1413, 1413, 1413, 1413, 1413, 1413, 543, 1413, - /* 2000 */ 1413, 1413, 1413, 1696, 1413, 542, 1413, 1413, 1413, 1413, - /* 2010 */ 1413, 1413, 1413, 1413, 1413, 1413, 1744, 1413, 1413, 1413, - /* 2020 */ 1413, 1413, 1413, 1413, 543, 1413, 1413, 1413, 1413, 1696, - /* 2030 */ 1757, 542, 1413, 1738, 1727, 545, 1729, 1730, 541, 1413, - /* 2040 */ 562, 1726, 1413, 1413, 1413, 1413, 1413, 1413, 1413, 1413, - /* 2050 */ 1413, 1413, 1413, 1726, 1413, 1413, 1757, 1413, 1413, 1737, - /* 2060 */ 1727, 545, 1729, 1730, 541, 1413, 562, 1413, 1413, 1744, - /* 2070 */ 1413, 1413, 1413, 1413, 1413, 1413, 1413, 543, 1413, 1413, - /* 2080 */ 1413, 1744, 1696, 1413, 542, 1413, 1413, 1413, 1413, 543, - /* 2090 */ 1413, 1413, 1413, 1413, 1696, 1413, 542, 1413, 1413, 1413, - /* 2100 */ 1413, 1413, 1413, 1413, 1726, 1413, 1413, 1413, 1413, 1757, - /* 2110 */ 1413, 1413, 1736, 1727, 545, 1729, 1730, 541, 1726, 562, - /* 2120 */ 1413, 1757, 1413, 1413, 299, 1727, 545, 1729, 1730, 541, - /* 2130 */ 1413, 562, 1744, 1413, 1413, 1413, 1413, 1413, 1413, 1413, - /* 2140 */ 543, 1413, 1413, 1413, 1413, 1696, 1744, 542, 1413, 1413, - /* 2150 */ 1413, 1413, 1413, 1413, 543, 1413, 1413, 1413, 1413, 1696, - /* 2160 */ 1413, 542, 1413, 1413, 1413, 1413, 1413, 1413, 1413, 1726, - /* 2170 */ 1413, 1413, 1757, 1413, 1413, 298, 1727, 545, 1729, 1730, - /* 2180 */ 541, 1726, 562, 1413, 1413, 1413, 1757, 1413, 1413, 300, - /* 2190 */ 1727, 545, 1729, 1730, 541, 1413, 562, 1744, 1413, 1413, - /* 2200 */ 1413, 1413, 1413, 1413, 1413, 543, 1413, 1413, 1413, 1744, - /* 2210 */ 1696, 1413, 542, 1413, 1413, 1413, 1413, 543, 1413, 1413, - /* 2220 */ 1413, 1413, 1696, 1413, 542, 1413, 1413, 1413, 1413, 1413, - /* 2230 */ 1413, 1413, 1413, 1413, 1413, 1413, 1413, 1757, 1413, 1413, - /* 2240 */ 297, 1727, 545, 1729, 1730, 541, 1413, 562, 1413, 1757, - /* 2250 */ 1413, 1413, 277, 1727, 545, 1729, 1730, 541, 1413, 562, + /* 0 */ 422, 1661, 423, 1462, 430, 1730, 423, 1462, 317, 1881, + /* 10 */ 141, 1425, 39, 37, 1518, 373, 1727, 69, 1552, 1550, + /* 20 */ 326, 1428, 1230, 1880, 379, 1730, 1367, 1878, 334, 1727, + /* 30 */ 115, 140, 1254, 1439, 1743, 1228, 1727, 338, 566, 1556, + /* 40 */ 1606, 1608, 101, 1723, 1729, 100, 99, 98, 97, 96, + /* 50 */ 95, 94, 93, 92, 570, 1881, 1723, 1729, 61, 14, + /* 60 */ 1309, 296, 1761, 1723, 1729, 1236, 1254, 570, 1761, 156, + /* 70 */ 550, 566, 343, 1878, 570, 1713, 519, 549, 39, 37, + /* 80 */ 1360, 427, 1, 504, 1255, 1230, 326, 1252, 1230, 33, + /* 90 */ 32, 439, 530, 40, 38, 36, 35, 34, 1228, 1743, + /* 100 */ 43, 1228, 151, 1774, 649, 520, 87, 1744, 552, 1746, + /* 110 */ 1747, 548, 1881, 570, 518, 1600, 1814, 69, 1301, 1302, + /* 120 */ 298, 1810, 60, 1881, 1255, 14, 156, 1761, 1236, 1881, + /* 130 */ 1878, 1236, 1881, 567, 567, 547, 60, 156, 526, 1557, + /* 140 */ 1713, 1878, 549, 157, 111, 161, 158, 1878, 2, 101, + /* 150 */ 1878, 460, 100, 99, 98, 97, 96, 95, 94, 93, + /* 160 */ 92, 1561, 1561, 1231, 1394, 1229, 119, 649, 1774, 604, + /* 170 */ 649, 287, 1744, 552, 1746, 1747, 548, 546, 570, 543, + /* 180 */ 1786, 1323, 1129, 1130, 1301, 1302, 1450, 1234, 1235, 534, + /* 190 */ 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, 568, 1298, + /* 200 */ 1299, 1300, 1303, 1285, 1328, 166, 117, 295, 1829, 1252, + /* 210 */ 40, 38, 36, 35, 34, 159, 405, 1427, 1236, 417, + /* 220 */ 528, 153, 1822, 1823, 567, 1827, 1231, 1713, 1229, 1231, + /* 230 */ 67, 1229, 1826, 66, 1384, 377, 390, 1285, 418, 27, + /* 240 */ 392, 110, 109, 108, 107, 106, 105, 104, 103, 102, + /* 250 */ 1234, 1235, 1561, 1234, 1235, 159, 1283, 1284, 1286, 1287, + /* 260 */ 1288, 1289, 1290, 545, 568, 1298, 1299, 1300, 1303, 159, + /* 270 */ 383, 512, 1382, 1383, 1385, 1386, 33, 32, 39, 37, + /* 280 */ 40, 38, 36, 35, 34, 1254, 326, 608, 1230, 1533, + /* 290 */ 1087, 593, 592, 591, 1091, 590, 1093, 1094, 589, 1096, + /* 300 */ 586, 1228, 1102, 583, 1104, 1105, 580, 577, 11, 10, + /* 310 */ 416, 22, 566, 411, 410, 409, 408, 407, 404, 403, + /* 320 */ 402, 401, 400, 396, 395, 394, 393, 387, 386, 385, + /* 330 */ 384, 1236, 381, 380, 39, 37, 1743, 1253, 310, 30, + /* 340 */ 240, 997, 326, 996, 1230, 33, 32, 209, 8, 40, + /* 350 */ 38, 36, 35, 34, 474, 473, 458, 1228, 1731, 472, + /* 360 */ 980, 1256, 116, 469, 1761, 567, 468, 467, 466, 1727, + /* 370 */ 649, 998, 550, 60, 42, 73, 111, 1713, 596, 549, + /* 380 */ 535, 14, 497, 465, 1301, 1302, 311, 1236, 309, 308, + /* 390 */ 1335, 462, 412, 1561, 530, 464, 1723, 1729, 515, 479, + /* 400 */ 984, 985, 1881, 1449, 2, 1774, 1440, 570, 87, 1744, + /* 410 */ 552, 1746, 1747, 548, 489, 570, 1879, 463, 1814, 567, + /* 420 */ 1878, 567, 298, 1810, 84, 553, 649, 1492, 201, 1231, + /* 430 */ 378, 1229, 382, 329, 1881, 607, 1658, 120, 170, 169, + /* 440 */ 1301, 1302, 482, 1448, 1713, 1553, 476, 1561, 156, 1561, + /* 450 */ 490, 200, 1878, 1234, 1235, 1546, 1283, 1284, 1286, 1287, + /* 460 */ 1288, 1289, 1290, 545, 568, 1298, 1299, 1300, 1303, 330, + /* 470 */ 521, 516, 39, 37, 1304, 421, 55, 138, 425, 54, + /* 480 */ 326, 159, 1230, 567, 1713, 1231, 1563, 1229, 474, 473, + /* 490 */ 1881, 231, 1420, 472, 397, 1228, 116, 469, 526, 1519, + /* 500 */ 468, 467, 466, 526, 156, 58, 159, 159, 1878, 1234, + /* 510 */ 1235, 1561, 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, + /* 520 */ 568, 1298, 1299, 1300, 1303, 1236, 119, 39, 37, 1607, + /* 530 */ 1608, 119, 567, 364, 1257, 326, 1447, 1230, 984, 985, + /* 540 */ 33, 32, 9, 398, 40, 38, 36, 35, 34, 202, + /* 550 */ 1228, 33, 32, 366, 362, 40, 38, 36, 35, 34, + /* 560 */ 1561, 567, 429, 1743, 649, 425, 117, 336, 997, 1446, + /* 570 */ 996, 117, 438, 1657, 1419, 138, 305, 1713, 1301, 1302, + /* 580 */ 1236, 154, 1822, 1823, 1563, 1827, 155, 1822, 1823, 1561, + /* 590 */ 1827, 1761, 602, 39, 37, 235, 567, 9, 998, 550, + /* 600 */ 1445, 326, 1444, 1230, 1713, 464, 549, 1558, 71, 304, + /* 610 */ 1713, 129, 128, 599, 598, 597, 1228, 567, 506, 649, + /* 620 */ 471, 470, 1479, 1231, 1561, 1229, 1374, 463, 1690, 36, + /* 630 */ 35, 34, 1774, 1301, 1302, 288, 1744, 552, 1746, 1747, + /* 640 */ 548, 1713, 570, 1713, 475, 1561, 1236, 1234, 1235, 1049, + /* 650 */ 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, 568, 1298, + /* 660 */ 1299, 1300, 1303, 2, 212, 567, 567, 33, 32, 1254, + /* 670 */ 567, 40, 38, 36, 35, 34, 498, 502, 1231, 1051, + /* 680 */ 1229, 564, 33, 32, 1651, 649, 40, 38, 36, 35, + /* 690 */ 34, 620, 618, 1561, 1561, 168, 1834, 1355, 1561, 1301, + /* 700 */ 1302, 1538, 1234, 1235, 1548, 1283, 1284, 1286, 1287, 1288, + /* 710 */ 1289, 1290, 545, 568, 1298, 1299, 1300, 1303, 299, 60, + /* 720 */ 567, 33, 32, 652, 339, 40, 38, 36, 35, 34, + /* 730 */ 1544, 565, 138, 299, 532, 205, 1613, 262, 567, 1539, + /* 740 */ 488, 1563, 1268, 331, 1231, 1443, 1229, 1613, 1561, 256, + /* 750 */ 1321, 149, 1611, 486, 337, 484, 642, 638, 634, 630, + /* 760 */ 260, 244, 1743, 1611, 1537, 1321, 1561, 1442, 1234, 1235, + /* 770 */ 1441, 1283, 1284, 1286, 1287, 1288, 1289, 1290, 545, 568, + /* 780 */ 1298, 1299, 1300, 1303, 138, 85, 1713, 139, 254, 553, + /* 790 */ 1761, 1438, 273, 1564, 1359, 602, 1268, 439, 550, 372, + /* 800 */ 1659, 371, 567, 1713, 1322, 549, 271, 57, 1713, 1829, + /* 810 */ 56, 1713, 544, 340, 129, 128, 599, 598, 597, 1322, + /* 820 */ 1437, 563, 604, 1212, 1213, 1656, 171, 1327, 305, 1613, + /* 830 */ 1561, 1774, 1713, 1825, 88, 1744, 552, 1746, 1747, 548, + /* 840 */ 1285, 570, 1327, 1489, 1814, 1612, 1436, 1435, 319, 1810, + /* 850 */ 1894, 60, 159, 211, 78, 1701, 7, 595, 1434, 1849, + /* 860 */ 1433, 1713, 29, 324, 1316, 1317, 1318, 1319, 1320, 1324, + /* 870 */ 1325, 1326, 245, 246, 1204, 1554, 204, 29, 324, 1316, + /* 880 */ 1317, 1318, 1319, 1320, 1324, 1325, 1326, 1713, 1713, 86, + /* 890 */ 33, 32, 513, 1432, 40, 38, 36, 35, 34, 1713, + /* 900 */ 1743, 1713, 352, 1431, 626, 625, 624, 341, 1829, 623, + /* 910 */ 622, 621, 121, 616, 615, 614, 613, 612, 611, 610, + /* 920 */ 609, 131, 605, 619, 64, 63, 376, 1430, 1761, 165, + /* 930 */ 208, 542, 1824, 304, 1713, 370, 529, 333, 332, 600, + /* 940 */ 537, 1713, 1604, 549, 1713, 601, 294, 1244, 1604, 360, + /* 950 */ 1239, 358, 354, 350, 162, 345, 267, 457, 72, 1591, + /* 960 */ 1237, 1743, 193, 367, 195, 191, 223, 194, 1713, 1774, + /* 970 */ 1536, 1474, 88, 1744, 552, 1746, 1747, 548, 197, 570, + /* 980 */ 199, 196, 1814, 198, 159, 1472, 319, 1810, 152, 1761, + /* 990 */ 1236, 52, 501, 477, 11, 10, 1238, 529, 491, 50, + /* 1000 */ 232, 1762, 1713, 83, 549, 26, 1358, 480, 505, 1842, + /* 1010 */ 1733, 33, 32, 80, 28, 40, 38, 36, 35, 34, + /* 1020 */ 33, 32, 1743, 342, 40, 38, 36, 35, 34, 571, + /* 1030 */ 1774, 1355, 137, 88, 1744, 552, 1746, 1747, 548, 1381, + /* 1040 */ 570, 1422, 1423, 1814, 1463, 1601, 1735, 319, 1810, 152, + /* 1050 */ 1761, 1845, 216, 41, 527, 234, 237, 239, 550, 1313, + /* 1060 */ 41, 5, 41, 1713, 602, 549, 242, 344, 3, 1252, + /* 1070 */ 1843, 123, 347, 351, 126, 127, 50, 1743, 306, 1049, + /* 1080 */ 1242, 575, 126, 129, 128, 599, 598, 597, 1245, 1468, + /* 1090 */ 1240, 1774, 218, 1329, 88, 1744, 552, 1746, 1747, 548, + /* 1100 */ 1291, 570, 1180, 127, 1814, 1761, 247, 112, 319, 1810, + /* 1110 */ 1894, 559, 1248, 550, 253, 1080, 266, 307, 1713, 1872, + /* 1120 */ 549, 1108, 1112, 568, 1298, 1299, 1241, 1196, 126, 263, + /* 1130 */ 1743, 1021, 399, 538, 1653, 167, 406, 644, 1258, 1743, + /* 1140 */ 414, 413, 415, 1119, 419, 1261, 1774, 1117, 431, 88, + /* 1150 */ 1744, 552, 1746, 1747, 548, 420, 570, 1743, 1761, 1814, + /* 1160 */ 428, 1022, 174, 319, 1810, 1894, 550, 1761, 130, 1260, + /* 1170 */ 433, 1713, 176, 549, 1833, 550, 432, 1262, 434, 179, + /* 1180 */ 1713, 181, 549, 1259, 437, 1761, 459, 183, 530, 436, + /* 1190 */ 68, 440, 186, 550, 461, 91, 1551, 530, 1713, 1774, + /* 1200 */ 549, 190, 280, 1744, 552, 1746, 1747, 548, 1774, 570, + /* 1210 */ 1547, 280, 1744, 552, 1746, 1747, 548, 192, 570, 132, + /* 1220 */ 133, 1549, 1743, 1545, 134, 135, 1774, 297, 1881, 89, + /* 1230 */ 1744, 552, 1746, 1747, 548, 1695, 570, 1881, 1743, 1814, + /* 1240 */ 264, 203, 158, 1813, 1810, 492, 1878, 1743, 493, 496, + /* 1250 */ 1761, 156, 1257, 206, 499, 1878, 503, 316, 550, 210, + /* 1260 */ 514, 1846, 509, 1713, 556, 549, 1761, 1856, 214, 511, + /* 1270 */ 217, 318, 6, 517, 550, 1761, 523, 510, 1836, 1713, + /* 1280 */ 224, 549, 508, 550, 507, 1855, 1355, 118, 1713, 226, + /* 1290 */ 549, 1774, 222, 227, 89, 1744, 552, 1746, 1747, 548, + /* 1300 */ 1743, 570, 146, 225, 1814, 1256, 1830, 1774, 541, 1810, + /* 1310 */ 142, 1744, 552, 1746, 1747, 548, 1774, 570, 44, 89, + /* 1320 */ 1744, 552, 1746, 1747, 548, 539, 570, 1877, 1761, 1814, + /* 1330 */ 188, 536, 320, 18, 1811, 124, 550, 233, 236, 228, + /* 1340 */ 1795, 1713, 125, 549, 144, 554, 555, 1897, 533, 456, + /* 1350 */ 452, 448, 444, 187, 1743, 531, 1895, 1694, 1663, 557, + /* 1360 */ 540, 328, 560, 1743, 561, 249, 251, 238, 562, 1774, + /* 1370 */ 265, 77, 283, 1744, 552, 1746, 1747, 548, 70, 570, + /* 1380 */ 1562, 185, 1761, 79, 573, 268, 1534, 645, 259, 1605, + /* 1390 */ 550, 1761, 646, 648, 51, 1713, 145, 549, 289, 550, + /* 1400 */ 272, 291, 290, 270, 1713, 1707, 549, 1706, 62, 1705, + /* 1410 */ 346, 522, 348, 1743, 1702, 349, 1223, 1224, 323, 163, + /* 1420 */ 353, 1700, 355, 1774, 1743, 356, 142, 1744, 552, 1746, + /* 1430 */ 1747, 548, 1774, 570, 357, 288, 1744, 552, 1746, 1747, + /* 1440 */ 548, 1761, 570, 184, 177, 1699, 182, 359, 1698, 547, + /* 1450 */ 435, 361, 1761, 1697, 1713, 363, 549, 1696, 365, 1680, + /* 1460 */ 550, 164, 368, 369, 1199, 1713, 1198, 549, 1674, 175, + /* 1470 */ 1673, 374, 1896, 375, 1672, 1671, 1743, 1168, 1646, 325, + /* 1480 */ 1645, 1644, 1774, 65, 1643, 287, 1744, 552, 1746, 1747, + /* 1490 */ 548, 1642, 570, 1774, 1787, 1641, 288, 1744, 552, 1746, + /* 1500 */ 1747, 548, 1640, 570, 1761, 1639, 388, 389, 1638, 391, + /* 1510 */ 1637, 1636, 550, 1635, 1634, 1633, 1632, 1713, 1631, 549, + /* 1520 */ 1630, 1629, 1628, 1627, 1626, 1625, 1624, 122, 1623, 1743, + /* 1530 */ 1622, 327, 1621, 1620, 1619, 1618, 1617, 1616, 1743, 1170, + /* 1540 */ 1615, 1614, 1491, 1459, 150, 1774, 172, 1743, 288, 1744, + /* 1550 */ 552, 1746, 1747, 548, 1458, 570, 1688, 1761, 113, 987, + /* 1560 */ 986, 1682, 1670, 1669, 180, 550, 1761, 1655, 1540, 173, + /* 1570 */ 1713, 1490, 549, 424, 550, 1761, 1488, 426, 114, 1713, + /* 1580 */ 1486, 549, 1484, 550, 1482, 441, 178, 443, 1713, 1471, + /* 1590 */ 549, 442, 445, 1470, 447, 449, 1455, 1542, 1774, 1743, + /* 1600 */ 446, 274, 1744, 552, 1746, 1747, 548, 1774, 570, 451, + /* 1610 */ 275, 1744, 552, 1746, 1747, 548, 1774, 570, 453, 276, + /* 1620 */ 1744, 552, 1746, 1747, 548, 1015, 570, 1761, 450, 49, + /* 1630 */ 455, 1122, 454, 1123, 1541, 550, 1048, 1047, 1046, 1045, + /* 1640 */ 1713, 1743, 549, 617, 1480, 1042, 1041, 1040, 189, 619, + /* 1650 */ 312, 1475, 313, 1473, 478, 314, 481, 1454, 483, 1453, + /* 1660 */ 485, 1743, 1452, 487, 1687, 90, 1206, 1681, 1774, 1761, + /* 1670 */ 494, 282, 1744, 552, 1746, 1747, 548, 550, 570, 1668, + /* 1680 */ 1666, 136, 1713, 1743, 549, 1667, 1665, 1664, 15, 1761, + /* 1690 */ 4, 1408, 41, 47, 10, 23, 213, 550, 1396, 207, + /* 1700 */ 143, 53, 1713, 215, 549, 1380, 219, 221, 24, 220, + /* 1710 */ 1774, 1761, 1373, 284, 1744, 552, 1746, 1747, 548, 550, + /* 1720 */ 570, 500, 495, 315, 1713, 74, 549, 1733, 16, 1352, + /* 1730 */ 1774, 25, 46, 277, 1744, 552, 1746, 1747, 548, 1743, + /* 1740 */ 570, 1351, 230, 147, 17, 1407, 1413, 321, 1743, 1412, + /* 1750 */ 1411, 1402, 1774, 322, 19, 285, 1744, 552, 1746, 1747, + /* 1760 */ 548, 1314, 570, 148, 1276, 1293, 31, 1761, 160, 1662, + /* 1770 */ 1654, 250, 1732, 1292, 241, 550, 1761, 45, 1378, 551, + /* 1780 */ 1713, 12, 549, 558, 550, 13, 20, 21, 243, 1713, + /* 1790 */ 248, 549, 80, 255, 1246, 75, 572, 574, 1743, 1295, + /* 1800 */ 252, 76, 1777, 569, 1101, 48, 335, 1743, 1774, 578, + /* 1810 */ 1109, 278, 1744, 552, 1746, 1747, 548, 1774, 570, 576, + /* 1820 */ 286, 1744, 552, 1746, 1747, 548, 1761, 570, 1106, 1103, + /* 1830 */ 579, 581, 582, 584, 550, 1761, 587, 1097, 585, 1713, + /* 1840 */ 1095, 549, 588, 550, 1100, 1099, 1086, 1098, 1713, 594, + /* 1850 */ 549, 1118, 257, 1114, 1013, 81, 603, 1743, 82, 59, + /* 1860 */ 1037, 606, 258, 1035, 1055, 1034, 1743, 1774, 1033, 1032, + /* 1870 */ 279, 1744, 552, 1746, 1747, 548, 1774, 570, 1031, 292, + /* 1880 */ 1744, 552, 1746, 1747, 548, 1761, 570, 1030, 1029, 1028, + /* 1890 */ 1050, 1052, 1025, 550, 1761, 1024, 1023, 1020, 1713, 1019, + /* 1900 */ 549, 1018, 550, 1487, 627, 628, 629, 1713, 1485, 549, + /* 1910 */ 631, 633, 1483, 635, 1481, 632, 637, 636, 1743, 639, + /* 1920 */ 640, 641, 1469, 643, 977, 1451, 1774, 1743, 261, 293, + /* 1930 */ 1744, 552, 1746, 1747, 548, 1774, 570, 647, 1755, 1744, + /* 1940 */ 552, 1746, 1747, 548, 650, 570, 1761, 1426, 1232, 269, + /* 1950 */ 651, 1426, 1426, 1426, 550, 1761, 1426, 1426, 1426, 1713, + /* 1960 */ 1426, 549, 1426, 550, 1426, 1426, 1426, 1426, 1713, 1426, + /* 1970 */ 549, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, + /* 1980 */ 1743, 1426, 1426, 1426, 1426, 1426, 1426, 1774, 1426, 1743, + /* 1990 */ 1754, 1744, 552, 1746, 1747, 548, 1774, 570, 1743, 1753, + /* 2000 */ 1744, 552, 1746, 1747, 548, 1426, 570, 1743, 1761, 1426, + /* 2010 */ 526, 1426, 1426, 1426, 1426, 1426, 550, 1761, 1426, 1426, + /* 2020 */ 1426, 1713, 1426, 549, 1426, 550, 1761, 1426, 1426, 1426, + /* 2030 */ 1713, 1426, 549, 1426, 550, 1761, 1426, 1426, 119, 1713, + /* 2040 */ 1426, 549, 1426, 550, 1426, 1426, 1426, 1426, 1713, 1774, + /* 2050 */ 549, 1426, 302, 1744, 552, 1746, 1747, 548, 1774, 570, + /* 2060 */ 530, 301, 1744, 552, 1746, 1747, 548, 1774, 570, 1426, + /* 2070 */ 303, 1744, 552, 1746, 1747, 548, 1774, 570, 117, 300, + /* 2080 */ 1744, 552, 1746, 1747, 548, 1743, 570, 1426, 1426, 1426, + /* 2090 */ 1426, 1426, 1426, 229, 1822, 525, 1426, 524, 1426, 526, + /* 2100 */ 1881, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, + /* 2110 */ 1426, 1426, 1426, 1761, 158, 1426, 1426, 1426, 1878, 1426, + /* 2120 */ 1426, 550, 1426, 1426, 1426, 1426, 1713, 119, 549, 1426, + /* 2130 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, + /* 2140 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 530, + /* 2150 */ 1426, 1426, 1426, 1426, 1774, 1426, 1426, 281, 1744, 552, + /* 2160 */ 1746, 1747, 548, 1426, 570, 1426, 1426, 117, 1426, 1426, + /* 2170 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, + /* 2180 */ 1426, 1426, 229, 1822, 525, 1426, 524, 1426, 1426, 1881, + /* 2190 */ 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, 1426, + /* 2200 */ 1426, 1426, 1426, 156, 1426, 1426, 1426, 1878, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 257, 251, 247, 253, 254, 329, 330, 251, 4, 253, - /* 10 */ 254, 344, 12, 13, 344, 12, 13, 14, 15, 16, - /* 20 */ 20, 278, 22, 286, 259, 358, 289, 290, 358, 362, - /* 30 */ 275, 277, 362, 275, 280, 35, 20, 272, 283, 255, - /* 40 */ 282, 2, 288, 288, 4, 290, 281, 8, 9, 291, - /* 50 */ 2, 12, 13, 14, 15, 16, 8, 9, 275, 59, - /* 60 */ 12, 13, 14, 15, 16, 65, 283, 283, 314, 315, - /* 70 */ 315, 303, 247, 318, 319, 320, 321, 322, 323, 325, - /* 80 */ 325, 257, 82, 328, 44, 45, 82, 332, 333, 334, - /* 90 */ 0, 8, 9, 344, 270, 12, 13, 14, 15, 16, - /* 100 */ 275, 346, 278, 320, 104, 58, 322, 358, 283, 354, - /* 110 */ 355, 362, 344, 288, 20, 290, 274, 82, 118, 119, - /* 120 */ 336, 337, 338, 339, 255, 341, 358, 255, 303, 287, - /* 130 */ 362, 12, 13, 14, 247, 266, 22, 47, 266, 20, - /* 140 */ 315, 22, 59, 318, 319, 320, 321, 322, 323, 35, - /* 150 */ 325, 20, 283, 328, 35, 283, 146, 332, 333, 61, - /* 160 */ 62, 161, 275, 163, 66, 20, 83, 69, 70, 344, - /* 170 */ 283, 73, 74, 75, 91, 288, 82, 290, 59, 65, - /* 180 */ 20, 1, 2, 358, 65, 185, 186, 362, 188, 189, + /* 0 */ 253, 0, 255, 256, 253, 279, 255, 256, 282, 347, + /* 10 */ 262, 246, 12, 13, 266, 307, 290, 261, 279, 278, + /* 20 */ 20, 0, 22, 361, 257, 279, 14, 365, 282, 290, + /* 30 */ 274, 248, 20, 250, 249, 35, 290, 288, 20, 283, + /* 40 */ 291, 292, 21, 317, 318, 24, 25, 26, 27, 28, + /* 50 */ 29, 30, 31, 32, 328, 347, 317, 318, 4, 59, + /* 60 */ 14, 294, 277, 317, 318, 65, 20, 328, 277, 361, + /* 70 */ 285, 20, 307, 365, 328, 290, 285, 292, 12, 13, + /* 80 */ 14, 14, 82, 307, 20, 22, 20, 20, 22, 8, + /* 90 */ 9, 58, 307, 12, 13, 14, 15, 16, 35, 249, + /* 100 */ 82, 35, 276, 318, 104, 20, 321, 322, 323, 324, + /* 110 */ 325, 326, 347, 328, 323, 289, 331, 261, 118, 119, + /* 120 */ 335, 336, 82, 347, 20, 59, 361, 277, 65, 347, + /* 130 */ 365, 65, 347, 257, 257, 285, 82, 361, 257, 283, + /* 140 */ 290, 365, 292, 361, 268, 268, 361, 365, 82, 21, + /* 150 */ 365, 275, 24, 25, 26, 27, 28, 29, 30, 31, + /* 160 */ 32, 285, 285, 163, 83, 165, 285, 104, 318, 58, + /* 170 */ 104, 321, 322, 323, 324, 325, 326, 327, 328, 329, + /* 180 */ 330, 145, 118, 119, 118, 119, 249, 187, 188, 43, /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - /* 200 */ 200, 82, 315, 20, 37, 318, 319, 320, 321, 322, - /* 210 */ 323, 33, 325, 213, 290, 328, 255, 213, 104, 332, - /* 220 */ 333, 334, 298, 104, 300, 47, 143, 185, 218, 219, - /* 230 */ 52, 53, 54, 55, 56, 14, 65, 118, 119, 8, - /* 240 */ 9, 20, 355, 12, 13, 14, 15, 16, 213, 166, - /* 250 */ 12, 13, 85, 292, 87, 88, 58, 90, 20, 81, - /* 260 */ 22, 94, 84, 83, 222, 223, 224, 225, 226, 289, - /* 270 */ 290, 12, 13, 35, 43, 161, 65, 163, 255, 20, - /* 280 */ 161, 22, 163, 116, 201, 202, 203, 204, 205, 206, - /* 290 */ 207, 208, 209, 210, 35, 20, 14, 59, 252, 185, - /* 300 */ 186, 255, 20, 65, 185, 186, 283, 188, 189, 190, - /* 310 */ 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, - /* 320 */ 82, 255, 144, 145, 65, 147, 303, 21, 277, 151, - /* 330 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 288, - /* 340 */ 260, 82, 104, 247, 264, 322, 8, 9, 170, 283, - /* 350 */ 12, 13, 14, 15, 16, 21, 118, 119, 277, 93, - /* 360 */ 337, 338, 339, 104, 341, 314, 315, 344, 34, 288, - /* 370 */ 36, 275, 20, 246, 22, 248, 325, 118, 119, 283, - /* 380 */ 263, 358, 265, 14, 288, 362, 290, 35, 322, 20, - /* 390 */ 12, 13, 14, 118, 119, 314, 315, 301, 20, 161, - /* 400 */ 22, 163, 50, 337, 338, 339, 325, 341, 0, 252, - /* 410 */ 189, 315, 255, 35, 318, 319, 320, 321, 322, 323, - /* 420 */ 161, 325, 163, 185, 186, 276, 188, 189, 190, 191, - /* 430 */ 192, 193, 194, 195, 196, 197, 198, 199, 200, 255, - /* 440 */ 247, 20, 94, 65, 185, 186, 259, 188, 189, 190, - /* 450 */ 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, - /* 460 */ 82, 113, 114, 115, 116, 117, 58, 283, 281, 8, - /* 470 */ 9, 189, 213, 12, 13, 14, 15, 16, 20, 114, - /* 480 */ 22, 288, 104, 247, 8, 9, 148, 303, 12, 13, - /* 490 */ 14, 15, 16, 156, 8, 9, 118, 119, 12, 13, - /* 500 */ 14, 15, 16, 82, 82, 316, 322, 255, 50, 12, - /* 510 */ 13, 261, 262, 176, 177, 255, 255, 20, 266, 22, - /* 520 */ 59, 337, 338, 339, 288, 341, 266, 266, 344, 340, - /* 530 */ 12, 13, 35, 273, 273, 283, 171, 172, 20, 161, - /* 540 */ 22, 163, 358, 283, 283, 20, 362, 14, 15, 16, - /* 550 */ 8, 9, 91, 35, 12, 13, 14, 15, 16, 83, - /* 560 */ 261, 262, 65, 185, 186, 0, 188, 189, 190, 191, - /* 570 */ 192, 193, 194, 195, 196, 197, 198, 199, 200, 82, - /* 580 */ 0, 307, 160, 65, 162, 76, 21, 276, 283, 24, - /* 590 */ 25, 26, 27, 28, 29, 30, 31, 32, 275, 294, - /* 600 */ 82, 104, 8, 9, 143, 282, 12, 13, 14, 15, - /* 610 */ 16, 267, 255, 267, 291, 118, 119, 0, 247, 275, - /* 620 */ 248, 275, 104, 266, 0, 83, 56, 166, 284, 56, - /* 630 */ 284, 122, 123, 247, 213, 213, 118, 119, 58, 113, - /* 640 */ 283, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 650 */ 255, 81, 316, 39, 84, 82, 255, 84, 161, 288, - /* 660 */ 163, 266, 201, 202, 203, 204, 205, 206, 207, 208, - /* 670 */ 209, 210, 48, 148, 288, 143, 340, 83, 283, 161, - /* 680 */ 247, 163, 185, 186, 283, 188, 189, 190, 191, 192, - /* 690 */ 193, 194, 195, 196, 197, 198, 199, 200, 166, 173, - /* 700 */ 174, 276, 303, 185, 186, 0, 188, 189, 190, 191, - /* 710 */ 192, 193, 194, 195, 196, 197, 198, 199, 200, 267, - /* 720 */ 275, 288, 18, 322, 20, 18, 35, 275, 316, 284, - /* 730 */ 23, 27, 285, 201, 30, 288, 284, 3, 337, 338, - /* 740 */ 339, 94, 341, 344, 37, 38, 275, 247, 41, 0, - /* 750 */ 290, 47, 340, 49, 244, 51, 65, 358, 20, 255, - /* 760 */ 300, 362, 291, 116, 57, 43, 61, 62, 63, 64, - /* 770 */ 266, 66, 67, 68, 69, 70, 71, 72, 73, 74, - /* 780 */ 75, 76, 77, 78, 79, 81, 213, 283, 288, 82, - /* 790 */ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - /* 800 */ 105, 0, 107, 108, 109, 110, 111, 112, 0, 285, - /* 810 */ 61, 62, 288, 303, 303, 66, 276, 268, 69, 70, - /* 820 */ 271, 276, 73, 74, 75, 121, 212, 120, 124, 125, - /* 830 */ 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, - /* 840 */ 136, 137, 138, 139, 140, 141, 44, 45, 255, 20, - /* 850 */ 276, 247, 247, 255, 344, 344, 247, 12, 13, 266, - /* 860 */ 153, 154, 155, 247, 266, 158, 255, 22, 358, 358, - /* 870 */ 247, 164, 362, 362, 4, 255, 283, 266, 247, 0, - /* 880 */ 35, 283, 175, 211, 212, 178, 266, 180, 181, 182, - /* 890 */ 183, 184, 288, 288, 283, 94, 247, 288, 275, 247, - /* 900 */ 43, 22, 94, 283, 288, 86, 283, 264, 89, 247, - /* 910 */ 65, 288, 247, 290, 113, 114, 115, 116, 117, 288, - /* 920 */ 213, 113, 114, 115, 116, 117, 303, 189, 247, 247, - /* 930 */ 247, 56, 247, 247, 148, 149, 86, 288, 315, 89, - /* 940 */ 288, 318, 319, 320, 321, 322, 323, 4, 325, 104, - /* 950 */ 288, 328, 255, 288, 232, 332, 333, 275, 86, 84, - /* 960 */ 59, 89, 19, 266, 230, 283, 0, 344, 255, 288, - /* 970 */ 288, 288, 290, 288, 288, 277, 33, 148, 280, 266, - /* 980 */ 283, 358, 1, 2, 86, 362, 288, 89, 22, 35, - /* 990 */ 47, 43, 247, 276, 51, 0, 283, 315, 255, 56, - /* 1000 */ 318, 319, 320, 321, 322, 323, 161, 325, 163, 266, - /* 1010 */ 328, 255, 314, 315, 332, 333, 334, 22, 43, 43, - /* 1020 */ 275, 43, 266, 325, 81, 343, 283, 84, 283, 255, - /* 1030 */ 185, 83, 43, 288, 82, 290, 118, 119, 46, 283, - /* 1040 */ 266, 196, 197, 198, 92, 43, 35, 43, 356, 365, - /* 1050 */ 43, 256, 43, 247, 351, 43, 275, 283, 83, 83, - /* 1060 */ 315, 83, 43, 318, 319, 320, 321, 322, 323, 35, - /* 1070 */ 325, 311, 83, 328, 82, 247, 256, 332, 333, 334, - /* 1080 */ 43, 275, 43, 43, 214, 83, 185, 83, 343, 283, - /* 1090 */ 83, 234, 83, 254, 288, 83, 290, 43, 287, 65, - /* 1100 */ 317, 43, 83, 275, 342, 359, 359, 359, 345, 215, - /* 1110 */ 313, 283, 20, 255, 47, 312, 288, 163, 290, 35, - /* 1120 */ 83, 315, 83, 83, 318, 319, 320, 321, 322, 323, - /* 1130 */ 261, 325, 159, 255, 328, 305, 247, 83, 332, 333, - /* 1140 */ 255, 83, 42, 315, 295, 293, 318, 319, 320, 321, - /* 1150 */ 322, 323, 293, 325, 255, 20, 328, 143, 249, 249, - /* 1160 */ 332, 333, 334, 20, 275, 309, 259, 290, 20, 302, - /* 1170 */ 259, 343, 283, 20, 163, 304, 259, 288, 302, 290, - /* 1180 */ 259, 20, 296, 259, 259, 255, 259, 249, 275, 247, - /* 1190 */ 275, 275, 303, 288, 275, 275, 249, 275, 275, 255, - /* 1200 */ 288, 275, 309, 247, 315, 169, 275, 318, 319, 320, - /* 1210 */ 321, 322, 323, 255, 325, 275, 275, 275, 257, 290, - /* 1220 */ 257, 257, 308, 255, 288, 283, 20, 221, 227, 152, - /* 1230 */ 288, 275, 290, 344, 302, 220, 299, 350, 288, 283, - /* 1240 */ 350, 288, 350, 288, 288, 303, 290, 358, 299, 353, - /* 1250 */ 317, 362, 352, 229, 348, 247, 228, 315, 216, 313, - /* 1260 */ 318, 319, 320, 321, 322, 323, 283, 325, 212, 20, - /* 1270 */ 42, 315, 231, 247, 318, 319, 320, 321, 322, 323, - /* 1280 */ 233, 325, 347, 275, 328, 316, 344, 236, 332, 333, - /* 1290 */ 82, 283, 335, 299, 349, 361, 288, 299, 290, 360, - /* 1300 */ 358, 275, 331, 145, 362, 288, 288, 297, 288, 283, - /* 1310 */ 283, 82, 296, 283, 288, 271, 290, 366, 257, 257, - /* 1320 */ 361, 361, 360, 315, 279, 247, 318, 319, 320, 321, - /* 1330 */ 322, 323, 324, 325, 326, 327, 288, 360, 265, 257, - /* 1340 */ 255, 315, 247, 36, 318, 319, 320, 321, 322, 323, - /* 1350 */ 249, 325, 250, 275, 258, 306, 310, 269, 269, 269, - /* 1360 */ 245, 283, 0, 0, 42, 0, 288, 73, 290, 0, - /* 1370 */ 275, 35, 179, 35, 35, 35, 179, 0, 283, 35, - /* 1380 */ 35, 179, 0, 288, 179, 290, 0, 35, 0, 363, - /* 1390 */ 364, 247, 22, 315, 0, 35, 318, 319, 320, 321, - /* 1400 */ 322, 323, 0, 325, 166, 82, 328, 165, 163, 161, - /* 1410 */ 315, 333, 0, 318, 319, 320, 321, 322, 323, 275, - /* 1420 */ 325, 0, 157, 156, 0, 0, 46, 283, 0, 142, - /* 1430 */ 0, 0, 288, 0, 290, 0, 0, 137, 35, 0, - /* 1440 */ 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 1450 */ 0, 247, 357, 0, 0, 0, 0, 42, 0, 315, - /* 1460 */ 247, 42, 318, 319, 320, 321, 322, 323, 39, 325, - /* 1470 */ 0, 0, 0, 0, 0, 0, 8, 9, 0, 275, - /* 1480 */ 12, 13, 14, 15, 16, 22, 0, 283, 275, 0, - /* 1490 */ 0, 0, 288, 14, 290, 14, 283, 46, 0, 40, - /* 1500 */ 43, 288, 0, 290, 39, 301, 46, 0, 364, 247, - /* 1510 */ 152, 0, 0, 0, 0, 39, 0, 0, 35, 315, - /* 1520 */ 0, 247, 318, 319, 320, 321, 322, 323, 315, 325, - /* 1530 */ 35, 318, 319, 320, 321, 322, 323, 275, 325, 47, - /* 1540 */ 327, 47, 60, 39, 39, 283, 0, 47, 39, 275, - /* 1550 */ 288, 0, 290, 35, 35, 47, 0, 283, 0, 0, - /* 1560 */ 39, 0, 288, 301, 290, 35, 22, 0, 91, 89, - /* 1570 */ 35, 35, 19, 35, 247, 301, 35, 315, 35, 0, - /* 1580 */ 318, 319, 320, 321, 322, 323, 33, 325, 43, 315, - /* 1590 */ 247, 43, 318, 319, 320, 321, 322, 323, 35, 325, - /* 1600 */ 47, 35, 275, 22, 0, 52, 53, 54, 55, 56, - /* 1610 */ 283, 22, 0, 49, 22, 288, 0, 290, 275, 35, - /* 1620 */ 35, 153, 0, 35, 0, 22, 283, 20, 0, 35, - /* 1630 */ 0, 288, 148, 290, 81, 22, 167, 84, 150, 247, - /* 1640 */ 0, 148, 315, 0, 145, 318, 319, 320, 321, 322, - /* 1650 */ 323, 148, 325, 0, 0, 0, 82, 43, 315, 83, - /* 1660 */ 43, 318, 319, 320, 321, 322, 323, 275, 325, 83, - /* 1670 */ 117, 46, 82, 82, 43, 283, 83, 82, 82, 217, - /* 1680 */ 288, 83, 290, 46, 43, 43, 2, 82, 43, 83, - /* 1690 */ 46, 83, 46, 83, 43, 35, 35, 35, 211, 247, - /* 1700 */ 147, 83, 217, 235, 35, 35, 35, 315, 247, 185, - /* 1710 */ 318, 319, 320, 321, 322, 323, 43, 325, 217, 83, - /* 1720 */ 46, 168, 83, 170, 46, 22, 187, 275, 146, 82, - /* 1730 */ 82, 82, 0, 39, 82, 283, 275, 46, 46, 83, - /* 1740 */ 288, 83, 290, 144, 283, 82, 22, 82, 82, 288, - /* 1750 */ 82, 290, 93, 35, 82, 35, 35, 247, 83, 92, - /* 1760 */ 83, 82, 82, 82, 35, 83, 83, 315, 82, 247, - /* 1770 */ 318, 319, 320, 321, 322, 323, 315, 325, 82, 318, - /* 1780 */ 319, 320, 321, 322, 323, 275, 325, 83, 35, 82, - /* 1790 */ 35, 83, 82, 283, 106, 106, 106, 275, 288, 106, - /* 1800 */ 290, 22, 35, 94, 82, 283, 43, 82, 82, 22, - /* 1810 */ 288, 60, 290, 59, 65, 35, 80, 43, 35, 35, - /* 1820 */ 247, 35, 22, 35, 35, 315, 35, 35, 318, 319, - /* 1830 */ 320, 321, 322, 323, 247, 325, 65, 315, 35, 35, - /* 1840 */ 318, 319, 320, 321, 322, 323, 35, 325, 275, 35, - /* 1850 */ 35, 35, 35, 0, 35, 47, 283, 39, 0, 35, - /* 1860 */ 47, 288, 275, 290, 39, 0, 35, 47, 39, 0, - /* 1870 */ 283, 35, 39, 47, 0, 288, 35, 290, 35, 0, - /* 1880 */ 20, 22, 21, 367, 22, 247, 22, 21, 315, 367, - /* 1890 */ 367, 318, 319, 320, 321, 322, 323, 247, 325, 367, - /* 1900 */ 367, 367, 315, 367, 367, 318, 319, 320, 321, 322, - /* 1910 */ 323, 247, 325, 275, 367, 367, 367, 367, 367, 367, - /* 1920 */ 367, 283, 367, 367, 367, 275, 288, 367, 290, 367, - /* 1930 */ 367, 367, 367, 283, 367, 367, 367, 367, 288, 275, - /* 1940 */ 290, 367, 367, 367, 367, 367, 367, 283, 367, 367, - /* 1950 */ 367, 367, 288, 315, 290, 367, 318, 319, 320, 321, - /* 1960 */ 322, 323, 247, 325, 367, 315, 367, 367, 318, 319, - /* 1970 */ 320, 321, 322, 323, 367, 325, 367, 367, 367, 315, - /* 1980 */ 367, 367, 318, 319, 320, 321, 322, 323, 247, 325, - /* 1990 */ 275, 367, 367, 367, 367, 367, 367, 367, 283, 367, - /* 2000 */ 367, 367, 367, 288, 367, 290, 367, 367, 367, 367, - /* 2010 */ 367, 367, 367, 367, 367, 367, 275, 367, 367, 367, - /* 2020 */ 367, 367, 367, 367, 283, 367, 367, 367, 367, 288, - /* 2030 */ 315, 290, 367, 318, 319, 320, 321, 322, 323, 367, - /* 2040 */ 325, 247, 367, 367, 367, 367, 367, 367, 367, 367, - /* 2050 */ 367, 367, 367, 247, 367, 367, 315, 367, 367, 318, - /* 2060 */ 319, 320, 321, 322, 323, 367, 325, 367, 367, 275, - /* 2070 */ 367, 367, 367, 367, 367, 367, 367, 283, 367, 367, - /* 2080 */ 367, 275, 288, 367, 290, 367, 367, 367, 367, 283, - /* 2090 */ 367, 367, 367, 367, 288, 367, 290, 367, 367, 367, - /* 2100 */ 367, 367, 367, 367, 247, 367, 367, 367, 367, 315, - /* 2110 */ 367, 367, 318, 319, 320, 321, 322, 323, 247, 325, - /* 2120 */ 367, 315, 367, 367, 318, 319, 320, 321, 322, 323, - /* 2130 */ 367, 325, 275, 367, 367, 367, 367, 367, 367, 367, - /* 2140 */ 283, 367, 367, 367, 367, 288, 275, 290, 367, 367, - /* 2150 */ 367, 367, 367, 367, 283, 367, 367, 367, 367, 288, - /* 2160 */ 367, 290, 367, 367, 367, 367, 367, 367, 367, 247, - /* 2170 */ 367, 367, 315, 367, 367, 318, 319, 320, 321, 322, - /* 2180 */ 323, 247, 325, 367, 367, 367, 315, 367, 367, 318, - /* 2190 */ 319, 320, 321, 322, 323, 367, 325, 275, 367, 367, - /* 2200 */ 367, 367, 367, 367, 367, 283, 367, 367, 367, 275, - /* 2210 */ 288, 367, 290, 367, 367, 367, 367, 283, 367, 367, - /* 2220 */ 367, 367, 288, 367, 290, 367, 367, 367, 367, 367, - /* 2230 */ 367, 367, 367, 367, 367, 367, 367, 315, 367, 367, - /* 2240 */ 318, 319, 320, 321, 322, 323, 367, 325, 367, 315, - /* 2250 */ 367, 367, 318, 319, 320, 321, 322, 323, 367, 325, + /* 200 */ 200, 201, 202, 191, 168, 56, 325, 18, 319, 20, + /* 210 */ 12, 13, 14, 15, 16, 215, 27, 0, 65, 30, + /* 220 */ 339, 340, 341, 342, 257, 344, 163, 290, 165, 163, + /* 230 */ 81, 165, 343, 84, 187, 268, 47, 191, 49, 203, + /* 240 */ 51, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 250 */ 187, 188, 285, 187, 188, 215, 190, 191, 192, 193, + /* 260 */ 194, 195, 196, 197, 198, 199, 200, 201, 202, 215, + /* 270 */ 81, 224, 225, 226, 227, 228, 8, 9, 12, 13, + /* 280 */ 12, 13, 14, 15, 16, 20, 20, 265, 22, 267, + /* 290 */ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + /* 300 */ 105, 35, 107, 108, 109, 110, 111, 112, 1, 2, + /* 310 */ 121, 43, 20, 124, 125, 126, 127, 128, 129, 130, + /* 320 */ 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, + /* 330 */ 141, 65, 143, 144, 12, 13, 249, 20, 37, 332, + /* 340 */ 333, 20, 20, 22, 22, 8, 9, 56, 82, 12, + /* 350 */ 13, 14, 15, 16, 61, 62, 35, 35, 279, 66, + /* 360 */ 4, 20, 69, 70, 277, 257, 73, 74, 75, 290, + /* 370 */ 104, 50, 285, 82, 82, 84, 268, 290, 93, 292, + /* 380 */ 234, 59, 311, 275, 118, 119, 85, 65, 87, 88, + /* 390 */ 83, 90, 76, 285, 307, 94, 317, 318, 148, 4, + /* 400 */ 44, 45, 347, 249, 82, 318, 250, 328, 321, 322, + /* 410 */ 323, 324, 325, 326, 19, 328, 361, 116, 331, 257, + /* 420 */ 365, 257, 335, 336, 259, 292, 104, 0, 33, 163, + /* 430 */ 268, 165, 268, 300, 347, 65, 303, 272, 122, 123, + /* 440 */ 118, 119, 47, 249, 290, 280, 51, 285, 361, 285, + /* 450 */ 307, 56, 365, 187, 188, 278, 190, 191, 192, 193, + /* 460 */ 194, 195, 196, 197, 198, 199, 200, 201, 202, 269, + /* 470 */ 220, 221, 12, 13, 14, 254, 81, 277, 257, 84, + /* 480 */ 20, 215, 22, 257, 290, 163, 286, 165, 61, 62, + /* 490 */ 347, 150, 155, 66, 268, 35, 69, 70, 257, 266, + /* 500 */ 73, 74, 75, 257, 361, 3, 215, 215, 365, 187, + /* 510 */ 188, 285, 190, 191, 192, 193, 194, 195, 196, 197, + /* 520 */ 198, 199, 200, 201, 202, 65, 285, 12, 13, 291, + /* 530 */ 292, 285, 257, 158, 20, 20, 249, 22, 44, 45, + /* 540 */ 8, 9, 82, 268, 12, 13, 14, 15, 16, 114, + /* 550 */ 35, 8, 9, 178, 179, 12, 13, 14, 15, 16, + /* 560 */ 285, 257, 254, 249, 104, 257, 325, 269, 20, 249, + /* 570 */ 22, 325, 268, 302, 237, 277, 305, 290, 118, 119, + /* 580 */ 65, 340, 341, 342, 286, 344, 340, 341, 342, 285, + /* 590 */ 344, 277, 94, 12, 13, 368, 257, 82, 50, 285, + /* 600 */ 249, 20, 249, 22, 290, 94, 292, 268, 173, 174, + /* 610 */ 290, 113, 114, 115, 116, 117, 35, 257, 304, 104, + /* 620 */ 263, 264, 0, 163, 285, 165, 83, 116, 268, 14, + /* 630 */ 15, 16, 318, 118, 119, 321, 322, 323, 324, 325, + /* 640 */ 326, 290, 328, 290, 22, 285, 65, 187, 188, 35, + /* 650 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + /* 660 */ 200, 201, 202, 82, 150, 257, 257, 8, 9, 20, + /* 670 */ 257, 12, 13, 14, 15, 16, 268, 268, 163, 65, + /* 680 */ 165, 268, 8, 9, 285, 104, 12, 13, 14, 15, + /* 690 */ 16, 263, 264, 285, 285, 296, 213, 214, 285, 118, + /* 700 */ 119, 0, 187, 188, 278, 190, 191, 192, 193, 194, + /* 710 */ 195, 196, 197, 198, 199, 200, 201, 202, 59, 82, + /* 720 */ 257, 8, 9, 19, 269, 12, 13, 14, 15, 16, + /* 730 */ 278, 268, 277, 59, 232, 278, 277, 33, 257, 0, + /* 740 */ 21, 286, 83, 284, 163, 249, 165, 277, 285, 268, + /* 750 */ 91, 47, 293, 34, 284, 36, 52, 53, 54, 55, + /* 760 */ 56, 113, 249, 293, 0, 91, 285, 249, 187, 188, + /* 770 */ 249, 190, 191, 192, 193, 194, 195, 196, 197, 198, + /* 780 */ 199, 200, 201, 202, 277, 81, 290, 18, 84, 292, + /* 790 */ 277, 249, 23, 286, 4, 94, 83, 58, 285, 162, + /* 800 */ 303, 164, 257, 290, 145, 292, 37, 38, 290, 319, + /* 810 */ 41, 290, 278, 268, 113, 114, 115, 116, 117, 145, + /* 820 */ 249, 117, 58, 175, 176, 302, 57, 168, 305, 277, + /* 830 */ 285, 318, 290, 343, 321, 322, 323, 324, 325, 326, + /* 840 */ 191, 328, 168, 0, 331, 293, 249, 249, 335, 336, + /* 850 */ 337, 82, 215, 149, 259, 0, 39, 278, 249, 346, + /* 860 */ 249, 290, 203, 204, 205, 206, 207, 208, 209, 210, + /* 870 */ 211, 212, 113, 114, 170, 280, 172, 203, 204, 205, + /* 880 */ 206, 207, 208, 209, 210, 211, 212, 290, 290, 120, + /* 890 */ 8, 9, 359, 249, 12, 13, 14, 15, 16, 290, + /* 900 */ 249, 290, 47, 249, 61, 62, 63, 64, 319, 66, + /* 910 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + /* 920 */ 77, 78, 79, 43, 155, 156, 157, 249, 277, 160, + /* 930 */ 56, 59, 343, 174, 290, 166, 285, 12, 13, 287, + /* 940 */ 43, 290, 290, 292, 290, 287, 177, 22, 290, 180, + /* 950 */ 35, 182, 183, 184, 185, 186, 270, 258, 84, 273, + /* 960 */ 35, 249, 86, 83, 86, 89, 354, 89, 290, 318, + /* 970 */ 0, 0, 321, 322, 323, 324, 325, 326, 86, 328, + /* 980 */ 86, 89, 331, 89, 215, 0, 335, 336, 337, 277, + /* 990 */ 65, 150, 151, 22, 1, 2, 35, 285, 314, 43, + /* 1000 */ 349, 277, 290, 82, 292, 2, 216, 22, 357, 358, + /* 1010 */ 46, 8, 9, 92, 2, 12, 13, 14, 15, 16, + /* 1020 */ 8, 9, 249, 258, 12, 13, 14, 15, 16, 104, + /* 1030 */ 318, 214, 150, 321, 322, 323, 324, 325, 326, 83, + /* 1040 */ 328, 118, 119, 331, 256, 289, 82, 335, 336, 337, + /* 1050 */ 277, 320, 43, 43, 345, 362, 362, 362, 285, 187, + /* 1060 */ 43, 217, 43, 290, 94, 292, 43, 316, 348, 20, + /* 1070 */ 358, 43, 257, 47, 43, 43, 43, 249, 315, 35, + /* 1080 */ 165, 43, 43, 113, 114, 115, 116, 117, 163, 0, + /* 1090 */ 165, 318, 83, 83, 321, 322, 323, 324, 325, 326, + /* 1100 */ 83, 328, 83, 43, 331, 277, 83, 43, 335, 336, + /* 1110 */ 337, 83, 187, 285, 83, 83, 83, 263, 290, 346, + /* 1120 */ 292, 83, 83, 198, 199, 200, 165, 161, 43, 309, + /* 1130 */ 249, 35, 257, 236, 257, 42, 297, 48, 20, 249, + /* 1140 */ 145, 295, 295, 83, 257, 20, 318, 83, 313, 321, + /* 1150 */ 322, 323, 324, 325, 326, 251, 328, 249, 277, 331, + /* 1160 */ 251, 65, 261, 335, 336, 337, 285, 277, 83, 20, + /* 1170 */ 306, 290, 261, 292, 346, 285, 292, 20, 308, 261, + /* 1180 */ 290, 261, 292, 20, 298, 277, 251, 261, 307, 306, + /* 1190 */ 261, 257, 261, 285, 277, 257, 277, 307, 290, 318, + /* 1200 */ 292, 277, 321, 322, 323, 324, 325, 326, 318, 328, + /* 1210 */ 277, 321, 322, 323, 324, 325, 326, 277, 328, 277, + /* 1220 */ 277, 277, 249, 277, 277, 277, 318, 251, 347, 321, + /* 1230 */ 322, 323, 324, 325, 326, 290, 328, 347, 249, 331, + /* 1240 */ 313, 259, 361, 335, 336, 171, 365, 249, 312, 292, + /* 1250 */ 277, 361, 20, 259, 257, 365, 257, 306, 285, 259, + /* 1260 */ 223, 320, 290, 290, 222, 292, 277, 353, 301, 290, + /* 1270 */ 301, 290, 229, 290, 285, 277, 154, 231, 356, 290, + /* 1280 */ 352, 292, 230, 285, 218, 353, 214, 285, 290, 350, + /* 1290 */ 292, 318, 355, 316, 321, 322, 323, 324, 325, 326, + /* 1300 */ 249, 328, 353, 351, 331, 20, 319, 318, 335, 336, + /* 1310 */ 321, 322, 323, 324, 325, 326, 318, 328, 42, 321, + /* 1320 */ 322, 323, 324, 325, 326, 235, 328, 364, 277, 331, + /* 1330 */ 33, 233, 238, 82, 336, 301, 285, 363, 363, 338, + /* 1340 */ 334, 290, 301, 292, 47, 290, 290, 369, 364, 52, + /* 1350 */ 53, 54, 55, 56, 249, 366, 367, 290, 290, 290, + /* 1360 */ 364, 290, 147, 249, 299, 285, 259, 363, 298, 318, + /* 1370 */ 273, 259, 321, 322, 323, 324, 325, 326, 81, 328, + /* 1380 */ 285, 84, 277, 82, 281, 257, 267, 36, 259, 290, + /* 1390 */ 285, 277, 252, 251, 310, 290, 305, 292, 271, 285, + /* 1400 */ 247, 271, 271, 260, 290, 0, 292, 0, 42, 0, + /* 1410 */ 73, 360, 35, 249, 0, 181, 35, 35, 304, 35, + /* 1420 */ 181, 0, 35, 318, 249, 35, 321, 322, 323, 324, + /* 1430 */ 325, 326, 318, 328, 181, 321, 322, 323, 324, 325, + /* 1440 */ 326, 277, 328, 146, 147, 0, 149, 181, 0, 285, + /* 1450 */ 153, 35, 277, 0, 290, 22, 292, 0, 35, 0, + /* 1460 */ 285, 82, 168, 167, 165, 290, 163, 292, 0, 172, + /* 1470 */ 0, 159, 367, 158, 0, 0, 249, 46, 0, 304, + /* 1480 */ 0, 0, 318, 142, 0, 321, 322, 323, 324, 325, + /* 1490 */ 326, 0, 328, 318, 330, 0, 321, 322, 323, 324, + /* 1500 */ 325, 326, 0, 328, 277, 0, 137, 35, 0, 137, + /* 1510 */ 0, 0, 285, 0, 0, 0, 0, 290, 0, 292, + /* 1520 */ 0, 0, 0, 0, 0, 0, 0, 42, 0, 249, + /* 1530 */ 0, 304, 0, 0, 0, 0, 0, 0, 249, 22, + /* 1540 */ 0, 0, 0, 0, 43, 318, 42, 249, 321, 322, + /* 1550 */ 323, 324, 325, 326, 0, 328, 0, 277, 39, 14, + /* 1560 */ 14, 0, 0, 0, 154, 285, 277, 0, 0, 40, + /* 1570 */ 290, 0, 292, 46, 285, 277, 0, 46, 39, 290, + /* 1580 */ 0, 292, 0, 285, 0, 35, 39, 39, 290, 0, + /* 1590 */ 292, 47, 35, 0, 39, 35, 0, 0, 318, 249, + /* 1600 */ 47, 321, 322, 323, 324, 325, 326, 318, 328, 39, + /* 1610 */ 321, 322, 323, 324, 325, 326, 318, 328, 35, 321, + /* 1620 */ 322, 323, 324, 325, 326, 60, 328, 277, 47, 91, + /* 1630 */ 39, 22, 47, 35, 0, 285, 35, 35, 35, 35, + /* 1640 */ 290, 249, 292, 43, 0, 35, 35, 35, 89, 43, + /* 1650 */ 22, 0, 22, 0, 49, 22, 35, 0, 35, 0, + /* 1660 */ 35, 249, 0, 22, 0, 20, 35, 0, 318, 277, + /* 1670 */ 22, 321, 322, 323, 324, 325, 326, 285, 328, 0, + /* 1680 */ 0, 169, 290, 249, 292, 0, 0, 0, 219, 277, + /* 1690 */ 43, 35, 43, 43, 2, 82, 82, 285, 83, 147, + /* 1700 */ 82, 150, 290, 83, 292, 83, 82, 46, 82, 43, + /* 1710 */ 318, 277, 83, 321, 322, 323, 324, 325, 326, 285, + /* 1720 */ 328, 152, 150, 150, 290, 82, 292, 46, 219, 83, + /* 1730 */ 318, 43, 43, 321, 322, 323, 324, 325, 326, 249, + /* 1740 */ 328, 83, 46, 46, 43, 35, 83, 35, 249, 35, + /* 1750 */ 35, 83, 318, 35, 43, 321, 322, 323, 324, 325, + /* 1760 */ 326, 187, 328, 46, 22, 83, 82, 277, 46, 0, + /* 1770 */ 0, 39, 46, 83, 83, 285, 277, 213, 83, 189, + /* 1780 */ 290, 82, 292, 148, 285, 219, 82, 82, 82, 290, + /* 1790 */ 82, 292, 92, 46, 22, 82, 93, 35, 249, 83, + /* 1800 */ 146, 82, 82, 82, 106, 82, 35, 249, 318, 35, + /* 1810 */ 83, 321, 322, 323, 324, 325, 326, 318, 328, 82, + /* 1820 */ 321, 322, 323, 324, 325, 326, 277, 328, 83, 83, + /* 1830 */ 82, 35, 82, 35, 285, 277, 35, 83, 82, 290, + /* 1840 */ 83, 292, 82, 285, 106, 106, 22, 106, 290, 94, + /* 1850 */ 292, 35, 43, 22, 60, 82, 59, 249, 82, 82, + /* 1860 */ 35, 80, 43, 35, 65, 35, 249, 318, 35, 35, + /* 1870 */ 321, 322, 323, 324, 325, 326, 318, 328, 35, 321, + /* 1880 */ 322, 323, 324, 325, 326, 277, 328, 22, 35, 35, + /* 1890 */ 35, 65, 35, 285, 277, 35, 35, 35, 290, 35, + /* 1900 */ 292, 35, 285, 0, 35, 47, 39, 290, 0, 292, + /* 1910 */ 35, 39, 0, 35, 0, 47, 39, 47, 249, 35, + /* 1920 */ 47, 39, 0, 35, 35, 0, 318, 249, 22, 321, + /* 1930 */ 322, 323, 324, 325, 326, 318, 328, 21, 321, 322, + /* 1940 */ 323, 324, 325, 326, 21, 328, 277, 370, 22, 22, + /* 1950 */ 20, 370, 370, 370, 285, 277, 370, 370, 370, 290, + /* 1960 */ 370, 292, 370, 285, 370, 370, 370, 370, 290, 370, + /* 1970 */ 292, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 1980 */ 249, 370, 370, 370, 370, 370, 370, 318, 370, 249, + /* 1990 */ 321, 322, 323, 324, 325, 326, 318, 328, 249, 321, + /* 2000 */ 322, 323, 324, 325, 326, 370, 328, 249, 277, 370, + /* 2010 */ 257, 370, 370, 370, 370, 370, 285, 277, 370, 370, + /* 2020 */ 370, 290, 370, 292, 370, 285, 277, 370, 370, 370, + /* 2030 */ 290, 370, 292, 370, 285, 277, 370, 370, 285, 290, + /* 2040 */ 370, 292, 370, 285, 370, 370, 370, 370, 290, 318, + /* 2050 */ 292, 370, 321, 322, 323, 324, 325, 326, 318, 328, + /* 2060 */ 307, 321, 322, 323, 324, 325, 326, 318, 328, 370, + /* 2070 */ 321, 322, 323, 324, 325, 326, 318, 328, 325, 321, + /* 2080 */ 322, 323, 324, 325, 326, 249, 328, 370, 370, 370, + /* 2090 */ 370, 370, 370, 340, 341, 342, 370, 344, 370, 257, + /* 2100 */ 347, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 2110 */ 370, 370, 370, 277, 361, 370, 370, 370, 365, 370, + /* 2120 */ 370, 285, 370, 370, 370, 370, 290, 285, 292, 370, + /* 2130 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 2140 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 307, + /* 2150 */ 370, 370, 370, 370, 318, 370, 370, 321, 322, 323, + /* 2160 */ 324, 325, 326, 370, 328, 370, 370, 325, 370, 370, + /* 2170 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 2180 */ 370, 370, 340, 341, 342, 370, 344, 370, 370, 347, + /* 2190 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 2200 */ 370, 370, 370, 361, 370, 370, 370, 365, }; -#define YY_SHIFT_COUNT (644) +#define YY_SHIFT_COUNT (652) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1879) +#define YY_SHIFT_MAX (1930) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 707, 0, 0, 119, 238, 238, 238, 238, 259, 259, - /* 10 */ 238, 238, 378, 497, 518, 497, 497, 497, 497, 497, - /* 20 */ 497, 497, 497, 497, 497, 497, 497, 497, 497, 497, - /* 30 */ 497, 497, 497, 497, 497, 497, 497, 497, 497, 497, - /* 40 */ 497, 497, 421, 421, 94, 94, 94, 845, 845, 845, - /* 50 */ 845, 422, 573, 35, 16, 16, 40, 40, 4, 275, - /* 60 */ 35, 35, 16, 16, 16, 16, 16, 16, 16, 16, - /* 70 */ 47, 16, 16, 16, 131, 145, 160, 16, 16, 160, - /* 80 */ 16, 160, 160, 160, 16, 198, 704, 83, 461, 461, - /* 90 */ 306, 98, 114, 114, 114, 114, 114, 114, 114, 114, - /* 100 */ 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, - /* 110 */ 114, 167, 275, 369, 369, 408, 691, 525, 525, 525, - /* 120 */ 580, 691, 183, 145, 160, 160, 171, 171, 266, 211, - /* 130 */ 695, 695, 695, 695, 695, 695, 695, 1553, 565, 749, - /* 140 */ 1468, 42, 352, 365, 10, 221, 282, 458, 802, 647, - /* 150 */ 829, 672, 614, 672, 734, 734, 734, 870, 738, 894, - /* 160 */ 1092, 1067, 1084, 973, 1092, 1092, 1100, 1014, 1014, 1092, - /* 170 */ 1135, 1135, 1143, 47, 145, 47, 1148, 1153, 47, 1148, - /* 180 */ 47, 1161, 47, 47, 1092, 47, 1135, 160, 160, 160, - /* 190 */ 160, 160, 160, 160, 160, 160, 160, 160, 1092, 1135, - /* 200 */ 171, 171, 1143, 198, 1036, 145, 198, 1092, 1092, 1148, - /* 210 */ 198, 1206, 171, 1006, 1015, 171, 1006, 1015, 171, 171, - /* 220 */ 160, 1001, 1077, 1006, 1024, 1028, 1042, 894, 1056, 183, - /* 230 */ 1249, 1228, 1047, 1041, 1051, 1047, 1041, 1047, 1041, 1208, - /* 240 */ 1015, 171, 171, 1015, 171, 1158, 183, 1161, 198, 266, - /* 250 */ 198, 183, 1229, 171, 211, 1092, 198, 1307, 1135, 2260, - /* 260 */ 2260, 2260, 2260, 2260, 2260, 2260, 705, 178, 617, 943, - /* 270 */ 476, 231, 542, 39, 48, 338, 594, 486, 486, 486, - /* 280 */ 486, 486, 486, 486, 486, 801, 808, 348, 3, 3, - /* 290 */ 337, 570, 509, 334, 526, 180, 532, 533, 533, 533, - /* 300 */ 533, 90, 948, 819, 850, 872, 898, 879, 966, 995, - /* 310 */ 875, 786, 975, 976, 981, 918, 722, 857, 978, 901, - /* 320 */ 989, 992, 1002, 1004, 1007, 1009, 1012, 954, 1011, 1019, - /* 330 */ 1037, 1039, 1040, 1054, 1058, 952, 1034, 624, 1362, 1363, - /* 340 */ 1322, 1365, 1294, 1369, 1336, 1193, 1338, 1339, 1340, 1197, - /* 350 */ 1377, 1344, 1345, 1202, 1382, 1205, 1386, 1352, 1388, 1370, - /* 360 */ 1394, 1360, 1402, 1323, 1238, 1242, 1245, 1248, 1412, 1421, - /* 370 */ 1265, 1267, 1424, 1425, 1380, 1428, 1287, 1430, 1431, 1433, - /* 380 */ 1435, 1436, 1300, 1403, 1439, 1303, 1441, 1442, 1443, 1444, - /* 390 */ 1445, 1446, 1447, 1448, 1449, 1450, 1453, 1454, 1455, 1456, - /* 400 */ 1415, 1458, 1470, 1471, 1472, 1473, 1474, 1463, 1475, 1478, - /* 410 */ 1486, 1489, 1490, 1491, 1419, 1429, 1457, 1479, 1451, 1481, - /* 420 */ 1460, 1498, 1459, 1465, 1502, 1507, 1520, 1476, 1358, 1511, - /* 430 */ 1512, 1513, 1482, 1514, 1516, 1483, 1492, 1504, 1517, 1495, - /* 440 */ 1494, 1505, 1546, 1518, 1500, 1509, 1551, 1519, 1508, 1521, - /* 450 */ 1556, 1558, 1559, 1561, 1477, 1480, 1530, 1544, 1567, 1535, - /* 460 */ 1536, 1538, 1541, 1545, 1548, 1543, 1563, 1566, 1579, 1581, - /* 470 */ 1604, 1589, 1564, 1612, 1592, 1584, 1616, 1585, 1622, 1588, - /* 480 */ 1624, 1603, 1607, 1628, 1484, 1594, 1630, 1469, 1613, 1493, - /* 490 */ 1499, 1640, 1643, 1503, 1488, 1653, 1654, 1655, 1614, 1617, - /* 500 */ 1462, 1574, 1576, 1590, 1586, 1631, 1593, 1591, 1595, 1596, - /* 510 */ 1598, 1641, 1625, 1637, 1605, 1642, 1485, 1606, 1608, 1644, - /* 520 */ 1487, 1645, 1646, 1610, 1651, 1501, 1618, 1660, 1661, 1662, - /* 530 */ 1669, 1670, 1671, 1618, 1684, 1524, 1673, 1636, 1647, 1639, - /* 540 */ 1674, 1648, 1649, 1678, 1703, 1539, 1652, 1656, 1658, 1663, - /* 550 */ 1665, 1582, 1666, 1732, 1694, 1599, 1668, 1667, 1691, 1692, - /* 560 */ 1672, 1675, 1679, 1724, 1680, 1659, 1677, 1718, 1720, 1681, - /* 570 */ 1682, 1721, 1686, 1683, 1729, 1696, 1704, 1753, 1707, 1708, - /* 580 */ 1755, 1710, 1688, 1689, 1690, 1693, 1779, 1709, 1722, 1725, - /* 590 */ 1767, 1726, 1763, 1763, 1787, 1751, 1754, 1780, 1749, 1736, - /* 600 */ 1774, 1783, 1784, 1786, 1788, 1789, 1800, 1791, 1792, 1771, - /* 610 */ 1545, 1803, 1548, 1804, 1811, 1814, 1815, 1816, 1817, 1853, - /* 620 */ 1819, 1808, 1818, 1858, 1824, 1813, 1825, 1865, 1831, 1820, - /* 630 */ 1829, 1869, 1836, 1826, 1833, 1874, 1841, 1843, 1879, 1859, - /* 640 */ 1861, 1862, 1864, 1866, 1860, + /* 0 */ 769, 0, 0, 66, 322, 322, 322, 322, 266, 266, + /* 10 */ 322, 322, 460, 515, 581, 515, 515, 515, 515, 515, + /* 20 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, + /* 30 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, + /* 40 */ 515, 515, 292, 292, 18, 18, 18, 925, 925, 925, + /* 50 */ 925, 637, 291, 40, 51, 51, 356, 356, 54, 64, + /* 60 */ 40, 40, 51, 51, 51, 51, 51, 51, 51, 51, + /* 70 */ 33, 51, 51, 51, 85, 104, 265, 51, 51, 265, + /* 80 */ 51, 265, 265, 265, 51, 111, 189, 659, 674, 674, + /* 90 */ 128, 293, 63, 63, 63, 63, 63, 63, 63, 63, + /* 100 */ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + /* 110 */ 63, 301, 64, 67, 67, 739, 614, 341, 341, 341, + /* 120 */ 764, 614, 317, 104, 1, 1, 265, 265, 153, 153, + /* 130 */ 285, 370, 195, 195, 195, 195, 195, 195, 195, 704, + /* 140 */ 21, 427, 337, 47, 321, 435, 250, 12, 46, 548, + /* 150 */ 494, 511, 514, 483, 817, 483, 502, 502, 502, 790, + /* 160 */ 649, 844, 1049, 1026, 1044, 966, 1049, 1049, 1093, 995, + /* 170 */ 995, 1049, 1118, 1118, 1125, 33, 104, 33, 1149, 1157, + /* 180 */ 33, 1149, 33, 1163, 33, 33, 1049, 33, 1118, 265, + /* 190 */ 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, + /* 200 */ 1049, 1118, 153, 1125, 111, 1074, 104, 111, 1049, 1049, + /* 210 */ 1149, 111, 1232, 153, 1037, 1042, 153, 1037, 1042, 153, + /* 220 */ 153, 265, 1043, 1122, 1037, 1046, 1052, 1066, 844, 1072, + /* 230 */ 317, 1285, 1276, 1090, 1098, 1094, 1090, 1098, 1090, 1098, + /* 240 */ 1251, 1042, 153, 153, 153, 153, 153, 1042, 153, 1215, + /* 250 */ 317, 1163, 111, 285, 111, 317, 1301, 153, 370, 1049, + /* 260 */ 111, 1351, 1118, 2208, 2208, 2208, 2208, 2208, 2208, 2208, + /* 270 */ 843, 1297, 217, 395, 81, 268, 543, 1003, 1012, 882, + /* 280 */ 713, 532, 532, 532, 532, 532, 532, 532, 532, 701, + /* 290 */ 970, 498, 198, 198, 375, 149, 316, 719, 307, 36, + /* 300 */ 615, 615, 615, 615, 648, 759, 855, 880, 876, 878, + /* 310 */ 892, 894, 622, 971, 985, 874, 841, 956, 1009, 993, + /* 320 */ 923, 146, 897, 1010, 872, 1017, 964, 1019, 1023, 1028, + /* 330 */ 1031, 1032, 915, 961, 1033, 1038, 1039, 1060, 1064, 1085, + /* 340 */ 921, 1096, 1089, 1405, 1407, 1366, 1409, 1337, 1414, 1377, + /* 350 */ 1234, 1381, 1382, 1384, 1239, 1421, 1387, 1390, 1253, 1445, + /* 360 */ 1266, 1448, 1416, 1453, 1433, 1457, 1423, 1459, 1379, 1294, + /* 370 */ 1296, 1299, 1303, 1468, 1470, 1312, 1315, 1474, 1475, 1431, + /* 380 */ 1478, 1480, 1481, 1341, 1484, 1491, 1495, 1502, 1505, 1369, + /* 390 */ 1472, 1508, 1372, 1510, 1511, 1513, 1514, 1515, 1516, 1518, + /* 400 */ 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1485, 1528, 1530, + /* 410 */ 1532, 1533, 1534, 1535, 1517, 1536, 1537, 1540, 1541, 1542, + /* 420 */ 1543, 1504, 1519, 1501, 1545, 1527, 1546, 1531, 1554, 1529, + /* 430 */ 1539, 1556, 1561, 1562, 1547, 1410, 1563, 1567, 1568, 1565, + /* 440 */ 1571, 1576, 1550, 1544, 1548, 1580, 1557, 1553, 1555, 1582, + /* 450 */ 1560, 1581, 1570, 1584, 1583, 1585, 1591, 1589, 1593, 1596, + /* 460 */ 1597, 1538, 1559, 1598, 1609, 1634, 1601, 1602, 1603, 1604, + /* 470 */ 1600, 1606, 1610, 1611, 1612, 1644, 1628, 1651, 1630, 1605, + /* 480 */ 1653, 1633, 1621, 1657, 1623, 1659, 1625, 1662, 1641, 1645, + /* 490 */ 1664, 1551, 1631, 1667, 1512, 1648, 1572, 1552, 1679, 1680, + /* 500 */ 1573, 1569, 1685, 1686, 1687, 1647, 1649, 1469, 1613, 1615, + /* 510 */ 1614, 1620, 1650, 1622, 1618, 1624, 1626, 1629, 1666, 1661, + /* 520 */ 1681, 1643, 1688, 1509, 1646, 1658, 1696, 1564, 1689, 1697, + /* 530 */ 1663, 1701, 1566, 1668, 1656, 1710, 1712, 1714, 1715, 1718, + /* 540 */ 1668, 1692, 1574, 1711, 1682, 1684, 1690, 1717, 1699, 1704, + /* 550 */ 1722, 1742, 1590, 1705, 1691, 1695, 1706, 1769, 1708, 1635, + /* 560 */ 1713, 1770, 1732, 1654, 1719, 1700, 1726, 1747, 1720, 1716, + /* 570 */ 1721, 1772, 1723, 1703, 1727, 1762, 1771, 1737, 1745, 1774, + /* 580 */ 1748, 1746, 1796, 1750, 1754, 1798, 1756, 1757, 1801, 1760, + /* 590 */ 1698, 1738, 1739, 1741, 1824, 1755, 1773, 1776, 1816, 1777, + /* 600 */ 1809, 1809, 1831, 1794, 1797, 1825, 1799, 1781, 1819, 1828, + /* 610 */ 1830, 1833, 1834, 1843, 1865, 1853, 1854, 1826, 1600, 1855, + /* 620 */ 1606, 1857, 1860, 1861, 1862, 1864, 1866, 1903, 1869, 1858, + /* 630 */ 1867, 1908, 1875, 1868, 1872, 1912, 1878, 1870, 1877, 1914, + /* 640 */ 1884, 1873, 1882, 1922, 1888, 1889, 1925, 1906, 1916, 1926, + /* 650 */ 1927, 1923, 1930, }; -#define YY_REDUCE_COUNT (265) -#define YY_REDUCE_MIN (-333) -#define YY_REDUCE_MAX (1934) +#define YY_REDUCE_COUNT (269) +#define YY_REDUCE_MIN (-338) +#define YY_REDUCE_MAX (1842) static const short yy_reduce_ofst[] = { - /* 0 */ 510, -175, 623, -245, -113, 682, 745, 828, 889, 942, - /* 10 */ 806, 956, 1008, 1026, 1078, 96, 1095, 1144, 1204, 1213, - /* 20 */ 1262, 1274, 1327, 1343, 1392, 1452, 1461, 1510, 1522, 1573, - /* 30 */ 1587, 1638, 1650, 1664, 1715, 1741, 1794, 1806, 1857, 1871, - /* 40 */ 1922, 1934, 23, 184, -216, 66, 401, -246, 698, 51, - /* 50 */ 81, -232, 399, 511, 260, 261, -250, -244, -333, -263, - /* 60 */ -330, -251, -131, -128, 252, 357, 395, 504, 593, 598, - /* 70 */ -235, 611, 697, 713, -217, -76, 344, 620, 743, -242, - /* 80 */ 756, 346, 323, 452, 774, -176, -39, -324, -324, -324, - /* 90 */ 127, 80, 193, 236, 371, 386, 433, 500, 604, 605, - /* 100 */ 609, 616, 631, 649, 652, 662, 665, 681, 683, 685, - /* 110 */ 686, -158, -20, 46, 157, 187, 250, 189, 336, 412, - /* 120 */ -257, 299, 305, 460, 445, 471, 447, 524, 549, 117, - /* 130 */ 149, 311, 425, 540, 545, 574, 717, 274, 372, 643, - /* 140 */ 684, 692, 795, 760, 703, 781, 781, 820, 839, 811, - /* 150 */ 783, 762, 762, 762, 746, 747, 748, 763, 781, 797, - /* 160 */ 858, 803, 869, 830, 878, 885, 849, 852, 859, 899, - /* 170 */ 909, 910, 856, 907, 877, 911, 867, 871, 917, 876, - /* 180 */ 921, 886, 924, 925, 930, 927, 938, 913, 915, 916, - /* 190 */ 919, 920, 922, 923, 926, 931, 940, 941, 944, 947, - /* 200 */ 905, 912, 893, 961, 914, 929, 963, 958, 968, 932, - /* 210 */ 964, 933, 936, 887, 937, 950, 890, 949, 953, 955, - /* 220 */ 781, 896, 900, 892, 945, 906, 935, 946, 762, 983, - /* 230 */ 969, 957, 934, 939, 951, 959, 962, 960, 977, 971, - /* 240 */ 994, 1017, 1018, 998, 1020, 1010, 1027, 1016, 1061, 1044, - /* 250 */ 1062, 1030, 1045, 1048, 1073, 1085, 1082, 1102, 1101, 1049, - /* 260 */ 1046, 1088, 1089, 1090, 1096, 1115, + /* 0 */ -235, -215, 87, 651, 712, 513, 773, 828, 881, 890, + /* 10 */ 908, 973, -150, 989, 998, 314, 1051, 1105, 1114, 1164, + /* 20 */ 1175, 1227, 1280, 1289, 1298, 1350, 1392, 1412, 1434, 1490, + /* 30 */ 1499, 1549, 1558, 1608, 1617, 1669, 1678, 1731, 1740, 1749, + /* 40 */ 1758, 1836, 1753, 1842, -119, 241, 246, -274, -254, -261, + /* 50 */ 79, -292, -224, 143, -124, 108, -253, -249, -338, -251, + /* 60 */ -218, 55, -123, -33, 162, 164, 226, 275, 304, 339, + /* 70 */ -244, 360, 408, 409, -209, 133, 200, 413, 463, 459, + /* 80 */ 481, 298, 470, 455, 545, 165, -233, 7, 7, 7, + /* 90 */ -217, -252, -63, 154, 194, 287, 320, 351, 353, 496, + /* 100 */ 518, 521, 542, 571, 597, 598, 609, 611, 644, 654, + /* 110 */ 678, -174, 238, 221, 308, -144, 357, -111, 490, 589, + /* 120 */ 595, 428, 399, 497, 271, 523, 507, 552, 652, 658, + /* 130 */ 686, 22, -259, 177, 426, 452, 457, 534, 579, 71, + /* 140 */ 156, 233, 227, 533, 699, 684, 612, 724, 724, 765, + /* 150 */ 788, 756, 731, 709, 709, 709, 693, 694, 695, 720, + /* 160 */ 724, 751, 815, 763, 854, 820, 875, 877, 839, 846, + /* 170 */ 847, 887, 904, 909, 835, 901, 884, 911, 864, 870, + /* 180 */ 918, 883, 920, 886, 926, 929, 934, 931, 935, 917, + /* 190 */ 919, 924, 933, 940, 942, 943, 944, 946, 947, 948, + /* 200 */ 938, 976, 945, 927, 982, 936, 957, 994, 997, 999, + /* 210 */ 951, 1000, 941, 972, 914, 967, 979, 932, 969, 981, + /* 220 */ 983, 724, 922, 937, 949, 928, 952, 939, 977, 709, + /* 230 */ 1002, 987, 1001, 963, 974, 978, 984, 975, 996, 1004, + /* 240 */ 1006, 1034, 1055, 1056, 1067, 1068, 1069, 1041, 1071, 1065, + /* 250 */ 1080, 1070, 1107, 1097, 1112, 1095, 1103, 1099, 1119, 1128, + /* 260 */ 1129, 1140, 1142, 1084, 1091, 1127, 1130, 1131, 1143, 1153, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 10 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 20 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 30 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 40 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 50 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 60 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 70 */ 1483, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 80 */ 1411, 1411, 1411, 1411, 1411, 1481, 1632, 1411, 1799, 1411, - /* 90 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 100 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 110 */ 1411, 1411, 1411, 1411, 1411, 1483, 1411, 1811, 1811, 1811, - /* 120 */ 1481, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1577, 1411, - /* 130 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1666, 1411, 1411, - /* 140 */ 1881, 1411, 1411, 1672, 1835, 1411, 1411, 1411, 1411, 1530, - /* 150 */ 1827, 1803, 1817, 1804, 1866, 1866, 1866, 1820, 1411, 1831, - /* 160 */ 1411, 1411, 1411, 1658, 1411, 1411, 1637, 1634, 1634, 1411, - /* 170 */ 1411, 1411, 1411, 1483, 1411, 1483, 1411, 1411, 1483, 1411, - /* 180 */ 1483, 1411, 1483, 1483, 1411, 1483, 1411, 1411, 1411, 1411, - /* 190 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 200 */ 1411, 1411, 1411, 1481, 1668, 1411, 1481, 1411, 1411, 1411, - /* 210 */ 1481, 1411, 1411, 1842, 1840, 1411, 1842, 1840, 1411, 1411, - /* 220 */ 1411, 1854, 1850, 1842, 1858, 1856, 1833, 1831, 1817, 1411, - /* 230 */ 1411, 1801, 1872, 1868, 1884, 1872, 1868, 1872, 1868, 1411, - /* 240 */ 1840, 1411, 1411, 1840, 1411, 1641, 1411, 1411, 1481, 1411, - /* 250 */ 1481, 1411, 1546, 1411, 1411, 1411, 1481, 1443, 1411, 1660, - /* 260 */ 1674, 1580, 1580, 1580, 1484, 1416, 1411, 1411, 1411, 1411, - /* 270 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1743, 1853, 1852, - /* 280 */ 1775, 1774, 1773, 1771, 1742, 1411, 1411, 1542, 1741, 1740, - /* 290 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1734, 1735, 1733, - /* 300 */ 1732, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 310 */ 1411, 1411, 1411, 1411, 1800, 1411, 1869, 1873, 1411, 1411, - /* 320 */ 1411, 1717, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 330 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 340 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 350 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 360 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 370 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 380 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 390 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 400 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 410 */ 1411, 1411, 1411, 1411, 1411, 1411, 1448, 1411, 1411, 1411, - /* 420 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 430 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 440 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 450 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 460 */ 1411, 1411, 1411, 1511, 1510, 1411, 1411, 1411, 1411, 1411, - /* 470 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 480 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 490 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1824, 1834, - /* 500 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 510 */ 1411, 1411, 1411, 1717, 1411, 1851, 1411, 1810, 1806, 1411, - /* 520 */ 1411, 1802, 1411, 1411, 1867, 1411, 1411, 1411, 1411, 1411, - /* 530 */ 1411, 1411, 1411, 1411, 1795, 1411, 1768, 1411, 1411, 1411, - /* 540 */ 1411, 1411, 1411, 1411, 1411, 1728, 1411, 1411, 1411, 1411, - /* 550 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1716, 1411, - /* 560 */ 1759, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1574, - /* 570 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 580 */ 1411, 1411, 1559, 1557, 1556, 1555, 1411, 1552, 1411, 1411, - /* 590 */ 1411, 1411, 1583, 1582, 1411, 1411, 1411, 1411, 1411, 1411, - /* 600 */ 1503, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 610 */ 1494, 1411, 1493, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 620 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 630 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, - /* 640 */ 1411, 1411, 1411, 1411, 1411, + /* 0 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 10 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 20 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 30 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 40 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 50 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 60 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 70 */ 1496, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 80 */ 1424, 1424, 1424, 1424, 1424, 1494, 1647, 1424, 1816, 1424, + /* 90 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 100 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 110 */ 1424, 1424, 1424, 1424, 1424, 1496, 1424, 1828, 1828, 1828, + /* 120 */ 1494, 1424, 1424, 1424, 1691, 1691, 1424, 1424, 1424, 1424, + /* 130 */ 1590, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1683, + /* 140 */ 1424, 1424, 1898, 1424, 1424, 1689, 1852, 1424, 1424, 1424, + /* 150 */ 1424, 1543, 1844, 1820, 1834, 1821, 1883, 1883, 1883, 1837, + /* 160 */ 1424, 1848, 1424, 1424, 1424, 1675, 1424, 1424, 1652, 1649, + /* 170 */ 1649, 1424, 1424, 1424, 1424, 1496, 1424, 1496, 1424, 1424, + /* 180 */ 1496, 1424, 1496, 1424, 1496, 1496, 1424, 1496, 1424, 1424, + /* 190 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 200 */ 1424, 1424, 1424, 1424, 1494, 1685, 1424, 1494, 1424, 1424, + /* 210 */ 1424, 1494, 1424, 1424, 1859, 1857, 1424, 1859, 1857, 1424, + /* 220 */ 1424, 1424, 1871, 1867, 1859, 1875, 1873, 1850, 1848, 1834, + /* 230 */ 1424, 1424, 1818, 1889, 1885, 1901, 1889, 1885, 1889, 1885, + /* 240 */ 1424, 1857, 1424, 1424, 1424, 1424, 1424, 1857, 1424, 1424, + /* 250 */ 1424, 1424, 1494, 1424, 1494, 1424, 1559, 1424, 1424, 1424, + /* 260 */ 1494, 1456, 1424, 1677, 1691, 1593, 1593, 1593, 1497, 1429, + /* 270 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 280 */ 1424, 1760, 1870, 1869, 1792, 1791, 1790, 1788, 1759, 1424, + /* 290 */ 1424, 1555, 1758, 1757, 1424, 1424, 1424, 1424, 1424, 1424, + /* 300 */ 1751, 1752, 1750, 1749, 1424, 1424, 1424, 1424, 1424, 1424, + /* 310 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1817, + /* 320 */ 1424, 1886, 1890, 1424, 1424, 1424, 1734, 1424, 1424, 1424, + /* 330 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 340 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 350 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 360 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 370 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 380 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 390 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 400 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 410 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 420 */ 1424, 1424, 1424, 1461, 1424, 1424, 1424, 1424, 1424, 1424, + /* 430 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 440 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 450 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 460 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 470 */ 1524, 1523, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 480 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 490 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 500 */ 1424, 1424, 1424, 1424, 1424, 1841, 1851, 1424, 1424, 1424, + /* 510 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 520 */ 1734, 1424, 1868, 1424, 1827, 1823, 1424, 1424, 1819, 1424, + /* 530 */ 1424, 1884, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 540 */ 1424, 1812, 1424, 1785, 1424, 1424, 1424, 1424, 1424, 1424, + /* 550 */ 1424, 1424, 1745, 1424, 1424, 1424, 1424, 1695, 1424, 1424, + /* 560 */ 1424, 1424, 1424, 1424, 1424, 1424, 1733, 1424, 1776, 1424, + /* 570 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1587, 1424, 1424, + /* 580 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 590 */ 1572, 1570, 1569, 1568, 1424, 1565, 1424, 1424, 1424, 1424, + /* 600 */ 1596, 1595, 1424, 1424, 1424, 1424, 1424, 1424, 1516, 1424, + /* 610 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1507, 1424, + /* 620 */ 1506, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 630 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 640 */ 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, + /* 650 */ 1424, 1424, 1424, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1003,6 +995,8 @@ static const YYCODETYPE yyFallback[] = { 0, /* CLUSTER => nothing */ 0, /* TRANSACTIONS => nothing */ 0, /* DISTRIBUTED => nothing */ + 0, /* CONSUMERS => nothing */ + 0, /* SUBSCRIPTIONS => nothing */ 0, /* LIKE => nothing */ 0, /* INDEX => nothing */ 0, /* FUNCTION => nothing */ @@ -1098,12 +1092,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ID => nothing */ - 237, /* NK_BITNOT => ID */ - 237, /* INSERT => ID */ - 237, /* VALUES => ID */ - 237, /* IMPORT => ID */ - 237, /* NK_SEMI => ID */ - 237, /* FILE => ID */ + 239, /* NK_BITNOT => ID */ + 239, /* INSERT => ID */ + 239, /* VALUES => ID */ + 239, /* IMPORT => ID */ + 239, /* NK_SEMI => ID */ + 239, /* FILE => ID */ }; #endif /* YYFALLBACK */ @@ -1334,230 +1328,233 @@ static const char *const yyTokenName[] = { /* 140 */ "CLUSTER", /* 141 */ "TRANSACTIONS", /* 142 */ "DISTRIBUTED", - /* 143 */ "LIKE", - /* 144 */ "INDEX", - /* 145 */ "FUNCTION", - /* 146 */ "INTERVAL", - /* 147 */ "TOPIC", - /* 148 */ "AS", - /* 149 */ "WITH", - /* 150 */ "META", - /* 151 */ "CONSUMER", - /* 152 */ "GROUP", - /* 153 */ "DESC", - /* 154 */ "DESCRIBE", - /* 155 */ "RESET", - /* 156 */ "QUERY", - /* 157 */ "CACHE", - /* 158 */ "EXPLAIN", - /* 159 */ "ANALYZE", - /* 160 */ "VERBOSE", - /* 161 */ "NK_BOOL", - /* 162 */ "RATIO", - /* 163 */ "NK_FLOAT", - /* 164 */ "COMPACT", - /* 165 */ "VNODES", - /* 166 */ "IN", - /* 167 */ "OUTPUTTYPE", - /* 168 */ "AGGREGATE", - /* 169 */ "BUFSIZE", - /* 170 */ "STREAM", - /* 171 */ "INTO", - /* 172 */ "TRIGGER", - /* 173 */ "AT_ONCE", - /* 174 */ "WINDOW_CLOSE", - /* 175 */ "KILL", - /* 176 */ "CONNECTION", - /* 177 */ "TRANSACTION", - /* 178 */ "BALANCE", - /* 179 */ "VGROUP", - /* 180 */ "MERGE", - /* 181 */ "REDISTRIBUTE", - /* 182 */ "SPLIT", - /* 183 */ "SYNCDB", - /* 184 */ "DELETE", - /* 185 */ "NULL", - /* 186 */ "NK_QUESTION", - /* 187 */ "NK_ARROW", - /* 188 */ "ROWTS", - /* 189 */ "TBNAME", - /* 190 */ "QSTARTTS", - /* 191 */ "QENDTS", - /* 192 */ "WSTARTTS", - /* 193 */ "WENDTS", - /* 194 */ "WDURATION", - /* 195 */ "CAST", - /* 196 */ "NOW", - /* 197 */ "TODAY", - /* 198 */ "TIMEZONE", - /* 199 */ "COUNT", - /* 200 */ "LAST_ROW", - /* 201 */ "BETWEEN", - /* 202 */ "IS", - /* 203 */ "NK_LT", - /* 204 */ "NK_GT", - /* 205 */ "NK_LE", - /* 206 */ "NK_GE", - /* 207 */ "NK_NE", - /* 208 */ "MATCH", - /* 209 */ "NMATCH", - /* 210 */ "CONTAINS", - /* 211 */ "JOIN", - /* 212 */ "INNER", - /* 213 */ "SELECT", - /* 214 */ "DISTINCT", - /* 215 */ "WHERE", - /* 216 */ "PARTITION", - /* 217 */ "BY", - /* 218 */ "SESSION", - /* 219 */ "STATE_WINDOW", - /* 220 */ "SLIDING", - /* 221 */ "FILL", - /* 222 */ "VALUE", - /* 223 */ "NONE", - /* 224 */ "PREV", - /* 225 */ "LINEAR", - /* 226 */ "NEXT", - /* 227 */ "HAVING", - /* 228 */ "RANGE", - /* 229 */ "EVERY", - /* 230 */ "ORDER", - /* 231 */ "SLIMIT", - /* 232 */ "SOFFSET", - /* 233 */ "LIMIT", - /* 234 */ "OFFSET", - /* 235 */ "ASC", - /* 236 */ "NULLS", - /* 237 */ "ID", - /* 238 */ "NK_BITNOT", - /* 239 */ "INSERT", - /* 240 */ "VALUES", - /* 241 */ "IMPORT", - /* 242 */ "NK_SEMI", - /* 243 */ "FILE", - /* 244 */ "cmd", - /* 245 */ "account_options", - /* 246 */ "alter_account_options", - /* 247 */ "literal", - /* 248 */ "alter_account_option", - /* 249 */ "user_name", - /* 250 */ "sysinfo_opt", - /* 251 */ "privileges", - /* 252 */ "priv_level", - /* 253 */ "priv_type_list", - /* 254 */ "priv_type", - /* 255 */ "db_name", - /* 256 */ "dnode_endpoint", - /* 257 */ "not_exists_opt", - /* 258 */ "db_options", - /* 259 */ "exists_opt", - /* 260 */ "alter_db_options", - /* 261 */ "integer_list", - /* 262 */ "variable_list", - /* 263 */ "retention_list", - /* 264 */ "alter_db_option", - /* 265 */ "retention", - /* 266 */ "full_table_name", - /* 267 */ "column_def_list", - /* 268 */ "tags_def_opt", - /* 269 */ "table_options", - /* 270 */ "multi_create_clause", - /* 271 */ "tags_def", - /* 272 */ "multi_drop_clause", - /* 273 */ "alter_table_clause", - /* 274 */ "alter_table_options", - /* 275 */ "column_name", - /* 276 */ "type_name", - /* 277 */ "signed_literal", - /* 278 */ "create_subtable_clause", - /* 279 */ "specific_tags_opt", - /* 280 */ "literal_list", - /* 281 */ "drop_table_clause", - /* 282 */ "col_name_list", - /* 283 */ "table_name", - /* 284 */ "column_def", - /* 285 */ "duration_list", - /* 286 */ "rollup_func_list", - /* 287 */ "alter_table_option", - /* 288 */ "duration_literal", - /* 289 */ "rollup_func_name", - /* 290 */ "function_name", - /* 291 */ "col_name", - /* 292 */ "db_name_cond_opt", - /* 293 */ "like_pattern_opt", - /* 294 */ "table_name_cond", - /* 295 */ "from_db_opt", - /* 296 */ "index_name", - /* 297 */ "index_options", - /* 298 */ "func_list", - /* 299 */ "sliding_opt", - /* 300 */ "func", - /* 301 */ "expression_list", - /* 302 */ "topic_name", - /* 303 */ "query_expression", - /* 304 */ "cgroup_name", - /* 305 */ "analyze_opt", - /* 306 */ "explain_options", - /* 307 */ "agg_func_opt", - /* 308 */ "bufsize_opt", - /* 309 */ "stream_name", - /* 310 */ "stream_options", - /* 311 */ "into_opt", - /* 312 */ "dnode_list", - /* 313 */ "where_clause_opt", - /* 314 */ "signed", - /* 315 */ "literal_func", - /* 316 */ "table_alias", - /* 317 */ "column_alias", - /* 318 */ "expression", - /* 319 */ "pseudo_column", - /* 320 */ "column_reference", - /* 321 */ "function_expression", - /* 322 */ "subquery", - /* 323 */ "star_func", - /* 324 */ "star_func_para_list", - /* 325 */ "noarg_func", - /* 326 */ "other_para_list", - /* 327 */ "star_func_para", - /* 328 */ "predicate", - /* 329 */ "compare_op", - /* 330 */ "in_op", - /* 331 */ "in_predicate_value", - /* 332 */ "boolean_value_expression", - /* 333 */ "boolean_primary", - /* 334 */ "common_expression", - /* 335 */ "from_clause_opt", - /* 336 */ "table_reference_list", - /* 337 */ "table_reference", - /* 338 */ "table_primary", - /* 339 */ "joined_table", - /* 340 */ "alias_opt", - /* 341 */ "parenthesized_joined_table", - /* 342 */ "join_type", - /* 343 */ "search_condition", - /* 344 */ "query_specification", - /* 345 */ "set_quantifier_opt", - /* 346 */ "select_list", - /* 347 */ "partition_by_clause_opt", - /* 348 */ "range_opt", - /* 349 */ "every_opt", - /* 350 */ "fill_opt", - /* 351 */ "twindow_clause_opt", - /* 352 */ "group_by_clause_opt", - /* 353 */ "having_clause_opt", - /* 354 */ "select_sublist", - /* 355 */ "select_item", - /* 356 */ "fill_mode", - /* 357 */ "group_by_list", - /* 358 */ "query_expression_body", - /* 359 */ "order_by_clause_opt", - /* 360 */ "slimit_clause_opt", - /* 361 */ "limit_clause_opt", - /* 362 */ "query_primary", - /* 363 */ "sort_specification_list", - /* 364 */ "sort_specification", - /* 365 */ "ordering_specification_opt", - /* 366 */ "null_ordering_opt", + /* 143 */ "CONSUMERS", + /* 144 */ "SUBSCRIPTIONS", + /* 145 */ "LIKE", + /* 146 */ "INDEX", + /* 147 */ "FUNCTION", + /* 148 */ "INTERVAL", + /* 149 */ "TOPIC", + /* 150 */ "AS", + /* 151 */ "WITH", + /* 152 */ "META", + /* 153 */ "CONSUMER", + /* 154 */ "GROUP", + /* 155 */ "DESC", + /* 156 */ "DESCRIBE", + /* 157 */ "RESET", + /* 158 */ "QUERY", + /* 159 */ "CACHE", + /* 160 */ "EXPLAIN", + /* 161 */ "ANALYZE", + /* 162 */ "VERBOSE", + /* 163 */ "NK_BOOL", + /* 164 */ "RATIO", + /* 165 */ "NK_FLOAT", + /* 166 */ "COMPACT", + /* 167 */ "VNODES", + /* 168 */ "IN", + /* 169 */ "OUTPUTTYPE", + /* 170 */ "AGGREGATE", + /* 171 */ "BUFSIZE", + /* 172 */ "STREAM", + /* 173 */ "INTO", + /* 174 */ "TRIGGER", + /* 175 */ "AT_ONCE", + /* 176 */ "WINDOW_CLOSE", + /* 177 */ "KILL", + /* 178 */ "CONNECTION", + /* 179 */ "TRANSACTION", + /* 180 */ "BALANCE", + /* 181 */ "VGROUP", + /* 182 */ "MERGE", + /* 183 */ "REDISTRIBUTE", + /* 184 */ "SPLIT", + /* 185 */ "SYNCDB", + /* 186 */ "DELETE", + /* 187 */ "NULL", + /* 188 */ "NK_QUESTION", + /* 189 */ "NK_ARROW", + /* 190 */ "ROWTS", + /* 191 */ "TBNAME", + /* 192 */ "QSTARTTS", + /* 193 */ "QENDTS", + /* 194 */ "WSTARTTS", + /* 195 */ "WENDTS", + /* 196 */ "WDURATION", + /* 197 */ "CAST", + /* 198 */ "NOW", + /* 199 */ "TODAY", + /* 200 */ "TIMEZONE", + /* 201 */ "COUNT", + /* 202 */ "LAST_ROW", + /* 203 */ "BETWEEN", + /* 204 */ "IS", + /* 205 */ "NK_LT", + /* 206 */ "NK_GT", + /* 207 */ "NK_LE", + /* 208 */ "NK_GE", + /* 209 */ "NK_NE", + /* 210 */ "MATCH", + /* 211 */ "NMATCH", + /* 212 */ "CONTAINS", + /* 213 */ "JOIN", + /* 214 */ "INNER", + /* 215 */ "SELECT", + /* 216 */ "DISTINCT", + /* 217 */ "WHERE", + /* 218 */ "PARTITION", + /* 219 */ "BY", + /* 220 */ "SESSION", + /* 221 */ "STATE_WINDOW", + /* 222 */ "SLIDING", + /* 223 */ "FILL", + /* 224 */ "VALUE", + /* 225 */ "NONE", + /* 226 */ "PREV", + /* 227 */ "LINEAR", + /* 228 */ "NEXT", + /* 229 */ "HAVING", + /* 230 */ "RANGE", + /* 231 */ "EVERY", + /* 232 */ "ORDER", + /* 233 */ "SLIMIT", + /* 234 */ "SOFFSET", + /* 235 */ "LIMIT", + /* 236 */ "OFFSET", + /* 237 */ "ASC", + /* 238 */ "NULLS", + /* 239 */ "ID", + /* 240 */ "NK_BITNOT", + /* 241 */ "INSERT", + /* 242 */ "VALUES", + /* 243 */ "IMPORT", + /* 244 */ "NK_SEMI", + /* 245 */ "FILE", + /* 246 */ "cmd", + /* 247 */ "account_options", + /* 248 */ "alter_account_options", + /* 249 */ "literal", + /* 250 */ "alter_account_option", + /* 251 */ "user_name", + /* 252 */ "sysinfo_opt", + /* 253 */ "privileges", + /* 254 */ "priv_level", + /* 255 */ "priv_type_list", + /* 256 */ "priv_type", + /* 257 */ "db_name", + /* 258 */ "dnode_endpoint", + /* 259 */ "not_exists_opt", + /* 260 */ "db_options", + /* 261 */ "exists_opt", + /* 262 */ "alter_db_options", + /* 263 */ "integer_list", + /* 264 */ "variable_list", + /* 265 */ "retention_list", + /* 266 */ "alter_db_option", + /* 267 */ "retention", + /* 268 */ "full_table_name", + /* 269 */ "column_def_list", + /* 270 */ "tags_def_opt", + /* 271 */ "table_options", + /* 272 */ "multi_create_clause", + /* 273 */ "tags_def", + /* 274 */ "multi_drop_clause", + /* 275 */ "alter_table_clause", + /* 276 */ "alter_table_options", + /* 277 */ "column_name", + /* 278 */ "type_name", + /* 279 */ "signed_literal", + /* 280 */ "create_subtable_clause", + /* 281 */ "specific_tags_opt", + /* 282 */ "literal_list", + /* 283 */ "drop_table_clause", + /* 284 */ "col_name_list", + /* 285 */ "table_name", + /* 286 */ "column_def", + /* 287 */ "duration_list", + /* 288 */ "rollup_func_list", + /* 289 */ "alter_table_option", + /* 290 */ "duration_literal", + /* 291 */ "rollup_func_name", + /* 292 */ "function_name", + /* 293 */ "col_name", + /* 294 */ "db_name_cond_opt", + /* 295 */ "like_pattern_opt", + /* 296 */ "table_name_cond", + /* 297 */ "from_db_opt", + /* 298 */ "index_name", + /* 299 */ "index_options", + /* 300 */ "func_list", + /* 301 */ "sliding_opt", + /* 302 */ "sma_stream_opt", + /* 303 */ "func", + /* 304 */ "expression_list", + /* 305 */ "stream_options", + /* 306 */ "topic_name", + /* 307 */ "query_expression", + /* 308 */ "cgroup_name", + /* 309 */ "analyze_opt", + /* 310 */ "explain_options", + /* 311 */ "agg_func_opt", + /* 312 */ "bufsize_opt", + /* 313 */ "stream_name", + /* 314 */ "into_opt", + /* 315 */ "dnode_list", + /* 316 */ "where_clause_opt", + /* 317 */ "signed", + /* 318 */ "literal_func", + /* 319 */ "table_alias", + /* 320 */ "column_alias", + /* 321 */ "expression", + /* 322 */ "pseudo_column", + /* 323 */ "column_reference", + /* 324 */ "function_expression", + /* 325 */ "subquery", + /* 326 */ "star_func", + /* 327 */ "star_func_para_list", + /* 328 */ "noarg_func", + /* 329 */ "other_para_list", + /* 330 */ "star_func_para", + /* 331 */ "predicate", + /* 332 */ "compare_op", + /* 333 */ "in_op", + /* 334 */ "in_predicate_value", + /* 335 */ "boolean_value_expression", + /* 336 */ "boolean_primary", + /* 337 */ "common_expression", + /* 338 */ "from_clause_opt", + /* 339 */ "table_reference_list", + /* 340 */ "table_reference", + /* 341 */ "table_primary", + /* 342 */ "joined_table", + /* 343 */ "alias_opt", + /* 344 */ "parenthesized_joined_table", + /* 345 */ "join_type", + /* 346 */ "search_condition", + /* 347 */ "query_specification", + /* 348 */ "set_quantifier_opt", + /* 349 */ "select_list", + /* 350 */ "partition_by_clause_opt", + /* 351 */ "range_opt", + /* 352 */ "every_opt", + /* 353 */ "fill_opt", + /* 354 */ "twindow_clause_opt", + /* 355 */ "group_by_clause_opt", + /* 356 */ "having_clause_opt", + /* 357 */ "select_sublist", + /* 358 */ "select_item", + /* 359 */ "fill_mode", + /* 360 */ "group_by_list", + /* 361 */ "query_expression_body", + /* 362 */ "order_by_clause_opt", + /* 363 */ "slimit_clause_opt", + /* 364 */ "limit_clause_opt", + /* 365 */ "query_primary", + /* 366 */ "sort_specification_list", + /* 367 */ "sort_specification", + /* 368 */ "ordering_specification_opt", + /* 369 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1783,261 +1780,265 @@ static const char *const yyRuleName[] = { /* 215 */ "cmd ::= SHOW CLUSTER", /* 216 */ "cmd ::= SHOW TRANSACTIONS", /* 217 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 218 */ "db_name_cond_opt ::=", - /* 219 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 220 */ "like_pattern_opt ::=", - /* 221 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 222 */ "table_name_cond ::= table_name", - /* 223 */ "from_db_opt ::=", - /* 224 */ "from_db_opt ::= FROM db_name", - /* 225 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 226 */ "cmd ::= DROP INDEX exists_opt index_name", - /* 227 */ "index_options ::=", - /* 228 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 229 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 230 */ "func_list ::= func", - /* 231 */ "func_list ::= func_list NK_COMMA func", - /* 232 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 233 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 234 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 235 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 236 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 237 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 238 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 239 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 240 */ "cmd ::= DESC full_table_name", - /* 241 */ "cmd ::= DESCRIBE full_table_name", - /* 242 */ "cmd ::= RESET QUERY CACHE", - /* 243 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 244 */ "analyze_opt ::=", - /* 245 */ "analyze_opt ::= ANALYZE", - /* 246 */ "explain_options ::=", - /* 247 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 248 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 249 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", - /* 250 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 251 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 252 */ "agg_func_opt ::=", - /* 253 */ "agg_func_opt ::= AGGREGATE", - /* 254 */ "bufsize_opt ::=", - /* 255 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 256 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", - /* 257 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 258 */ "into_opt ::=", - /* 259 */ "into_opt ::= INTO full_table_name", - /* 260 */ "stream_options ::=", - /* 261 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 262 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 263 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 264 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 265 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 266 */ "cmd ::= KILL QUERY NK_STRING", - /* 267 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 268 */ "cmd ::= BALANCE VGROUP", - /* 269 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 270 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 271 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 272 */ "dnode_list ::= DNODE NK_INTEGER", - /* 273 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 274 */ "cmd ::= SYNCDB db_name REPLICA", - /* 275 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 276 */ "cmd ::= query_expression", - /* 277 */ "literal ::= NK_INTEGER", - /* 278 */ "literal ::= NK_FLOAT", - /* 279 */ "literal ::= NK_STRING", - /* 280 */ "literal ::= NK_BOOL", - /* 281 */ "literal ::= TIMESTAMP NK_STRING", - /* 282 */ "literal ::= duration_literal", - /* 283 */ "literal ::= NULL", - /* 284 */ "literal ::= NK_QUESTION", - /* 285 */ "duration_literal ::= NK_VARIABLE", - /* 286 */ "signed ::= NK_INTEGER", - /* 287 */ "signed ::= NK_PLUS NK_INTEGER", - /* 288 */ "signed ::= NK_MINUS NK_INTEGER", - /* 289 */ "signed ::= NK_FLOAT", - /* 290 */ "signed ::= NK_PLUS NK_FLOAT", - /* 291 */ "signed ::= NK_MINUS NK_FLOAT", - /* 292 */ "signed_literal ::= signed", - /* 293 */ "signed_literal ::= NK_STRING", - /* 294 */ "signed_literal ::= NK_BOOL", - /* 295 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 296 */ "signed_literal ::= duration_literal", - /* 297 */ "signed_literal ::= NULL", - /* 298 */ "signed_literal ::= literal_func", - /* 299 */ "literal_list ::= signed_literal", - /* 300 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 301 */ "db_name ::= NK_ID", - /* 302 */ "table_name ::= NK_ID", - /* 303 */ "column_name ::= NK_ID", - /* 304 */ "function_name ::= NK_ID", - /* 305 */ "table_alias ::= NK_ID", - /* 306 */ "column_alias ::= NK_ID", - /* 307 */ "user_name ::= NK_ID", - /* 308 */ "index_name ::= NK_ID", - /* 309 */ "topic_name ::= NK_ID", - /* 310 */ "stream_name ::= NK_ID", - /* 311 */ "cgroup_name ::= NK_ID", - /* 312 */ "expression ::= literal", - /* 313 */ "expression ::= pseudo_column", - /* 314 */ "expression ::= column_reference", - /* 315 */ "expression ::= function_expression", - /* 316 */ "expression ::= subquery", - /* 317 */ "expression ::= NK_LP expression NK_RP", - /* 318 */ "expression ::= NK_PLUS expression", - /* 319 */ "expression ::= NK_MINUS expression", - /* 320 */ "expression ::= expression NK_PLUS expression", - /* 321 */ "expression ::= expression NK_MINUS expression", - /* 322 */ "expression ::= expression NK_STAR expression", - /* 323 */ "expression ::= expression NK_SLASH expression", - /* 324 */ "expression ::= expression NK_REM expression", - /* 325 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 326 */ "expression ::= expression NK_BITAND expression", - /* 327 */ "expression ::= expression NK_BITOR expression", - /* 328 */ "expression_list ::= expression", - /* 329 */ "expression_list ::= expression_list NK_COMMA expression", - /* 330 */ "column_reference ::= column_name", - /* 331 */ "column_reference ::= table_name NK_DOT column_name", - /* 332 */ "pseudo_column ::= ROWTS", - /* 333 */ "pseudo_column ::= TBNAME", - /* 334 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 335 */ "pseudo_column ::= QSTARTTS", - /* 336 */ "pseudo_column ::= QENDTS", - /* 337 */ "pseudo_column ::= WSTARTTS", - /* 338 */ "pseudo_column ::= WENDTS", - /* 339 */ "pseudo_column ::= WDURATION", - /* 340 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 341 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 342 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 343 */ "function_expression ::= literal_func", - /* 344 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 345 */ "literal_func ::= NOW", - /* 346 */ "noarg_func ::= NOW", - /* 347 */ "noarg_func ::= TODAY", - /* 348 */ "noarg_func ::= TIMEZONE", - /* 349 */ "star_func ::= COUNT", - /* 350 */ "star_func ::= FIRST", - /* 351 */ "star_func ::= LAST", - /* 352 */ "star_func ::= LAST_ROW", - /* 353 */ "star_func_para_list ::= NK_STAR", - /* 354 */ "star_func_para_list ::= other_para_list", - /* 355 */ "other_para_list ::= star_func_para", - /* 356 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 357 */ "star_func_para ::= expression", - /* 358 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 359 */ "predicate ::= expression compare_op expression", - /* 360 */ "predicate ::= expression BETWEEN expression AND expression", - /* 361 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 362 */ "predicate ::= expression IS NULL", - /* 363 */ "predicate ::= expression IS NOT NULL", - /* 364 */ "predicate ::= expression in_op in_predicate_value", - /* 365 */ "compare_op ::= NK_LT", - /* 366 */ "compare_op ::= NK_GT", - /* 367 */ "compare_op ::= NK_LE", - /* 368 */ "compare_op ::= NK_GE", - /* 369 */ "compare_op ::= NK_NE", - /* 370 */ "compare_op ::= NK_EQ", - /* 371 */ "compare_op ::= LIKE", - /* 372 */ "compare_op ::= NOT LIKE", - /* 373 */ "compare_op ::= MATCH", - /* 374 */ "compare_op ::= NMATCH", - /* 375 */ "compare_op ::= CONTAINS", - /* 376 */ "in_op ::= IN", - /* 377 */ "in_op ::= NOT IN", - /* 378 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 379 */ "boolean_value_expression ::= boolean_primary", - /* 380 */ "boolean_value_expression ::= NOT boolean_primary", - /* 381 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 382 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 383 */ "boolean_primary ::= predicate", - /* 384 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 385 */ "common_expression ::= expression", - /* 386 */ "common_expression ::= boolean_value_expression", - /* 387 */ "from_clause_opt ::=", - /* 388 */ "from_clause_opt ::= FROM table_reference_list", - /* 389 */ "table_reference_list ::= table_reference", - /* 390 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 391 */ "table_reference ::= table_primary", - /* 392 */ "table_reference ::= joined_table", - /* 393 */ "table_primary ::= table_name alias_opt", - /* 394 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 395 */ "table_primary ::= subquery alias_opt", - /* 396 */ "table_primary ::= parenthesized_joined_table", - /* 397 */ "alias_opt ::=", - /* 398 */ "alias_opt ::= table_alias", - /* 399 */ "alias_opt ::= AS table_alias", - /* 400 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 401 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 402 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 403 */ "join_type ::=", - /* 404 */ "join_type ::= INNER", - /* 405 */ "query_specification ::= SELECT set_quantifier_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", - /* 406 */ "set_quantifier_opt ::=", - /* 407 */ "set_quantifier_opt ::= DISTINCT", - /* 408 */ "set_quantifier_opt ::= ALL", - /* 409 */ "select_list ::= NK_STAR", - /* 410 */ "select_list ::= select_sublist", - /* 411 */ "select_sublist ::= select_item", - /* 412 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 413 */ "select_item ::= common_expression", - /* 414 */ "select_item ::= common_expression column_alias", - /* 415 */ "select_item ::= common_expression AS column_alias", - /* 416 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 417 */ "where_clause_opt ::=", - /* 418 */ "where_clause_opt ::= WHERE search_condition", - /* 419 */ "partition_by_clause_opt ::=", - /* 420 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 421 */ "twindow_clause_opt ::=", - /* 422 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 423 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 424 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 425 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 426 */ "sliding_opt ::=", - /* 427 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 428 */ "fill_opt ::=", - /* 429 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 430 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 431 */ "fill_mode ::= NONE", - /* 432 */ "fill_mode ::= PREV", - /* 433 */ "fill_mode ::= NULL", - /* 434 */ "fill_mode ::= LINEAR", - /* 435 */ "fill_mode ::= NEXT", - /* 436 */ "group_by_clause_opt ::=", - /* 437 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 438 */ "group_by_list ::= expression", - /* 439 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 440 */ "having_clause_opt ::=", - /* 441 */ "having_clause_opt ::= HAVING search_condition", - /* 442 */ "range_opt ::=", - /* 443 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", - /* 444 */ "every_opt ::=", - /* 445 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 446 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 447 */ "query_expression_body ::= query_primary", - /* 448 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 449 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 450 */ "query_primary ::= query_specification", - /* 451 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 452 */ "order_by_clause_opt ::=", - /* 453 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 454 */ "slimit_clause_opt ::=", - /* 455 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 456 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 457 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 458 */ "limit_clause_opt ::=", - /* 459 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 460 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 461 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 462 */ "subquery ::= NK_LP query_expression NK_RP", - /* 463 */ "search_condition ::= common_expression", - /* 464 */ "sort_specification_list ::= sort_specification", - /* 465 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 466 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 467 */ "ordering_specification_opt ::=", - /* 468 */ "ordering_specification_opt ::= ASC", - /* 469 */ "ordering_specification_opt ::= DESC", - /* 470 */ "null_ordering_opt ::=", - /* 471 */ "null_ordering_opt ::= NULLS FIRST", - /* 472 */ "null_ordering_opt ::= NULLS LAST", + /* 218 */ "cmd ::= SHOW CONSUMERS", + /* 219 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 220 */ "db_name_cond_opt ::=", + /* 221 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 222 */ "like_pattern_opt ::=", + /* 223 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 224 */ "table_name_cond ::= table_name", + /* 225 */ "from_db_opt ::=", + /* 226 */ "from_db_opt ::= FROM db_name", + /* 227 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 228 */ "cmd ::= DROP INDEX exists_opt index_name", + /* 229 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 230 */ "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", + /* 231 */ "func_list ::= func", + /* 232 */ "func_list ::= func_list NK_COMMA func", + /* 233 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 234 */ "sma_stream_opt ::=", + /* 235 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", + /* 236 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", + /* 237 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 238 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 239 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 240 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 241 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 242 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 243 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 244 */ "cmd ::= DESC full_table_name", + /* 245 */ "cmd ::= DESCRIBE full_table_name", + /* 246 */ "cmd ::= RESET QUERY CACHE", + /* 247 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 248 */ "analyze_opt ::=", + /* 249 */ "analyze_opt ::= ANALYZE", + /* 250 */ "explain_options ::=", + /* 251 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 252 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 253 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", + /* 254 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 255 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 256 */ "agg_func_opt ::=", + /* 257 */ "agg_func_opt ::= AGGREGATE", + /* 258 */ "bufsize_opt ::=", + /* 259 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 260 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", + /* 261 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 262 */ "into_opt ::=", + /* 263 */ "into_opt ::= INTO full_table_name", + /* 264 */ "stream_options ::=", + /* 265 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 266 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 267 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 268 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 269 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 270 */ "cmd ::= KILL QUERY NK_STRING", + /* 271 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 272 */ "cmd ::= BALANCE VGROUP", + /* 273 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 274 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 275 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 276 */ "dnode_list ::= DNODE NK_INTEGER", + /* 277 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 278 */ "cmd ::= SYNCDB db_name REPLICA", + /* 279 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 280 */ "cmd ::= query_expression", + /* 281 */ "literal ::= NK_INTEGER", + /* 282 */ "literal ::= NK_FLOAT", + /* 283 */ "literal ::= NK_STRING", + /* 284 */ "literal ::= NK_BOOL", + /* 285 */ "literal ::= TIMESTAMP NK_STRING", + /* 286 */ "literal ::= duration_literal", + /* 287 */ "literal ::= NULL", + /* 288 */ "literal ::= NK_QUESTION", + /* 289 */ "duration_literal ::= NK_VARIABLE", + /* 290 */ "signed ::= NK_INTEGER", + /* 291 */ "signed ::= NK_PLUS NK_INTEGER", + /* 292 */ "signed ::= NK_MINUS NK_INTEGER", + /* 293 */ "signed ::= NK_FLOAT", + /* 294 */ "signed ::= NK_PLUS NK_FLOAT", + /* 295 */ "signed ::= NK_MINUS NK_FLOAT", + /* 296 */ "signed_literal ::= signed", + /* 297 */ "signed_literal ::= NK_STRING", + /* 298 */ "signed_literal ::= NK_BOOL", + /* 299 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 300 */ "signed_literal ::= duration_literal", + /* 301 */ "signed_literal ::= NULL", + /* 302 */ "signed_literal ::= literal_func", + /* 303 */ "literal_list ::= signed_literal", + /* 304 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 305 */ "db_name ::= NK_ID", + /* 306 */ "table_name ::= NK_ID", + /* 307 */ "column_name ::= NK_ID", + /* 308 */ "function_name ::= NK_ID", + /* 309 */ "table_alias ::= NK_ID", + /* 310 */ "column_alias ::= NK_ID", + /* 311 */ "user_name ::= NK_ID", + /* 312 */ "index_name ::= NK_ID", + /* 313 */ "topic_name ::= NK_ID", + /* 314 */ "stream_name ::= NK_ID", + /* 315 */ "cgroup_name ::= NK_ID", + /* 316 */ "expression ::= literal", + /* 317 */ "expression ::= pseudo_column", + /* 318 */ "expression ::= column_reference", + /* 319 */ "expression ::= function_expression", + /* 320 */ "expression ::= subquery", + /* 321 */ "expression ::= NK_LP expression NK_RP", + /* 322 */ "expression ::= NK_PLUS expression", + /* 323 */ "expression ::= NK_MINUS expression", + /* 324 */ "expression ::= expression NK_PLUS expression", + /* 325 */ "expression ::= expression NK_MINUS expression", + /* 326 */ "expression ::= expression NK_STAR expression", + /* 327 */ "expression ::= expression NK_SLASH expression", + /* 328 */ "expression ::= expression NK_REM expression", + /* 329 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 330 */ "expression ::= expression NK_BITAND expression", + /* 331 */ "expression ::= expression NK_BITOR expression", + /* 332 */ "expression_list ::= expression", + /* 333 */ "expression_list ::= expression_list NK_COMMA expression", + /* 334 */ "column_reference ::= column_name", + /* 335 */ "column_reference ::= table_name NK_DOT column_name", + /* 336 */ "pseudo_column ::= ROWTS", + /* 337 */ "pseudo_column ::= TBNAME", + /* 338 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 339 */ "pseudo_column ::= QSTARTTS", + /* 340 */ "pseudo_column ::= QENDTS", + /* 341 */ "pseudo_column ::= WSTARTTS", + /* 342 */ "pseudo_column ::= WENDTS", + /* 343 */ "pseudo_column ::= WDURATION", + /* 344 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 345 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 346 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 347 */ "function_expression ::= literal_func", + /* 348 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 349 */ "literal_func ::= NOW", + /* 350 */ "noarg_func ::= NOW", + /* 351 */ "noarg_func ::= TODAY", + /* 352 */ "noarg_func ::= TIMEZONE", + /* 353 */ "star_func ::= COUNT", + /* 354 */ "star_func ::= FIRST", + /* 355 */ "star_func ::= LAST", + /* 356 */ "star_func ::= LAST_ROW", + /* 357 */ "star_func_para_list ::= NK_STAR", + /* 358 */ "star_func_para_list ::= other_para_list", + /* 359 */ "other_para_list ::= star_func_para", + /* 360 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 361 */ "star_func_para ::= expression", + /* 362 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 363 */ "predicate ::= expression compare_op expression", + /* 364 */ "predicate ::= expression BETWEEN expression AND expression", + /* 365 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 366 */ "predicate ::= expression IS NULL", + /* 367 */ "predicate ::= expression IS NOT NULL", + /* 368 */ "predicate ::= expression in_op in_predicate_value", + /* 369 */ "compare_op ::= NK_LT", + /* 370 */ "compare_op ::= NK_GT", + /* 371 */ "compare_op ::= NK_LE", + /* 372 */ "compare_op ::= NK_GE", + /* 373 */ "compare_op ::= NK_NE", + /* 374 */ "compare_op ::= NK_EQ", + /* 375 */ "compare_op ::= LIKE", + /* 376 */ "compare_op ::= NOT LIKE", + /* 377 */ "compare_op ::= MATCH", + /* 378 */ "compare_op ::= NMATCH", + /* 379 */ "compare_op ::= CONTAINS", + /* 380 */ "in_op ::= IN", + /* 381 */ "in_op ::= NOT IN", + /* 382 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 383 */ "boolean_value_expression ::= boolean_primary", + /* 384 */ "boolean_value_expression ::= NOT boolean_primary", + /* 385 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 386 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 387 */ "boolean_primary ::= predicate", + /* 388 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 389 */ "common_expression ::= expression", + /* 390 */ "common_expression ::= boolean_value_expression", + /* 391 */ "from_clause_opt ::=", + /* 392 */ "from_clause_opt ::= FROM table_reference_list", + /* 393 */ "table_reference_list ::= table_reference", + /* 394 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 395 */ "table_reference ::= table_primary", + /* 396 */ "table_reference ::= joined_table", + /* 397 */ "table_primary ::= table_name alias_opt", + /* 398 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 399 */ "table_primary ::= subquery alias_opt", + /* 400 */ "table_primary ::= parenthesized_joined_table", + /* 401 */ "alias_opt ::=", + /* 402 */ "alias_opt ::= table_alias", + /* 403 */ "alias_opt ::= AS table_alias", + /* 404 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 405 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 406 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 407 */ "join_type ::=", + /* 408 */ "join_type ::= INNER", + /* 409 */ "query_specification ::= SELECT set_quantifier_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", + /* 410 */ "set_quantifier_opt ::=", + /* 411 */ "set_quantifier_opt ::= DISTINCT", + /* 412 */ "set_quantifier_opt ::= ALL", + /* 413 */ "select_list ::= NK_STAR", + /* 414 */ "select_list ::= select_sublist", + /* 415 */ "select_sublist ::= select_item", + /* 416 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 417 */ "select_item ::= common_expression", + /* 418 */ "select_item ::= common_expression column_alias", + /* 419 */ "select_item ::= common_expression AS column_alias", + /* 420 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 421 */ "where_clause_opt ::=", + /* 422 */ "where_clause_opt ::= WHERE search_condition", + /* 423 */ "partition_by_clause_opt ::=", + /* 424 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 425 */ "twindow_clause_opt ::=", + /* 426 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 427 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 428 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 429 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 430 */ "sliding_opt ::=", + /* 431 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 432 */ "fill_opt ::=", + /* 433 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 434 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 435 */ "fill_mode ::= NONE", + /* 436 */ "fill_mode ::= PREV", + /* 437 */ "fill_mode ::= NULL", + /* 438 */ "fill_mode ::= LINEAR", + /* 439 */ "fill_mode ::= NEXT", + /* 440 */ "group_by_clause_opt ::=", + /* 441 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 442 */ "group_by_list ::= expression", + /* 443 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 444 */ "having_clause_opt ::=", + /* 445 */ "having_clause_opt ::= HAVING search_condition", + /* 446 */ "range_opt ::=", + /* 447 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", + /* 448 */ "every_opt ::=", + /* 449 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 450 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 451 */ "query_expression_body ::= query_primary", + /* 452 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 453 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 454 */ "query_primary ::= query_specification", + /* 455 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 456 */ "order_by_clause_opt ::=", + /* 457 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 458 */ "slimit_clause_opt ::=", + /* 459 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 460 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 461 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 462 */ "limit_clause_opt ::=", + /* 463 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 464 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 465 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 466 */ "subquery ::= NK_LP query_expression NK_RP", + /* 467 */ "search_condition ::= common_expression", + /* 468 */ "sort_specification_list ::= sort_specification", + /* 469 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 470 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 471 */ "ordering_specification_opt ::=", + /* 472 */ "ordering_specification_opt ::= ASC", + /* 473 */ "ordering_specification_opt ::= DESC", + /* 474 */ "null_ordering_opt ::=", + /* 475 */ "null_ordering_opt ::= NULLS FIRST", + /* 476 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2164,181 +2165,182 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 244: /* cmd */ - case 247: /* literal */ - case 258: /* db_options */ - case 260: /* alter_db_options */ - case 265: /* retention */ - case 266: /* full_table_name */ - case 269: /* table_options */ - case 273: /* alter_table_clause */ - case 274: /* alter_table_options */ - case 277: /* signed_literal */ - case 278: /* create_subtable_clause */ - case 281: /* drop_table_clause */ - case 284: /* column_def */ - case 288: /* duration_literal */ - case 289: /* rollup_func_name */ - case 291: /* col_name */ - case 292: /* db_name_cond_opt */ - case 293: /* like_pattern_opt */ - case 294: /* table_name_cond */ - case 295: /* from_db_opt */ - case 297: /* index_options */ - case 299: /* sliding_opt */ - case 300: /* func */ - case 303: /* query_expression */ - case 306: /* explain_options */ - case 310: /* stream_options */ - case 311: /* into_opt */ - case 313: /* where_clause_opt */ - case 314: /* signed */ - case 315: /* literal_func */ - case 318: /* expression */ - case 319: /* pseudo_column */ - case 320: /* column_reference */ - case 321: /* function_expression */ - case 322: /* subquery */ - case 327: /* star_func_para */ - case 328: /* predicate */ - case 331: /* in_predicate_value */ - case 332: /* boolean_value_expression */ - case 333: /* boolean_primary */ - case 334: /* common_expression */ - case 335: /* from_clause_opt */ - case 336: /* table_reference_list */ - case 337: /* table_reference */ - case 338: /* table_primary */ - case 339: /* joined_table */ - case 341: /* parenthesized_joined_table */ - case 343: /* search_condition */ - case 344: /* query_specification */ - case 348: /* range_opt */ - case 349: /* every_opt */ - case 350: /* fill_opt */ - case 351: /* twindow_clause_opt */ - case 353: /* having_clause_opt */ - case 355: /* select_item */ - case 358: /* query_expression_body */ - case 360: /* slimit_clause_opt */ - case 361: /* limit_clause_opt */ - case 362: /* query_primary */ - case 364: /* sort_specification */ + case 246: /* cmd */ + case 249: /* literal */ + case 260: /* db_options */ + case 262: /* alter_db_options */ + case 267: /* retention */ + case 268: /* full_table_name */ + case 271: /* table_options */ + case 275: /* alter_table_clause */ + case 276: /* alter_table_options */ + case 279: /* signed_literal */ + case 280: /* create_subtable_clause */ + case 283: /* drop_table_clause */ + case 286: /* column_def */ + case 290: /* duration_literal */ + case 291: /* rollup_func_name */ + case 293: /* col_name */ + case 294: /* db_name_cond_opt */ + case 295: /* like_pattern_opt */ + case 296: /* table_name_cond */ + case 297: /* from_db_opt */ + case 299: /* index_options */ + case 301: /* sliding_opt */ + case 302: /* sma_stream_opt */ + case 303: /* func */ + case 305: /* stream_options */ + case 307: /* query_expression */ + case 310: /* explain_options */ + case 314: /* into_opt */ + case 316: /* where_clause_opt */ + case 317: /* signed */ + case 318: /* literal_func */ + case 321: /* expression */ + case 322: /* pseudo_column */ + case 323: /* column_reference */ + case 324: /* function_expression */ + case 325: /* subquery */ + case 330: /* star_func_para */ + case 331: /* predicate */ + case 334: /* in_predicate_value */ + case 335: /* boolean_value_expression */ + case 336: /* boolean_primary */ + case 337: /* common_expression */ + case 338: /* from_clause_opt */ + case 339: /* table_reference_list */ + case 340: /* table_reference */ + case 341: /* table_primary */ + case 342: /* joined_table */ + case 344: /* parenthesized_joined_table */ + case 346: /* search_condition */ + case 347: /* query_specification */ + case 351: /* range_opt */ + case 352: /* every_opt */ + case 353: /* fill_opt */ + case 354: /* twindow_clause_opt */ + case 356: /* having_clause_opt */ + case 358: /* select_item */ + case 361: /* query_expression_body */ + case 363: /* slimit_clause_opt */ + case 364: /* limit_clause_opt */ + case 365: /* query_primary */ + case 367: /* sort_specification */ { - nodesDestroyNode((yypminor->yy442)); + nodesDestroyNode((yypminor->yy452)); } break; - case 245: /* account_options */ - case 246: /* alter_account_options */ - case 248: /* alter_account_option */ - case 308: /* bufsize_opt */ + case 247: /* account_options */ + case 248: /* alter_account_options */ + case 250: /* alter_account_option */ + case 312: /* bufsize_opt */ { } break; - case 249: /* user_name */ - case 252: /* priv_level */ - case 255: /* db_name */ - case 256: /* dnode_endpoint */ - case 275: /* column_name */ - case 283: /* table_name */ - case 290: /* function_name */ - case 296: /* index_name */ - case 302: /* topic_name */ - case 304: /* cgroup_name */ - case 309: /* stream_name */ - case 316: /* table_alias */ - case 317: /* column_alias */ - case 323: /* star_func */ - case 325: /* noarg_func */ - case 340: /* alias_opt */ + case 251: /* user_name */ + case 254: /* priv_level */ + case 257: /* db_name */ + case 258: /* dnode_endpoint */ + case 277: /* column_name */ + case 285: /* table_name */ + case 292: /* function_name */ + case 298: /* index_name */ + case 306: /* topic_name */ + case 308: /* cgroup_name */ + case 313: /* stream_name */ + case 319: /* table_alias */ + case 320: /* column_alias */ + case 326: /* star_func */ + case 328: /* noarg_func */ + case 343: /* alias_opt */ { } break; - case 250: /* sysinfo_opt */ + case 252: /* sysinfo_opt */ { } break; - case 251: /* privileges */ - case 253: /* priv_type_list */ - case 254: /* priv_type */ + case 253: /* privileges */ + case 255: /* priv_type_list */ + case 256: /* priv_type */ { } break; - case 257: /* not_exists_opt */ - case 259: /* exists_opt */ - case 305: /* analyze_opt */ - case 307: /* agg_func_opt */ - case 345: /* set_quantifier_opt */ + case 259: /* not_exists_opt */ + case 261: /* exists_opt */ + case 309: /* analyze_opt */ + case 311: /* agg_func_opt */ + case 348: /* set_quantifier_opt */ { } break; - case 261: /* integer_list */ - case 262: /* variable_list */ - case 263: /* retention_list */ - case 267: /* column_def_list */ - case 268: /* tags_def_opt */ - case 270: /* multi_create_clause */ - case 271: /* tags_def */ - case 272: /* multi_drop_clause */ - case 279: /* specific_tags_opt */ - case 280: /* literal_list */ - case 282: /* col_name_list */ - case 285: /* duration_list */ - case 286: /* rollup_func_list */ - case 298: /* func_list */ - case 301: /* expression_list */ - case 312: /* dnode_list */ - case 324: /* star_func_para_list */ - case 326: /* other_para_list */ - case 346: /* select_list */ - case 347: /* partition_by_clause_opt */ - case 352: /* group_by_clause_opt */ - case 354: /* select_sublist */ - case 357: /* group_by_list */ - case 359: /* order_by_clause_opt */ - case 363: /* sort_specification_list */ + case 263: /* integer_list */ + case 264: /* variable_list */ + case 265: /* retention_list */ + case 269: /* column_def_list */ + case 270: /* tags_def_opt */ + case 272: /* multi_create_clause */ + case 273: /* tags_def */ + case 274: /* multi_drop_clause */ + case 281: /* specific_tags_opt */ + case 282: /* literal_list */ + case 284: /* col_name_list */ + case 287: /* duration_list */ + case 288: /* rollup_func_list */ + case 300: /* func_list */ + case 304: /* expression_list */ + case 315: /* dnode_list */ + case 327: /* star_func_para_list */ + case 329: /* other_para_list */ + case 349: /* select_list */ + case 350: /* partition_by_clause_opt */ + case 355: /* group_by_clause_opt */ + case 357: /* select_sublist */ + case 360: /* group_by_list */ + case 362: /* order_by_clause_opt */ + case 366: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy368)); + nodesDestroyList((yypminor->yy404)); } break; - case 264: /* alter_db_option */ - case 287: /* alter_table_option */ + case 266: /* alter_db_option */ + case 289: /* alter_table_option */ { } break; - case 276: /* type_name */ + case 278: /* type_name */ { } break; - case 329: /* compare_op */ - case 330: /* in_op */ + case 332: /* compare_op */ + case 333: /* in_op */ { } break; - case 342: /* join_type */ + case 345: /* join_type */ { } break; - case 356: /* fill_mode */ + case 359: /* fill_mode */ { } break; - case 365: /* ordering_specification_opt */ + case 368: /* ordering_specification_opt */ { } break; - case 366: /* null_ordering_opt */ + case 369: /* null_ordering_opt */ { } @@ -2637,479 +2639,483 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 244, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 244, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 245, 0 }, /* (2) account_options ::= */ - { 245, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 245, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 245, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 245, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 245, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 245, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 245, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 245, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 245, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 246, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 246, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 248, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 248, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 248, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 248, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 248, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 248, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 248, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 248, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 248, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 248, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 244, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 244, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 244, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 244, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 244, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 250, 0 }, /* (29) sysinfo_opt ::= */ - { 250, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 244, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 244, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 251, -1 }, /* (33) privileges ::= ALL */ - { 251, -1 }, /* (34) privileges ::= priv_type_list */ - { 253, -1 }, /* (35) priv_type_list ::= priv_type */ - { 253, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 254, -1 }, /* (37) priv_type ::= READ */ - { 254, -1 }, /* (38) priv_type ::= WRITE */ - { 252, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 252, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ - { 244, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ - { 244, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 244, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ - { 244, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ - { 244, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 244, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 244, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ - { 244, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 256, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ - { 256, -1 }, /* (50) dnode_endpoint ::= NK_ID */ - { 256, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ - { 244, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ - { 244, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 244, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 244, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 244, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ - { 244, -2 }, /* (64) cmd ::= USE db_name */ - { 244, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 257, -3 }, /* (66) not_exists_opt ::= IF NOT EXISTS */ - { 257, 0 }, /* (67) not_exists_opt ::= */ - { 259, -2 }, /* (68) exists_opt ::= IF EXISTS */ - { 259, 0 }, /* (69) exists_opt ::= */ - { 258, 0 }, /* (70) db_options ::= */ - { 258, -3 }, /* (71) db_options ::= db_options BUFFER NK_INTEGER */ - { 258, -3 }, /* (72) db_options ::= db_options CACHELAST NK_INTEGER */ - { 258, -3 }, /* (73) db_options ::= db_options COMP NK_INTEGER */ - { 258, -3 }, /* (74) db_options ::= db_options DURATION NK_INTEGER */ - { 258, -3 }, /* (75) db_options ::= db_options DURATION NK_VARIABLE */ - { 258, -3 }, /* (76) db_options ::= db_options FSYNC NK_INTEGER */ - { 258, -3 }, /* (77) db_options ::= db_options MAXROWS NK_INTEGER */ - { 258, -3 }, /* (78) db_options ::= db_options MINROWS NK_INTEGER */ - { 258, -3 }, /* (79) db_options ::= db_options KEEP integer_list */ - { 258, -3 }, /* (80) db_options ::= db_options KEEP variable_list */ - { 258, -3 }, /* (81) db_options ::= db_options PAGES NK_INTEGER */ - { 258, -3 }, /* (82) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 258, -3 }, /* (83) db_options ::= db_options PRECISION NK_STRING */ - { 258, -3 }, /* (84) db_options ::= db_options REPLICA NK_INTEGER */ - { 258, -3 }, /* (85) db_options ::= db_options STRICT NK_INTEGER */ - { 258, -3 }, /* (86) db_options ::= db_options WAL NK_INTEGER */ - { 258, -3 }, /* (87) db_options ::= db_options VGROUPS NK_INTEGER */ - { 258, -3 }, /* (88) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 258, -3 }, /* (89) db_options ::= db_options RETENTIONS retention_list */ - { 258, -3 }, /* (90) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 260, -1 }, /* (91) alter_db_options ::= alter_db_option */ - { 260, -2 }, /* (92) alter_db_options ::= alter_db_options alter_db_option */ - { 264, -2 }, /* (93) alter_db_option ::= BUFFER NK_INTEGER */ - { 264, -2 }, /* (94) alter_db_option ::= CACHELAST NK_INTEGER */ - { 264, -2 }, /* (95) alter_db_option ::= FSYNC NK_INTEGER */ - { 264, -2 }, /* (96) alter_db_option ::= KEEP integer_list */ - { 264, -2 }, /* (97) alter_db_option ::= KEEP variable_list */ - { 264, -2 }, /* (98) alter_db_option ::= PAGES NK_INTEGER */ - { 264, -2 }, /* (99) alter_db_option ::= REPLICA NK_INTEGER */ - { 264, -2 }, /* (100) alter_db_option ::= STRICT NK_INTEGER */ - { 264, -2 }, /* (101) alter_db_option ::= WAL NK_INTEGER */ - { 261, -1 }, /* (102) integer_list ::= NK_INTEGER */ - { 261, -3 }, /* (103) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 262, -1 }, /* (104) variable_list ::= NK_VARIABLE */ - { 262, -3 }, /* (105) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 263, -1 }, /* (106) retention_list ::= retention */ - { 263, -3 }, /* (107) retention_list ::= retention_list NK_COMMA retention */ - { 265, -3 }, /* (108) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 244, -9 }, /* (109) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 244, -3 }, /* (110) cmd ::= CREATE TABLE multi_create_clause */ - { 244, -9 }, /* (111) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 244, -3 }, /* (112) cmd ::= DROP TABLE multi_drop_clause */ - { 244, -4 }, /* (113) cmd ::= DROP STABLE exists_opt full_table_name */ - { 244, -3 }, /* (114) cmd ::= ALTER TABLE alter_table_clause */ - { 244, -3 }, /* (115) cmd ::= ALTER STABLE alter_table_clause */ - { 273, -2 }, /* (116) alter_table_clause ::= full_table_name alter_table_options */ - { 273, -5 }, /* (117) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 273, -4 }, /* (118) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 273, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 273, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 273, -5 }, /* (121) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 273, -4 }, /* (122) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 273, -5 }, /* (123) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 273, -5 }, /* (124) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 273, -6 }, /* (125) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 270, -1 }, /* (126) multi_create_clause ::= create_subtable_clause */ - { 270, -2 }, /* (127) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 278, -10 }, /* (128) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ - { 272, -1 }, /* (129) multi_drop_clause ::= drop_table_clause */ - { 272, -2 }, /* (130) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 281, -2 }, /* (131) drop_table_clause ::= exists_opt full_table_name */ - { 279, 0 }, /* (132) specific_tags_opt ::= */ - { 279, -3 }, /* (133) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 266, -1 }, /* (134) full_table_name ::= table_name */ - { 266, -3 }, /* (135) full_table_name ::= db_name NK_DOT table_name */ - { 267, -1 }, /* (136) column_def_list ::= column_def */ - { 267, -3 }, /* (137) column_def_list ::= column_def_list NK_COMMA column_def */ - { 284, -2 }, /* (138) column_def ::= column_name type_name */ - { 284, -4 }, /* (139) column_def ::= column_name type_name COMMENT NK_STRING */ - { 276, -1 }, /* (140) type_name ::= BOOL */ - { 276, -1 }, /* (141) type_name ::= TINYINT */ - { 276, -1 }, /* (142) type_name ::= SMALLINT */ - { 276, -1 }, /* (143) type_name ::= INT */ - { 276, -1 }, /* (144) type_name ::= INTEGER */ - { 276, -1 }, /* (145) type_name ::= BIGINT */ - { 276, -1 }, /* (146) type_name ::= FLOAT */ - { 276, -1 }, /* (147) type_name ::= DOUBLE */ - { 276, -4 }, /* (148) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 276, -1 }, /* (149) type_name ::= TIMESTAMP */ - { 276, -4 }, /* (150) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 276, -2 }, /* (151) type_name ::= TINYINT UNSIGNED */ - { 276, -2 }, /* (152) type_name ::= SMALLINT UNSIGNED */ - { 276, -2 }, /* (153) type_name ::= INT UNSIGNED */ - { 276, -2 }, /* (154) type_name ::= BIGINT UNSIGNED */ - { 276, -1 }, /* (155) type_name ::= JSON */ - { 276, -4 }, /* (156) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 276, -1 }, /* (157) type_name ::= MEDIUMBLOB */ - { 276, -1 }, /* (158) type_name ::= BLOB */ - { 276, -4 }, /* (159) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 276, -1 }, /* (160) type_name ::= DECIMAL */ - { 276, -4 }, /* (161) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 276, -6 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 268, 0 }, /* (163) tags_def_opt ::= */ - { 268, -1 }, /* (164) tags_def_opt ::= tags_def */ - { 271, -4 }, /* (165) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 269, 0 }, /* (166) table_options ::= */ - { 269, -3 }, /* (167) table_options ::= table_options COMMENT NK_STRING */ - { 269, -3 }, /* (168) table_options ::= table_options MAX_DELAY duration_list */ - { 269, -3 }, /* (169) table_options ::= table_options WATERMARK duration_list */ - { 269, -5 }, /* (170) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 269, -3 }, /* (171) table_options ::= table_options TTL NK_INTEGER */ - { 269, -5 }, /* (172) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 274, -1 }, /* (173) alter_table_options ::= alter_table_option */ - { 274, -2 }, /* (174) alter_table_options ::= alter_table_options alter_table_option */ - { 287, -2 }, /* (175) alter_table_option ::= COMMENT NK_STRING */ - { 287, -2 }, /* (176) alter_table_option ::= TTL NK_INTEGER */ - { 285, -1 }, /* (177) duration_list ::= duration_literal */ - { 285, -3 }, /* (178) duration_list ::= duration_list NK_COMMA duration_literal */ - { 286, -1 }, /* (179) rollup_func_list ::= rollup_func_name */ - { 286, -3 }, /* (180) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 289, -1 }, /* (181) rollup_func_name ::= function_name */ - { 289, -1 }, /* (182) rollup_func_name ::= FIRST */ - { 289, -1 }, /* (183) rollup_func_name ::= LAST */ - { 282, -1 }, /* (184) col_name_list ::= col_name */ - { 282, -3 }, /* (185) col_name_list ::= col_name_list NK_COMMA col_name */ - { 291, -1 }, /* (186) col_name ::= column_name */ - { 244, -2 }, /* (187) cmd ::= SHOW DNODES */ - { 244, -2 }, /* (188) cmd ::= SHOW USERS */ - { 244, -2 }, /* (189) cmd ::= SHOW DATABASES */ - { 244, -4 }, /* (190) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 244, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 244, -3 }, /* (192) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 244, -2 }, /* (193) cmd ::= SHOW MNODES */ - { 244, -2 }, /* (194) cmd ::= SHOW MODULES */ - { 244, -2 }, /* (195) cmd ::= SHOW QNODES */ - { 244, -2 }, /* (196) cmd ::= SHOW FUNCTIONS */ - { 244, -5 }, /* (197) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 244, -2 }, /* (198) cmd ::= SHOW STREAMS */ - { 244, -2 }, /* (199) cmd ::= SHOW ACCOUNTS */ - { 244, -2 }, /* (200) cmd ::= SHOW APPS */ - { 244, -2 }, /* (201) cmd ::= SHOW CONNECTIONS */ - { 244, -2 }, /* (202) cmd ::= SHOW LICENCE */ - { 244, -2 }, /* (203) cmd ::= SHOW GRANTS */ - { 244, -4 }, /* (204) cmd ::= SHOW CREATE DATABASE db_name */ - { 244, -4 }, /* (205) cmd ::= SHOW CREATE TABLE full_table_name */ - { 244, -4 }, /* (206) cmd ::= SHOW CREATE STABLE full_table_name */ - { 244, -2 }, /* (207) cmd ::= SHOW QUERIES */ - { 244, -2 }, /* (208) cmd ::= SHOW SCORES */ - { 244, -2 }, /* (209) cmd ::= SHOW TOPICS */ - { 244, -2 }, /* (210) cmd ::= SHOW VARIABLES */ - { 244, -3 }, /* (211) cmd ::= SHOW LOCAL VARIABLES */ - { 244, -4 }, /* (212) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 244, -2 }, /* (213) cmd ::= SHOW BNODES */ - { 244, -2 }, /* (214) cmd ::= SHOW SNODES */ - { 244, -2 }, /* (215) cmd ::= SHOW CLUSTER */ - { 244, -2 }, /* (216) cmd ::= SHOW TRANSACTIONS */ - { 244, -4 }, /* (217) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 292, 0 }, /* (218) db_name_cond_opt ::= */ - { 292, -2 }, /* (219) db_name_cond_opt ::= db_name NK_DOT */ - { 293, 0 }, /* (220) like_pattern_opt ::= */ - { 293, -2 }, /* (221) like_pattern_opt ::= LIKE NK_STRING */ - { 294, -1 }, /* (222) table_name_cond ::= table_name */ - { 295, 0 }, /* (223) from_db_opt ::= */ - { 295, -2 }, /* (224) from_db_opt ::= FROM db_name */ - { 244, -8 }, /* (225) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 244, -4 }, /* (226) cmd ::= DROP INDEX exists_opt index_name */ - { 297, 0 }, /* (227) index_options ::= */ - { 297, -9 }, /* (228) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 297, -11 }, /* (229) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 298, -1 }, /* (230) func_list ::= func */ - { 298, -3 }, /* (231) func_list ::= func_list NK_COMMA func */ - { 300, -4 }, /* (232) func ::= function_name NK_LP expression_list NK_RP */ - { 244, -6 }, /* (233) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 244, -7 }, /* (234) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 244, -9 }, /* (235) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 244, -7 }, /* (236) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 244, -9 }, /* (237) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 244, -4 }, /* (238) cmd ::= DROP TOPIC exists_opt topic_name */ - { 244, -7 }, /* (239) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 244, -2 }, /* (240) cmd ::= DESC full_table_name */ - { 244, -2 }, /* (241) cmd ::= DESCRIBE full_table_name */ - { 244, -3 }, /* (242) cmd ::= RESET QUERY CACHE */ - { 244, -4 }, /* (243) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 305, 0 }, /* (244) analyze_opt ::= */ - { 305, -1 }, /* (245) analyze_opt ::= ANALYZE */ - { 306, 0 }, /* (246) explain_options ::= */ - { 306, -3 }, /* (247) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 306, -3 }, /* (248) explain_options ::= explain_options RATIO NK_FLOAT */ - { 244, -6 }, /* (249) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 244, -10 }, /* (250) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 244, -4 }, /* (251) cmd ::= DROP FUNCTION exists_opt function_name */ - { 307, 0 }, /* (252) agg_func_opt ::= */ - { 307, -1 }, /* (253) agg_func_opt ::= AGGREGATE */ - { 308, 0 }, /* (254) bufsize_opt ::= */ - { 308, -2 }, /* (255) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 244, -8 }, /* (256) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 244, -4 }, /* (257) cmd ::= DROP STREAM exists_opt stream_name */ - { 311, 0 }, /* (258) into_opt ::= */ - { 311, -2 }, /* (259) into_opt ::= INTO full_table_name */ - { 310, 0 }, /* (260) stream_options ::= */ - { 310, -3 }, /* (261) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 310, -3 }, /* (262) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 310, -4 }, /* (263) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 310, -3 }, /* (264) stream_options ::= stream_options WATERMARK duration_literal */ - { 244, -3 }, /* (265) cmd ::= KILL CONNECTION NK_INTEGER */ - { 244, -3 }, /* (266) cmd ::= KILL QUERY NK_STRING */ - { 244, -3 }, /* (267) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 244, -2 }, /* (268) cmd ::= BALANCE VGROUP */ - { 244, -4 }, /* (269) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 244, -4 }, /* (270) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 244, -3 }, /* (271) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 312, -2 }, /* (272) dnode_list ::= DNODE NK_INTEGER */ - { 312, -3 }, /* (273) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 244, -3 }, /* (274) cmd ::= SYNCDB db_name REPLICA */ - { 244, -4 }, /* (275) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 244, -1 }, /* (276) cmd ::= query_expression */ - { 247, -1 }, /* (277) literal ::= NK_INTEGER */ - { 247, -1 }, /* (278) literal ::= NK_FLOAT */ - { 247, -1 }, /* (279) literal ::= NK_STRING */ - { 247, -1 }, /* (280) literal ::= NK_BOOL */ - { 247, -2 }, /* (281) literal ::= TIMESTAMP NK_STRING */ - { 247, -1 }, /* (282) literal ::= duration_literal */ - { 247, -1 }, /* (283) literal ::= NULL */ - { 247, -1 }, /* (284) literal ::= NK_QUESTION */ - { 288, -1 }, /* (285) duration_literal ::= NK_VARIABLE */ - { 314, -1 }, /* (286) signed ::= NK_INTEGER */ - { 314, -2 }, /* (287) signed ::= NK_PLUS NK_INTEGER */ - { 314, -2 }, /* (288) signed ::= NK_MINUS NK_INTEGER */ - { 314, -1 }, /* (289) signed ::= NK_FLOAT */ - { 314, -2 }, /* (290) signed ::= NK_PLUS NK_FLOAT */ - { 314, -2 }, /* (291) signed ::= NK_MINUS NK_FLOAT */ - { 277, -1 }, /* (292) signed_literal ::= signed */ - { 277, -1 }, /* (293) signed_literal ::= NK_STRING */ - { 277, -1 }, /* (294) signed_literal ::= NK_BOOL */ - { 277, -2 }, /* (295) signed_literal ::= TIMESTAMP NK_STRING */ - { 277, -1 }, /* (296) signed_literal ::= duration_literal */ - { 277, -1 }, /* (297) signed_literal ::= NULL */ - { 277, -1 }, /* (298) signed_literal ::= literal_func */ - { 280, -1 }, /* (299) literal_list ::= signed_literal */ - { 280, -3 }, /* (300) literal_list ::= literal_list NK_COMMA signed_literal */ - { 255, -1 }, /* (301) db_name ::= NK_ID */ - { 283, -1 }, /* (302) table_name ::= NK_ID */ - { 275, -1 }, /* (303) column_name ::= NK_ID */ - { 290, -1 }, /* (304) function_name ::= NK_ID */ - { 316, -1 }, /* (305) table_alias ::= NK_ID */ - { 317, -1 }, /* (306) column_alias ::= NK_ID */ - { 249, -1 }, /* (307) user_name ::= NK_ID */ - { 296, -1 }, /* (308) index_name ::= NK_ID */ - { 302, -1 }, /* (309) topic_name ::= NK_ID */ - { 309, -1 }, /* (310) stream_name ::= NK_ID */ - { 304, -1 }, /* (311) cgroup_name ::= NK_ID */ - { 318, -1 }, /* (312) expression ::= literal */ - { 318, -1 }, /* (313) expression ::= pseudo_column */ - { 318, -1 }, /* (314) expression ::= column_reference */ - { 318, -1 }, /* (315) expression ::= function_expression */ - { 318, -1 }, /* (316) expression ::= subquery */ - { 318, -3 }, /* (317) expression ::= NK_LP expression NK_RP */ - { 318, -2 }, /* (318) expression ::= NK_PLUS expression */ - { 318, -2 }, /* (319) expression ::= NK_MINUS expression */ - { 318, -3 }, /* (320) expression ::= expression NK_PLUS expression */ - { 318, -3 }, /* (321) expression ::= expression NK_MINUS expression */ - { 318, -3 }, /* (322) expression ::= expression NK_STAR expression */ - { 318, -3 }, /* (323) expression ::= expression NK_SLASH expression */ - { 318, -3 }, /* (324) expression ::= expression NK_REM expression */ - { 318, -3 }, /* (325) expression ::= column_reference NK_ARROW NK_STRING */ - { 318, -3 }, /* (326) expression ::= expression NK_BITAND expression */ - { 318, -3 }, /* (327) expression ::= expression NK_BITOR expression */ - { 301, -1 }, /* (328) expression_list ::= expression */ - { 301, -3 }, /* (329) expression_list ::= expression_list NK_COMMA expression */ - { 320, -1 }, /* (330) column_reference ::= column_name */ - { 320, -3 }, /* (331) column_reference ::= table_name NK_DOT column_name */ - { 319, -1 }, /* (332) pseudo_column ::= ROWTS */ - { 319, -1 }, /* (333) pseudo_column ::= TBNAME */ - { 319, -3 }, /* (334) pseudo_column ::= table_name NK_DOT TBNAME */ - { 319, -1 }, /* (335) pseudo_column ::= QSTARTTS */ - { 319, -1 }, /* (336) pseudo_column ::= QENDTS */ - { 319, -1 }, /* (337) pseudo_column ::= WSTARTTS */ - { 319, -1 }, /* (338) pseudo_column ::= WENDTS */ - { 319, -1 }, /* (339) pseudo_column ::= WDURATION */ - { 321, -4 }, /* (340) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 321, -4 }, /* (341) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 321, -6 }, /* (342) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 321, -1 }, /* (343) function_expression ::= literal_func */ - { 315, -3 }, /* (344) literal_func ::= noarg_func NK_LP NK_RP */ - { 315, -1 }, /* (345) literal_func ::= NOW */ - { 325, -1 }, /* (346) noarg_func ::= NOW */ - { 325, -1 }, /* (347) noarg_func ::= TODAY */ - { 325, -1 }, /* (348) noarg_func ::= TIMEZONE */ - { 323, -1 }, /* (349) star_func ::= COUNT */ - { 323, -1 }, /* (350) star_func ::= FIRST */ - { 323, -1 }, /* (351) star_func ::= LAST */ - { 323, -1 }, /* (352) star_func ::= LAST_ROW */ - { 324, -1 }, /* (353) star_func_para_list ::= NK_STAR */ - { 324, -1 }, /* (354) star_func_para_list ::= other_para_list */ - { 326, -1 }, /* (355) other_para_list ::= star_func_para */ - { 326, -3 }, /* (356) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 327, -1 }, /* (357) star_func_para ::= expression */ - { 327, -3 }, /* (358) star_func_para ::= table_name NK_DOT NK_STAR */ - { 328, -3 }, /* (359) predicate ::= expression compare_op expression */ - { 328, -5 }, /* (360) predicate ::= expression BETWEEN expression AND expression */ - { 328, -6 }, /* (361) predicate ::= expression NOT BETWEEN expression AND expression */ - { 328, -3 }, /* (362) predicate ::= expression IS NULL */ - { 328, -4 }, /* (363) predicate ::= expression IS NOT NULL */ - { 328, -3 }, /* (364) predicate ::= expression in_op in_predicate_value */ - { 329, -1 }, /* (365) compare_op ::= NK_LT */ - { 329, -1 }, /* (366) compare_op ::= NK_GT */ - { 329, -1 }, /* (367) compare_op ::= NK_LE */ - { 329, -1 }, /* (368) compare_op ::= NK_GE */ - { 329, -1 }, /* (369) compare_op ::= NK_NE */ - { 329, -1 }, /* (370) compare_op ::= NK_EQ */ - { 329, -1 }, /* (371) compare_op ::= LIKE */ - { 329, -2 }, /* (372) compare_op ::= NOT LIKE */ - { 329, -1 }, /* (373) compare_op ::= MATCH */ - { 329, -1 }, /* (374) compare_op ::= NMATCH */ - { 329, -1 }, /* (375) compare_op ::= CONTAINS */ - { 330, -1 }, /* (376) in_op ::= IN */ - { 330, -2 }, /* (377) in_op ::= NOT IN */ - { 331, -3 }, /* (378) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 332, -1 }, /* (379) boolean_value_expression ::= boolean_primary */ - { 332, -2 }, /* (380) boolean_value_expression ::= NOT boolean_primary */ - { 332, -3 }, /* (381) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 332, -3 }, /* (382) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 333, -1 }, /* (383) boolean_primary ::= predicate */ - { 333, -3 }, /* (384) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 334, -1 }, /* (385) common_expression ::= expression */ - { 334, -1 }, /* (386) common_expression ::= boolean_value_expression */ - { 335, 0 }, /* (387) from_clause_opt ::= */ - { 335, -2 }, /* (388) from_clause_opt ::= FROM table_reference_list */ - { 336, -1 }, /* (389) table_reference_list ::= table_reference */ - { 336, -3 }, /* (390) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 337, -1 }, /* (391) table_reference ::= table_primary */ - { 337, -1 }, /* (392) table_reference ::= joined_table */ - { 338, -2 }, /* (393) table_primary ::= table_name alias_opt */ - { 338, -4 }, /* (394) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 338, -2 }, /* (395) table_primary ::= subquery alias_opt */ - { 338, -1 }, /* (396) table_primary ::= parenthesized_joined_table */ - { 340, 0 }, /* (397) alias_opt ::= */ - { 340, -1 }, /* (398) alias_opt ::= table_alias */ - { 340, -2 }, /* (399) alias_opt ::= AS table_alias */ - { 341, -3 }, /* (400) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 341, -3 }, /* (401) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 339, -6 }, /* (402) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 342, 0 }, /* (403) join_type ::= */ - { 342, -1 }, /* (404) join_type ::= INNER */ - { 344, -12 }, /* (405) query_specification ::= SELECT set_quantifier_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 */ - { 345, 0 }, /* (406) set_quantifier_opt ::= */ - { 345, -1 }, /* (407) set_quantifier_opt ::= DISTINCT */ - { 345, -1 }, /* (408) set_quantifier_opt ::= ALL */ - { 346, -1 }, /* (409) select_list ::= NK_STAR */ - { 346, -1 }, /* (410) select_list ::= select_sublist */ - { 354, -1 }, /* (411) select_sublist ::= select_item */ - { 354, -3 }, /* (412) select_sublist ::= select_sublist NK_COMMA select_item */ - { 355, -1 }, /* (413) select_item ::= common_expression */ - { 355, -2 }, /* (414) select_item ::= common_expression column_alias */ - { 355, -3 }, /* (415) select_item ::= common_expression AS column_alias */ - { 355, -3 }, /* (416) select_item ::= table_name NK_DOT NK_STAR */ - { 313, 0 }, /* (417) where_clause_opt ::= */ - { 313, -2 }, /* (418) where_clause_opt ::= WHERE search_condition */ - { 347, 0 }, /* (419) partition_by_clause_opt ::= */ - { 347, -3 }, /* (420) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 351, 0 }, /* (421) twindow_clause_opt ::= */ - { 351, -6 }, /* (422) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 351, -4 }, /* (423) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 351, -6 }, /* (424) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 351, -8 }, /* (425) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 299, 0 }, /* (426) sliding_opt ::= */ - { 299, -4 }, /* (427) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 350, 0 }, /* (428) fill_opt ::= */ - { 350, -4 }, /* (429) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 350, -6 }, /* (430) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 356, -1 }, /* (431) fill_mode ::= NONE */ - { 356, -1 }, /* (432) fill_mode ::= PREV */ - { 356, -1 }, /* (433) fill_mode ::= NULL */ - { 356, -1 }, /* (434) fill_mode ::= LINEAR */ - { 356, -1 }, /* (435) fill_mode ::= NEXT */ - { 352, 0 }, /* (436) group_by_clause_opt ::= */ - { 352, -3 }, /* (437) group_by_clause_opt ::= GROUP BY group_by_list */ - { 357, -1 }, /* (438) group_by_list ::= expression */ - { 357, -3 }, /* (439) group_by_list ::= group_by_list NK_COMMA expression */ - { 353, 0 }, /* (440) having_clause_opt ::= */ - { 353, -2 }, /* (441) having_clause_opt ::= HAVING search_condition */ - { 348, 0 }, /* (442) range_opt ::= */ - { 348, -6 }, /* (443) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ - { 349, 0 }, /* (444) every_opt ::= */ - { 349, -4 }, /* (445) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 303, -4 }, /* (446) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 358, -1 }, /* (447) query_expression_body ::= query_primary */ - { 358, -4 }, /* (448) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 358, -3 }, /* (449) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 362, -1 }, /* (450) query_primary ::= query_specification */ - { 362, -6 }, /* (451) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 359, 0 }, /* (452) order_by_clause_opt ::= */ - { 359, -3 }, /* (453) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 360, 0 }, /* (454) slimit_clause_opt ::= */ - { 360, -2 }, /* (455) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 360, -4 }, /* (456) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 360, -4 }, /* (457) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 361, 0 }, /* (458) limit_clause_opt ::= */ - { 361, -2 }, /* (459) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 361, -4 }, /* (460) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 361, -4 }, /* (461) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 322, -3 }, /* (462) subquery ::= NK_LP query_expression NK_RP */ - { 343, -1 }, /* (463) search_condition ::= common_expression */ - { 363, -1 }, /* (464) sort_specification_list ::= sort_specification */ - { 363, -3 }, /* (465) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 364, -3 }, /* (466) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 365, 0 }, /* (467) ordering_specification_opt ::= */ - { 365, -1 }, /* (468) ordering_specification_opt ::= ASC */ - { 365, -1 }, /* (469) ordering_specification_opt ::= DESC */ - { 366, 0 }, /* (470) null_ordering_opt ::= */ - { 366, -2 }, /* (471) null_ordering_opt ::= NULLS FIRST */ - { 366, -2 }, /* (472) null_ordering_opt ::= NULLS LAST */ + { 246, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 246, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 247, 0 }, /* (2) account_options ::= */ + { 247, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 247, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 247, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 247, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 247, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 247, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 247, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 247, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 247, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 248, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 248, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 250, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 250, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 250, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 250, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 250, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 250, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 250, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 250, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 250, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 250, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 246, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 246, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 246, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 246, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 246, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 252, 0 }, /* (29) sysinfo_opt ::= */ + { 252, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 246, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 246, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 253, -1 }, /* (33) privileges ::= ALL */ + { 253, -1 }, /* (34) privileges ::= priv_type_list */ + { 255, -1 }, /* (35) priv_type_list ::= priv_type */ + { 255, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 256, -1 }, /* (37) priv_type ::= READ */ + { 256, -1 }, /* (38) priv_type ::= WRITE */ + { 254, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 254, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ + { 246, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ + { 246, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 246, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ + { 246, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ + { 246, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 246, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 246, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ + { 246, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 258, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ + { 258, -1 }, /* (50) dnode_endpoint ::= NK_ID */ + { 258, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ + { 246, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ + { 246, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 246, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 246, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 246, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ + { 246, -2 }, /* (64) cmd ::= USE db_name */ + { 246, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 259, -3 }, /* (66) not_exists_opt ::= IF NOT EXISTS */ + { 259, 0 }, /* (67) not_exists_opt ::= */ + { 261, -2 }, /* (68) exists_opt ::= IF EXISTS */ + { 261, 0 }, /* (69) exists_opt ::= */ + { 260, 0 }, /* (70) db_options ::= */ + { 260, -3 }, /* (71) db_options ::= db_options BUFFER NK_INTEGER */ + { 260, -3 }, /* (72) db_options ::= db_options CACHELAST NK_INTEGER */ + { 260, -3 }, /* (73) db_options ::= db_options COMP NK_INTEGER */ + { 260, -3 }, /* (74) db_options ::= db_options DURATION NK_INTEGER */ + { 260, -3 }, /* (75) db_options ::= db_options DURATION NK_VARIABLE */ + { 260, -3 }, /* (76) db_options ::= db_options FSYNC NK_INTEGER */ + { 260, -3 }, /* (77) db_options ::= db_options MAXROWS NK_INTEGER */ + { 260, -3 }, /* (78) db_options ::= db_options MINROWS NK_INTEGER */ + { 260, -3 }, /* (79) db_options ::= db_options KEEP integer_list */ + { 260, -3 }, /* (80) db_options ::= db_options KEEP variable_list */ + { 260, -3 }, /* (81) db_options ::= db_options PAGES NK_INTEGER */ + { 260, -3 }, /* (82) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 260, -3 }, /* (83) db_options ::= db_options PRECISION NK_STRING */ + { 260, -3 }, /* (84) db_options ::= db_options REPLICA NK_INTEGER */ + { 260, -3 }, /* (85) db_options ::= db_options STRICT NK_INTEGER */ + { 260, -3 }, /* (86) db_options ::= db_options WAL NK_INTEGER */ + { 260, -3 }, /* (87) db_options ::= db_options VGROUPS NK_INTEGER */ + { 260, -3 }, /* (88) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 260, -3 }, /* (89) db_options ::= db_options RETENTIONS retention_list */ + { 260, -3 }, /* (90) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 262, -1 }, /* (91) alter_db_options ::= alter_db_option */ + { 262, -2 }, /* (92) alter_db_options ::= alter_db_options alter_db_option */ + { 266, -2 }, /* (93) alter_db_option ::= BUFFER NK_INTEGER */ + { 266, -2 }, /* (94) alter_db_option ::= CACHELAST NK_INTEGER */ + { 266, -2 }, /* (95) alter_db_option ::= FSYNC NK_INTEGER */ + { 266, -2 }, /* (96) alter_db_option ::= KEEP integer_list */ + { 266, -2 }, /* (97) alter_db_option ::= KEEP variable_list */ + { 266, -2 }, /* (98) alter_db_option ::= PAGES NK_INTEGER */ + { 266, -2 }, /* (99) alter_db_option ::= REPLICA NK_INTEGER */ + { 266, -2 }, /* (100) alter_db_option ::= STRICT NK_INTEGER */ + { 266, -2 }, /* (101) alter_db_option ::= WAL NK_INTEGER */ + { 263, -1 }, /* (102) integer_list ::= NK_INTEGER */ + { 263, -3 }, /* (103) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 264, -1 }, /* (104) variable_list ::= NK_VARIABLE */ + { 264, -3 }, /* (105) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 265, -1 }, /* (106) retention_list ::= retention */ + { 265, -3 }, /* (107) retention_list ::= retention_list NK_COMMA retention */ + { 267, -3 }, /* (108) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 246, -9 }, /* (109) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 246, -3 }, /* (110) cmd ::= CREATE TABLE multi_create_clause */ + { 246, -9 }, /* (111) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 246, -3 }, /* (112) cmd ::= DROP TABLE multi_drop_clause */ + { 246, -4 }, /* (113) cmd ::= DROP STABLE exists_opt full_table_name */ + { 246, -3 }, /* (114) cmd ::= ALTER TABLE alter_table_clause */ + { 246, -3 }, /* (115) cmd ::= ALTER STABLE alter_table_clause */ + { 275, -2 }, /* (116) alter_table_clause ::= full_table_name alter_table_options */ + { 275, -5 }, /* (117) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 275, -4 }, /* (118) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 275, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 275, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 275, -5 }, /* (121) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 275, -4 }, /* (122) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 275, -5 }, /* (123) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 275, -5 }, /* (124) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 275, -6 }, /* (125) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 272, -1 }, /* (126) multi_create_clause ::= create_subtable_clause */ + { 272, -2 }, /* (127) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 280, -10 }, /* (128) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ + { 274, -1 }, /* (129) multi_drop_clause ::= drop_table_clause */ + { 274, -2 }, /* (130) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 283, -2 }, /* (131) drop_table_clause ::= exists_opt full_table_name */ + { 281, 0 }, /* (132) specific_tags_opt ::= */ + { 281, -3 }, /* (133) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 268, -1 }, /* (134) full_table_name ::= table_name */ + { 268, -3 }, /* (135) full_table_name ::= db_name NK_DOT table_name */ + { 269, -1 }, /* (136) column_def_list ::= column_def */ + { 269, -3 }, /* (137) column_def_list ::= column_def_list NK_COMMA column_def */ + { 286, -2 }, /* (138) column_def ::= column_name type_name */ + { 286, -4 }, /* (139) column_def ::= column_name type_name COMMENT NK_STRING */ + { 278, -1 }, /* (140) type_name ::= BOOL */ + { 278, -1 }, /* (141) type_name ::= TINYINT */ + { 278, -1 }, /* (142) type_name ::= SMALLINT */ + { 278, -1 }, /* (143) type_name ::= INT */ + { 278, -1 }, /* (144) type_name ::= INTEGER */ + { 278, -1 }, /* (145) type_name ::= BIGINT */ + { 278, -1 }, /* (146) type_name ::= FLOAT */ + { 278, -1 }, /* (147) type_name ::= DOUBLE */ + { 278, -4 }, /* (148) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 278, -1 }, /* (149) type_name ::= TIMESTAMP */ + { 278, -4 }, /* (150) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 278, -2 }, /* (151) type_name ::= TINYINT UNSIGNED */ + { 278, -2 }, /* (152) type_name ::= SMALLINT UNSIGNED */ + { 278, -2 }, /* (153) type_name ::= INT UNSIGNED */ + { 278, -2 }, /* (154) type_name ::= BIGINT UNSIGNED */ + { 278, -1 }, /* (155) type_name ::= JSON */ + { 278, -4 }, /* (156) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 278, -1 }, /* (157) type_name ::= MEDIUMBLOB */ + { 278, -1 }, /* (158) type_name ::= BLOB */ + { 278, -4 }, /* (159) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 278, -1 }, /* (160) type_name ::= DECIMAL */ + { 278, -4 }, /* (161) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 278, -6 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 270, 0 }, /* (163) tags_def_opt ::= */ + { 270, -1 }, /* (164) tags_def_opt ::= tags_def */ + { 273, -4 }, /* (165) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 271, 0 }, /* (166) table_options ::= */ + { 271, -3 }, /* (167) table_options ::= table_options COMMENT NK_STRING */ + { 271, -3 }, /* (168) table_options ::= table_options MAX_DELAY duration_list */ + { 271, -3 }, /* (169) table_options ::= table_options WATERMARK duration_list */ + { 271, -5 }, /* (170) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 271, -3 }, /* (171) table_options ::= table_options TTL NK_INTEGER */ + { 271, -5 }, /* (172) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 276, -1 }, /* (173) alter_table_options ::= alter_table_option */ + { 276, -2 }, /* (174) alter_table_options ::= alter_table_options alter_table_option */ + { 289, -2 }, /* (175) alter_table_option ::= COMMENT NK_STRING */ + { 289, -2 }, /* (176) alter_table_option ::= TTL NK_INTEGER */ + { 287, -1 }, /* (177) duration_list ::= duration_literal */ + { 287, -3 }, /* (178) duration_list ::= duration_list NK_COMMA duration_literal */ + { 288, -1 }, /* (179) rollup_func_list ::= rollup_func_name */ + { 288, -3 }, /* (180) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 291, -1 }, /* (181) rollup_func_name ::= function_name */ + { 291, -1 }, /* (182) rollup_func_name ::= FIRST */ + { 291, -1 }, /* (183) rollup_func_name ::= LAST */ + { 284, -1 }, /* (184) col_name_list ::= col_name */ + { 284, -3 }, /* (185) col_name_list ::= col_name_list NK_COMMA col_name */ + { 293, -1 }, /* (186) col_name ::= column_name */ + { 246, -2 }, /* (187) cmd ::= SHOW DNODES */ + { 246, -2 }, /* (188) cmd ::= SHOW USERS */ + { 246, -2 }, /* (189) cmd ::= SHOW DATABASES */ + { 246, -4 }, /* (190) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 246, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 246, -3 }, /* (192) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 246, -2 }, /* (193) cmd ::= SHOW MNODES */ + { 246, -2 }, /* (194) cmd ::= SHOW MODULES */ + { 246, -2 }, /* (195) cmd ::= SHOW QNODES */ + { 246, -2 }, /* (196) cmd ::= SHOW FUNCTIONS */ + { 246, -5 }, /* (197) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 246, -2 }, /* (198) cmd ::= SHOW STREAMS */ + { 246, -2 }, /* (199) cmd ::= SHOW ACCOUNTS */ + { 246, -2 }, /* (200) cmd ::= SHOW APPS */ + { 246, -2 }, /* (201) cmd ::= SHOW CONNECTIONS */ + { 246, -2 }, /* (202) cmd ::= SHOW LICENCE */ + { 246, -2 }, /* (203) cmd ::= SHOW GRANTS */ + { 246, -4 }, /* (204) cmd ::= SHOW CREATE DATABASE db_name */ + { 246, -4 }, /* (205) cmd ::= SHOW CREATE TABLE full_table_name */ + { 246, -4 }, /* (206) cmd ::= SHOW CREATE STABLE full_table_name */ + { 246, -2 }, /* (207) cmd ::= SHOW QUERIES */ + { 246, -2 }, /* (208) cmd ::= SHOW SCORES */ + { 246, -2 }, /* (209) cmd ::= SHOW TOPICS */ + { 246, -2 }, /* (210) cmd ::= SHOW VARIABLES */ + { 246, -3 }, /* (211) cmd ::= SHOW LOCAL VARIABLES */ + { 246, -4 }, /* (212) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 246, -2 }, /* (213) cmd ::= SHOW BNODES */ + { 246, -2 }, /* (214) cmd ::= SHOW SNODES */ + { 246, -2 }, /* (215) cmd ::= SHOW CLUSTER */ + { 246, -2 }, /* (216) cmd ::= SHOW TRANSACTIONS */ + { 246, -4 }, /* (217) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 246, -2 }, /* (218) cmd ::= SHOW CONSUMERS */ + { 246, -2 }, /* (219) cmd ::= SHOW SUBSCRIPTIONS */ + { 294, 0 }, /* (220) db_name_cond_opt ::= */ + { 294, -2 }, /* (221) db_name_cond_opt ::= db_name NK_DOT */ + { 295, 0 }, /* (222) like_pattern_opt ::= */ + { 295, -2 }, /* (223) like_pattern_opt ::= LIKE NK_STRING */ + { 296, -1 }, /* (224) table_name_cond ::= table_name */ + { 297, 0 }, /* (225) from_db_opt ::= */ + { 297, -2 }, /* (226) from_db_opt ::= FROM db_name */ + { 246, -8 }, /* (227) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 246, -4 }, /* (228) cmd ::= DROP INDEX exists_opt index_name */ + { 299, -10 }, /* (229) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 299, -12 }, /* (230) 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 */ + { 300, -1 }, /* (231) func_list ::= func */ + { 300, -3 }, /* (232) func_list ::= func_list NK_COMMA func */ + { 303, -4 }, /* (233) func ::= function_name NK_LP expression_list NK_RP */ + { 302, 0 }, /* (234) sma_stream_opt ::= */ + { 302, -3 }, /* (235) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 302, -3 }, /* (236) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 246, -6 }, /* (237) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 246, -7 }, /* (238) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 246, -9 }, /* (239) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 246, -7 }, /* (240) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 246, -9 }, /* (241) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 246, -4 }, /* (242) cmd ::= DROP TOPIC exists_opt topic_name */ + { 246, -7 }, /* (243) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 246, -2 }, /* (244) cmd ::= DESC full_table_name */ + { 246, -2 }, /* (245) cmd ::= DESCRIBE full_table_name */ + { 246, -3 }, /* (246) cmd ::= RESET QUERY CACHE */ + { 246, -4 }, /* (247) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 309, 0 }, /* (248) analyze_opt ::= */ + { 309, -1 }, /* (249) analyze_opt ::= ANALYZE */ + { 310, 0 }, /* (250) explain_options ::= */ + { 310, -3 }, /* (251) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 310, -3 }, /* (252) explain_options ::= explain_options RATIO NK_FLOAT */ + { 246, -6 }, /* (253) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 246, -10 }, /* (254) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 246, -4 }, /* (255) cmd ::= DROP FUNCTION exists_opt function_name */ + { 311, 0 }, /* (256) agg_func_opt ::= */ + { 311, -1 }, /* (257) agg_func_opt ::= AGGREGATE */ + { 312, 0 }, /* (258) bufsize_opt ::= */ + { 312, -2 }, /* (259) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 246, -8 }, /* (260) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 246, -4 }, /* (261) cmd ::= DROP STREAM exists_opt stream_name */ + { 314, 0 }, /* (262) into_opt ::= */ + { 314, -2 }, /* (263) into_opt ::= INTO full_table_name */ + { 305, 0 }, /* (264) stream_options ::= */ + { 305, -3 }, /* (265) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 305, -3 }, /* (266) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 305, -4 }, /* (267) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 305, -3 }, /* (268) stream_options ::= stream_options WATERMARK duration_literal */ + { 246, -3 }, /* (269) cmd ::= KILL CONNECTION NK_INTEGER */ + { 246, -3 }, /* (270) cmd ::= KILL QUERY NK_STRING */ + { 246, -3 }, /* (271) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 246, -2 }, /* (272) cmd ::= BALANCE VGROUP */ + { 246, -4 }, /* (273) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 246, -4 }, /* (274) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 246, -3 }, /* (275) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 315, -2 }, /* (276) dnode_list ::= DNODE NK_INTEGER */ + { 315, -3 }, /* (277) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 246, -3 }, /* (278) cmd ::= SYNCDB db_name REPLICA */ + { 246, -4 }, /* (279) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 246, -1 }, /* (280) cmd ::= query_expression */ + { 249, -1 }, /* (281) literal ::= NK_INTEGER */ + { 249, -1 }, /* (282) literal ::= NK_FLOAT */ + { 249, -1 }, /* (283) literal ::= NK_STRING */ + { 249, -1 }, /* (284) literal ::= NK_BOOL */ + { 249, -2 }, /* (285) literal ::= TIMESTAMP NK_STRING */ + { 249, -1 }, /* (286) literal ::= duration_literal */ + { 249, -1 }, /* (287) literal ::= NULL */ + { 249, -1 }, /* (288) literal ::= NK_QUESTION */ + { 290, -1 }, /* (289) duration_literal ::= NK_VARIABLE */ + { 317, -1 }, /* (290) signed ::= NK_INTEGER */ + { 317, -2 }, /* (291) signed ::= NK_PLUS NK_INTEGER */ + { 317, -2 }, /* (292) signed ::= NK_MINUS NK_INTEGER */ + { 317, -1 }, /* (293) signed ::= NK_FLOAT */ + { 317, -2 }, /* (294) signed ::= NK_PLUS NK_FLOAT */ + { 317, -2 }, /* (295) signed ::= NK_MINUS NK_FLOAT */ + { 279, -1 }, /* (296) signed_literal ::= signed */ + { 279, -1 }, /* (297) signed_literal ::= NK_STRING */ + { 279, -1 }, /* (298) signed_literal ::= NK_BOOL */ + { 279, -2 }, /* (299) signed_literal ::= TIMESTAMP NK_STRING */ + { 279, -1 }, /* (300) signed_literal ::= duration_literal */ + { 279, -1 }, /* (301) signed_literal ::= NULL */ + { 279, -1 }, /* (302) signed_literal ::= literal_func */ + { 282, -1 }, /* (303) literal_list ::= signed_literal */ + { 282, -3 }, /* (304) literal_list ::= literal_list NK_COMMA signed_literal */ + { 257, -1 }, /* (305) db_name ::= NK_ID */ + { 285, -1 }, /* (306) table_name ::= NK_ID */ + { 277, -1 }, /* (307) column_name ::= NK_ID */ + { 292, -1 }, /* (308) function_name ::= NK_ID */ + { 319, -1 }, /* (309) table_alias ::= NK_ID */ + { 320, -1 }, /* (310) column_alias ::= NK_ID */ + { 251, -1 }, /* (311) user_name ::= NK_ID */ + { 298, -1 }, /* (312) index_name ::= NK_ID */ + { 306, -1 }, /* (313) topic_name ::= NK_ID */ + { 313, -1 }, /* (314) stream_name ::= NK_ID */ + { 308, -1 }, /* (315) cgroup_name ::= NK_ID */ + { 321, -1 }, /* (316) expression ::= literal */ + { 321, -1 }, /* (317) expression ::= pseudo_column */ + { 321, -1 }, /* (318) expression ::= column_reference */ + { 321, -1 }, /* (319) expression ::= function_expression */ + { 321, -1 }, /* (320) expression ::= subquery */ + { 321, -3 }, /* (321) expression ::= NK_LP expression NK_RP */ + { 321, -2 }, /* (322) expression ::= NK_PLUS expression */ + { 321, -2 }, /* (323) expression ::= NK_MINUS expression */ + { 321, -3 }, /* (324) expression ::= expression NK_PLUS expression */ + { 321, -3 }, /* (325) expression ::= expression NK_MINUS expression */ + { 321, -3 }, /* (326) expression ::= expression NK_STAR expression */ + { 321, -3 }, /* (327) expression ::= expression NK_SLASH expression */ + { 321, -3 }, /* (328) expression ::= expression NK_REM expression */ + { 321, -3 }, /* (329) expression ::= column_reference NK_ARROW NK_STRING */ + { 321, -3 }, /* (330) expression ::= expression NK_BITAND expression */ + { 321, -3 }, /* (331) expression ::= expression NK_BITOR expression */ + { 304, -1 }, /* (332) expression_list ::= expression */ + { 304, -3 }, /* (333) expression_list ::= expression_list NK_COMMA expression */ + { 323, -1 }, /* (334) column_reference ::= column_name */ + { 323, -3 }, /* (335) column_reference ::= table_name NK_DOT column_name */ + { 322, -1 }, /* (336) pseudo_column ::= ROWTS */ + { 322, -1 }, /* (337) pseudo_column ::= TBNAME */ + { 322, -3 }, /* (338) pseudo_column ::= table_name NK_DOT TBNAME */ + { 322, -1 }, /* (339) pseudo_column ::= QSTARTTS */ + { 322, -1 }, /* (340) pseudo_column ::= QENDTS */ + { 322, -1 }, /* (341) pseudo_column ::= WSTARTTS */ + { 322, -1 }, /* (342) pseudo_column ::= WENDTS */ + { 322, -1 }, /* (343) pseudo_column ::= WDURATION */ + { 324, -4 }, /* (344) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 324, -4 }, /* (345) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 324, -6 }, /* (346) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 324, -1 }, /* (347) function_expression ::= literal_func */ + { 318, -3 }, /* (348) literal_func ::= noarg_func NK_LP NK_RP */ + { 318, -1 }, /* (349) literal_func ::= NOW */ + { 328, -1 }, /* (350) noarg_func ::= NOW */ + { 328, -1 }, /* (351) noarg_func ::= TODAY */ + { 328, -1 }, /* (352) noarg_func ::= TIMEZONE */ + { 326, -1 }, /* (353) star_func ::= COUNT */ + { 326, -1 }, /* (354) star_func ::= FIRST */ + { 326, -1 }, /* (355) star_func ::= LAST */ + { 326, -1 }, /* (356) star_func ::= LAST_ROW */ + { 327, -1 }, /* (357) star_func_para_list ::= NK_STAR */ + { 327, -1 }, /* (358) star_func_para_list ::= other_para_list */ + { 329, -1 }, /* (359) other_para_list ::= star_func_para */ + { 329, -3 }, /* (360) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 330, -1 }, /* (361) star_func_para ::= expression */ + { 330, -3 }, /* (362) star_func_para ::= table_name NK_DOT NK_STAR */ + { 331, -3 }, /* (363) predicate ::= expression compare_op expression */ + { 331, -5 }, /* (364) predicate ::= expression BETWEEN expression AND expression */ + { 331, -6 }, /* (365) predicate ::= expression NOT BETWEEN expression AND expression */ + { 331, -3 }, /* (366) predicate ::= expression IS NULL */ + { 331, -4 }, /* (367) predicate ::= expression IS NOT NULL */ + { 331, -3 }, /* (368) predicate ::= expression in_op in_predicate_value */ + { 332, -1 }, /* (369) compare_op ::= NK_LT */ + { 332, -1 }, /* (370) compare_op ::= NK_GT */ + { 332, -1 }, /* (371) compare_op ::= NK_LE */ + { 332, -1 }, /* (372) compare_op ::= NK_GE */ + { 332, -1 }, /* (373) compare_op ::= NK_NE */ + { 332, -1 }, /* (374) compare_op ::= NK_EQ */ + { 332, -1 }, /* (375) compare_op ::= LIKE */ + { 332, -2 }, /* (376) compare_op ::= NOT LIKE */ + { 332, -1 }, /* (377) compare_op ::= MATCH */ + { 332, -1 }, /* (378) compare_op ::= NMATCH */ + { 332, -1 }, /* (379) compare_op ::= CONTAINS */ + { 333, -1 }, /* (380) in_op ::= IN */ + { 333, -2 }, /* (381) in_op ::= NOT IN */ + { 334, -3 }, /* (382) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 335, -1 }, /* (383) boolean_value_expression ::= boolean_primary */ + { 335, -2 }, /* (384) boolean_value_expression ::= NOT boolean_primary */ + { 335, -3 }, /* (385) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 335, -3 }, /* (386) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 336, -1 }, /* (387) boolean_primary ::= predicate */ + { 336, -3 }, /* (388) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 337, -1 }, /* (389) common_expression ::= expression */ + { 337, -1 }, /* (390) common_expression ::= boolean_value_expression */ + { 338, 0 }, /* (391) from_clause_opt ::= */ + { 338, -2 }, /* (392) from_clause_opt ::= FROM table_reference_list */ + { 339, -1 }, /* (393) table_reference_list ::= table_reference */ + { 339, -3 }, /* (394) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 340, -1 }, /* (395) table_reference ::= table_primary */ + { 340, -1 }, /* (396) table_reference ::= joined_table */ + { 341, -2 }, /* (397) table_primary ::= table_name alias_opt */ + { 341, -4 }, /* (398) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 341, -2 }, /* (399) table_primary ::= subquery alias_opt */ + { 341, -1 }, /* (400) table_primary ::= parenthesized_joined_table */ + { 343, 0 }, /* (401) alias_opt ::= */ + { 343, -1 }, /* (402) alias_opt ::= table_alias */ + { 343, -2 }, /* (403) alias_opt ::= AS table_alias */ + { 344, -3 }, /* (404) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 344, -3 }, /* (405) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 342, -6 }, /* (406) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 345, 0 }, /* (407) join_type ::= */ + { 345, -1 }, /* (408) join_type ::= INNER */ + { 347, -12 }, /* (409) query_specification ::= SELECT set_quantifier_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 */ + { 348, 0 }, /* (410) set_quantifier_opt ::= */ + { 348, -1 }, /* (411) set_quantifier_opt ::= DISTINCT */ + { 348, -1 }, /* (412) set_quantifier_opt ::= ALL */ + { 349, -1 }, /* (413) select_list ::= NK_STAR */ + { 349, -1 }, /* (414) select_list ::= select_sublist */ + { 357, -1 }, /* (415) select_sublist ::= select_item */ + { 357, -3 }, /* (416) select_sublist ::= select_sublist NK_COMMA select_item */ + { 358, -1 }, /* (417) select_item ::= common_expression */ + { 358, -2 }, /* (418) select_item ::= common_expression column_alias */ + { 358, -3 }, /* (419) select_item ::= common_expression AS column_alias */ + { 358, -3 }, /* (420) select_item ::= table_name NK_DOT NK_STAR */ + { 316, 0 }, /* (421) where_clause_opt ::= */ + { 316, -2 }, /* (422) where_clause_opt ::= WHERE search_condition */ + { 350, 0 }, /* (423) partition_by_clause_opt ::= */ + { 350, -3 }, /* (424) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 354, 0 }, /* (425) twindow_clause_opt ::= */ + { 354, -6 }, /* (426) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 354, -4 }, /* (427) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 354, -6 }, /* (428) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 354, -8 }, /* (429) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 301, 0 }, /* (430) sliding_opt ::= */ + { 301, -4 }, /* (431) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 353, 0 }, /* (432) fill_opt ::= */ + { 353, -4 }, /* (433) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 353, -6 }, /* (434) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 359, -1 }, /* (435) fill_mode ::= NONE */ + { 359, -1 }, /* (436) fill_mode ::= PREV */ + { 359, -1 }, /* (437) fill_mode ::= NULL */ + { 359, -1 }, /* (438) fill_mode ::= LINEAR */ + { 359, -1 }, /* (439) fill_mode ::= NEXT */ + { 355, 0 }, /* (440) group_by_clause_opt ::= */ + { 355, -3 }, /* (441) group_by_clause_opt ::= GROUP BY group_by_list */ + { 360, -1 }, /* (442) group_by_list ::= expression */ + { 360, -3 }, /* (443) group_by_list ::= group_by_list NK_COMMA expression */ + { 356, 0 }, /* (444) having_clause_opt ::= */ + { 356, -2 }, /* (445) having_clause_opt ::= HAVING search_condition */ + { 351, 0 }, /* (446) range_opt ::= */ + { 351, -6 }, /* (447) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ + { 352, 0 }, /* (448) every_opt ::= */ + { 352, -4 }, /* (449) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 307, -4 }, /* (450) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 361, -1 }, /* (451) query_expression_body ::= query_primary */ + { 361, -4 }, /* (452) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 361, -3 }, /* (453) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 365, -1 }, /* (454) query_primary ::= query_specification */ + { 365, -6 }, /* (455) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 362, 0 }, /* (456) order_by_clause_opt ::= */ + { 362, -3 }, /* (457) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 363, 0 }, /* (458) slimit_clause_opt ::= */ + { 363, -2 }, /* (459) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 363, -4 }, /* (460) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 363, -4 }, /* (461) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 364, 0 }, /* (462) limit_clause_opt ::= */ + { 364, -2 }, /* (463) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 364, -4 }, /* (464) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 364, -4 }, /* (465) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 325, -3 }, /* (466) subquery ::= NK_LP query_expression NK_RP */ + { 346, -1 }, /* (467) search_condition ::= common_expression */ + { 366, -1 }, /* (468) sort_specification_list ::= sort_specification */ + { 366, -3 }, /* (469) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 367, -3 }, /* (470) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 368, 0 }, /* (471) ordering_specification_opt ::= */ + { 368, -1 }, /* (472) ordering_specification_opt ::= ASC */ + { 368, -1 }, /* (473) ordering_specification_opt ::= DESC */ + { 369, 0 }, /* (474) null_ordering_opt ::= */ + { 369, -2 }, /* (475) null_ordering_opt ::= NULLS FIRST */ + { 369, -2 }, /* (476) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3198,11 +3204,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,245,&yymsp[0].minor); + yy_destructor(yypParser,247,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,246,&yymsp[0].minor); + yy_destructor(yypParser,248,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3216,20 +3222,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,245,&yymsp[-2].minor); +{ yy_destructor(yypParser,247,&yymsp[-2].minor); { } - yy_destructor(yypParser,247,&yymsp[0].minor); + yy_destructor(yypParser,249,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,248,&yymsp[0].minor); +{ yy_destructor(yypParser,250,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,246,&yymsp[-1].minor); +{ yy_destructor(yypParser,248,&yymsp[-1].minor); { } - yy_destructor(yypParser,248,&yymsp[0].minor); + yy_destructor(yypParser,250,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3243,72 +3249,72 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,247,&yymsp[0].minor); + yy_destructor(yypParser,249,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy0, yymsp[0].minor.yy629); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy109, &yymsp[-1].minor.yy0, yymsp[0].minor.yy323); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy109, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy109, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy109, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy109); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy629 = 1; } +{ yymsp[1].minor.yy323 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy629 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy323 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy683, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy209, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy683, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy209, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy683 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy209 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); -{ yylhsminor.yy683 = yymsp[0].minor.yy683; } - yymsp[0].minor.yy683 = yylhsminor.yy683; +{ yylhsminor.yy209 = yymsp[0].minor.yy209; } + yymsp[0].minor.yy209 = yylhsminor.yy209; break; case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy683 = yymsp[-2].minor.yy683 | yymsp[0].minor.yy683; } - yymsp[-2].minor.yy683 = yylhsminor.yy683; +{ yylhsminor.yy209 = yymsp[-2].minor.yy209 | yymsp[0].minor.yy209; } + yymsp[-2].minor.yy209 = yylhsminor.yy209; break; case 37: /* priv_type ::= READ */ -{ yymsp[0].minor.yy683 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy209 = PRIVILEGE_TYPE_READ; } break; case 38: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy683 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy209 = PRIVILEGE_TYPE_WRITE; } break; case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy241 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy241 = yylhsminor.yy241; +{ yylhsminor.yy109 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy109 = yylhsminor.yy109; break; case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy241 = yymsp[-2].minor.yy241; } - yymsp[-2].minor.yy241 = yylhsminor.yy241; +{ yylhsminor.yy109 = yymsp[-2].minor.yy109; } + yymsp[-2].minor.yy109 = yylhsminor.yy109; break; case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy241, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy109, NULL); } break; case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 44: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy109); } break; case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3325,26 +3331,26 @@ static YYACTIONTYPE yy_reduce( case 49: /* dnode_endpoint ::= NK_STRING */ case 50: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==50); case 51: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==51); - case 301: /* db_name ::= NK_ID */ yytestcase(yyruleno==301); - case 302: /* table_name ::= NK_ID */ yytestcase(yyruleno==302); - case 303: /* column_name ::= NK_ID */ yytestcase(yyruleno==303); - case 304: /* function_name ::= NK_ID */ yytestcase(yyruleno==304); - case 305: /* table_alias ::= NK_ID */ yytestcase(yyruleno==305); - case 306: /* column_alias ::= NK_ID */ yytestcase(yyruleno==306); - case 307: /* user_name ::= NK_ID */ yytestcase(yyruleno==307); - case 308: /* index_name ::= NK_ID */ yytestcase(yyruleno==308); - case 309: /* topic_name ::= NK_ID */ yytestcase(yyruleno==309); - case 310: /* stream_name ::= NK_ID */ yytestcase(yyruleno==310); - case 311: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==311); - case 346: /* noarg_func ::= NOW */ yytestcase(yyruleno==346); - case 347: /* noarg_func ::= TODAY */ yytestcase(yyruleno==347); - case 348: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==348); - case 349: /* star_func ::= COUNT */ yytestcase(yyruleno==349); - case 350: /* star_func ::= FIRST */ yytestcase(yyruleno==350); - case 351: /* star_func ::= LAST */ yytestcase(yyruleno==351); - case 352: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==352); -{ yylhsminor.yy241 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy241 = yylhsminor.yy241; + case 305: /* db_name ::= NK_ID */ yytestcase(yyruleno==305); + case 306: /* table_name ::= NK_ID */ yytestcase(yyruleno==306); + case 307: /* column_name ::= NK_ID */ yytestcase(yyruleno==307); + case 308: /* function_name ::= NK_ID */ yytestcase(yyruleno==308); + case 309: /* table_alias ::= NK_ID */ yytestcase(yyruleno==309); + case 310: /* column_alias ::= NK_ID */ yytestcase(yyruleno==310); + case 311: /* user_name ::= NK_ID */ yytestcase(yyruleno==311); + case 312: /* index_name ::= NK_ID */ yytestcase(yyruleno==312); + case 313: /* topic_name ::= NK_ID */ yytestcase(yyruleno==313); + case 314: /* stream_name ::= NK_ID */ yytestcase(yyruleno==314); + case 315: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==315); + case 350: /* noarg_func ::= NOW */ yytestcase(yyruleno==350); + case 351: /* noarg_func ::= TODAY */ yytestcase(yyruleno==351); + case 352: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==352); + case 353: /* star_func ::= COUNT */ yytestcase(yyruleno==353); + case 354: /* star_func ::= FIRST */ yytestcase(yyruleno==354); + case 355: /* star_func ::= LAST */ yytestcase(yyruleno==355); + case 356: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==356); +{ yylhsminor.yy109 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy109 = yylhsminor.yy109; break; case 52: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3377,156 +3383,156 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy197, &yymsp[-1].minor.yy241, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy437, &yymsp[-1].minor.yy109, yymsp[0].minor.yy452); } break; case 63: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } break; case 64: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy109); } break; case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy241, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy109, yymsp[0].minor.yy452); } break; case 66: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy197 = true; } +{ yymsp[-2].minor.yy437 = true; } break; case 67: /* not_exists_opt ::= */ case 69: /* exists_opt ::= */ yytestcase(yyruleno==69); - case 244: /* analyze_opt ::= */ yytestcase(yyruleno==244); - case 252: /* agg_func_opt ::= */ yytestcase(yyruleno==252); - case 406: /* set_quantifier_opt ::= */ yytestcase(yyruleno==406); -{ yymsp[1].minor.yy197 = false; } + case 248: /* analyze_opt ::= */ yytestcase(yyruleno==248); + case 256: /* agg_func_opt ::= */ yytestcase(yyruleno==256); + case 410: /* set_quantifier_opt ::= */ yytestcase(yyruleno==410); +{ yymsp[1].minor.yy437 = false; } break; case 68: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy197 = true; } +{ yymsp[-1].minor.yy437 = true; } break; case 70: /* db_options ::= */ -{ yymsp[1].minor.yy442 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy452 = createDefaultDatabaseOptions(pCxt); } break; case 71: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 72: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 73: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 74: /* db_options ::= db_options DURATION NK_INTEGER */ case 75: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==75); -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 76: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 77: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 78: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 79: /* db_options ::= db_options KEEP integer_list */ case 80: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==80); -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_KEEP, yymsp[0].minor.yy368); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_KEEP, yymsp[0].minor.yy404); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 81: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 82: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 83: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 84: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 85: /* db_options ::= db_options STRICT NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 86: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 87: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 88: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 89: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_RETENTIONS, yymsp[0].minor.yy368); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_RETENTIONS, yymsp[0].minor.yy404); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 90: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setDatabaseOption(pCxt, yymsp[-2].minor.yy452, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 91: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy442 = createAlterDatabaseOptions(pCxt); yylhsminor.yy442 = setAlterDatabaseOption(pCxt, yylhsminor.yy442, &yymsp[0].minor.yy301); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterDatabaseOptions(pCxt); yylhsminor.yy452 = setAlterDatabaseOption(pCxt, yylhsminor.yy452, &yymsp[0].minor.yy85); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 92: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy442 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy442, &yymsp[0].minor.yy301); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy452, &yymsp[0].minor.yy85); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; case 93: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 94: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 95: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 96: /* alter_db_option ::= KEEP integer_list */ case 97: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==97); -{ yymsp[-1].minor.yy301.type = DB_OPTION_KEEP; yymsp[-1].minor.yy301.pList = yymsp[0].minor.yy368; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_KEEP; yymsp[-1].minor.yy85.pList = yymsp[0].minor.yy404; } break; case 98: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_PAGES; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_PAGES; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 99: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 100: /* alter_db_option ::= STRICT NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_STRICT; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_STRICT; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 101: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = DB_OPTION_WAL; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = DB_OPTION_WAL; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 102: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy368 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy368 = yylhsminor.yy368; +{ yylhsminor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; case 103: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 273: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==273); -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy368 = yylhsminor.yy368; + case 277: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==277); +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy404 = yylhsminor.yy404; break; case 104: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy368 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy368 = yylhsminor.yy368; +{ yylhsminor.yy404 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; case 105: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy368 = yylhsminor.yy368; +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy404 = yylhsminor.yy404; break; case 106: /* retention_list ::= retention */ case 126: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==126); @@ -3534,266 +3540,266 @@ static YYACTIONTYPE yy_reduce( case 136: /* column_def_list ::= column_def */ yytestcase(yyruleno==136); case 179: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==179); case 184: /* col_name_list ::= col_name */ yytestcase(yyruleno==184); - case 230: /* func_list ::= func */ yytestcase(yyruleno==230); - case 299: /* literal_list ::= signed_literal */ yytestcase(yyruleno==299); - case 355: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==355); - case 411: /* select_sublist ::= select_item */ yytestcase(yyruleno==411); - case 464: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==464); -{ yylhsminor.yy368 = createNodeList(pCxt, yymsp[0].minor.yy442); } - yymsp[0].minor.yy368 = yylhsminor.yy368; + case 231: /* func_list ::= func */ yytestcase(yyruleno==231); + case 303: /* literal_list ::= signed_literal */ yytestcase(yyruleno==303); + case 359: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==359); + case 415: /* select_sublist ::= select_item */ yytestcase(yyruleno==415); + case 468: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==468); +{ yylhsminor.yy404 = createNodeList(pCxt, yymsp[0].minor.yy452); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; case 107: /* retention_list ::= retention_list NK_COMMA retention */ case 137: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==137); case 180: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==180); case 185: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==185); - case 231: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==231); - case 300: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==300); - case 356: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==356); - case 412: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==412); - case 465: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==465); -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, yymsp[0].minor.yy442); } - yymsp[-2].minor.yy368 = yylhsminor.yy368; + case 232: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==232); + case 304: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==304); + case 360: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==360); + case 416: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==416); + case 469: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==469); +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, yymsp[0].minor.yy452); } + yymsp[-2].minor.yy404 = yylhsminor.yy404; break; case 108: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy442 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 109: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 111: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==111); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy197, yymsp[-5].minor.yy442, yymsp[-3].minor.yy368, yymsp[-1].minor.yy368, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy437, yymsp[-5].minor.yy452, yymsp[-3].minor.yy404, yymsp[-1].minor.yy404, yymsp[0].minor.yy452); } break; case 110: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy368); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy404); } break; case 112: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy368); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy404); } break; case 113: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy197, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy437, yymsp[0].minor.yy452); } break; case 114: /* cmd ::= ALTER TABLE alter_table_clause */ case 115: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==115); - case 276: /* cmd ::= query_expression */ yytestcase(yyruleno==276); -{ pCxt->pRootNode = yymsp[0].minor.yy442; } + case 280: /* cmd ::= query_expression */ yytestcase(yyruleno==280); +{ pCxt->pRootNode = yymsp[0].minor.yy452; } break; case 116: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy442 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; case 117: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 118: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy442 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy442, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy241); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy452, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy109); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; case 119: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 120: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy442 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 121: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 122: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy442 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy442, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy241); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy452, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy109); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; case 123: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 124: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy442 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy452, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 125: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy442 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy442, &yymsp[-2].minor.yy241, yymsp[0].minor.yy442); } - yymsp[-5].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy452, &yymsp[-2].minor.yy109, yymsp[0].minor.yy452); } + yymsp[-5].minor.yy452 = yylhsminor.yy452; break; case 127: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 130: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==130); -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-1].minor.yy368, yymsp[0].minor.yy442); } - yymsp[-1].minor.yy368 = yylhsminor.yy368; +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-1].minor.yy404, yymsp[0].minor.yy452); } + yymsp[-1].minor.yy404 = yylhsminor.yy404; break; case 128: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ -{ yylhsminor.yy442 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy197, yymsp[-8].minor.yy442, yymsp[-6].minor.yy442, yymsp[-5].minor.yy368, yymsp[-2].minor.yy368, yymsp[0].minor.yy442); } - yymsp[-9].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy437, yymsp[-8].minor.yy452, yymsp[-6].minor.yy452, yymsp[-5].minor.yy404, yymsp[-2].minor.yy404, yymsp[0].minor.yy452); } + yymsp[-9].minor.yy452 = yylhsminor.yy452; break; case 131: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy442 = createDropTableClause(pCxt, yymsp[-1].minor.yy197, yymsp[0].minor.yy442); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createDropTableClause(pCxt, yymsp[-1].minor.yy437, yymsp[0].minor.yy452); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; case 132: /* specific_tags_opt ::= */ case 163: /* tags_def_opt ::= */ yytestcase(yyruleno==163); - case 419: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==419); - case 436: /* group_by_clause_opt ::= */ yytestcase(yyruleno==436); - case 452: /* order_by_clause_opt ::= */ yytestcase(yyruleno==452); -{ yymsp[1].minor.yy368 = NULL; } + case 423: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==423); + case 440: /* group_by_clause_opt ::= */ yytestcase(yyruleno==440); + case 456: /* order_by_clause_opt ::= */ yytestcase(yyruleno==456); +{ yymsp[1].minor.yy404 = NULL; } break; case 133: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy368 = yymsp[-1].minor.yy368; } +{ yymsp[-2].minor.yy404 = yymsp[-1].minor.yy404; } break; case 134: /* full_table_name ::= table_name */ -{ yylhsminor.yy442 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy241, NULL); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy109, NULL); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 135: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy442 = createRealTableNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, NULL); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createRealTableNode(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109, NULL); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 138: /* column_def ::= column_name type_name */ -{ yylhsminor.yy442 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392, NULL); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy109, yymsp[0].minor.yy504, NULL); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; case 139: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy442 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-2].minor.yy392, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy109, yymsp[-2].minor.yy504, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; case 140: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 141: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 142: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 143: /* type_name ::= INT */ case 144: /* type_name ::= INTEGER */ yytestcase(yyruleno==144); -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_INT); } break; case 145: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 146: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 147: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 148: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 149: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 150: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 151: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 152: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 153: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 154: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy504 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 155: /* type_name ::= JSON */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 156: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 157: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 158: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 159: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy504 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 160: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 161: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy392 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 162: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy392 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy504 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 164: /* tags_def_opt ::= tags_def */ - case 354: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==354); - case 410: /* select_list ::= select_sublist */ yytestcase(yyruleno==410); -{ yylhsminor.yy368 = yymsp[0].minor.yy368; } - yymsp[0].minor.yy368 = yylhsminor.yy368; + case 358: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==358); + case 414: /* select_list ::= select_sublist */ yytestcase(yyruleno==414); +{ yylhsminor.yy404 = yymsp[0].minor.yy404; } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; case 165: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy368 = yymsp[-1].minor.yy368; } +{ yymsp[-3].minor.yy404 = yymsp[-1].minor.yy404; } break; case 166: /* table_options ::= */ -{ yymsp[1].minor.yy442 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy452 = createDefaultTableOptions(pCxt); } break; case 167: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 168: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy368); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy404); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 169: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy368); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy404); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 170: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-4].minor.yy442, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy368); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-4].minor.yy452, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy404); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 171: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-2].minor.yy452, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; case 172: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-4].minor.yy442, TABLE_OPTION_SMA, yymsp[-1].minor.yy368); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-4].minor.yy452, TABLE_OPTION_SMA, yymsp[-1].minor.yy404); } + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; case 173: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy442 = createAlterTableOptions(pCxt); yylhsminor.yy442 = setTableOption(pCxt, yylhsminor.yy442, yymsp[0].minor.yy301.type, &yymsp[0].minor.yy301.val); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createAlterTableOptions(pCxt); yylhsminor.yy452 = setTableOption(pCxt, yylhsminor.yy452, yymsp[0].minor.yy85.type, &yymsp[0].minor.yy85.val); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 174: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-1].minor.yy442, yymsp[0].minor.yy301.type, &yymsp[0].minor.yy301.val); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = setTableOption(pCxt, yymsp[-1].minor.yy452, yymsp[0].minor.yy85.type, &yymsp[0].minor.yy85.val); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; case 175: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy301.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 176: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy301.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy85.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy85.val = yymsp[0].minor.yy0; } break; case 177: /* duration_list ::= duration_literal */ - case 328: /* expression_list ::= expression */ yytestcase(yyruleno==328); -{ yylhsminor.yy368 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy442)); } - yymsp[0].minor.yy368 = yylhsminor.yy368; + case 332: /* expression_list ::= expression */ yytestcase(yyruleno==332); +{ yylhsminor.yy404 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; case 178: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 329: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==329); -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, releaseRawExprNode(pCxt, yymsp[0].minor.yy442)); } - yymsp[-2].minor.yy368 = yylhsminor.yy368; + case 333: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==333); +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); } + yymsp[-2].minor.yy404 = yylhsminor.yy404; break; case 181: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy442 = createFunctionNode(pCxt, &yymsp[0].minor.yy241, NULL); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[0].minor.yy109, NULL); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 182: /* rollup_func_name ::= FIRST */ case 183: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==183); -{ yylhsminor.yy442 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 186: /* col_name ::= column_name */ -{ yylhsminor.yy442 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241); } - yymsp[0].minor.yy442 = yylhsminor.yy442; +{ yylhsminor.yy452 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy109); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; case 187: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -3805,13 +3811,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; case 190: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy442, yymsp[0].minor.yy442, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy452, yymsp[0].minor.yy452, OP_TYPE_LIKE); } break; case 191: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy442, yymsp[0].minor.yy442, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy452, yymsp[0].minor.yy452, OP_TYPE_LIKE); } break; case 192: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy442, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy452, NULL, OP_TYPE_LIKE); } break; case 193: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -3826,7 +3832,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; case 197: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy442, yymsp[-1].minor.yy442, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy452, yymsp[-1].minor.yy452, OP_TYPE_EQUAL); } break; case 198: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -3845,13 +3851,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT); } break; case 204: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy241); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy109); } break; case 205: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy452); } break; case 206: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy452); } break; case 207: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -3884,697 +3890,708 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; case 217: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy442); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy452); } break; - case 218: /* db_name_cond_opt ::= */ - case 223: /* from_db_opt ::= */ yytestcase(yyruleno==223); -{ yymsp[1].minor.yy442 = createDefaultDatabaseCondValue(pCxt); } + case 218: /* cmd ::= SHOW CONSUMERS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 219: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy241); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + case 219: /* cmd ::= SHOW SUBSCRIPTIONS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 220: /* like_pattern_opt ::= */ - case 227: /* index_options ::= */ yytestcase(yyruleno==227); - case 258: /* into_opt ::= */ yytestcase(yyruleno==258); - case 387: /* from_clause_opt ::= */ yytestcase(yyruleno==387); - case 417: /* where_clause_opt ::= */ yytestcase(yyruleno==417); - case 421: /* twindow_clause_opt ::= */ yytestcase(yyruleno==421); - case 426: /* sliding_opt ::= */ yytestcase(yyruleno==426); - case 428: /* fill_opt ::= */ yytestcase(yyruleno==428); - case 440: /* having_clause_opt ::= */ yytestcase(yyruleno==440); - case 442: /* range_opt ::= */ yytestcase(yyruleno==442); - case 444: /* every_opt ::= */ yytestcase(yyruleno==444); - case 454: /* slimit_clause_opt ::= */ yytestcase(yyruleno==454); - case 458: /* limit_clause_opt ::= */ yytestcase(yyruleno==458); -{ yymsp[1].minor.yy442 = NULL; } + case 220: /* db_name_cond_opt ::= */ + case 225: /* from_db_opt ::= */ yytestcase(yyruleno==225); +{ yymsp[1].minor.yy452 = createDefaultDatabaseCondValue(pCxt); } break; - case 221: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 221: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy109); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 222: /* table_name_cond ::= table_name */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy241); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 222: /* like_pattern_opt ::= */ + case 262: /* into_opt ::= */ yytestcase(yyruleno==262); + case 391: /* from_clause_opt ::= */ yytestcase(yyruleno==391); + case 421: /* where_clause_opt ::= */ yytestcase(yyruleno==421); + case 425: /* twindow_clause_opt ::= */ yytestcase(yyruleno==425); + case 430: /* sliding_opt ::= */ yytestcase(yyruleno==430); + case 432: /* fill_opt ::= */ yytestcase(yyruleno==432); + case 444: /* having_clause_opt ::= */ yytestcase(yyruleno==444); + case 446: /* range_opt ::= */ yytestcase(yyruleno==446); + case 448: /* every_opt ::= */ yytestcase(yyruleno==448); + case 458: /* slimit_clause_opt ::= */ yytestcase(yyruleno==458); + case 462: /* limit_clause_opt ::= */ yytestcase(yyruleno==462); +{ yymsp[1].minor.yy452 = NULL; } break; - case 224: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy241); } + case 223: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 225: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy197, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, NULL, yymsp[0].minor.yy442); } + case 224: /* table_name_cond ::= table_name */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy109); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 226: /* cmd ::= DROP INDEX exists_opt index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } + case 226: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy109); } break; - case 228: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy442 = createIndexOption(pCxt, yymsp[-6].minor.yy368, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), NULL, yymsp[0].minor.yy442); } + case 227: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy437, &yymsp[-3].minor.yy109, &yymsp[-1].minor.yy109, NULL, yymsp[0].minor.yy452); } break; - case 229: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy442 = createIndexOption(pCxt, yymsp[-8].minor.yy368, releaseRawExprNode(pCxt, yymsp[-4].minor.yy442), releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), yymsp[0].minor.yy442); } + case 228: /* cmd ::= DROP INDEX exists_opt index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } break; - case 232: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy442 = createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy368); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + case 229: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy452 = createIndexOption(pCxt, yymsp[-7].minor.yy404, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), NULL, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } break; - case 233: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy197, &yymsp[-2].minor.yy241, yymsp[0].minor.yy442); } + case 230: /* 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 */ +{ yymsp[-11].minor.yy452 = createIndexOption(pCxt, yymsp[-9].minor.yy404, releaseRawExprNode(pCxt, yymsp[-5].minor.yy452), releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } break; - case 234: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy197, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy241, false); } + case 233: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy452 = createFunctionNode(pCxt, &yymsp[-3].minor.yy109, yymsp[-1].minor.yy404); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 235: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy197, &yymsp[-5].minor.yy241, &yymsp[0].minor.yy241, true); } + case 234: /* sma_stream_opt ::= */ + case 264: /* stream_options ::= */ yytestcase(yyruleno==264); +{ yymsp[1].minor.yy452 = createStreamOptions(pCxt); } break; - case 236: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy197, &yymsp[-3].minor.yy241, yymsp[0].minor.yy442, false); } + case 235: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ + case 268: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==268); +{ ((SStreamOptions*)yymsp[-2].minor.yy452)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); yylhsminor.yy452 = yymsp[-2].minor.yy452; } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 237: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy197, &yymsp[-5].minor.yy241, yymsp[0].minor.yy442, true); } + case 236: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy452)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); yylhsminor.yy452 = yymsp[-2].minor.yy452; } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 238: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } + case 237: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy437, &yymsp[-2].minor.yy109, yymsp[0].minor.yy452); } break; - case 239: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy197, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } + case 238: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy437, &yymsp[-3].minor.yy109, &yymsp[0].minor.yy109, false); } break; - case 240: /* cmd ::= DESC full_table_name */ - case 241: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==241); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy442); } + case 239: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy437, &yymsp[-5].minor.yy109, &yymsp[0].minor.yy109, true); } break; - case 242: /* cmd ::= RESET QUERY CACHE */ + case 240: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy437, &yymsp[-3].minor.yy109, yymsp[0].minor.yy452, false); } + break; + case 241: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy437, &yymsp[-5].minor.yy109, yymsp[0].minor.yy452, true); } + break; + case 242: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } + break; + case 243: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy437, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109); } + break; + case 244: /* cmd ::= DESC full_table_name */ + case 245: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==245); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy452); } + break; + case 246: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 243: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy197, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } + case 247: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy437, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } break; - case 245: /* analyze_opt ::= ANALYZE */ - case 253: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==253); - case 407: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==407); -{ yymsp[0].minor.yy197 = true; } + case 249: /* analyze_opt ::= ANALYZE */ + case 257: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==257); + case 411: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==411); +{ yymsp[0].minor.yy437 = true; } break; - case 246: /* explain_options ::= */ -{ yymsp[1].minor.yy442 = createDefaultExplainOptions(pCxt); } + case 250: /* explain_options ::= */ +{ yymsp[1].minor.yy452 = createDefaultExplainOptions(pCxt); } break; - case 247: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy442 = setExplainVerbose(pCxt, yymsp[-2].minor.yy442, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 251: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy452 = setExplainVerbose(pCxt, yymsp[-2].minor.yy452, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 248: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy442 = setExplainRatio(pCxt, yymsp[-2].minor.yy442, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 252: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy452 = setExplainRatio(pCxt, yymsp[-2].minor.yy452, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 249: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy368); } + case 253: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy404); } break; - case 250: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy197, yymsp[-8].minor.yy197, &yymsp[-5].minor.yy241, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy578); } + case 254: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy437, yymsp[-8].minor.yy437, &yymsp[-5].minor.yy109, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy504, yymsp[0].minor.yy100); } break; - case 251: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } + case 255: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } break; - case 254: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy578 = 0; } + case 258: /* bufsize_opt ::= */ +{ yymsp[1].minor.yy100 = 0; } break; - case 255: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy578 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 259: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy100 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 256: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy197, &yymsp[-4].minor.yy241, yymsp[-2].minor.yy442, yymsp[-3].minor.yy442, yymsp[0].minor.yy442); } + case 260: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy437, &yymsp[-4].minor.yy109, yymsp[-2].minor.yy452, yymsp[-3].minor.yy452, yymsp[0].minor.yy452); } break; - case 257: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } + case 261: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy437, &yymsp[0].minor.yy109); } break; - case 259: /* into_opt ::= INTO full_table_name */ - case 388: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==388); - case 418: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==418); - case 441: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==441); -{ yymsp[-1].minor.yy442 = yymsp[0].minor.yy442; } + case 263: /* into_opt ::= INTO full_table_name */ + case 392: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==392); + case 422: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==422); + case 445: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==445); +{ yymsp[-1].minor.yy452 = yymsp[0].minor.yy452; } break; - case 260: /* stream_options ::= */ -{ yymsp[1].minor.yy442 = createStreamOptions(pCxt); } + case 265: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy452)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy452 = yymsp[-2].minor.yy452; } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 261: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy442)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy442 = yymsp[-2].minor.yy442; } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 266: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy452)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy452 = yymsp[-2].minor.yy452; } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 262: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy442)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy442 = yymsp[-2].minor.yy442; } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 267: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy452)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy452)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); yylhsminor.yy452 = yymsp[-3].minor.yy452; } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 263: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy442)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy442)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy442); yylhsminor.yy442 = yymsp[-3].minor.yy442; } - yymsp[-3].minor.yy442 = yylhsminor.yy442; - break; - case 264: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy442)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy442); yylhsminor.yy442 = yymsp[-2].minor.yy442; } - yymsp[-2].minor.yy442 = yylhsminor.yy442; - break; - case 265: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 269: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 266: /* cmd ::= KILL QUERY NK_STRING */ + case 270: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 267: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 271: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 268: /* cmd ::= BALANCE VGROUP */ + case 272: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 269: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 273: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 270: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy368); } + case 274: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy404); } break; - case 271: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 275: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 272: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy368 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 276: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy404 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 274: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy241); } + case 278: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy109); } break; - case 275: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } + case 279: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } break; - case 277: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 281: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 278: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 282: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 279: /* literal ::= NK_STRING */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 283: /* literal ::= NK_STRING */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 280: /* literal ::= NK_BOOL */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 284: /* literal ::= NK_BOOL */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 281: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + case 285: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 282: /* literal ::= duration_literal */ - case 292: /* signed_literal ::= signed */ yytestcase(yyruleno==292); - case 312: /* expression ::= literal */ yytestcase(yyruleno==312); - case 313: /* expression ::= pseudo_column */ yytestcase(yyruleno==313); - case 314: /* expression ::= column_reference */ yytestcase(yyruleno==314); - case 315: /* expression ::= function_expression */ yytestcase(yyruleno==315); - case 316: /* expression ::= subquery */ yytestcase(yyruleno==316); - case 343: /* function_expression ::= literal_func */ yytestcase(yyruleno==343); - case 379: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==379); - case 383: /* boolean_primary ::= predicate */ yytestcase(yyruleno==383); - case 385: /* common_expression ::= expression */ yytestcase(yyruleno==385); - case 386: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==386); - case 389: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==389); - case 391: /* table_reference ::= table_primary */ yytestcase(yyruleno==391); - case 392: /* table_reference ::= joined_table */ yytestcase(yyruleno==392); - case 396: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==396); - case 447: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==447); - case 450: /* query_primary ::= query_specification */ yytestcase(yyruleno==450); -{ yylhsminor.yy442 = yymsp[0].minor.yy442; } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 286: /* literal ::= duration_literal */ + case 296: /* signed_literal ::= signed */ yytestcase(yyruleno==296); + case 316: /* expression ::= literal */ yytestcase(yyruleno==316); + case 317: /* expression ::= pseudo_column */ yytestcase(yyruleno==317); + case 318: /* expression ::= column_reference */ yytestcase(yyruleno==318); + case 319: /* expression ::= function_expression */ yytestcase(yyruleno==319); + case 320: /* expression ::= subquery */ yytestcase(yyruleno==320); + case 347: /* function_expression ::= literal_func */ yytestcase(yyruleno==347); + case 383: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==383); + case 387: /* boolean_primary ::= predicate */ yytestcase(yyruleno==387); + case 389: /* common_expression ::= expression */ yytestcase(yyruleno==389); + case 390: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==390); + case 393: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==393); + case 395: /* table_reference ::= table_primary */ yytestcase(yyruleno==395); + case 396: /* table_reference ::= joined_table */ yytestcase(yyruleno==396); + case 400: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==400); + case 451: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==451); + case 454: /* query_primary ::= query_specification */ yytestcase(yyruleno==454); +{ yylhsminor.yy452 = yymsp[0].minor.yy452; } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 283: /* literal ::= NULL */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 287: /* literal ::= NULL */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 284: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 288: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 285: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 289: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 286: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 290: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 287: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 291: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; - case 288: /* signed ::= NK_MINUS NK_INTEGER */ + case 292: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 289: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 293: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 290: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 294: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 291: /* signed ::= NK_MINUS NK_FLOAT */ + case 295: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 293: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 297: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 294: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 298: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 295: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 299: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 296: /* signed_literal ::= duration_literal */ - case 298: /* signed_literal ::= literal_func */ yytestcase(yyruleno==298); - case 357: /* star_func_para ::= expression */ yytestcase(yyruleno==357); - case 413: /* select_item ::= common_expression */ yytestcase(yyruleno==413); - case 463: /* search_condition ::= common_expression */ yytestcase(yyruleno==463); -{ yylhsminor.yy442 = releaseRawExprNode(pCxt, yymsp[0].minor.yy442); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 300: /* signed_literal ::= duration_literal */ + case 302: /* signed_literal ::= literal_func */ yytestcase(yyruleno==302); + case 361: /* star_func_para ::= expression */ yytestcase(yyruleno==361); + case 417: /* select_item ::= common_expression */ yytestcase(yyruleno==417); + case 467: /* search_condition ::= common_expression */ yytestcase(yyruleno==467); +{ yylhsminor.yy452 = releaseRawExprNode(pCxt, yymsp[0].minor.yy452); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 297: /* signed_literal ::= NULL */ -{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 301: /* signed_literal ::= NULL */ +{ yylhsminor.yy452 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 317: /* expression ::= NK_LP expression NK_RP */ - case 384: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==384); -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 321: /* expression ::= NK_LP expression NK_RP */ + case 388: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==388); +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 318: /* expression ::= NK_PLUS expression */ + case 322: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy442)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy452)); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 319: /* expression ::= NK_MINUS expression */ + case 323: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy442), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy452), NULL)); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 320: /* expression ::= expression NK_PLUS expression */ + case 324: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 321: /* expression ::= expression NK_MINUS expression */ + case 325: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 322: /* expression ::= expression NK_STAR expression */ + case 326: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 323: /* expression ::= expression NK_SLASH expression */ + case 327: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 324: /* expression ::= expression NK_REM expression */ + case 328: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 325: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 329: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 326: /* expression ::= expression NK_BITAND expression */ + case 330: /* expression ::= expression NK_BITAND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 327: /* expression ::= expression NK_BITOR expression */ + case 331: /* expression ::= expression NK_BITOR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 330: /* column_reference ::= column_name */ -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy241, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 334: /* column_reference ::= column_name */ +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy109, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy109)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 331: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 335: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109, createColumnNode(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy109)); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 332: /* pseudo_column ::= ROWTS */ - case 333: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==333); - case 335: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==335); - case 336: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==336); - case 337: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==337); - case 338: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==338); - case 339: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==339); - case 345: /* literal_func ::= NOW */ yytestcase(yyruleno==345); -{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy442 = yylhsminor.yy442; + case 336: /* pseudo_column ::= ROWTS */ + case 337: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==337); + case 339: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==339); + case 340: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==340); + case 341: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==341); + case 342: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==342); + case 343: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==343); + case 349: /* literal_func ::= NOW */ yytestcase(yyruleno==349); +{ yylhsminor.yy452 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy452 = yylhsminor.yy452; break; - case 334: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy241)))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 338: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy109)))); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 340: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 341: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==341); -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy368)); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + case 344: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 345: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==345); +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy109, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy109, yymsp[-1].minor.yy404)); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 342: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), yymsp[-1].minor.yy392)); } - yymsp[-5].minor.yy442 = yylhsminor.yy442; + case 346: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), yymsp[-1].minor.yy504)); } + yymsp[-5].minor.yy452 = yylhsminor.yy452; break; - case 344: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy241, NULL)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 348: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy109, NULL)); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 353: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy368 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy368 = yylhsminor.yy368; + case 357: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy404 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; - case 358: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 416: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==416); -{ yylhsminor.yy442 = createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 362: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 420: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==420); +{ yylhsminor.yy452 = createColumnNode(pCxt, &yymsp[-2].minor.yy109, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 359: /* predicate ::= expression compare_op expression */ - case 364: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==364); + case 363: /* predicate ::= expression compare_op expression */ + case 368: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==368); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy412, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy440, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 360: /* predicate ::= expression BETWEEN expression AND expression */ + case 364: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy442), releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy452), releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-4].minor.yy442 = yylhsminor.yy442; + yymsp[-4].minor.yy452 = yylhsminor.yy452; break; - case 361: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 365: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy442), releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy452), releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-5].minor.yy442 = yylhsminor.yy442; + yymsp[-5].minor.yy452 = yylhsminor.yy452; break; - case 362: /* predicate ::= expression IS NULL */ + case 366: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), NULL)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 363: /* predicate ::= expression IS NOT NULL */ + case 367: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), NULL)); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 365: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy412 = OP_TYPE_LOWER_THAN; } + case 369: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy440 = OP_TYPE_LOWER_THAN; } break; - case 366: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy412 = OP_TYPE_GREATER_THAN; } + case 370: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy440 = OP_TYPE_GREATER_THAN; } break; - case 367: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy412 = OP_TYPE_LOWER_EQUAL; } + case 371: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy440 = OP_TYPE_LOWER_EQUAL; } break; - case 368: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy412 = OP_TYPE_GREATER_EQUAL; } + case 372: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy440 = OP_TYPE_GREATER_EQUAL; } break; - case 369: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy412 = OP_TYPE_NOT_EQUAL; } + case 373: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy440 = OP_TYPE_NOT_EQUAL; } break; - case 370: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy412 = OP_TYPE_EQUAL; } + case 374: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy440 = OP_TYPE_EQUAL; } break; - case 371: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy412 = OP_TYPE_LIKE; } + case 375: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy440 = OP_TYPE_LIKE; } break; - case 372: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy412 = OP_TYPE_NOT_LIKE; } + case 376: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy440 = OP_TYPE_NOT_LIKE; } break; - case 373: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy412 = OP_TYPE_MATCH; } + case 377: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy440 = OP_TYPE_MATCH; } break; - case 374: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy412 = OP_TYPE_NMATCH; } + case 378: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy440 = OP_TYPE_NMATCH; } break; - case 375: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy412 = OP_TYPE_JSON_CONTAINS; } + case 379: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy440 = OP_TYPE_JSON_CONTAINS; } break; - case 376: /* in_op ::= IN */ -{ yymsp[0].minor.yy412 = OP_TYPE_IN; } + case 380: /* in_op ::= IN */ +{ yymsp[0].minor.yy440 = OP_TYPE_IN; } break; - case 377: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy412 = OP_TYPE_NOT_IN; } + case 381: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy440 = OP_TYPE_NOT_IN; } break; - case 378: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy368)); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 382: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy404)); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 380: /* boolean_value_expression ::= NOT boolean_primary */ + case 384: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy442), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy452), NULL)); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 381: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 385: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 382: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 386: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); - yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy452); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy452); + yylhsminor.yy452 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 390: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy442 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy442, yymsp[0].minor.yy442, NULL); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 394: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy452 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy452, yymsp[0].minor.yy452, NULL); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 393: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy442 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + case 397: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy452 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 394: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy442 = createRealTableNode(pCxt, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + case 398: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy452 = createRealTableNode(pCxt, &yymsp[-3].minor.yy109, &yymsp[-1].minor.yy109, &yymsp[0].minor.yy109); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 395: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy442 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442), &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + case 399: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy452 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452), &yymsp[0].minor.yy109); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 397: /* alias_opt ::= */ -{ yymsp[1].minor.yy241 = nil_token; } + case 401: /* alias_opt ::= */ +{ yymsp[1].minor.yy109 = nil_token; } break; - case 398: /* alias_opt ::= table_alias */ -{ yylhsminor.yy241 = yymsp[0].minor.yy241; } - yymsp[0].minor.yy241 = yylhsminor.yy241; + case 402: /* alias_opt ::= table_alias */ +{ yylhsminor.yy109 = yymsp[0].minor.yy109; } + yymsp[0].minor.yy109 = yylhsminor.yy109; break; - case 399: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy241 = yymsp[0].minor.yy241; } + case 403: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy109 = yymsp[0].minor.yy109; } break; - case 400: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 401: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==401); -{ yymsp[-2].minor.yy442 = yymsp[-1].minor.yy442; } + case 404: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 405: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==405); +{ yymsp[-2].minor.yy452 = yymsp[-1].minor.yy452; } break; - case 402: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy442 = createJoinTableNode(pCxt, yymsp[-4].minor.yy208, yymsp[-5].minor.yy442, yymsp[-2].minor.yy442, yymsp[0].minor.yy442); } - yymsp[-5].minor.yy442 = yylhsminor.yy442; + case 406: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy452 = createJoinTableNode(pCxt, yymsp[-4].minor.yy532, yymsp[-5].minor.yy452, yymsp[-2].minor.yy452, yymsp[0].minor.yy452); } + yymsp[-5].minor.yy452 = yylhsminor.yy452; break; - case 403: /* join_type ::= */ -{ yymsp[1].minor.yy208 = JOIN_TYPE_INNER; } + case 407: /* join_type ::= */ +{ yymsp[1].minor.yy532 = JOIN_TYPE_INNER; } break; - case 404: /* join_type ::= INNER */ -{ yymsp[0].minor.yy208 = JOIN_TYPE_INNER; } + case 408: /* join_type ::= INNER */ +{ yymsp[0].minor.yy532 = JOIN_TYPE_INNER; } break; - case 405: /* query_specification ::= SELECT set_quantifier_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 */ + case 409: /* query_specification ::= SELECT set_quantifier_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 */ { - yymsp[-11].minor.yy442 = createSelectStmt(pCxt, yymsp[-10].minor.yy197, yymsp[-9].minor.yy368, yymsp[-8].minor.yy442); - yymsp[-11].minor.yy442 = addWhereClause(pCxt, yymsp[-11].minor.yy442, yymsp[-7].minor.yy442); - yymsp[-11].minor.yy442 = addPartitionByClause(pCxt, yymsp[-11].minor.yy442, yymsp[-6].minor.yy368); - yymsp[-11].minor.yy442 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy442, yymsp[-2].minor.yy442); - yymsp[-11].minor.yy442 = addGroupByClause(pCxt, yymsp[-11].minor.yy442, yymsp[-1].minor.yy368); - yymsp[-11].minor.yy442 = addHavingClause(pCxt, yymsp[-11].minor.yy442, yymsp[0].minor.yy442); - yymsp[-11].minor.yy442 = addRangeClause(pCxt, yymsp[-11].minor.yy442, yymsp[-5].minor.yy442); - yymsp[-11].minor.yy442 = addEveryClause(pCxt, yymsp[-11].minor.yy442, yymsp[-4].minor.yy442); - yymsp[-11].minor.yy442 = addFillClause(pCxt, yymsp[-11].minor.yy442, yymsp[-3].minor.yy442); + yymsp[-11].minor.yy452 = createSelectStmt(pCxt, yymsp[-10].minor.yy437, yymsp[-9].minor.yy404, yymsp[-8].minor.yy452); + yymsp[-11].minor.yy452 = addWhereClause(pCxt, yymsp[-11].minor.yy452, yymsp[-7].minor.yy452); + yymsp[-11].minor.yy452 = addPartitionByClause(pCxt, yymsp[-11].minor.yy452, yymsp[-6].minor.yy404); + yymsp[-11].minor.yy452 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy452, yymsp[-2].minor.yy452); + yymsp[-11].minor.yy452 = addGroupByClause(pCxt, yymsp[-11].minor.yy452, yymsp[-1].minor.yy404); + yymsp[-11].minor.yy452 = addHavingClause(pCxt, yymsp[-11].minor.yy452, yymsp[0].minor.yy452); + yymsp[-11].minor.yy452 = addRangeClause(pCxt, yymsp[-11].minor.yy452, yymsp[-5].minor.yy452); + yymsp[-11].minor.yy452 = addEveryClause(pCxt, yymsp[-11].minor.yy452, yymsp[-4].minor.yy452); + yymsp[-11].minor.yy452 = addFillClause(pCxt, yymsp[-11].minor.yy452, yymsp[-3].minor.yy452); } break; - case 408: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy197 = false; } + case 412: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy437 = false; } break; - case 409: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy368 = NULL; } + case 413: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy404 = NULL; } break; - case 414: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy442 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442), &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy442 = yylhsminor.yy442; + case 418: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy452 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452), &yymsp[0].minor.yy109); } + yymsp[-1].minor.yy452 = yylhsminor.yy452; break; - case 415: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy442 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), &yymsp[0].minor.yy241); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 419: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy452 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), &yymsp[0].minor.yy109); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 420: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 437: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==437); - case 453: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==453); -{ yymsp[-2].minor.yy368 = yymsp[0].minor.yy368; } + case 424: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 441: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==441); + case 457: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==457); +{ yymsp[-2].minor.yy404 = yymsp[0].minor.yy404; } break; - case 422: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy442 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } + case 426: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy452 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } break; - case 423: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy442 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } + case 427: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy452 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } break; - case 424: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy442 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), NULL, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } + case 428: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy452 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), NULL, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } break; - case 425: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy442 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy442), releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } + case 429: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy452 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy452), releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), yymsp[-1].minor.yy452, yymsp[0].minor.yy452); } break; - case 427: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - case 445: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==445); -{ yymsp[-3].minor.yy442 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy442); } + case 431: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 449: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==449); +{ yymsp[-3].minor.yy452 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy452); } break; - case 429: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy442 = createFillNode(pCxt, yymsp[-1].minor.yy388, NULL); } + case 433: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy452 = createFillNode(pCxt, yymsp[-1].minor.yy614, NULL); } break; - case 430: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy442 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy368)); } + case 434: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy452 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy404)); } break; - case 431: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy388 = FILL_MODE_NONE; } + case 435: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy614 = FILL_MODE_NONE; } break; - case 432: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy388 = FILL_MODE_PREV; } + case 436: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy614 = FILL_MODE_PREV; } break; - case 433: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy388 = FILL_MODE_NULL; } + case 437: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy614 = FILL_MODE_NULL; } break; - case 434: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy388 = FILL_MODE_LINEAR; } + case 438: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy614 = FILL_MODE_LINEAR; } break; - case 435: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy388 = FILL_MODE_NEXT; } + case 439: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy614 = FILL_MODE_NEXT; } break; - case 438: /* group_by_list ::= expression */ -{ yylhsminor.yy368 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[0].minor.yy368 = yylhsminor.yy368; + case 442: /* group_by_list ::= expression */ +{ yylhsminor.yy404 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } + yymsp[0].minor.yy404 = yylhsminor.yy404; break; - case 439: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-2].minor.yy368 = yylhsminor.yy368; + case 443: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy404 = addNodeToList(pCxt, yymsp[-2].minor.yy404, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy452))); } + yymsp[-2].minor.yy404 = yylhsminor.yy404; break; - case 443: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ -{ yymsp[-5].minor.yy442 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } + case 447: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ +{ yymsp[-5].minor.yy452 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy452), releaseRawExprNode(pCxt, yymsp[-1].minor.yy452)); } break; - case 446: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 450: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy442 = addOrderByClause(pCxt, yymsp[-3].minor.yy442, yymsp[-2].minor.yy368); - yylhsminor.yy442 = addSlimitClause(pCxt, yylhsminor.yy442, yymsp[-1].minor.yy442); - yylhsminor.yy442 = addLimitClause(pCxt, yylhsminor.yy442, yymsp[0].minor.yy442); + yylhsminor.yy452 = addOrderByClause(pCxt, yymsp[-3].minor.yy452, yymsp[-2].minor.yy404); + yylhsminor.yy452 = addSlimitClause(pCxt, yylhsminor.yy452, yymsp[-1].minor.yy452); + yylhsminor.yy452 = addLimitClause(pCxt, yylhsminor.yy452, yymsp[0].minor.yy452); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 448: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy442 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy442, yymsp[0].minor.yy442); } - yymsp[-3].minor.yy442 = yylhsminor.yy442; + case 452: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy452 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy452, yymsp[0].minor.yy452); } + yymsp[-3].minor.yy452 = yylhsminor.yy452; break; - case 449: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy442 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy442, yymsp[0].minor.yy442); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 453: /* query_expression_body ::= query_expression_body UNION query_expression_body */ +{ yylhsminor.yy452 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy452, yymsp[0].minor.yy452); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 451: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ -{ yymsp[-5].minor.yy442 = yymsp[-4].minor.yy442; } - yy_destructor(yypParser,359,&yymsp[-3].minor); - yy_destructor(yypParser,360,&yymsp[-2].minor); - yy_destructor(yypParser,361,&yymsp[-1].minor); + case 455: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ +{ yymsp[-5].minor.yy452 = yymsp[-4].minor.yy452; } + yy_destructor(yypParser,362,&yymsp[-3].minor); + yy_destructor(yypParser,363,&yymsp[-2].minor); + yy_destructor(yypParser,364,&yymsp[-1].minor); break; - case 455: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 459: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==459); -{ yymsp[-1].minor.yy442 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 459: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 463: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==463); +{ yymsp[-1].minor.yy452 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 456: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 460: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==460); -{ yymsp[-3].minor.yy442 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 460: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 464: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==464); +{ yymsp[-3].minor.yy452 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 457: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 461: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==461); -{ yymsp[-3].minor.yy442 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 461: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 465: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==465); +{ yymsp[-3].minor.yy452 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 462: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy442); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 466: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy452 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy452); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 466: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy442 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), yymsp[-1].minor.yy362, yymsp[0].minor.yy417); } - yymsp[-2].minor.yy442 = yylhsminor.yy442; + case 470: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy452 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy452), yymsp[-1].minor.yy178, yymsp[0].minor.yy77); } + yymsp[-2].minor.yy452 = yylhsminor.yy452; break; - case 467: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy362 = ORDER_ASC; } + case 471: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy178 = ORDER_ASC; } break; - case 468: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy362 = ORDER_ASC; } + case 472: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy178 = ORDER_ASC; } break; - case 469: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy362 = ORDER_DESC; } + case 473: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy178 = ORDER_DESC; } break; - case 470: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy417 = NULL_ORDER_DEFAULT; } + case 474: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy77 = NULL_ORDER_DEFAULT; } break; - case 471: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy417 = NULL_ORDER_FIRST; } + case 475: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy77 = NULL_ORDER_FIRST; } break; - case 472: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy417 = NULL_ORDER_LAST; } + case 476: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy77 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index 8802f91bdf..36a2eb3808 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -25,95 +25,125 @@ #ifdef WINDOWS #define TD_USE_WINSOCK #endif + #include "mockCatalog.h" + +#include "systable.h" namespace { void generateInformationSchema(MockCatalogService* mcs) { { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnodes", TSDB_SYSTEM_TABLE, 1) - .addColumn("id", TSDB_DATA_TYPE_INT); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "mnodes", TSDB_SYSTEM_TABLE, 1) - .addColumn("id", TSDB_DATA_TYPE_INT); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "modules", TSDB_SYSTEM_TABLE, 1) - .addColumn("id", TSDB_DATA_TYPE_INT); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "qnodes", TSDB_SYSTEM_TABLE, 1) - .addColumn("id", TSDB_DATA_TYPE_INT); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_databases", TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_functions", TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_indexes", TSDB_SYSTEM_TABLE, 2) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) - .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_stables", TSDB_SYSTEM_TABLE, 2) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) - .addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); - builder.done(); - } - { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_tables", TSDB_SYSTEM_TABLE, 2) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) - .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODES, TSDB_SYSTEM_TABLE, 1) + .addColumn("id", TSDB_DATA_TYPE_INT); builder.done(); } { ITableBuilder& builder = - mcs->createTableBuilder("information_schema", "user_table_distributed", TSDB_SYSTEM_TABLE, 1) + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MNODES, TSDB_SYSTEM_TABLE, 1) + .addColumn("id", TSDB_DATA_TYPE_INT); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_MODULES, TSDB_SYSTEM_TABLE, 1) + .addColumn("id", TSDB_DATA_TYPE_INT); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_QNODES, TSDB_SYSTEM_TABLE, 1) + .addColumn("id", TSDB_DATA_TYPE_INT); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_DATABASES, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_FUNCTIONS, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_INDEXES, TSDB_SYSTEM_TABLE, 2) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_STABLES, TSDB_SYSTEM_TABLE, 2) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_TABLES, TSDB_SYSTEM_TABLE, 2) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED, TSDB_SYSTEM_TABLE, 1) .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); builder.done(); } { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "user_users", TSDB_SYSTEM_TABLE, 1) - .addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_USERS, TSDB_SYSTEM_TABLE, 1) + .addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN); builder.done(); } { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "vgroups", TSDB_SYSTEM_TABLE, 1) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VGROUPS, TSDB_SYSTEM_TABLE, 1) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN); builder.done(); } { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "configs", TSDB_SYSTEM_TABLE, 1) - .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CONFIG_OPTION_LEN); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CONFIGS, TSDB_SYSTEM_TABLE, 1) + .addColumn("name", TSDB_DATA_TYPE_BINARY, TSDB_CONFIG_OPTION_LEN); builder.done(); } { - ITableBuilder& builder = mcs->createTableBuilder("information_schema", "dnode_variables", TSDB_SYSTEM_TABLE, 1) - .addColumn("dnode_id", TSDB_DATA_TYPE_INT); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_DNODE_VARIABLES, TSDB_SYSTEM_TABLE, 1) + .addColumn("dnode_id", TSDB_DATA_TYPE_INT); builder.done(); } } void generatePerformanceSchema(MockCatalogService* mcs) { { - ITableBuilder& builder = mcs->createTableBuilder("performance_schema", "trans", TSDB_SYSTEM_TABLE, 1) - .addColumn("id", TSDB_DATA_TYPE_INT); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_TRANS, TSDB_SYSTEM_TABLE, 1) + .addColumn("id", TSDB_DATA_TYPE_INT); builder.done(); } { - ITableBuilder& builder = mcs->createTableBuilder("performance_schema", "streams", TSDB_SYSTEM_TABLE, 1) - .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_STREAMS, TSDB_SYSTEM_TABLE, 1) + .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_CONSUMERS, TSDB_SYSTEM_TABLE, 1) + .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); + builder.done(); + } + { + ITableBuilder& builder = + mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, TSDB_SYSTEM_TABLE, 1) + .addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN); builder.done(); } } @@ -261,7 +291,8 @@ int32_t __catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArra return g_mockCatalogService->catalogGetDnodeList(pDnodeList); } -int32_t __catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg** pCfg) { +int32_t __catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, + STableCfg** pCfg) { *pCfg = (STableCfg*)taosMemoryCalloc(1, sizeof(STableCfg)); return 0; } diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index dd154427c6..5c8439f846 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -144,15 +144,17 @@ TEST_F(ParserSelectTest, IndefiniteRowsFunc) { TEST_F(ParserSelectTest, IndefiniteRowsFuncSemanticCheck) { useDb("root", "test"); - run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE); + run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); - run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE); + run("SELECT DIFF(c1), tbname FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); - run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE); + run("SELECT DIFF(c1), count(*) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); - run("SELECT DIFF(c1), CSUM(c1) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE); + run("SELECT DIFF(c1), CSUM(c1) FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC); - // run("SELECT DIFF(c1) FROM t1 INTERVAL(10s)"); + run("SELECT CSUM(c3) FROM t1 STATE_WINDOW(c1)", TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC); + + run("SELECT DIFF(c1) FROM t1 INTERVAL(10s)", TSDB_CODE_PAR_WINDOW_NOT_ALLOWED_FUNC); } TEST_F(ParserSelectTest, useDefinedFunc) { @@ -384,6 +386,12 @@ TEST_F(ParserSelectTest, setOperator) { run("SELECT c1, c2 FROM t1 UNION ALL SELECT c1 as a, c2 as b FROM t1 ORDER BY c1"); } +TEST_F(ParserSelectTest, setOperatorSemanticCheck) { + useDb("root", "test"); + + run("SELECT c1, c2 FROM t1 UNION ALL SELECT c1, c2 FROM t1 ORDER BY ts", TSDB_CODE_PAR_INVALID_COLUMN); +} + TEST_F(ParserSelectTest, informationSchema) { useDb("root", "test"); diff --git a/source/libs/parser/test/parShowToUse.cpp b/source/libs/parser/test/parShowToUse.cpp index 81a09114e3..e109781169 100644 --- a/source/libs/parser/test/parShowToUse.cpp +++ b/source/libs/parser/test/parShowToUse.cpp @@ -25,6 +25,15 @@ class ParserShowToUseTest : public ParserDdlTest {}; // todo SHOW apps // todo SHOW connections +TEST_F(ParserShowToUseTest, showConsumers) { + useDb("root", "test"); + + setCheckDdlFunc( + [&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SELECT_STMT); }); + + run("SHOW CONSUMERS"); +} + TEST_F(ParserShowToUseTest, showCreateDatabase) { useDb("root", "test"); @@ -143,6 +152,15 @@ TEST_F(ParserShowToUseTest, showStreams) { run("SHOW streams"); } +TEST_F(ParserShowToUseTest, showSubscriptions) { + useDb("root", "test"); + + setCheckDdlFunc( + [&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SELECT_STMT); }); + + run("SHOW SUBSCRIPTIONS"); +} + TEST_F(ParserShowToUseTest, showTransactions) { useDb("root", "test"); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 9dbd49e66c..ffb97bcc04 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -19,6 +19,7 @@ typedef struct SLogicPlanContext { SPlanContext* pPlanCxt; + SLogicNode* pCurrRoot; } SLogicPlanContext; typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, void*, SLogicNode**); @@ -140,6 +141,7 @@ static int32_t createRootLogicNode(SLogicPlanContext* pCxt, void* pStmt, uint8_t if (TSDB_CODE_SUCCESS == code && NULL != pNode) { pNode->precision = precision; code = pushLogicNode(pCxt, pRoot, pNode); + pCxt->pCurrRoot = pNode; } if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode((SNode*)pNode); @@ -152,12 +154,16 @@ static int32_t createSelectRootLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p return createRootLogicNode(pCxt, pSelect, pSelect->precision, (FCreateLogicNode)func, pRoot); } -static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols, SNodeList* pScanCols, - int8_t tableType) { +static EScanType getScanType(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNodeList* pScanPseudoCols, + SNodeList* pScanCols, int8_t tableType) { if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) { return SCAN_TYPE_STREAM; } + if (pSelect->hasLastRowFunc) { + return SCAN_TYPE_LAST_ROW; + } + if (NULL == pScanCols) { // select count(*) from t return NULL == pScanPseudoCols @@ -273,7 +279,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect code = rewriteExprsForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM); } - pScan->scanType = getScanType(pCxt, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType); + pScan->scanType = getScanType(pCxt, pSelect, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType); if (TSDB_CODE_SUCCESS == code) { code = addPrimaryKeyCol(pScan->tableId, &pScan->pScanCols); @@ -319,36 +325,6 @@ static int32_t createColumnByLastRow(SNodeList* pFuncs, SNodeList** pOutput) { return code; } -static int32_t createLastRowScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable, - SLogicNode** pLogicNode) { - SScanLogicNode* pScan = NULL; - int32_t code = makeScanLogicNode(pCxt, pRealTable, false, (SLogicNode**)&pScan); - - SNodeList* pFuncs = NULL; - if (TSDB_CODE_SUCCESS == code) { - pScan->scanType = SCAN_TYPE_LAST_ROW; - code = nodesCollectFuncs(pSelect, SQL_CLAUSE_FROM, fmIsLastRowFunc, &pFuncs); - } - if (TSDB_CODE_SUCCESS == code) { - code = rewriteExprsForSelect(pFuncs, pSelect, SQL_CLAUSE_FROM); - } - if (TSDB_CODE_SUCCESS == code) { - code = createColumnByLastRow(pFuncs, &pScan->pScanCols); - } - if (TSDB_CODE_SUCCESS == code) { - code = createColumnByRewriteExprs(pScan->pScanCols, &pScan->node.pTargets); - } - - if (TSDB_CODE_SUCCESS == code) { - *pLogicNode = (SLogicNode*)pScan; - } else { - nodesDestroyNode((SNode*)pScan); - } - nodesDestroyList(pFuncs); - - return code; -} - static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable, SLogicNode** pLogicNode) { return createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode); @@ -420,11 +396,7 @@ static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pS SLogicNode** pLogicNode) { switch (nodeType(pTable)) { case QUERY_NODE_REAL_TABLE: - if (pSelect->hasLastRowFunc) { - return createLastRowScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); - } else { - return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); - } + return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); case QUERY_NODE_TEMP_TABLE: return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable, pLogicNode); case QUERY_NODE_JOIN_TABLE: @@ -447,6 +419,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel } pNode->precision = pSelect->precision; *pLogicNode = pNode; + pCxt->pCurrRoot = pNode; } return code; } @@ -728,6 +701,10 @@ static int32_t createFillLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect } int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_WINDOW, NULL, COLLECT_COL_TYPE_ALL, &pFill->node.pTargets); + if (TSDB_CODE_SUCCESS == code && NULL == pFill->node.pTargets) { + code = nodesListMakeStrictAppend(&pFill->node.pTargets, + nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0))); + } pFill->mode = pFillNode->mode; pFill->timeRange = pFillNode->timeRange; @@ -757,6 +734,10 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect } int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_ORDER_BY, NULL, COLLECT_COL_TYPE_ALL, &pSort->node.pTargets); + if (TSDB_CODE_SUCCESS == code && NULL == pSort->node.pTargets) { + code = nodesListMakeStrictAppend(&pSort->node.pTargets, + nodesCloneNode(nodesListGetNode(pCxt->pCurrRoot->pTargets, 0))); + } if (TSDB_CODE_SUCCESS == code) { pSort->pSortKeys = nodesCloneList(pSelect->pOrderByList); @@ -799,21 +780,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel return TSDB_CODE_OUT_OF_MEMORY; } - if (NULL != pSelect->pLimit) { - pProject->limit = pSelect->pLimit->limit; - pProject->offset = pSelect->pLimit->offset; - } else { - pProject->limit = -1; - pProject->offset = -1; - } - - if (NULL != pSelect->pSlimit) { - pProject->slimit = ((SLimitNode*)pSelect->pSlimit)->limit; - pProject->soffset = ((SLimitNode*)pSelect->pSlimit)->offset; - } else { - pProject->slimit = -1; - pProject->soffset = -1; - } + pProject->node.pLimit = (SNode*)pSelect->pLimit; + pProject->node.pSlimit = (SNode*)pSelect->pSlimit; int32_t code = TSDB_CODE_SUCCESS; @@ -848,6 +816,9 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_PARTITION_BY, NULL, COLLECT_COL_TYPE_ALL, &pPartition->node.pTargets); + if (TSDB_CODE_SUCCESS == code && NULL == pPartition->node.pTargets) { + code = nodesListMakeStrictAppend(&pPartition->node.pTargets, nodesListGetNode(pCxt->pCurrRoot->pTargets, 0)); + } if (TSDB_CODE_SUCCESS == code) { pPartition->pPartitionKeys = nodesCloneList(pSelect->pPartitionByList); @@ -969,6 +940,8 @@ static int32_t createSetOpSortLogicNode(SLogicPlanContext* pCxt, SSetOperator* p return TSDB_CODE_OUT_OF_MEMORY; } + pSort->node.pLimit = pSetOperator->pLimit; + int32_t code = TSDB_CODE_SUCCESS; pSort->node.pTargets = nodesCloneList(pSetOperator->pProjectionList); @@ -999,12 +972,8 @@ static int32_t createSetOpProjectLogicNode(SLogicPlanContext* pCxt, SSetOperator return TSDB_CODE_OUT_OF_MEMORY; } - if (NULL != pSetOperator->pLimit) { - pProject->limit = ((SLimitNode*)pSetOperator->pLimit)->limit; - pProject->offset = ((SLimitNode*)pSetOperator->pLimit)->offset; - } else { - pProject->limit = -1; - pProject->offset = -1; + if (NULL == pSetOperator->pOrderByList) { + pProject->node.pLimit = pSetOperator->pLimit; } int32_t code = TSDB_CODE_SUCCESS; @@ -1034,6 +1003,10 @@ static int32_t createSetOpAggLogicNode(SLogicPlanContext* pCxt, SSetOperator* pS return TSDB_CODE_OUT_OF_MEMORY; } + if (NULL == pSetOperator->pOrderByList) { + pAgg->node.pLimit = pSetOperator->pLimit; + } + int32_t code = TSDB_CODE_SUCCESS; pAgg->pGroupKeys = nodesCloneList(pSetOperator->pProjectionList); if (NULL == pAgg->pGroupKeys) { diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 5b9dbe8388..7862ad5445 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1117,8 +1117,7 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) { } SProjectLogicNode* pProjectNode = (SProjectLogicNode*)pNode; - if (-1 != pProjectNode->limit || -1 != pProjectNode->slimit || -1 != pProjectNode->offset || - -1 != pProjectNode->soffset) { + if (NULL != pProjectNode->node.pLimit || NULL != pProjectNode->node.pSlimit) { return false; } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 5f8fd4ac4e..fc88d46c7b 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -348,6 +348,9 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode return NULL; } + pPhysiNode->pLimit = pLogicNode->pLimit; + pPhysiNode->pSlimit = pLogicNode->pSlimit; + int32_t code = createDataBlockDesc(pCxt, pLogicNode->pTargets, &pPhysiNode->pOutputDataBlockDesc); if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode((SNode*)pPhysiNode); @@ -921,11 +924,6 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild return TSDB_CODE_OUT_OF_MEMORY; } - pProject->limit = pProjectLogicNode->limit; - pProject->offset = pProjectLogicNode->offset; - pProject->slimit = pProjectLogicNode->slimit; - pProject->soffset = pProjectLogicNode->soffset; - int32_t code = TSDB_CODE_SUCCESS; if (0 == LIST_LENGTH(pChildren)) { pProject->pProjections = nodesCloneList(pProjectLogicNode->pProjections); diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 9847755a7a..0e35239621 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -1040,6 +1040,7 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pS if (NULL == pExchange->node.pTargets) { return TSDB_CODE_OUT_OF_MEMORY; } + TSWAP(pExchange->node.pLimit, pProject->node.pLimit); pSubplan->subplanType = SUBPLAN_TYPE_MERGE; diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index 790c418b17..ea40567dae 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -37,13 +37,6 @@ TEST_F(PlanBasicTest, whereClause) { run("SELECT * FROM t1 WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59'"); } -TEST_F(PlanBasicTest, joinClause) { - useDb("root", "test"); - - run("SELECT t1.c1, t2.c2 FROM st1s1 t1, st1s2 t2 WHERE t1.ts = t2.ts"); - run("SELECT t1.c1, t2.c2 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts"); -} - TEST_F(PlanBasicTest, func) { useDb("root", "test"); diff --git a/source/libs/planner/test/planOrderByTest.cpp b/source/libs/planner/test/planOrderByTest.cpp index 2ca662cf86..e542f4772f 100644 --- a/source/libs/planner/test/planOrderByTest.cpp +++ b/source/libs/planner/test/planOrderByTest.cpp @@ -31,6 +31,8 @@ TEST_F(PlanOrderByTest, basic) { run("SELECT c1 AS a FROM t1 ORDER BY a"); run("SELECT c1 + 10 AS a FROM t1 ORDER BY a"); + + run("SELECT 1 FROM t1 ORDER BY c1"); } TEST_F(PlanOrderByTest, expr) { diff --git a/source/libs/planner/test/planSetOpTest.cpp b/source/libs/planner/test/planSetOpTest.cpp index bf26f55c02..62e017052e 100644 --- a/source/libs/planner/test/planSetOpTest.cpp +++ b/source/libs/planner/test/planSetOpTest.cpp @@ -54,6 +54,14 @@ TEST_F(PlanSetOpTest, unionAllWithOrderBy) { run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1"); } +TEST_F(PlanSetOpTest, unionAllWithLimit) { + useDb("root", "test"); + + run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 LIMIT 10, 20"); + + run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION ALL SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1 LIMIT 10, 20"); +} + TEST_F(PlanSetOpTest, union) { useDb("root", "test"); @@ -65,6 +73,14 @@ TEST_F(PlanSetOpTest, union) { "UNION SELECT c1, c2 FROM t1 WHERE c1 > 30"); } +TEST_F(PlanSetOpTest, unionWithLimit) { + useDb("root", "test"); + + run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION SELECT c1, c2 FROM t1 WHERE c1 > 20 LIMIT 10, 20"); + + run("SELECT c1, c2 FROM t1 WHERE c1 > 10 UNION SELECT c1, c2 FROM t1 WHERE c1 > 20 ORDER BY 1 LIMIT 10, 20"); +} + TEST_F(PlanSetOpTest, unionContainJoin) { useDb("root", "test"); diff --git a/source/libs/planner/test/planSubqueryTest.cpp b/source/libs/planner/test/planSubqueryTest.cpp index 7d1ac84aea..4d4f780473 100644 --- a/source/libs/planner/test/planSubqueryTest.cpp +++ b/source/libs/planner/test/planSubqueryTest.cpp @@ -33,7 +33,9 @@ TEST_F(PlanSubqeuryTest, basic) { run("SELECT NOW() FROM (SELECT * FROM t1)"); - // run("SELECT NOW() FROM (SELECT * FROM t1) ORDER BY ts"); + run("SELECT * FROM (SELECT NOW() FROM t1)"); + + run("SELECT NOW() FROM (SELECT * FROM t1) ORDER BY ts"); } TEST_F(PlanSubqeuryTest, doubleGroupBy) { From 9bcc0cd3023397d3d45aa12938c8bb18ef891373 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 23 Jun 2022 19:26:23 +0800 Subject: [PATCH 12/73] feat: sql command 'show consumers' and 'show subscriptions' --- source/libs/parser/src/parUtil.c | 8 ++++---- source/libs/parser/test/mockCatalogService.cpp | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 689ff08ab1..c4f4624355 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -897,7 +897,7 @@ STableCfg* tableCfgDup(STableCfg* pCfg) { if (pNew->pFuncs) { pNew->pFuncs = taosArrayDup(pNew->pFuncs); } - + int32_t schemaSize = (pCfg->numOfColumns + pCfg->numOfTags) * sizeof(SSchema); SSchema* pSchema = taosMemoryMalloc(schemaSize); @@ -912,7 +912,7 @@ int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, ST char fullName[TSDB_TABLE_FNAME_LEN]; tNameExtractFullName(pName, fullName); STableCfg* pCfg = NULL; - int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg); + int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg); if (TSDB_CODE_SUCCESS == code) { *pOutput = tableCfgDup(pCfg); if (NULL == *pOutput) { @@ -929,10 +929,10 @@ int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache) { int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) { SMetaRes* pRes = taosArrayGet(pMetaCache->pDnodes, 0); - if (pRes->code) { + if (TSDB_CODE_SUCCESS != pRes->code) { return pRes->code; } - + *pDnodes = taosArrayDup((SArray*)pRes->pRes); if (NULL == *pDnodes) { return TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 4263b59cc3..db33381f5e 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -166,13 +166,10 @@ class MockCatalogServiceImpl { } int32_t catalogGetDnodeList(SArray** pDnodes) const { - SMetaRes res = {0}; - res.pRes = taosArrayInit(dnode_.size(), sizeof(SEpSet)); + *pDnodes = taosArrayInit(dnode_.size(), sizeof(SEpSet)); for (const auto& dnode : dnode_) { - taosArrayPush((SArray*)res.pRes, &dnode.second); + taosArrayPush(*pDnodes, &dnode.second); } - *pDnodes = taosArrayInit(1, sizeof(SMetaRes)); - taosArrayPush(*pDnodes, &res); return TSDB_CODE_SUCCESS; } @@ -200,7 +197,7 @@ class MockCatalogServiceImpl { code = getAllTableIndex(pCatalogReq->pTableIndex, &pMetaData->pTableIndex); } if (TSDB_CODE_SUCCESS == code && pCatalogReq->dNodeRequired) { - code = catalogGetDnodeList(&pMetaData->pDnodeList); + code = getAllDnodeList(&pMetaData->pDnodeList); } if (TSDB_CODE_SUCCESS == code) { code = getAllTableCfg(pCatalogReq->pTableCfg, &pMetaData->pTableCfg); @@ -565,6 +562,13 @@ class MockCatalogServiceImpl { return TSDB_CODE_SUCCESS; } + int32_t getAllDnodeList(SArray** pDnodes) const { + SMetaRes res = {0}; + *pDnodes = taosArrayInit(1, sizeof(SMetaRes)); + taosArrayPush(*pDnodes, &res); + return catalogGetDnodeList((SArray**)&res.pRes); + } + uint64_t id_; std::unique_ptr builder_; DbMetaCache meta_; From 2c2b36680c342680eae6bcab5d9227023bc251a7 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 23 Jun 2022 19:29:28 +0800 Subject: [PATCH 13/73] feat: sql command 'show consumers' and 'show subscriptions' --- source/libs/parser/test/mockCatalogService.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index db33381f5e..8830bc7cb3 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -564,9 +564,10 @@ class MockCatalogServiceImpl { int32_t getAllDnodeList(SArray** pDnodes) const { SMetaRes res = {0}; + catalogGetDnodeList((SArray**)&res.pRes); *pDnodes = taosArrayInit(1, sizeof(SMetaRes)); taosArrayPush(*pDnodes, &res); - return catalogGetDnodeList((SArray**)&res.pRes); + return TSDB_CODE_SUCCESS; } uint64_t id_; From 470639fc182c96c93db663f934e99ee1438821f3 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Fri, 24 Jun 2022 10:48:49 +0800 Subject: [PATCH 14/73] fix: fix invalid write --- include/libs/nodes/nodes.h | 1 + source/libs/nodes/src/nodesUtilFuncs.c | 18 ++++++++++++++++++ source/libs/parser/src/parCalcConst.c | 5 ++++- source/libs/parser/src/parTranslater.c | 4 ++-- source/libs/planner/src/planPhysiCreater.c | 3 +++ source/libs/planner/test/planTestMain.cpp | 9 ++++++++- source/libs/planner/test/planTestUtil.cpp | 11 +++++++++-- 7 files changed, 45 insertions(+), 6 deletions(-) diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 777e67769f..2153f59bf8 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -285,6 +285,7 @@ int32_t nodesListPushFront(SNodeList* pList, SNode* pNode); SListCell* nodesListErase(SNodeList* pList, SListCell* pCell); void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc); SNode* nodesListGetNode(SNodeList* pList, int32_t index); +SListCell* nodesListGetCell(SNodeList* pList, int32_t index); void nodesDestroyList(SNodeList* pList); // Only clear the linked list structure, without releasing the elements inside void nodesClearList(SNodeList* pList); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 57ead2d2ae..1d8baf5373 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -372,6 +372,8 @@ static void destroyScanPhysiNode(SScanPhysiNode* pNode) { static void destroyDataSinkNode(SDataSinkNode* pNode) { nodesDestroyNode((SNode*)pNode->pInputDataBlockDesc); } +static void destroyExprNode(SExprNode* pExpr) { taosArrayDestroy(pExpr->pAssociation); } + void nodesDestroyNode(SNode* pNode) { if (NULL == pNode) { return; @@ -379,9 +381,11 @@ void nodesDestroyNode(SNode* pNode) { switch (nodeType(pNode)) { case QUERY_NODE_COLUMN: // pProjectRef is weak reference, no need to release + destroyExprNode((SExprNode*)pNode); break; case QUERY_NODE_VALUE: { SValueNode* pValue = (SValueNode*)pNode; + destroyExprNode((SExprNode*)pNode); taosMemoryFreeClear(pValue->literal); if (IS_VAR_DATA_TYPE(pValue->node.resType.type)) { taosMemoryFreeClear(pValue->datum.p); @@ -390,14 +394,17 @@ void nodesDestroyNode(SNode* pNode) { } case QUERY_NODE_OPERATOR: { SOperatorNode* pOp = (SOperatorNode*)pNode; + destroyExprNode((SExprNode*)pNode); nodesDestroyNode(pOp->pLeft); nodesDestroyNode(pOp->pRight); break; } case QUERY_NODE_LOGIC_CONDITION: + destroyExprNode((SExprNode*)pNode); nodesDestroyList(((SLogicConditionNode*)pNode)->pParameterList); break; case QUERY_NODE_FUNCTION: + destroyExprNode((SExprNode*)pNode); nodesDestroyList(((SFunctionNode*)pNode)->pParameterList); break; case QUERY_NODE_REAL_TABLE: { @@ -833,6 +840,7 @@ void nodesDestroyNode(SNode* pNode) { destroyPhysiNode((SPhysiNode*)pPhyNode); nodesDestroyList(pPhyNode->pExprs); nodesDestroyList(pPhyNode->pSortKeys); + nodesDestroyList(pPhyNode->pTargets); break; } case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: @@ -1096,6 +1104,16 @@ SNode* nodesListGetNode(SNodeList* pList, int32_t index) { return NULL; } +SListCell* nodesListGetCell(SNodeList* pList, int32_t index) { + SNode* node; + FOREACH(node, pList) { + if (0 == index--) { + return cell; + } + } + return NULL; +} + void nodesDestroyList(SNodeList* pList) { if (NULL == pList) { return; diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 495950f35c..dcdf73630f 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -183,12 +183,15 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) { int32_t size = taosArrayGetSize(pAssociation); for (int32_t i = 0; i < size; ++i) { SNode** pCol = taosArrayGetP(pAssociation, i); + nodesDestroyNode(*pCol); *pCol = nodesCloneNode(*pNew); if (NULL == *pCol) { - return TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; + break; } } } + taosArrayDestroy(pAssociation); return code; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index eb767ffa61..424968ac80 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -517,8 +517,9 @@ static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* p if (NULL == pCol) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); } - setColumnInfoByExpr(pTable, (SExprNode*)pNode, &pCol); nodesListAppend(pList, (SNode*)pCol); + SListCell* pCell = nodesListGetCell(pList, LIST_LENGTH(pList) - 1); + setColumnInfoByExpr(pTable, (SExprNode*)pNode, (SColumnNode**)&pCell->pNode); } } return TSDB_CODE_SUCCESS; @@ -4658,7 +4659,6 @@ static int32_t extractShowLocalVariablesResultSchema(int32_t* numOfCols, SSchema return TSDB_CODE_SUCCESS; } - int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) { if (NULL == pRoot) { return TSDB_CODE_SUCCESS; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index fc88d46c7b..efb0f790e1 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1197,6 +1197,9 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren nodesDestroyNode((SNode*)pSort); } + nodesDestroyList(pPrecalcExprs); + nodesDestroyList(pSortKeys); + return code; } diff --git a/source/libs/planner/test/planTestMain.cpp b/source/libs/planner/test/planTestMain.cpp index acac3d5053..43b6bf5772 100644 --- a/source/libs/planner/test/planTestMain.cpp +++ b/source/libs/planner/test/planTestMain.cpp @@ -16,9 +16,11 @@ #include #include + #include "functionMgt.h" #include "getopt.h" #include "mockCatalog.h" +#include "parser.h" #include "planTestUtil.h" class PlannerEnv : public testing::Environment { @@ -30,7 +32,12 @@ class PlannerEnv : public testing::Environment { initLog(TD_TMP_DIR_PATH "td"); } - virtual void TearDown() { destroyMetaDataEnv(); } + virtual void TearDown() { + destroyMetaDataEnv(); + qCleanupKeywordsTable(); + fmFuncMgtDestroy(); + taosCloseLog(); + } PlannerEnv() {} virtual ~PlannerEnv() {} diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp index 57d7cb6608..f1ab9c8196 100644 --- a/source/libs/planner/test/planTestUtil.cpp +++ b/source/libs/planner/test/planTestUtil.cpp @@ -102,12 +102,15 @@ class PlannerTestBaseImpl { try { SQuery* pQuery = nullptr; doParseSql(sql, &pQuery); + unique_ptr query(pQuery, qDestroyQuery); SPlanContext cxt = {0}; setPlanContext(pQuery, &cxt); SLogicSubplan* pLogicSubplan = nullptr; doCreateLogicPlan(&cxt, &pLogicSubplan); + unique_ptr logicSubplan(pLogicSubplan, + (void (*)(SLogicSubplan*))nodesDestroyNode); doOptimizeLogicPlan(&cxt, pLogicSubplan); @@ -115,9 +118,12 @@ class PlannerTestBaseImpl { SQueryLogicPlan* pLogicPlan = nullptr; doScaleOutLogicPlan(&cxt, pLogicSubplan, &pLogicPlan); + unique_ptr logicPlan(pLogicPlan, + (void (*)(SQueryLogicPlan*))nodesDestroyNode); SQueryPlan* pPlan = nullptr; doCreatePhysiPlan(&cxt, pLogicPlan, &pPlan); + unique_ptr plan(pPlan, (void (*)(SQueryPlan*))nodesDestroyNode); dump(g_dumpModule); } catch (...) { @@ -345,8 +351,9 @@ class PlannerTestBaseImpl { } void doCreatePhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryPlan** pPlan) { - SArray* pExecNodeList = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SQueryNodeAddr)); - DO_WITH_THROW(createPhysiPlan, pCxt, pLogicPlan, pPlan, pExecNodeList); + unique_ptr execNodeList((SArray*)taosArrayInit(TARRAY_MIN_SIZE, sizeof(SQueryNodeAddr)), + (void (*)(SArray*))taosArrayDestroy); + DO_WITH_THROW(createPhysiPlan, pCxt, pLogicPlan, pPlan, execNodeList.get()); res_.physiPlan_ = toString((SNode*)(*pPlan)); SNode* pNode; FOREACH(pNode, (*pPlan)->pSubplans) { From 34259e28c15944075d07716406c923700a6c8cc2 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Fri, 24 Jun 2022 11:13:40 +0800 Subject: [PATCH 15/73] fix(wal): set first version to -1 if all log rollbacked --- source/libs/wal/src/walWrite.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index 34f83fb8a9..f82f27e3af 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -179,6 +179,10 @@ int32_t walRollback(SWal *pWal, int64_t ver) { } ((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->lastVer = ver - 1; ((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->fileSize = entry.offset; + if (((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->lastVer < ver - 1) { + ASSERT(((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->fileSize == 0); + ((SWalFileInfo *)taosArrayGetLast(pWal->fileInfoSet))->firstVer = -1; + } taosCloseFile(&pIdxTFile); taosCloseFile(&pLogTFile); @@ -396,8 +400,12 @@ int64_t walWriteWithSyncInfo(SWal *pWal, int64_t index, tmsg_t msgType, SSyncLog } // set status + if (pWal->vers.firstVer == -1) pWal->vers.firstVer = index; pWal->vers.lastVer = index; pWal->totSize += sizeof(SWalHead) + bodyLen; + if (walGetCurFileInfo(pWal)->firstVer == -1) { + walGetCurFileInfo(pWal)->firstVer = index; + } walGetCurFileInfo(pWal)->lastVer = index; walGetCurFileInfo(pWal)->fileSize += sizeof(SWalHead) + bodyLen; From 74b52270a6bf5f3b29c6a29b41b1f039d57773e3 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 24 Jun 2022 11:36:26 +0800 Subject: [PATCH 16/73] refactor(sync): add trace log --- source/libs/sync/src/syncMain.c | 42 ++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 8bbee65369..42ba2b85b1 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -1322,11 +1322,11 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) { snprintf(logBuf, sizeof(logBuf), "vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d, %s", + "lconfig:%ld, changing:%d, restore:%d, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, - pSyncNode->changing, printStr); + pSyncNode->changing, pSyncNode->restoreFinish, printStr); } else { snprintf(logBuf, sizeof(logBuf), "%s", str); } @@ -1339,11 +1339,11 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) { snprintf(s, len, "vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " "replica-num:%d, " - "lconfig:%ld, changing:%d, %s", + "lconfig:%ld, changing:%d, restore:%d, %s", pSyncNode->vgId, syncUtilState2String(pSyncNode->state), str, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, - pSyncNode->changing, printStr); + pSyncNode->changing, pSyncNode->restoreFinish, printStr); } else { snprintf(s, len, "%s", str); } @@ -1403,14 +1403,34 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) { char* syncNode2SimpleStr(const SSyncNode* pSyncNode) { int len = 256; char* s = (char*)taosMemoryMalloc(len); + + SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; + if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { + pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); + } + SyncIndex logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); + SyncIndex logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); + snprintf(s, len, - "syncNode: vgId:%d, currentTerm:%lu, commitIndex:%ld, state:%d %s, isStandBy:%d, " - "electTimerLogicClock:%lu, " - "electTimerLogicClockUser:%lu, " - "electTimerMS:%d, replicaNum:%d", - pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, pSyncNode->state, - syncUtilState2String(pSyncNode->state), pSyncNode->pRaftCfg->isStandBy, pSyncNode->electTimerLogicClock, - pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS, pSyncNode->replicaNum); + "vgId:%d, sync %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, " + "replica-num:%d, " + "lconfig:%ld, changing:%d, restore:%d", + pSyncNode->vgId, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm, + pSyncNode->commitIndex, logBeginIndex, logLastIndex, snapshot.lastApplyIndex, pSyncNode->pRaftCfg->isStandBy, + pSyncNode->replicaNum, pSyncNode->pRaftCfg->lastConfigIndex, pSyncNode->changing, pSyncNode->restoreFinish); + + /* + snprintf(s, len, + "syncNode: vgId:%d, term:%lu, commit:%ld, state:%d %s, standby:%d, " + "lc:%lu, " + "lc-user:%lu, " + "ems:%d, replica-num:%d, restore:%d, changing:%d", + pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, pSyncNode->state, + syncUtilState2String(pSyncNode->state), pSyncNode->pRaftCfg->isStandBy, pSyncNode->electTimerLogicClock, + pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS, pSyncNode->replicaNum, + pSyncNode->restoreFinish, pSyncNode->changing); + */ + return s; } From 7e6ddc7a6fa362af8382360554fc56f1a26dd17d Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 24 Jun 2022 20:10:38 +0800 Subject: [PATCH 17/73] fix case --- tests/pytest/util/sql.py | 3 +- tests/system-test/1-insert/time_range_wise.py | 100 ++++++++++++++++-- 2 files changed, 94 insertions(+), 9 deletions(-) diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index d417551cce..fe802dd9a3 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -118,8 +118,7 @@ class TDSql: col_name_list = [] col_type_list = [] self.cursor.execute(sql) - self.queryCols = self.cursor.description - for query_col in self.queryCols: + for query_col in self.cursor.description: col_name_list.append(query_col[0]) col_type_list.append(query_col[1]) except Exception as e: diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index 2fb9b17220..5aa1fe3101 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -96,6 +96,10 @@ class SMAschema: drop : str = "DROP" drop_flag : str = "INDEX" querySmaOptimize : int = 1 + show : str = "SHOW" + show_msg : str = "INDEXES" + show_oper : str = "FROM" + dbname : str = None def __post_init__(self): if isinstance(self.other, dict): @@ -141,9 +145,21 @@ class SMAschema: self.drop_flag = v del self.other[k] + if k.lower() == "show_msg" and isinstance(v, str) and not self.show_msg: + self.show_msg = v + del self.other[k] -# from ...pytest.util.sql import * -# from ...pytest.util.constant import * + if k.lower() == "dbname" and isinstance(v, str) and not self.dbname: + self.dbname = v + del self.other[k] + + if k.lower() == "show_oper" and isinstance(v, str) and not self.show_oper: + self.show_oper = v + del self.other[k] + + +from ...pytest.util.sql import * +from ...pytest.util.constant import * class TDTestCase: updatecfgDict = {"querySmaOptimize": 1} @@ -152,6 +168,7 @@ class TDTestCase: tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) self.precision = "ms" + self.sma_count = 0 """ create sma index : @@ -194,6 +211,17 @@ class TDTestCase: return sql + def __get_sma_func_col(self, func): + cols = [] + if isinstance(func, str): + cols.append( func.split("(")[-1].split(")")[0] ) + elif isinstance(func, tuple) or isinstance(func, list): + for func_col in func: + cols.append(func_col.split("(")[-1].split(")")[0]) + else: + cols = [] + return cols + def __check_sma_func(self, func:tuple): if not isinstance(func, str) and not isinstance(func, tuple) and not isinstance(func, list): return False @@ -291,6 +319,8 @@ class TDTestCase: if self.updatecfgDict["querySmaOptimize"] == 0: return False tdSql.query("show stables") + if not sma.tbname: + return False stb_in_list = False for row in tdSql.queryResult: if sma.tbname == row[0]: @@ -305,10 +335,18 @@ class TDTestCase: return False if not sma.operator or not isinstance(sma.operator, str) or sma.operator.upper() != "ON": return False - if not sma.tbname: - return False + if not sma.func or not self.__check_sma_func(sma.func): return False + tdSql.query(f"desc {sma.tbname}") + _col_list = [] + for col_row in tdSql.queryResult: + _col_list.append(col_row[0]) + _sma_func_cols = self.__get_sma_func_col(sma.func) + for _sma_func_col in _sma_func_cols: + if _sma_func_col not in _col_list: + return False + if not sma.sliding or not self.__check_sma_sliding(sma.sliding): return False interval, _ = self.__get_interval_offset(sma.interval) @@ -324,7 +362,55 @@ class TDTestCase: return True def sma_create_check(self, sma:SMAschema): - tdSql.query(self.__create_sma_index(sma)) if self.__sma_create_check(sma) else tdSql.error(self.__create_sma_index(sma)) + if self.__sma_create_check(sma): + tdSql.query(self.__create_sma_index(sma)) + self.sma_count += 1 + else: + tdSql.error(self.__create_sma_index(sma)) + + def __drop_sma_index(self, sma:SMAschema): + sql = f"{sma.drop} {sma.drop_flag} {sma.index_name}" + return sql + + def __sma_drop_check(self, sma:SMAschema): + if not sma.drop: + return False + if not sma.drop_flag: + return False + if not sma.index_name: + return False + + return True + + def sma_drop_check(self, sma:SMAschema): + if self.__sma_drop_check(sma): + tdSql.query(self.__drop_sma_index(sma)) + self.sma_count -= 1 + else: + tdSql.error(self.__drop_sma_index(sma)) + + def __show_sma_index(self, sma:SMAschema): + sql = f"{sma.show} {sma.show_msg} {sma.show_oper} {sma.tbname}" + return sql + + def __sma_show_check(self, sma:SMAschema): + if not sma.show: + return False + if not sma.show_msg: + return False + if not sma.show_oper: + return False + if not sma.tbname: + return False + + return True + + def sma_show_check(self, sma:SMAschema): + if self.__sma_show_check(sma): + tdSql.query(self.__show_sma_index(sma)) + tdSql.checkRows(self.sma_count) + else: + tdSql.error(self.__show_sma_index(sma)) @property def __create_sma_sql(self): @@ -337,8 +423,8 @@ class TDTestCase: # err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) # err_sqls.append( SMAschema(operator="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) # err_sqls.append( SMAschema(tbname="", func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - # err_sqls.append( SMAschema(func="",tbname=STBNAME ) ) - err_sqls.append( SMAschema(interval=("6m"),tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(func=("",),tbname=STBNAME ) ) + # err_sqls.append( SMAschema(interval=(""),tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) # err_sqls.append( SMAschema(sliding="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) # err_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) # err_sqls.append( SMAschema(watermark="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) From 00482e9c2c57bfa5d2cb309bafac91aff8cdf0ac Mon Sep 17 00:00:00 2001 From: "wenzhouwww@live.cn" Date: Sat, 25 Jun 2022 17:38:23 +0800 Subject: [PATCH 18/73] update case for tag compute --- tests/system-test/2-query/abs.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/system-test/2-query/abs.py b/tests/system-test/2-query/abs.py index 244cccb041..36f14a88b3 100644 --- a/tests/system-test/2-query/abs.py +++ b/tests/system-test/2-query/abs.py @@ -23,7 +23,6 @@ class TDTestCase: self.time_step = 1000 def insert_datas_and_check_abs(self ,tbnums , rownums , time_step ): - tdLog.info(" prepare datas for auto check abs function ") tdSql.execute(" create database test ") @@ -36,7 +35,7 @@ class TDTestCase: ts = self.ts for row in range(rownums): - ts += time_step*row + ts = self.ts + time_step*row c1 = random.randint(0,10000) c2 = random.randint(0,100000) c3 = random.randint(0,125) @@ -538,22 +537,23 @@ class TDTestCase: # tdSql.query(" select sum(c1) from stb1 where t1+10 >1; ") # taosd crash tdSql.query("select c1 ,t1 from stb1 where t1 =0 ") tdSql.checkRows(13) - # tdSql.query("select t1 from stb1 where t1 >0 ") - # tdSql.checkRows(3) + tdSql.query("select t1 from stb1 where t1 >0 ") + tdSql.checkRows(3) + tdSql.query("select t1 from stb1 where t1 =3 ") + tdSql.checkRows(1) # tdSql.query("select sum(t1) from (select c1 ,t1 from stb1)") # tdSql.checkData(0,0,61) # tdSql.query("select distinct(c1) ,t1 from stb1") # tdSql.checkRows(20) - # tdSql.query("select max(t2) , t1 ,c1, t2 from stb1") - # tdSql.checkData(0,3,33333) + tdSql.query("select max(t2) , t1 ,c1, t2 from stb1") + tdSql.checkData(0,3,33333) # tag filter with abs function - # tdSql.query("select t1 from stb1 where abs(t1)=1") - # tdSql.checkRows(1) - tdSql.query("select t1 from stb1 where abs(c1+t1)=1") + tdSql.query("select t1 from stb1 where abs(t1)=1") tdSql.checkRows(1) - # tdSql.query("select t1 from stb1 where abs(t1+c1)=1") - # tdSql.checkRows(1) + tdSql.query("select t1 from stb1 where abs(c1+t1)=1") + tdSql.checkRows(0) + tdSql.query( "select abs(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1") From eca49c56a0f1db8c67b6c9d4827780a1e69156bc Mon Sep 17 00:00:00 2001 From: cpwu Date: Sat, 25 Jun 2022 17:43:57 +0800 Subject: [PATCH 19/73] fix case --- .../system-test/1-insert/create_retentions.py | 6 +- tests/system-test/1-insert/time_range_wise.py | 77 ++++++++++++++----- 2 files changed, 62 insertions(+), 21 deletions(-) diff --git a/tests/system-test/1-insert/create_retentions.py b/tests/system-test/1-insert/create_retentions.py index bf3c8d8309..4b37eeb9a5 100644 --- a/tests/system-test/1-insert/create_retentions.py +++ b/tests/system-test/1-insert/create_retentions.py @@ -21,9 +21,9 @@ SINT_UN_COL = "c_sint_un" BINT_UN_COL = "c_bint_un" INT_UN_COL = "c_int_un" -BINARY_COL = "c8" -NCHAR_COL = "c9" -TS_COL = "c10" +BINARY_COL = "c_binary" +NCHAR_COL = "c_nchar" +TS_COL = "c_ts" NUM_COL = [ INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ] CHAR_COL = [ BINARY_COL, NCHAR_COL, ] diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index 5aa1fe3101..cc231908aa 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -158,8 +158,8 @@ class SMAschema: del self.other[k] -from ...pytest.util.sql import * -from ...pytest.util.constant import * +# from ...pytest.util.sql import * +# from ...pytest.util.constant import * class TDTestCase: updatecfgDict = {"querySmaOptimize": 1} @@ -169,6 +169,7 @@ class TDTestCase: tdSql.init(conn.cursor(), False) self.precision = "ms" self.sma_count = 0 + self.sma_created_index = [] """ create sma index : @@ -347,14 +348,16 @@ class TDTestCase: if _sma_func_col not in _col_list: return False - if not sma.sliding or not self.__check_sma_sliding(sma.sliding): + if sma.sliding and not self.__check_sma_sliding(sma.sliding): return False interval, _ = self.__get_interval_offset(sma.interval) - if not sma.interval or not self.__check_sma_interval(sma.interval) or tdSql.get_times(interval) < tdSql.get_times(sma.sliding): + if not sma.interval or not self.__check_sma_interval(sma.interval) : return False - if not sma.watermark or not self.__check_sma_watermark(sma.watermark): + if sma.sliding and tdSql.get_times(interval) < tdSql.get_times(sma.sliding): return False - if not sma.max_delay or not self.__check_sma_max_delay(sma.max_delay): + if sma.watermark and not self.__check_sma_watermark(sma.watermark): + return False + if sma.max_delay and not self.__check_sma_max_delay(sma.max_delay): return False if sma.other: return False @@ -365,6 +368,10 @@ class TDTestCase: if self.__sma_create_check(sma): tdSql.query(self.__create_sma_index(sma)) self.sma_count += 1 + self.sma_created_index.append(sma.index_name) + tdSql.query("show streams") + tdSql.checkRows(self.sma_count) + else: tdSql.error(self.__create_sma_index(sma)) @@ -385,7 +392,12 @@ class TDTestCase: def sma_drop_check(self, sma:SMAschema): if self.__sma_drop_check(sma): tdSql.query(self.__drop_sma_index(sma)) + print(self.__drop_sma_index(sma)) self.sma_count -= 1 + self.sma_created_index = list(filter(lambda x: x != sma.index_name, self.sma_created_index)) + tdSql.query("show streams") + tdSql.checkRows(self.sma_count) + else: tdSql.error(self.__drop_sma_index(sma)) @@ -418,27 +430,56 @@ class TDTestCase: cur_sqls = [] # err_set # # case 1: required fields check - # err_sqls.append( SMAschema(creation="", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - # err_sqls.append( SMAschema(index_name="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - # err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - # err_sqls.append( SMAschema(operator="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - # err_sqls.append( SMAschema(tbname="", func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + ### 1.1 create + err_sqls.append( SMAschema(creation="", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(index_name="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(operator="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(tbname="", func=(f"min({INT_COL})",f"max({INT_COL})") ) ) err_sqls.append( SMAschema(func=("",),tbname=STBNAME ) ) - # err_sqls.append( SMAschema(interval=(""),tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - # err_sqls.append( SMAschema(sliding="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - # err_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) - # err_sqls.append( SMAschema(watermark="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(interval=(""),tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + + # current_set + + cur_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + cur_sqls.append( SMAschema(watermark="",index_name="sma_index_2",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + cur_sqls.append( SMAschema(sliding="",index_name='sma_index_3',tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + return err_sqls, cur_sqls - def test_create_sma(self): err_sqls , cur_sqls = self.__create_sma_sql for err_sql in err_sqls: self.sma_create_check(err_sql) + for cur_sql in cur_sqls: + self.sma_create_check(cur_sql) + + @property + def __drop_sma_sql(self): + err_sqls = [] + cur_sqls = [] + # err_set + ## case 1: required fields check + err_sqls.append( SMAschema(drop="") ) + err_sqls.append( SMAschema(drop_flag="") ) + err_sqls.append( SMAschema(index_name="") ) + + for index in self.sma_created_index: + cur_sqls.append(SMAschema(index_name=index)) + + return err_sqls, cur_sqls + + def test_drop_sma(self): + err_sqls , cur_sqls = self.__drop_sma_sql + for err_sql in err_sqls: + self.sma_drop_check(err_sql) + for cur_sql in cur_sqls: + self.sma_drop_check(cur_sql) def all_test(self): self.test_create_sma() + self.test_drop_sma() pass @@ -545,8 +586,8 @@ class TDTestCase: tdLog.printNoPrefix("==========step1:create table in normal database") tdSql.prepare() self.__create_tb() - self.__insert_data() - self.all_test() + # self.__insert_data() + # self.all_test() return From 6a73aa933cc0e219f46eaf17301970ceb9f9c404 Mon Sep 17 00:00:00 2001 From: "wenzhouwww@live.cn" Date: Sat, 25 Jun 2022 19:39:32 +0800 Subject: [PATCH 20/73] update case --- tests/system-test/2-query/abs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/system-test/2-query/abs.py b/tests/system-test/2-query/abs.py index 36f14a88b3..5ffb426d89 100644 --- a/tests/system-test/2-query/abs.py +++ b/tests/system-test/2-query/abs.py @@ -552,7 +552,8 @@ class TDTestCase: tdSql.query("select t1 from stb1 where abs(t1)=1") tdSql.checkRows(1) tdSql.query("select t1 from stb1 where abs(c1+t1)=1") - tdSql.checkRows(0) + tdSql.checkRows(1) + tdSql.checkData(0,0,0) tdSql.query( "select abs(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1") From a6f33ba01c987682f8212ff8dfba8e6d7c176151 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Sat, 25 Jun 2022 20:31:42 +0800 Subject: [PATCH 21/73] refactor(sync): optimized one replica --- include/libs/sync/syncTools.h | 4 +- source/dnode/mnode/impl/src/mndMain.c | 10 ++--- source/dnode/vnode/src/vnd/vnodeSync.c | 60 ++++++++++++++------------ source/libs/sync/inc/syncIO.h | 2 +- source/libs/sync/inc/syncInt.h | 3 +- source/libs/sync/src/syncCommit.c | 1 + source/libs/sync/src/syncIO.c | 2 +- source/libs/sync/src/syncMain.c | 57 ++++++++++++++++++++---- 8 files changed, 92 insertions(+), 47 deletions(-) diff --git a/include/libs/sync/syncTools.h b/include/libs/sync/syncTools.h index e51b20a404..5d892352d6 100644 --- a/include/libs/sync/syncTools.h +++ b/include/libs/sync/syncTools.h @@ -524,7 +524,7 @@ void syncReconfigFinishLog2(char* s, const SyncReconfigFinish* pMsg); int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg); int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg); int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg); -int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg); +int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex); int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg); int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg); int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg); @@ -541,7 +541,7 @@ int32_t syncNodeOnSnapshotRspCb(SSyncNode* ths, SyncSnapshotRsp* pMsg); // ----------------------------------------- typedef int32_t (*FpOnPingCb)(SSyncNode* ths, SyncPing* pMsg); typedef int32_t (*FpOnPingReplyCb)(SSyncNode* ths, SyncPingReply* pMsg); -typedef int32_t (*FpOnClientRequestCb)(SSyncNode* ths, SyncClientRequest* pMsg); +typedef int32_t (*FpOnClientRequestCb)(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex); typedef int32_t (*FpOnRequestVoteCb)(SSyncNode* ths, SyncRequestVote* pMsg); typedef int32_t (*FpOnRequestVoteReplyCb)(SSyncNode* ths, SyncRequestVoteReply* pMsg); typedef int32_t (*FpOnAppendEntriesCb)(SSyncNode* ths, SyncAppendEntries* pMsg); diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 000e1041d0..ead7eaaeb6 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -442,7 +442,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { syncPingReplyDestroy(pSyncMsg); } else if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) { SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pMsg); - code = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg); + code = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg, NULL); syncClientRequestDestroy(pSyncMsg); } else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) { SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg); @@ -491,7 +491,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { syncPingReplyDestroy(pSyncMsg); } else if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) { SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pMsg); - code = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg); + code = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg, NULL); syncClientRequestDestroy(pSyncMsg); } else if (pMsg->msgType == TDMT_SYNC_REQUEST_VOTE) { SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pMsg); @@ -555,10 +555,10 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { static int32_t mndCheckMsgContent(SRpcMsg *pMsg) { if (!IsReq(pMsg)) return 0; if (pMsg->contLen != 0 && pMsg->pCont != NULL) return 0; - + const STraceId *trace = &pMsg->info.traceId; mGError("msg:%p, failed to check msg, cont:%p contLen:%d, app:%p type:%s", pMsg, pMsg->pCont, pMsg->contLen, - pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); + pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); terrno = TSDB_CODE_INVALID_MSG_LEN; return -1; } @@ -723,7 +723,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr pIter = sdbFetch(pSdb, SDB_STB, pIter, (void **)&pStb); if (pIter == NULL) break; - SMonStbDesc desc = {0}; + SMonStbDesc desc = {0}; SName name1 = {0}; tNameFromString(&name1, pStb->db, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 4c56180979..ba68e7811d 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -137,6 +137,26 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { vError("vgId:%d, failed to pre-process msg:%p since %s", vgId, pMsg, terrstr()); } else { code = syncPropose(pVnode->sync, pMsg, vnodeIsMsgWeak(pMsg->msgType)); + if (code == 1) { + do { + static int32_t cnt = 0; + if (cnt++ % 1000 == 1) { + vInfo("vgId:%d, msg:%p apply right now, apply index:%ld, msgtype:%s,%d", vgId, pMsg, + pMsg->info.conn.applyIndex, TMSG_INFO(pMsg->msgType), pMsg->msgType); + } + } while (0); + + SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info}; + if (vnodeProcessWriteReq(pVnode, pMsg, pMsg->info.conn.applyIndex, &rsp) < 0) { + rsp.code = terrno; + vInfo("vgId:%d, msg:%p failed to apply right now since %s", vgId, pMsg, terrstr()); + } + + if (rsp.info.handle != NULL) { + tmsgSendRsp(&rsp); + } + code = 0; + } } } @@ -260,7 +280,7 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg); assert(pSyncMsg != NULL); - ret = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg); + ret = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg, NULL); syncClientRequestDestroy(pSyncMsg); } else if (pRpcMsg->msgType == TDMT_SYNC_REQUEST_VOTE) { @@ -359,34 +379,18 @@ static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta c SyncIndex beginIndex = SYNC_INDEX_INVALID; char logBuf[256] = {0}; - if (pFsm->FpGetSnapshotInfo != NULL) { - (*pFsm->FpGetSnapshotInfo)(pFsm, &snapshot); - beginIndex = snapshot.lastApplyIndex; - } + snprintf(logBuf, sizeof(logBuf), + "==callback== ==CommitCb== execute, pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, beginIndex :%ld\n", + pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), + beginIndex); + syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); - if (cbMeta.index > beginIndex) { - snprintf( - logBuf, sizeof(logBuf), - "==callback== ==CommitCb== execute, pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, beginIndex :%ld\n", - pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), beginIndex); - syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); - - SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen}; - rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen); - memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen); - syncGetAndDelRespRpc(pVnode->sync, cbMeta.seqNum, &rpcMsg.info); - rpcMsg.info.conn.applyIndex = cbMeta.index; - tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg); - - } else { - char logBuf[256] = {0}; - snprintf(logBuf, sizeof(logBuf), - "==callback== ==CommitCb== do not execute, pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s, " - "beginIndex :%ld\n", - pFsm, cbMeta.index, cbMeta.isWeak, cbMeta.code, cbMeta.state, syncUtilState2String(cbMeta.state), - beginIndex); - syncRpcMsgLog2(logBuf, (SRpcMsg *)pMsg); - } + SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen}; + rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen); + memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen); + syncGetAndDelRespRpc(pVnode->sync, cbMeta.seqNum, &rpcMsg.info); + rpcMsg.info.conn.applyIndex = cbMeta.index; + tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg); } static void vnodeSyncPreCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { diff --git a/source/libs/sync/inc/syncIO.h b/source/libs/sync/inc/syncIO.h index 88d3065375..21ae40f92d 100644 --- a/source/libs/sync/inc/syncIO.h +++ b/source/libs/sync/inc/syncIO.h @@ -50,7 +50,7 @@ typedef struct SSyncIO { void *pSyncNode; int32_t (*FpOnSyncPing)(SSyncNode *pSyncNode, SyncPing *pMsg); int32_t (*FpOnSyncPingReply)(SSyncNode *pSyncNode, SyncPingReply *pMsg); - int32_t (*FpOnSyncClientRequest)(SSyncNode *pSyncNode, SyncClientRequest *pMsg); + int32_t (*FpOnSyncClientRequest)(SSyncNode *pSyncNode, SyncClientRequest *pMsg, SyncIndex* pRetIndex); int32_t (*FpOnSyncRequestVote)(SSyncNode *pSyncNode, SyncRequestVote *pMsg); int32_t (*FpOnSyncRequestVoteReply)(SSyncNode *pSyncNode, SyncRequestVoteReply *pMsg); int32_t (*FpOnSyncAppendEntries)(SSyncNode *pSyncNode, SyncAppendEntries *pMsg); diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index 1bd0671fb5..d351dc50f4 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -169,7 +169,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo); void syncNodeStart(SSyncNode* pSyncNode); void syncNodeStartStandBy(SSyncNode* pSyncNode); void syncNodeClose(SSyncNode* pSyncNode); -int32_t syncNodePropose(SSyncNode* pSyncNode, const SRpcMsg* pMsg, bool isWeak); +int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak); // option bool syncNodeSnapshotEnable(SSyncNode* pSyncNode); @@ -233,6 +233,7 @@ SyncIndex syncNodeGetPreIndex(SSyncNode* pSyncNode, SyncIndex index); SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index); int32_t syncNodeGetPreIndexTerm(SSyncNode* pSyncNode, SyncIndex index, SyncIndex* pPreIndex, SyncTerm* pPreTerm); +bool syncNodeIsOptimizedOneReplica(SSyncNode* ths, SRpcMsg* pMsg); int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, uint64_t flag); int32_t syncNodeUpdateNewConfigIndex(SSyncNode* ths, SSyncCfg* pNewCfg); diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index c92edae381..982d37826a 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -102,6 +102,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { } } + // maybe execute fsm if (newCommitIndex > pSyncNode->commitIndex) { SyncIndex beginIndex = pSyncNode->commitIndex + 1; SyncIndex endIndex = newCommitIndex; diff --git a/source/libs/sync/src/syncIO.c b/source/libs/sync/src/syncIO.c index 038c36c417..4243a933b0 100644 --- a/source/libs/sync/src/syncIO.c +++ b/source/libs/sync/src/syncIO.c @@ -281,7 +281,7 @@ static void *syncIOConsumerFunc(void *param) { if (io->FpOnSyncClientRequest != NULL) { SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg); ASSERT(pSyncMsg != NULL); - io->FpOnSyncClientRequest(io->pSyncNode, pSyncMsg); + io->FpOnSyncClientRequest(io->pSyncNode, pSyncMsg, NULL); syncClientRequestDestroy(pSyncMsg); } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 3100d0525c..2c00dccb60 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -50,7 +50,7 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths); // process message ---- int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg); int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg); -int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg); +int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex); // life cycle static void syncFreeNode(void* param); @@ -627,7 +627,7 @@ int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak) { return ret; } -int32_t syncNodePropose(SSyncNode* pSyncNode, const SRpcMsg* pMsg, bool isWeak) { +int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { int32_t ret = 0; char eventLog[128]; @@ -664,13 +664,34 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, const SRpcMsg* pMsg, bool isWeak) SRpcMsg rpcMsg; syncClientRequest2RpcMsg(pSyncMsg, &rpcMsg); - if (pSyncNode->FpEqMsg != NULL && (*pSyncNode->FpEqMsg)(pSyncNode->msgcb, &rpcMsg) == 0) { - ret = 0; + // optimized one replica + if (syncNodeIsOptimizedOneReplica(pSyncNode, pMsg)) { + SyncIndex retIndex; + int32_t code = syncNodeOnClientRequestCb(pSyncNode, pSyncMsg, &retIndex); + if (code == 0) { + pMsg->info.conn.applyIndex = retIndex; + rpcFreeCont(rpcMsg.pCont); + syncRespMgrDel(pSyncNode->pSyncRespMgr, seqNum); + ret = 1; + sDebug("vgId:%d optimized index:%ld success, msgtype:%s,%d", pSyncNode->vgId, retIndex, + TMSG_INFO(pMsg->msgType), pMsg->msgType); + } else { + ret = -1; + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + sError("vgId:%d optimized index:%ld error, msgtype:%s,%d", pSyncNode->vgId, retIndex, TMSG_INFO(pMsg->msgType), + pMsg->msgType); + } + } else { - ret = -1; - terrno = TSDB_CODE_SYN_INTERNAL_ERROR; - sError("syncPropose pSyncNode->FpEqMsg is NULL"); + if (pSyncNode->FpEqMsg != NULL && (*pSyncNode->FpEqMsg)(pSyncNode->msgcb, &rpcMsg) == 0) { + ret = 0; + } else { + ret = -1; + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + sError("enqueue msg error, FpEqMsg is NULL"); + } } + syncClientRequestDestroy(pSyncMsg); goto _END; @@ -2377,7 +2398,7 @@ int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg) { // /\ UNCHANGED <> // -int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) { +int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex) { int32_t ret = 0; syncClientRequestLog2("==syncNodeOnClientRequestCb==", pMsg); @@ -2436,6 +2457,14 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) { rpcFreeCont(rpcMsg.pCont); } + if (pRetIndex != NULL) { + if (ret == 0 && pEntry != NULL) { + *pRetIndex = pEntry->index; + } else { + *pRetIndex = SYNC_INDEX_INVALID; + } + } + syncEntryDestory(pEntry); return ret; } @@ -2600,6 +2629,10 @@ static int32_t syncNodeProposeConfigChangeFinish(SSyncNode* ths, SyncReconfigFin return 0; } +bool syncNodeIsOptimizedOneReplica(SSyncNode* ths, SRpcMsg* pMsg) { + return (ths->replicaNum == 1 && syncUtilUserCommit(pMsg->msgType) && ths->vgId != 1); +} + int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, uint64_t flag) { int32_t code = 0; ESyncState state = flag; @@ -2621,7 +2654,13 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, syncEntry2OriginalRpc(pEntry, &rpcMsg); // user commit - if (ths->pFsm->FpCommitCb != NULL && syncUtilUserCommit(pEntry->originalRpcType)) { + bool internalExecute = (ths->pFsm->FpCommitCb != NULL) && syncUtilUserCommit(pEntry->originalRpcType); + if (ths->replicaNum == 1) { + internalExecute = syncNodeIsOptimizedOneReplica(ths, &rpcMsg) && !(ths->restoreFinish); + } + + // execute fsm in apply thread, or execute outside syncPropose + if (internalExecute) { SFsmCbMeta cbMeta = {0}; cbMeta.index = pEntry->index; cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); From 6eecbcd1a6500e9052cf86b43aa5f58d0cbcfe44 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Sun, 26 Jun 2022 01:16:11 +0800 Subject: [PATCH 22/73] refactor(sync): optimized one replica --- include/libs/sync/sync.h | 4 +-- source/dnode/vnode/src/vnd/vnodeSync.c | 11 +++--- source/libs/sync/inc/syncEnv.h | 12 +++---- source/libs/sync/inc/syncIO.h | 2 +- source/libs/sync/inc/syncRaftCfg.h | 10 +++--- source/libs/sync/src/syncIO.c | 6 ++-- source/libs/sync/src/syncIndexMgr.c | 2 +- source/libs/sync/src/syncMain.c | 42 +++++++++++++--------- source/libs/sync/src/syncRaftCfg.c | 8 ++--- source/libs/sync/src/syncRaftStore.c | 2 +- source/libs/sync/src/syncSnapshot.c | 10 +++--- source/libs/sync/src/syncVoteMgr.c | 4 +-- source/libs/sync/test/syncRaftLogTest2.cpp | 27 +++++++------- source/libs/sync/test/syncRaftLogTest3.cpp | 2 +- 14 files changed, 74 insertions(+), 68 deletions(-) diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 52d9b6f810..5fa7eed40c 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -26,9 +26,9 @@ extern "C" { extern bool gRaftDetailLog; -#define SYNC_INDEX_BEGIN 0 +#define SYNC_INDEX_BEGIN 0 #define SYNC_INDEX_INVALID -1 -#define SYNC_TERM_INVALID 0xFFFFFFFFFFFFFFFF +#define SYNC_TERM_INVALID 0xFFFFFFFFFFFFFFFF typedef uint64_t SyncNodeId; typedef int32_t SyncGroupId; diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index ba68e7811d..b998f40195 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -155,7 +155,6 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { if (rsp.info.handle != NULL) { tmsgSendRsp(&rsp); } - code = 0; } } } @@ -183,10 +182,12 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info}; tmsgSendRedirectRsp(&rsp, &newEpSet); } else { - if (terrno != 0) code = terrno; - vError("vgId:%d, msg:%p failed to propose since %s, code:0x%x", vgId, pMsg, tstrerror(code), code); - SRpcMsg rsp = {.code = code, .info = pMsg->info}; - tmsgSendRsp(&rsp); + if (code != 1) { + if (terrno != 0) code = terrno; + vError("vgId:%d, msg:%p failed to propose since %s, code:0x%x", vgId, pMsg, tstrerror(code), code); + SRpcMsg rsp = {.code = code, .info = pMsg->info}; + tmsgSendRsp(&rsp); + } } vGTrace("vgId:%d, msg:%p is freed, code:0x%x", vgId, pMsg, code); diff --git a/source/libs/sync/inc/syncEnv.h b/source/libs/sync/inc/syncEnv.h index 2e8e0e1227..beddec64c5 100644 --- a/source/libs/sync/inc/syncEnv.h +++ b/source/libs/sync/inc/syncEnv.h @@ -28,13 +28,13 @@ extern "C" { #include "trpc.h" #include "ttimer.h" -#define TIMER_MAX_MS 0x7FFFFFFF -#define ENV_TICK_TIMER_MS 1000 -#define PING_TIMER_MS 1000 -#define ELECT_TIMER_MS_MIN 1300 -#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2) +#define TIMER_MAX_MS 0x7FFFFFFF +#define ENV_TICK_TIMER_MS 1000 +#define PING_TIMER_MS 1000 +#define ELECT_TIMER_MS_MIN 1300 +#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2) #define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN) -#define HEARTBEAT_TIMER_MS 900 +#define HEARTBEAT_TIMER_MS 900 #define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0}) diff --git a/source/libs/sync/inc/syncIO.h b/source/libs/sync/inc/syncIO.h index 21ae40f92d..f3064e668d 100644 --- a/source/libs/sync/inc/syncIO.h +++ b/source/libs/sync/inc/syncIO.h @@ -50,7 +50,7 @@ typedef struct SSyncIO { void *pSyncNode; int32_t (*FpOnSyncPing)(SSyncNode *pSyncNode, SyncPing *pMsg); int32_t (*FpOnSyncPingReply)(SSyncNode *pSyncNode, SyncPingReply *pMsg); - int32_t (*FpOnSyncClientRequest)(SSyncNode *pSyncNode, SyncClientRequest *pMsg, SyncIndex* pRetIndex); + int32_t (*FpOnSyncClientRequest)(SSyncNode *pSyncNode, SyncClientRequest *pMsg, SyncIndex *pRetIndex); int32_t (*FpOnSyncRequestVote)(SSyncNode *pSyncNode, SyncRequestVote *pMsg); int32_t (*FpOnSyncRequestVoteReply)(SSyncNode *pSyncNode, SyncRequestVoteReply *pMsg); int32_t (*FpOnSyncAppendEntries)(SSyncNode *pSyncNode, SyncAppendEntries *pMsg); diff --git a/source/libs/sync/inc/syncRaftCfg.h b/source/libs/sync/inc/syncRaftCfg.h index efe8a65b77..521ca6068d 100644 --- a/source/libs/sync/inc/syncRaftCfg.h +++ b/source/libs/sync/inc/syncRaftCfg.h @@ -49,14 +49,14 @@ int32_t raftCfgClose(SRaftCfg *pRaftCfg); int32_t raftCfgPersist(SRaftCfg *pRaftCfg); int32_t raftCfgAddConfigIndex(SRaftCfg *pRaftCfg, SyncIndex configIndex); -cJSON *syncCfg2Json(SSyncCfg *pSyncCfg); -char *syncCfg2Str(SSyncCfg *pSyncCfg); -char *syncCfg2SimpleStr(SSyncCfg *pSyncCfg); +cJSON * syncCfg2Json(SSyncCfg *pSyncCfg); +char * syncCfg2Str(SSyncCfg *pSyncCfg); +char * syncCfg2SimpleStr(SSyncCfg *pSyncCfg); int32_t syncCfgFromJson(const cJSON *pRoot, SSyncCfg *pSyncCfg); int32_t syncCfgFromStr(const char *s, SSyncCfg *pSyncCfg); -cJSON *raftCfg2Json(SRaftCfg *pRaftCfg); -char *raftCfg2Str(SRaftCfg *pRaftCfg); +cJSON * raftCfg2Json(SRaftCfg *pRaftCfg); +char * raftCfg2Str(SRaftCfg *pRaftCfg); int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg); int32_t raftCfgFromStr(const char *s, SRaftCfg *pRaftCfg); diff --git a/source/libs/sync/src/syncIO.c b/source/libs/sync/src/syncIO.c index 4243a933b0..663745a7d7 100644 --- a/source/libs/sync/src/syncIO.c +++ b/source/libs/sync/src/syncIO.c @@ -30,7 +30,7 @@ static int32_t syncIODestroy(SSyncIO *io); static int32_t syncIOStartInternal(SSyncIO *io); static int32_t syncIOStopInternal(SSyncIO *io); -static void *syncIOConsumerFunc(void *param); +static void * syncIOConsumerFunc(void *param); static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey); @@ -242,9 +242,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) { } static void *syncIOConsumerFunc(void *param) { - SSyncIO *io = param; + SSyncIO * io = param; STaosQall *qall; - SRpcMsg *pRpcMsg, rpcMsg; + SRpcMsg * pRpcMsg, rpcMsg; qall = taosAllocateQall(); while (1) { diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 5b432aeec4..10f0e0e335 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -126,7 +126,7 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) { char *syncIndexMgr2Str(SSyncIndexMgr *pSyncIndexMgr) { cJSON *pJson = syncIndexMgr2Json(pSyncIndexMgr); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 2c00dccb60..3996193037 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -2654,25 +2654,33 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, syncEntry2OriginalRpc(pEntry, &rpcMsg); // user commit - bool internalExecute = (ths->pFsm->FpCommitCb != NULL) && syncUtilUserCommit(pEntry->originalRpcType); - if (ths->replicaNum == 1) { - internalExecute = syncNodeIsOptimizedOneReplica(ths, &rpcMsg) && !(ths->restoreFinish); - } + if ((ths->pFsm->FpCommitCb != NULL) && syncUtilUserCommit(pEntry->originalRpcType)) { + bool internalExecute = true; + if ((ths->replicaNum == 1) && ths->restoreFinish && (ths->vgId != 1)) { + internalExecute = false; + } - // execute fsm in apply thread, or execute outside syncPropose - if (internalExecute) { - SFsmCbMeta cbMeta = {0}; - cbMeta.index = pEntry->index; - cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); - cbMeta.isWeak = pEntry->isWeak; - cbMeta.code = 0; - cbMeta.state = ths->state; - cbMeta.seqNum = pEntry->seqNum; - cbMeta.term = pEntry->term; - cbMeta.currentTerm = ths->pRaftStore->currentTerm; - cbMeta.flag = flag; + do { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "index:%ld, internalExecute:%d", i, internalExecute); + syncNodeEventLog(ths, logBuf); + } while (0); - ths->pFsm->FpCommitCb(ths->pFsm, &rpcMsg, cbMeta); + // execute fsm in apply thread, or execute outside syncPropose + if (internalExecute) { + SFsmCbMeta cbMeta = {0}; + cbMeta.index = pEntry->index; + cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, cbMeta.index); + cbMeta.isWeak = pEntry->isWeak; + cbMeta.code = 0; + cbMeta.state = ths->state; + cbMeta.seqNum = pEntry->seqNum; + cbMeta.term = pEntry->term; + cbMeta.currentTerm = ths->pRaftStore->currentTerm; + cbMeta.flag = flag; + + ths->pFsm->FpCommitCb(ths->pFsm, &rpcMsg, cbMeta); + } } // config change diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index f40eff57d9..9d16bed6c1 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -101,7 +101,7 @@ cJSON *syncCfg2Json(SSyncCfg *pSyncCfg) { char *syncCfg2Str(SSyncCfg *pSyncCfg) { cJSON *pJson = syncCfg2Json(pSyncCfg); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -109,7 +109,7 @@ char *syncCfg2Str(SSyncCfg *pSyncCfg) { char *syncCfg2SimpleStr(SSyncCfg *pSyncCfg) { if (pSyncCfg != NULL) { int32_t len = 512; - char *s = taosMemoryMalloc(len); + char * s = taosMemoryMalloc(len); memset(s, 0, len); snprintf(s, len, "{replica-num:%d, my-index:%d, ", pSyncCfg->replicaNum, pSyncCfg->myIndex); @@ -205,7 +205,7 @@ cJSON *raftCfg2Json(SRaftCfg *pRaftCfg) { char *raftCfg2Str(SRaftCfg *pRaftCfg) { cJSON *pJson = raftCfg2Json(pRaftCfg); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -271,7 +271,7 @@ int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg) { (pRaftCfg->configIndexArr)[i] = atoll(pIndex->valuestring); } - cJSON *pJsonSyncCfg = cJSON_GetObjectItem(pJson, "SSyncCfg"); + cJSON * pJsonSyncCfg = cJSON_GetObjectItem(pJson, "SSyncCfg"); int32_t code = syncCfgFromJson(pJsonSyncCfg, &(pRaftCfg->cfg)); ASSERT(code == 0); diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index a1ab95c00f..9f5cba6c66 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -216,7 +216,7 @@ cJSON *raftStore2Json(SRaftStore *pRaftStore) { char *raftStore2Str(SRaftStore *pRaftStore) { cJSON *pJson = raftStore2Json(pRaftStore); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 4fc0128400..0feaf532bb 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -314,14 +314,14 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) { char *snapshotSender2Str(SSyncSnapshotSender *pSender) { cJSON *pJson = snapshotSender2Json(pSender); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } char *snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event) { int32_t len = 256; - char *s = taosMemoryMalloc(len); + char * s = taosMemoryMalloc(len); SRaftId destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; char host[128]; @@ -461,7 +461,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { cJSON_AddStringToObject(pFromId, "addr", u64buf); { uint64_t u64 = pReceiver->fromId.addr; - cJSON *pTmp = pFromId; + cJSON * pTmp = pFromId; char host[128] = {0}; uint16_t port; syncUtilU642Addr(u64, host, sizeof(host), &port); @@ -494,14 +494,14 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver) { cJSON *pJson = snapshotReceiver2Json(pReceiver); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event) { int32_t len = 256; - char *s = taosMemoryMalloc(len); + char * s = taosMemoryMalloc(len); SRaftId fromId = pReceiver->fromId; char host[128]; diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index d6c2cbd34e..2c43312064 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -127,7 +127,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { char *voteGranted2Str(SVotesGranted *pVotesGranted) { cJSON *pJson = voteGranted2Json(pVotesGranted); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -256,7 +256,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { char *votesRespond2Str(SVotesRespond *pVotesRespond) { cJSON *pJson = votesRespond2Json(pVotesRespond); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/test/syncRaftLogTest2.cpp b/source/libs/sync/test/syncRaftLogTest2.cpp index e3ceae0615..9e0c2ecc29 100644 --- a/source/libs/sync/test/syncRaftLogTest2.cpp +++ b/source/libs/sync/test/syncRaftLogTest2.cpp @@ -113,7 +113,7 @@ void test2() { pLogStore = logStoreCreate(pSyncNode); assert(pLogStore); pSyncNode->pLogStore = pLogStore; - //pLogStore->syncLogSetBeginIndex(pLogStore, 5); + // pLogStore->syncLogSetBeginIndex(pLogStore, 5); pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4); logStoreLog2((char*)"\n\n\ntest2 ----- ", pLogStore); @@ -229,7 +229,7 @@ void test4() { assert(pLogStore); pSyncNode->pLogStore = pLogStore; logStoreLog2((char*)"\n\n\ntest4 ----- ", pLogStore); - //pLogStore->syncLogSetBeginIndex(pLogStore, 5); + // pLogStore->syncLogSetBeginIndex(pLogStore, 5); pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4); for (int i = 5; i <= 9; ++i) { @@ -291,7 +291,7 @@ void test5() { assert(pLogStore); pSyncNode->pLogStore = pLogStore; logStoreLog2((char*)"\n\n\ntest5 ----- ", pLogStore); - //pLogStore->syncLogSetBeginIndex(pLogStore, 5); + // pLogStore->syncLogSetBeginIndex(pLogStore, 5); pLogStore->syncLogRestoreFromSnapshot(pLogStore, 4); for (int i = 5; i <= 9; ++i) { @@ -412,26 +412,23 @@ void test6() { do { SyncIndex firstVer = walGetFirstVer(pWal); SyncIndex lastVer = walGetLastVer(pWal); - bool isEmpty = walIsEmpty(pWal); + bool isEmpty = walIsEmpty(pWal); printf("before -------- firstVer:%ld lastVer:%ld isEmpty:%d \n", firstVer, lastVer, isEmpty); } while (0); logStoreDestory(pLogStore); cleanup(); - - // restart init(); pLogStore = logStoreCreate(pSyncNode); assert(pLogStore); pSyncNode->pLogStore = pLogStore; - do { SyncIndex firstVer = walGetFirstVer(pWal); SyncIndex lastVer = walGetLastVer(pWal); - bool isEmpty = walIsEmpty(pWal); + bool isEmpty = walIsEmpty(pWal); printf("after -------- firstVer:%ld lastVer:%ld isEmpty:%d \n", firstVer, lastVer, isEmpty); } while (0); @@ -461,13 +458,13 @@ int main(int argc, char** argv) { } sTrace("gAssert : %d", gAssert); -/* - test1(); - test2(); - test3(); - test4(); - test5(); -*/ + /* + test1(); + test2(); + test3(); + test4(); + test5(); + */ test6(); return 0; diff --git a/source/libs/sync/test/syncRaftLogTest3.cpp b/source/libs/sync/test/syncRaftLogTest3.cpp index 302e29a091..ea1788c545 100644 --- a/source/libs/sync/test/syncRaftLogTest3.cpp +++ b/source/libs/sync/test/syncRaftLogTest3.cpp @@ -312,7 +312,7 @@ void test5() { pSyncNode->pLogStore = pLogStore; logStoreLog2((char*)"\n\n\ntest5 ----- ", pLogStore); - //pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, 6); + // pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, 6); pLogStore->syncLogRestoreFromSnapshot(pSyncNode->pLogStore, 5); for (int i = 6; i <= 10; ++i) { int32_t dataLen = 10; From 0597f3b9cdbb98fb087315fb9d8d111f510afc60 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Sun, 26 Jun 2022 18:44:49 +0800 Subject: [PATCH 23/73] refactor: rsma resource release --- source/common/src/tmsg.c | 10 +- source/dnode/vnode/inc/vnode.h | 1 + source/dnode/vnode/src/inc/meta.h | 1 + source/dnode/vnode/src/inc/sma.h | 30 +- source/dnode/vnode/src/inc/vnodeInt.h | 6 + source/dnode/vnode/src/meta/metaOpen.c | 9 + source/dnode/vnode/src/meta/metaQuery.c | 64 ++++ source/dnode/vnode/src/meta/metaTable.c | 12 + source/dnode/vnode/src/sma/smaEnv.c | 139 +++++---- source/dnode/vnode/src/sma/smaOpen.c | 18 +- source/dnode/vnode/src/sma/smaRollup.c | 371 ++++++++++++++++------- source/dnode/vnode/src/sma/smaUtil.c | 11 +- source/dnode/vnode/src/tsdb/tsdbRead.c | 24 ++ source/dnode/vnode/src/vnd/vnodeCommit.c | 7 +- source/dnode/vnode/src/vnd/vnodeOpen.c | 6 +- source/libs/executor/inc/executorimpl.h | 1 + source/libs/executor/src/executorimpl.c | 10 +- source/os/src/osFile.c | 4 +- 18 files changed, 526 insertions(+), 198 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 9db5019512..8a052026f2 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -3696,7 +3696,7 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq * if (tDecodeI8(&decoder, &pReq->isTsma) < 0) return -1; if (pReq->isTsma) { - if (tDecodeBinaryAlloc(&decoder, &pReq->pTsma, NULL) < 0) return -1; + if (tDecodeBinary(&decoder, (uint8_t **)&pReq->pTsma, NULL) < 0) return -1; } tEndDecode(&decoder); @@ -3707,9 +3707,6 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq * int32_t tFreeSCreateVnodeReq(SCreateVnodeReq *pReq) { taosArrayDestroy(pReq->pRetensions); pReq->pRetensions = NULL; - if (pReq->isTsma) { - taosMemoryFreeClear(pReq->pTsma); - } return 0; } @@ -4747,9 +4744,8 @@ int32_t tDecodeSRSmaParam(SDecoder *pCoder, SRSmaParam *pRSmaParam) { if (tDecodeI64v(pCoder, &pRSmaParam->watermark[i]) < 0) return -1; if (tDecodeI32v(pCoder, &pRSmaParam->qmsgLen[i]) < 0) return -1; if (pRSmaParam->qmsgLen[i] > 0) { - uint64_t len; - if (tDecodeBinaryAlloc(pCoder, (void **)&pRSmaParam->qmsg[i], &len) < 0) - return -1; // qmsgLen contains len of '\0' + tDecoderMalloc(pCoder, pRSmaParam->qmsgLen[i]); + if (tDecodeBinary(pCoder, (uint8_t **)&pRSmaParam->qmsg[i], NULL) < 0) return -1; // qmsgLen contains len of '\0' } else { pRSmaParam->qmsg[i] = NULL; } diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 858376519d..c49b33beb2 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -125,6 +125,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT *pReader, STableBlockDistInfo bool isTsdbCacheLastRow(tsdbReaderT *pReader); int32_t tsdbGetAllTableList(SMeta *pMeta, uint64_t uid, SArray *list); int32_t tsdbGetCtbIdList(SMeta *pMeta, int64_t suid, SArray *list); +int32_t tsdbGetStbIdList(SMeta *pMeta, int64_t suid, SArray *list); void *tsdbGetIdx(SMeta *pMeta); void *tsdbGetIvtIdx(SMeta *pMeta); int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT *pHandle); diff --git a/source/dnode/vnode/src/inc/meta.h b/source/dnode/vnode/src/inc/meta.h index 63a8e7ec68..66d1689d57 100644 --- a/source/dnode/vnode/src/inc/meta.h +++ b/source/dnode/vnode/src/inc/meta.h @@ -69,6 +69,7 @@ struct SMeta { TTB* pUidIdx; TTB* pNameIdx; TTB* pCtbIdx; + TTB* pSuidIdx; // ivt idx and idx void* pTagIvtIdx; TTB* pTagIdx; diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 1489b02492..956e451b58 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -60,8 +60,9 @@ struct SRSmaStat { SSma *pSma; void *tmrHandle; tmr_h tmrId; - int8_t tmrStat; int32_t tmrSeconds; + int8_t triggerStat; + int8_t runningStat; SHashObj *rsmaInfoHash; // key: stbUid, value: SRSmaInfo; }; @@ -72,13 +73,21 @@ struct SSmaStat { }; T_REF_DECLARE() }; -#define SMA_TSMA_STAT(s) (&(s)->tsmaStat) -#define SMA_RSMA_STAT(s) (&(s)->rsmaStat) -#define SMA_RSMA_INFO_HASH(s) ((s)->rsmaStat.rsmaInfoHash) -#define SMA_RSMA_TMR_HANDLE(s) ((s)->rsmaStat.tmrHandle) -#define SMA_RSMA_TMR_STAT(s) ((s)->rsmaStat.tmrStat) -#define RSMA_INFO_HASH(r) ((r)->rsmaInfoHash) +#define SMA_TSMA_STAT(s) (&(s)->tsmaStat) +#define SMA_RSMA_STAT(s) (&(s)->rsmaStat) +#define RSMA_INFO_HASH(r) ((r)->rsmaInfoHash) +#define RSMA_TMR_ID(r) ((r)->tmrId) +#define RSMA_TMR_HANDLE(r) ((r)->tmrHandle) +#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat) +#define RSMA_RUNNING_STAT(r) (&(r)->runningStat) +enum { + TASK_TRIGGER_STAT_INIT = 0, + TASK_TRIGGER_STAT_ACTIVE = 1, + TASK_TRIGGER_STAT_INACTIVE = 2, + TASK_TRIGGER_STAT_CANCELLED = 3, + TASK_TRIGGER_STAT_FINISHED = 4, +}; void tdDestroySmaEnv(SSmaEnv *pSmaEnv); void *tdFreeSmaEnv(SSmaEnv *pSmaEnv); @@ -174,6 +183,8 @@ int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg); int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg); int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days); +// smaFileUtil ================ + typedef struct STFInfo STFInfo; typedef struct STFile STFile; @@ -181,7 +192,7 @@ struct STFInfo { uint32_t magic; uint32_t ftype; uint32_t fver; - uint64_t fsize; + int64_t fsize; }; struct STFile { @@ -199,11 +210,8 @@ struct STFile { #define TD_FILE_OPENED(tf) (TD_FILE_PFILE(tf) != NULL) #define TD_FILE_CLOSED(tf) (!TD_FILE_OPENED(tf)) #define TD_FILE_SET_CLOSED(f) (TD_FILE_PFILE(f) = NULL) -#define TD_FILE_STATE(tf) ((tf)->state) #define TD_FILE_SET_STATE(tf, s) ((tf)->state = (s)) #define TD_FILE_DID(tf) (TD_FILE_F(tf)->did) -#define TD_FILE_IS_OK(tf) (TD_FILE_STATE(tf) == TD_FILE_STATE_OK) -#define TD_FILE_IS_BAD(tf) (TD_FILE_STATE(tf) == TD_FILE_STATE_BAD) int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname); int32_t tdCreateTFile(STFile *pTFile, STfs *pTfs, bool updateHeader, int8_t fType); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 3b30224e17..68ed6dde51 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -76,6 +76,7 @@ void vnodeFree(void* p); // meta typedef struct SMCtbCursor SMCtbCursor; +typedef struct SMStbCursor SMStbCursor; typedef struct STbUidStore STbUidStore; int metaOpen(SVnode* pVnode, SMeta** ppMeta); @@ -97,6 +98,9 @@ int metaGetTbNum(SMeta* pMeta); SMCtbCursor* metaOpenCtbCursor(SMeta* pMeta, tb_uid_t uid); void metaCloseCtbCursor(SMCtbCursor* pCtbCur); tb_uid_t metaCtbCursorNext(SMCtbCursor* pCtbCur); +SMStbCursor* metaOpenStbCursor(SMeta* pMeta, tb_uid_t uid); +void metaCloseStbCursor(SMStbCursor* pStbCur); +tb_uid_t metaStbCursorNext(SMStbCursor* pStbCur); STSma* metaGetSmaInfoByIndex(SMeta* pMeta, int64_t indexUid); STSmaWrapper* metaGetSmaInfoByTable(SMeta* pMeta, tb_uid_t uid, bool deepCopy); SArray* metaGetSmaIdsByTable(SMeta* pMeta, tb_uid_t uid); @@ -158,6 +162,8 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool // sma int32_t smaOpen(SVnode* pVnode); int32_t smaClose(SSma* pSma); +int32_t smaCloseEnv(SSma* pSma); +int32_t smaCloseEx(SSma* pSma); int32_t tdProcessTSmaCreate(SSma* pSma, int64_t version, const char* msg); int32_t tdProcessTSmaInsert(SSma* pSma, int64_t indexUid, const char* msg); diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index 95510c25e5..614ccc5b5e 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -92,6 +92,13 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) { goto _err; } + // open pSuidIdx + ret = tdbTbOpen("suid.idx", sizeof(tb_uid_t), 0, uidIdxKeyCmpr, pMeta->pEnv, &pMeta->pSuidIdx); + if (ret < 0) { + metaError("vgId:%d, failed to open meta super table index since %s", TD_VID(pVnode), tstrerror(terrno)); + goto _err; + } + // open pTagIdx // TODO(yihaoDeng), refactor later char indexFullPath[128] = {0}; @@ -141,6 +148,7 @@ _err: if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx); if (pMeta->pTagIdx) tdbTbClose(pMeta->pTagIdx); if (pMeta->pCtbIdx) tdbTbClose(pMeta->pCtbIdx); + if (pMeta->pSuidIdx) tdbTbClose(pMeta->pSuidIdx); if (pMeta->pNameIdx) tdbTbClose(pMeta->pNameIdx); if (pMeta->pUidIdx) tdbTbClose(pMeta->pUidIdx); if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb); @@ -162,6 +170,7 @@ int metaClose(SMeta *pMeta) { if (pMeta->pTagIdx) tdbTbClose(pMeta->pTagIdx); #endif if (pMeta->pCtbIdx) tdbTbClose(pMeta->pCtbIdx); + if (pMeta->pSuidIdx) tdbTbClose(pMeta->pSuidIdx); if (pMeta->pNameIdx) tdbTbClose(pMeta->pNameIdx); if (pMeta->pUidIdx) tdbTbClose(pMeta->pUidIdx); if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb); diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 910f4bba51..f57ee54400 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -325,6 +325,70 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) { return pCtbIdxKey->uid; } +struct SMStbCursor { + SMeta *pMeta; + TBC *pCur; + tb_uid_t suid; + void *pKey; + void *pVal; + int kLen; + int vLen; +}; + +SMStbCursor *metaOpenStbCursor(SMeta *pMeta, tb_uid_t suid) { + SMStbCursor *pStbCur = NULL; + int ret = 0; + int c = 0; + + pStbCur = (SMStbCursor *)taosMemoryCalloc(1, sizeof(*pStbCur)); + if (pStbCur == NULL) { + return NULL; + } + + pStbCur->pMeta = pMeta; + pStbCur->suid = suid; + metaRLock(pMeta); + + ret = tdbTbcOpen(pMeta->pSuidIdx, &pStbCur->pCur, NULL); + if (ret < 0) { + metaULock(pMeta); + taosMemoryFree(pStbCur); + return NULL; + } + + // move to the suid + tdbTbcMoveTo(pStbCur->pCur, &suid, sizeof(suid), &c); + if (c > 0) { + tdbTbcMoveToNext(pStbCur->pCur); + } + + return pStbCur; +} + +void metaCloseStbCursor(SMStbCursor *pStbCur) { + if (pStbCur) { + if (pStbCur->pMeta) metaULock(pStbCur->pMeta); + if (pStbCur->pCur) { + tdbTbcClose(pStbCur->pCur); + + tdbFree(pStbCur->pKey); + tdbFree(pStbCur->pVal); + } + + taosMemoryFree(pStbCur); + } +} + +tb_uid_t metaStbCursorNext(SMStbCursor *pStbCur) { + int ret; + + ret = tdbTbcNext(pStbCur->pCur, &pStbCur->pKey, &pStbCur->kLen, &pStbCur->pVal, &pStbCur->vLen); + if (ret < 0) { + return 0; + } + return *(tb_uid_t*)pStbCur->pKey; +} + STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) { // SMetaReader mr = {0}; STSchema * pTSchema = NULL; diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 7109bf1dfc..ea425ca7de 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -23,6 +23,7 @@ static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME); static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME); +static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry); static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type); @@ -209,6 +210,7 @@ _drop_super_table: &pMeta->txn); tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pMeta->txn); tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pMeta->txn); + tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), &pMeta->txn); metaULock(pMeta); @@ -436,11 +438,13 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), &pMeta->txn); if(e.type != TSDB_SUPER_TABLE) metaDeleteTtlIdx(pMeta, &e); + if (e.type == TSDB_CHILD_TABLE) { tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), &pMeta->txn); } else if (e.type == TSDB_NORMAL_TABLE) { // drop schema.db (todo) } else if (e.type == TSDB_SUPER_TABLE) { + tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), &pMeta->txn); // drop schema.db (todo) } @@ -911,6 +915,10 @@ static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) { return tdbTbInsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &pME->version, sizeof(int64_t), &pMeta->txn); } +static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME) { + return tdbTbInsert(pMeta->pSuidIdx, &pME->uid, sizeof(tb_uid_t), NULL, 0, &pMeta->txn); +} + static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) { return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), &pMeta->txn); } @@ -1081,6 +1089,10 @@ static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) { } else { // update schema.db if (metaSaveToSkmDb(pMeta, pME) < 0) goto _err; + + if (pME->type == TSDB_SUPER_TABLE) { + if (metaUpdateSuidIdx(pMeta, pME) < 0) goto _err; + } } if (pME->type != TSDB_SUPER_TABLE) { diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index 4e907e93ca..1e8832615e 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -126,22 +126,21 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS } if (smaType == TSDB_SMA_TYPE_ROLLUP) { - SMA_RSMA_STAT(*pSmaStat)->pSma = (SSma*)pSma; + SRSmaStat *pRSmaStat = (SRSmaStat *)(*pSmaStat); + pRSmaStat->pSma = (SSma *)pSma; // init timer - SMA_RSMA_TMR_HANDLE(*pSmaStat) = taosTmrInit(10000, 100, 10000, "RSMA_G"); - if (!SMA_RSMA_TMR_HANDLE(*pSmaStat)) { + RSMA_TMR_HANDLE(pRSmaStat) = taosTmrInit(10000, 100, 10000, "RSMA"); + if (!RSMA_TMR_HANDLE(pRSmaStat)) { taosMemoryFreeClear(*pSmaStat); return TSDB_CODE_FAILED; } - - atomic_store_8(&SMA_RSMA_TMR_STAT(*pSmaStat), TASK_TRIGGER_STATUS__ACTIVE); // init hash - SMA_RSMA_INFO_HASH(*pSmaStat) = taosHashInit( + RSMA_INFO_HASH(pRSmaStat) = taosHashInit( RSMA_TASK_INFO_HASH_SLOT, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK); - if (!SMA_RSMA_INFO_HASH(*pSmaStat)) { - if (SMA_RSMA_TMR_HANDLE(*pSmaStat)) { - taosTmrCleanUp(SMA_RSMA_TMR_HANDLE(*pSmaStat)); + if (!RSMA_INFO_HASH(pRSmaStat)) { + if (RSMA_TMR_HANDLE(pRSmaStat)) { + taosTmrCleanUp(RSMA_TMR_HANDLE(pRSmaStat)); } taosMemoryFreeClear(*pSmaStat); return TSDB_CODE_FAILED; @@ -155,12 +154,79 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS return TSDB_CODE_SUCCESS; } -static void *tdFreeTSmaStat(STSmaStat *pStat) { +static void tdDestroyTSmaStat(STSmaStat *pStat) { if (pStat) { tDestroyTSma(pStat->pTSma); taosMemoryFreeClear(pStat->pTSma); - taosMemoryFreeClear(pStat); + taosMemoryFreeClear(pStat->pTSchema); } +} + +static void *tdFreeTSmaStat(STSmaStat *pStat) { + tdDestroyTSmaStat(pStat); + taosMemoryFreeClear(pStat); + return NULL; +} + +static void tdDestroyRSmaStat(SRSmaStat *pStat) { + if (pStat) { + smaDebug("vgId:%d, %s:%d free rsma stat", SMA_VID(pStat->pSma), __func__, __LINE__); + // step 1: set persistence task cancelled + atomic_store_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_CANCELLED); + + // step 2: clean timer + taosTmrStopA(&RSMA_TMR_ID(pStat)); + if (RSMA_TMR_HANDLE(pStat)) { + taosTmrCleanUp(RSMA_TMR_HANDLE(pStat)); + } + + // step 3: wait the persistence thread to finish + int32_t nLoops = 0; + if (atomic_load_8(RSMA_RUNNING_STAT(pStat)) == 1) { + while (1) { + if (atomic_load_8(RSMA_TRIGGER_STAT(pStat)) == TASK_TRIGGER_STAT_FINISHED) { + break; + } else { + smaDebug("not destroyed since rsma stat in %" PRIi8, atomic_load_8(RSMA_TRIGGER_STAT(pStat))); + } + ++nLoops; + if (nLoops > 1000) { + sched_yield(); + nLoops = 0; + } + taosMsleep(1000); // TODO: remove this line when release + } + } + + // step 4: destroy the rsma info and associated fetch tasks + // TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready. + void *infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), NULL); + while (infoHash) { + SRSmaInfo *pSmaInfo = *(SRSmaInfo **)infoHash; + tdFreeRSmaInfo(pSmaInfo); + infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), infoHash); + } + taosHashCleanup(RSMA_INFO_HASH(pStat)); + + // step 5: wait all triggered fetch tasks finished + nLoops = 0; + while (1) { + if (T_REF_VAL_GET((SSmaStat *)pStat) == 0) { + break; + } + ++nLoops; + if (nLoops > 1000) { + sched_yield(); + nLoops = 0; + } + taosMsleep(1000); // TODO: remove this line when release + } + } +} + +static void *tdFreeRSmaStat(SRSmaStat *pStat) { + tdDestroyRSmaStat(pStat); + taosMemoryFreeClear(pStat); return NULL; } @@ -179,22 +245,16 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { if (pSmaStat) { if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - tdFreeTSmaStat(&pSmaStat->tsmaStat); + smaDebug("%s:%d destroy tsma stat", __func__, __LINE__); + tdDestroyTSmaStat(SMA_TSMA_STAT(pSmaStat)); } else if (smaType == TSDB_SMA_TYPE_ROLLUP) { - if (SMA_RSMA_TMR_HANDLE(pSmaStat)) { - taosTmrCleanUp(SMA_RSMA_TMR_HANDLE(pSmaStat)); - } - // TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready. - void *infoHash = taosHashIterate(SMA_RSMA_INFO_HASH(pSmaStat), NULL); - while (infoHash) { - SRSmaInfo *pInfoHash = *(SRSmaInfo **)infoHash; - tdFreeRSmaInfo(pInfoHash); - infoHash = taosHashIterate(SMA_RSMA_INFO_HASH(pSmaStat), infoHash); - } - taosHashCleanup(SMA_RSMA_INFO_HASH(pSmaStat)); + smaDebug("%s:%d destroy rsma stat", __func__, __LINE__); + tdDestroyRSmaStat(SMA_RSMA_STAT(pSmaStat)); } else { ASSERT(0); } + } else { + smaDebug("%s:%d no need to destroy rsma stat", __func__, __LINE__); } return TSDB_CODE_SUCCESS; } @@ -259,35 +319,4 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) { tdUnLockSma(pSma); return TSDB_CODE_SUCCESS; -}; - -int32_t smaTimerInit(void **timer, int8_t *initFlag, const char *label) { - int8_t old; - while (1) { - old = atomic_val_compare_exchange_8(initFlag, 0, 2); - if (old != 2) break; - } - - if (old == 0) { - *timer = taosTmrInit(10000, 100, 10000, label); - if (!(*timer)) { - atomic_store_8(initFlag, 0); - return -1; - } - atomic_store_8(initFlag, 1); - } - return 0; -} - -void smaTimerCleanUp(void *timer, int8_t *initFlag) { - int8_t old; - while (1) { - old = atomic_val_compare_exchange_8(initFlag, 1, 2); - if (old != 2) break; - } - - if (old == 1) { - taosTmrCleanUp(timer); - atomic_store_8(initFlag, 0); - } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index 383c264e7b..2f40df8b45 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -126,19 +126,31 @@ _err: return -1; } -int32_t smaClose(SSma *pSma) { +int32_t smaCloseEnv(SSma *pSma) { + if(pSma) { + SMA_TSMA_ENV(pSma) = tdFreeSmaEnv(SMA_TSMA_ENV(pSma)); + SMA_RSMA_ENV(pSma) = tdFreeSmaEnv(SMA_RSMA_ENV(pSma)); + } + return 0; +} + +int32_t smaCloseEx(SSma *pSma) { if (pSma) { taosThreadMutexDestroy(&pSma->mutex); if SMA_RSMA_TSDB0 (pSma) tsdbClose(&SMA_RSMA_TSDB0(pSma)); if SMA_RSMA_TSDB1 (pSma) tsdbClose(&SMA_RSMA_TSDB1(pSma)); if SMA_RSMA_TSDB2 (pSma) tsdbClose(&SMA_RSMA_TSDB2(pSma)); - // SMA_TSMA_ENV(pSma) = tdFreeSmaEnv(SMA_TSMA_ENV(pSma)); - // SMA_RSMA_ENV(pSma) = tdFreeSmaEnv(SMA_RSMA_ENV(pSma)); taosMemoryFreeClear(pSma); } return 0; } +int32_t smaClose(SSma *pSma) { + smaCloseEnv(pSma); + smaCloseEx(pSma); + return 0; +} + /** * @brief rsma env restore * diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 3c2f710fa7..020ee38db9 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -14,8 +14,8 @@ */ #include "sma.h" -#include "tstream.h" +#define RSMA_QTASK_PERSIST_MS 7200000 typedef enum { TD_QTASK_TMP_FILE = 0, TD_QTASK_CUR_FILE } TD_QTASK_FILE_T; static const char *tdQTaskInfoFname[] = {"qtaskinfo.t", "qtaskinfo"}; @@ -31,13 +31,13 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId); struct SRSmaInfoItem { SRSmaInfo *pRsmaInfo; void *taskInfo; // qTaskInfo_t - void *tmrHandle; tmr_h tmrId; int8_t level; int8_t tmrInitFlag; - int8_t triggerStatus; // TASK_TRIGGER_STATUS__IN_ACTIVE/TASK_TRIGGER_STATUS__ACTIVE + int8_t triggerStat; int32_t maxDelay; }; + struct SRSmaInfo { STSchema *pTSchema; SSma *pSma; @@ -45,11 +45,14 @@ struct SRSmaInfo { SRSmaInfoItem items[TSDB_RETENTION_L2]; }; -static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle) { +static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) { // Note: free/kill may in RC qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle); if (otaskHandle && atomic_val_compare_exchange_ptr(taskHandle, otaskHandle, NULL)) { + smaDebug("vgId:%d, %s:%d free qTaskInfo_t %p of level %d", vgId, __func__, __LINE__, otaskHandle, level); qDestroyTask(otaskHandle); + } else { + smaDebug("vgId:%d, %s:%d not free qTaskInfo_t %p of level %d", vgId, __func__, __LINE__, otaskHandle, level); } } @@ -58,14 +61,19 @@ void *tdFreeRSmaInfo(SRSmaInfo *pInfo) { for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { SRSmaInfoItem *pItem = &pInfo->items[i]; if (pItem->taskInfo) { - tdFreeTaskHandle(pItem->taskInfo); - } - if (pItem->tmrHandle) { - taosTmrCleanUp(pItem->tmrHandle); + smaDebug("vgId:%d, stb %" PRIi64 " stop fetch-timer %p level %d", SMA_VID(pInfo->pSma), pInfo->suid, + pItem->tmrId, i + 1); + taosTmrStopA(&pItem->tmrId); + tdFreeTaskHandle(&pItem->taskInfo, SMA_VID(pInfo->pSma), i + 1); + } else { + smaDebug("vgId:%d, stb %" PRIi64 " no need to destroy rsma info level %d since empty taskInfo", + SMA_VID(pInfo->pSma), pInfo->suid, i + 1); } } taosMemoryFree(pInfo->pTSchema); taosMemoryFree(pInfo); + } else { + smaDebug("vgId:%d, stb %" PRIi64 " no need to destroy rsma info since empty", SMA_VID(pInfo->pSma), pInfo->suid); } return NULL; @@ -83,7 +91,7 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) { static FORCE_INLINE int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids) { SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); - SSmaStat *pStat = SMA_ENV_STAT(pEnv); + SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); SRSmaInfo *pRSmaInfo = NULL; if (!suid || !tbUids) { @@ -92,27 +100,31 @@ static FORCE_INLINE int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SA return TSDB_CODE_FAILED; } - pRSmaInfo = taosHashGet(SMA_RSMA_INFO_HASH(pStat), suid, sizeof(tb_uid_t)); + pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), suid, sizeof(tb_uid_t)); if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) { smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64, SMA_VID(pSma), *suid); terrno = TSDB_CODE_RSMA_INVALID_STAT; return TSDB_CODE_FAILED; } - if (pRSmaInfo->items[0].taskInfo && (qUpdateQualifiedTableId(pRSmaInfo->items[0].taskInfo, tbUids, true) < 0)) { - smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr(terrno)); - return TSDB_CODE_FAILED; - } else { - smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 ", uid:%" PRIi64, SMA_VID(pSma), - pRSmaInfo->items[0].taskInfo, *suid, *(int64_t *)taosArrayGet(tbUids, 0)); + if (pRSmaInfo->items[0].taskInfo) { + if ((qUpdateQualifiedTableId(pRSmaInfo->items[0].taskInfo, tbUids, true) < 0)) { + smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr(terrno)); + return TSDB_CODE_FAILED; + } else { + smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 ", uid:%" PRIi64, SMA_VID(pSma), + pRSmaInfo->items[0].taskInfo, *suid, *(int64_t *)taosArrayGet(tbUids, 0)); + } } - if (pRSmaInfo->items[1].taskInfo && (qUpdateQualifiedTableId(pRSmaInfo->items[1].taskInfo, tbUids, true) < 0)) { - smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr(terrno)); - return TSDB_CODE_FAILED; - } else { - smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 ", uid:%" PRIi64, SMA_VID(pSma), - pRSmaInfo->items[1].taskInfo, *suid, *(int64_t *)taosArrayGet(tbUids, 0)); + if (pRSmaInfo->items[1].taskInfo) { + if ((qUpdateQualifiedTableId(pRSmaInfo->items[1].taskInfo, tbUids, true) < 0)) { + smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr(terrno)); + return TSDB_CODE_FAILED; + } else { + smaDebug("vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%" PRIi64 ", uid:%" PRIi64, SMA_VID(pSma), + pRSmaInfo->items[1].taskInfo, *suid, *(int64_t *)taosArrayGet(tbUids, 0)); + } } return TSDB_CODE_SUCCESS; @@ -159,9 +171,9 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui return TSDB_CODE_SUCCESS; } - SSmaStat *pStat = SMA_ENV_STAT(pEnv); - SHashObj *infoHash = NULL; - if (!pStat || !(infoHash = SMA_RSMA_INFO_HASH(pStat))) { + SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); + SHashObj *infoHash = NULL; + if (!pStat || !(infoHash = RSMA_INFO_HASH(pStat))) { terrno = TSDB_CODE_RSMA_INVALID_STAT; return TSDB_CODE_FAILED; } @@ -195,11 +207,11 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaInfo if (param->qmsg[idx]) { SRSmaInfoItem *pItem = &(pRSmaInfo->items[idx]); pItem->pRsmaInfo = pRSmaInfo; - pItem->taskInfo = qCreateStreamExecTaskInfo(param->qmsg[0], pReadHandle); + pItem->taskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], pReadHandle); if (!pItem->taskInfo) { goto _err; } - pItem->triggerStatus = TASK_TRIGGER_STATUS__IN_ACTIVE; + pItem->triggerStat = TASK_TRIGGER_STAT_INACTIVE; if (param->maxdelay[idx] < TSDB_MIN_ROLLUP_MAX_DELAY) { int64_t msInterval = convertTimeFromPrecisionToUnit(pRetention[idx + 1].freq, pTsdbCfg->precision, TIME_UNIT_MILLISECOND); @@ -211,10 +223,6 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaInfo pItem->maxDelay = TSDB_MAX_ROLLUP_MAX_DELAY; } pItem->level = (idx == 0 ? TSDB_RETENTION_L1 : TSDB_RETENTION_L2); - pItem->tmrHandle = taosTmrInit(10000, 100, 10000, "RSMA"); - if (!pItem->tmrHandle) { - goto _err; - } } return TSDB_CODE_SUCCESS; _err: @@ -251,10 +259,10 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { } SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); - SSmaStat *pStat = SMA_ENV_STAT(pEnv); + SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); SRSmaInfo *pRSmaInfo = NULL; - pRSmaInfo = taosHashGet(SMA_RSMA_INFO_HASH(pStat), &pReq->suid, sizeof(tb_uid_t)); + pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &pReq->suid, sizeof(tb_uid_t)); if (pRSmaInfo) { ASSERT(0); // TODO: free original pRSmaInfo is exists abnormally smaWarn("vgId:%d, rsma info already exists for stb: %s, %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); @@ -293,16 +301,23 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { if (tdSetRSmaInfoItemParams(pSma, param, pRSmaInfo, &handle, 0) < 0) { goto _err; } + if (tdSetRSmaInfoItemParams(pSma, param, pRSmaInfo, &handle, 1) < 0) { goto _err; } - if (taosHashPut(SMA_RSMA_INFO_HASH(pStat), &pReq->suid, sizeof(tb_uid_t), &pRSmaInfo, sizeof(pRSmaInfo)) < 0) { + if (taosHashPut(RSMA_INFO_HASH(pStat), &pReq->suid, sizeof(tb_uid_t), &pRSmaInfo, sizeof(pRSmaInfo)) < 0) { goto _err; } else { smaDebug("vgId:%d, register rsma info succeed for suid:%" PRIi64, SMA_VID(pSma), pReq->suid); } + // start the persist timer + if (TASK_TRIGGER_STAT_INIT == + atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_INIT, TASK_TRIGGER_STAT_ACTIVE)) { + taosTmrStart(tdRSmaPersistTrigger, RSMA_QTASK_PERSIST_MS, pStat, RSMA_TMR_HANDLE(pStat)); + } + return TSDB_CODE_SUCCESS; _err: tdFreeRSmaInfo(pRSmaInfo); @@ -432,6 +447,16 @@ static int32_t tdFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) { return 0; } +static void tdDestroySDataBlockArray(SArray *pArray) { +#if 0 + for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) { + SSDataBlock *pDataBlock = taosArrayGet(pArray, i); + blockDestroyInner(pDataBlock); + } +#endif + taosArrayDestroy(pArray); +} + static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType) { SArray *pResult = NULL; SRSmaInfo *pRSmaInfo = pItem->pRsmaInfo; @@ -466,6 +491,7 @@ static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType) #endif STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb1 : pSma->pRSmaTsdb2); SSubmitReq *pReq = NULL; + // TODO: the schema update should be handled if (buildSubmitReqFromDataBlock(&pReq, pResult, pRSmaInfo->pTSchema, SMA_VID(pSma), pRSmaInfo->suid) < 0) { goto _err; } @@ -477,17 +503,13 @@ static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType) taosMemoryFreeClear(pReq); } else { - smaDebug("vgId:%d, no rsma % " PRIi8 " data generated since %s", SMA_VID(pSma), pItem->level, tstrerror(terrno)); + smaDebug("vgId:%d, no rsma %" PRIi8 " data generated since %s", SMA_VID(pSma), pItem->level, tstrerror(terrno)); } - if (blkType == STREAM_DATA_TYPE_SUBMIT_BLOCK) { - atomic_store_8(&pItem->triggerStatus, TASK_TRIGGER_STATUS__ACTIVE); - } - - taosArrayDestroy(pResult); + tdDestroySDataBlockArray(pResult); return TSDB_CODE_SUCCESS; _err: - taosArrayDestroy(pResult); + tdDestroySDataBlockArray(pResult); return TSDB_CODE_FAILED; } @@ -499,22 +521,34 @@ _err: */ static void tdRSmaFetchTrigger(void *param, void *tmrId) { SRSmaInfoItem *pItem = param; + SSma *pSma = pItem->pRsmaInfo->pSma; + SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT((SSmaEnv *)pSma->pRSmaEnv); - if (atomic_load_8(&pItem->triggerStatus) == TASK_TRIGGER_STATUS__ACTIVE) { - smaWarn("%s:%d THREAD:%" PRIi64 " level %" PRIi8 " status is active for tb suid:%" PRIi64, __func__, __LINE__, - taosGetSelfPthreadId(), pItem->level, pItem->pRsmaInfo->suid); - SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL}; - - atomic_store_8(&pItem->triggerStatus, TASK_TRIGGER_STATUS__IN_ACTIVE); - qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_DATA_TYPE_SSDATA_BLOCK, false); - - tdFetchAndSubmitRSmaResult(pItem, STREAM_DATA_TYPE_SSDATA_BLOCK); - } else { - smaWarn("%s:%d THREAD:%" PRIi64 " level %" PRIi8 " status is inactive for tb suid:%" PRIi64, __func__, __LINE__, - taosGetSelfPthreadId(), pItem->level, pItem->pRsmaInfo->suid); + int8_t rsmaTriggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pStat)); + if (rsmaTriggerStat == TASK_TRIGGER_STAT_CANCELLED || rsmaTriggerStat == TASK_TRIGGER_STAT_FINISHED) { + smaDebug("vgId:%d, %s:%d level %" PRIi8 " not fetch since stat is cancelled for table suid:%" PRIi64, SMA_VID(pSma), + __func__, __LINE__, pItem->level, pItem->pRsmaInfo->suid); + return; } - // taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, pItem->tmrHandle, &pItem->tmrId); + int8_t fetchTriggerStat = + atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE); + if (fetchTriggerStat == TASK_TRIGGER_STAT_ACTIVE) { + smaDebug("vgId:%d, %s:%d level %" PRIi8 " stat is active for table suid:%" PRIi64, SMA_VID(pSma), __func__, + __LINE__, pItem->level, pItem->pRsmaInfo->suid); + + tdRefSmaStat(pSma, (SSmaStat *)pStat); + + SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL}; + qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_DATA_TYPE_SSDATA_BLOCK, false); + tdFetchAndSubmitRSmaResult(pItem, STREAM_DATA_TYPE_SSDATA_BLOCK); + + tdUnRefSmaStat(pSma, (SSmaStat *)pStat); + + } else { + smaDebug("vgId:%d, %s:%d level %" PRIi8 " stat is inactive for table suid:%" PRIi64, SMA_VID(pSma), __func__, + __LINE__, pItem->level, pItem->pRsmaInfo->suid); + } } static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem, @@ -533,14 +567,17 @@ static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int3 } tdFetchAndSubmitRSmaResult(pItem, STREAM_DATA_TYPE_SUBMIT_BLOCK); - atomic_store_8(&pItem->triggerStatus, TASK_TRIGGER_STATUS__ACTIVE); - smaWarn("%s:%d THREAD:%" PRIi64 " process rsma insert", __func__, __LINE__, taosGetSelfPthreadId()); + atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE); + smaDebug("vgId:%d, %s:%d process rsma insert", SMA_VID(pSma), __func__, __LINE__); SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pStat = SMA_RSMA_STAT(pEnv->pStat); - taosTmrStart(tdRSmaPersistTrigger, 5000, pStat, pStat->tmrHandle); - taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, pItem->tmrHandle, &pItem->tmrId); + if (pStat->tmrHandle) { + taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, pStat->tmrHandle, &pItem->tmrId); + } else { + ASSERT(0); + } return TSDB_CODE_SUCCESS; } @@ -552,10 +589,10 @@ static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb return TSDB_CODE_SUCCESS; } - SSmaStat *pStat = SMA_ENV_STAT(pEnv); + SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); SRSmaInfo *pRSmaInfo = NULL; - pRSmaInfo = taosHashGet(SMA_RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t)); + pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t)); if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) { smaDebug("vgId:%d, return as no rsma info for suid:%" PRIu64, SMA_VID(pSma), suid); @@ -608,7 +645,7 @@ int32_t tdProcessRSmaSubmit(SSma *pSma, void *pMsg, int32_t inputType) { return TSDB_CODE_SUCCESS; } -void tdRSmaQTaskGetFName(int32_t vid, int8_t ftype, char* outputName) { +void tdRSmaQTaskGetFName(int32_t vid, int8_t ftype, char *outputName) { tdGetVndFileName(vid, "rsma", tdQTaskInfoFname[ftype], outputName); } @@ -618,6 +655,23 @@ static void *tdRSmaPersistExec(void *param) { SSma *pSma = pRSmaStat->pSma; STfs *pTfs = pSma->pVnode->pTfs; int64_t toffset = 0; + bool isFileCreated = false; + + if (TASK_TRIGGER_STAT_CANCELLED == atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))) { + goto _end; + } + +#if 0 + SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t)); + if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) { + ASSERT(0); + } else { + for (int32_t i = 0; i < taosArrayGetSize(suidList); ++i) { + tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i); + smaDebug("suid [%d] is %" PRIi64, i, suid); + } + } +#endif void *infoHash = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), NULL); if (!infoHash) { @@ -625,67 +679,142 @@ static void *tdRSmaPersistExec(void *param) { } STFile tFile = {0}; - int32_t vid = 2; - char qTaskInfoFName[TSDB_FILENAME_LEN]; - tdRSmaQTaskGetFName(vid, TD_QTASK_TMP_FILE, qTaskInfoFName); - tdInitTFile(&tFile, pTfs, qTaskInfoFName); - tdCreateTFile(&tFile, pTfs, true, -1); + int32_t vid = SMA_VID(pSma); while (infoHash) { SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)infoHash; - char *pOutput = NULL; - int32_t len = 0; - if (qSerializeTaskStatus(pRSmaInfo->items[0].taskInfo, &pOutput, &len) < 0) { - smaError("serialize rsma task for table %" PRIi64 " failed since %s", pRSmaInfo->items[0].pRsmaInfo->suid, - terrstr(terrno)); - } else { - smaWarn("serialize rsma task for table %" PRIi64 " success and len is %d", pRSmaInfo->items[0].pRsmaInfo->suid, - len); - } - tdAppendTFile(&tFile, &len, sizeof(len), &toffset); - tdAppendTFile(&tFile, pOutput, len, &toffset); - taosMemoryFree(pOutput); +#if 0 + smaDebug("table %" PRIi64 " sleep 15s start ...", pRSmaInfo->items[0].pRsmaInfo->suid); + for (int32_t i = 15; i > 0; --i) { + taosSsleep(1); + smaDebug("table %" PRIi64 " countdown %d", pRSmaInfo->items[0].pRsmaInfo->suid, i); + } + smaDebug("table %" PRIi64 " sleep 15s end ...", pRSmaInfo->items[0].pRsmaInfo->suid); +#endif + for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { + qTaskInfo_t taskInfo = pRSmaInfo->items[i].taskInfo; + if (!taskInfo) { + smaDebug("vgId:%d, table %" PRIi64 " level %d qTaskInfo is NULL", vid, pRSmaInfo->suid, i + 1); + continue; + } + char *pOutput = NULL; + int32_t len = 0; + int8_t type = 0; + if (qSerializeTaskStatus(taskInfo, &pOutput, &len) < 0) { + smaError("vgId:%d, table %" PRIi64 " level %d serialize rsma task failed since %s", vid, pRSmaInfo->suid, i + 1, + terrstr(terrno)); + goto _err; + } else { + if (!pOutput) { + smaDebug("vgId:%d, table %" PRIi64 + " level %d serialize rsma task success but no output(len %d) and no need to persist", + vid, pRSmaInfo->suid, i + 1, len); + continue; + } else if (len <= 0) { + smaDebug("vgId:%d, table %" PRIi64 " level %d serialize rsma task success with len %d and no need to persist", + vid, pRSmaInfo->suid, i + 1, len); + taosMemoryFree(pOutput); + } + smaDebug("vgId:%d, table %" PRIi64 " level %d serialize rsma task success with len %d and need persist", vid, + pRSmaInfo->suid, i + 1, len); +#if 1 + if (qDeserializeTaskStatus(taskInfo, pOutput, len) < 0) { + smaError("vgId:%d, table %" PRIi64 "level %d deserialize rsma task failed since %s", vid, pRSmaInfo->suid, + i + 1, terrstr(terrno)); + } else { + smaDebug("vgId:%d, table %" PRIi64 " level %d deserialize rsma task success", vid, pRSmaInfo->suid, i + 1); + } +#endif + } + + if (!isFileCreated) { + char qTaskInfoFName[TSDB_FILENAME_LEN]; + tdRSmaQTaskGetFName(vid, TD_QTASK_TMP_FILE, qTaskInfoFName); + tdInitTFile(&tFile, pTfs, qTaskInfoFName); + tdCreateTFile(&tFile, pTfs, true, -1); + + isFileCreated = true; + } + len += (sizeof(len) + sizeof(pRSmaInfo->suid)); + tdAppendTFile(&tFile, &len, sizeof(len), &toffset); + tdAppendTFile(&tFile, &pRSmaInfo->suid, sizeof(pRSmaInfo->suid), &toffset); + tdAppendTFile(&tFile, pOutput, len, &toffset); + + taosMemoryFree(pOutput); + } infoHash = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), infoHash); } -_end: +_normal: + if (isFileCreated) { + if (tdUpdateTFileHeader(&tFile) < 0) { + smaError("vgId:%d, failed to update tfile %s header since %s", vid, TD_FILE_FULL_NAME(&tFile), tstrerror(terrno)); + tdCloseTFile(&tFile); + tdRemoveTFile(&tFile); + goto _err; + } else { + smaDebug("vgId:%d, succeed to update tfile %s header", vid, TD_FILE_FULL_NAME(&tFile)); + } - if (tdUpdateTFileHeader(&tFile) < 0) { - smaError("vgId:%d, failed to update tfile %s header since %s", vid, TD_FILE_FULL_NAME(&tFile), tstrerror(terrno)); tdCloseTFile(&tFile); - tdRemoveTFile(&tFile); - return NULL; + + char newFName[TSDB_FILENAME_LEN]; + strncpy(newFName, TD_FILE_FULL_NAME(&tFile), TSDB_FILENAME_LEN); + char *pos = strstr(newFName, tdQTaskInfoFname[TD_QTASK_TMP_FILE]); + strncpy(pos, tdQTaskInfoFname[TD_QTASK_CUR_FILE], TSDB_FILENAME_LEN - POINTER_DISTANCE(pos, newFName)); + if (taosRenameFile(TD_FILE_FULL_NAME(&tFile), newFName) != 0) { + smaError("vgId:%d, failed to rename %s to %s", vid, TD_FILE_FULL_NAME(&tFile), newFName); + goto _err; + } else { + smaDebug("vgId:%d, succeed to rename %s to %s", vid, TD_FILE_FULL_NAME(&tFile), newFName); + } } - - tdCloseTFile(&tFile); - - char newFName[TSDB_FILENAME_LEN]; - strncpy(newFName, TD_FILE_FULL_NAME(&tFile), TSDB_FILENAME_LEN); - char *pos = strstr(newFName, tdQTaskInfoFname[TD_QTASK_TMP_FILE]); - strncpy(pos, tdQTaskInfoFname[TD_QTASK_CUR_FILE], TSDB_FILENAME_LEN - POINTER_DISTANCE(pos, newFName)); - taosRenameFile(TD_FILE_FULL_NAME(&tFile), newFName); - - atomic_store_8(&pRSmaStat->tmrStat, TASK_TRIGGER_STATUS__ACTIVE); - return NULL; + goto _end; _err: - atomic_store_8(&pRSmaStat->tmrStat, TASK_TRIGGER_STATUS__ACTIVE); - // remove the .tmp file + if (isFileCreated) { + tdRemoveTFile(&tFile); + } +_end: + if (TASK_TRIGGER_STAT_INACTIVE == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), + TASK_TRIGGER_STAT_INACTIVE, + TASK_TRIGGER_STAT_ACTIVE)) { + smaDebug("vgId:%d, persist task is active again", vid); + } else if (TASK_TRIGGER_STAT_CANCELLED == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), + TASK_TRIGGER_STAT_CANCELLED, + TASK_TRIGGER_STAT_FINISHED)) { + smaDebug("vgId:%d, persist task is cancelled", vid); + } else { + smaWarn("vgId:%d, persist task in abnormal stat %" PRIi8, vid, atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))); + ASSERT(0); + } + atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); + taosThreadExit(NULL); return NULL; } static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) { - smaWarn("%s:%d entry ", __func__, __LINE__); - TdThread threadId; TdThreadAttr thAttr; taosThreadAttrInit(&thAttr); taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_DETACHED); + TdThread tid; - if (taosThreadCreate(&threadId, &thAttr, tdRSmaPersistExec, pRSmaStat) != 0) { - smaError("failed to create thread to persist rsma qTaskInfo since %s", strerror(errno)); + if (taosThreadCreate(&tid, &thAttr, tdRSmaPersistExec, pRSmaStat) != 0) { + if (TASK_TRIGGER_STAT_INACTIVE == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), + TASK_TRIGGER_STAT_INACTIVE, + TASK_TRIGGER_STAT_ACTIVE)) { + smaDebug("persist task is active again"); + } else if (TASK_TRIGGER_STAT_CANCELLED == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), + TASK_TRIGGER_STAT_CANCELLED, + TASK_TRIGGER_STAT_FINISHED)) { + smaDebug(" persist task is cancelled and set finished"); + } else { + smaWarn("persist task in abnormal stat %" PRIi8, atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat))); + ASSERT(0); + } + atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); } taosThreadAttrDestroy(&thAttr); - smaWarn("%s:%d end ", __func__, __LINE__); } /** @@ -696,17 +825,33 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) { */ static void tdRSmaPersistTrigger(void *param, void *tmrId) { SRSmaStat *pRSmaStat = param; - - if (atomic_load_8(&pRSmaStat->tmrStat) == TASK_TRIGGER_STATUS__ACTIVE) { - smaWarn("%s:%d THREAD:%" PRIi64 " rsma persistence start since active", __func__, __LINE__, taosGetSelfPthreadId()); - atomic_store_8(&pRSmaStat->tmrStat, TASK_TRIGGER_STATUS__IN_ACTIVE); - - // execution - tdRSmaPersistTask(pRSmaStat); - } else { - smaWarn("%s:%d THREAD:%" PRIi64 " rsma persistence not start since inactive", __func__, __LINE__, - taosGetSelfPthreadId()); + int8_t tmrStat = + atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE); + switch (tmrStat) { + case TASK_TRIGGER_STAT_ACTIVE: { + atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 1); + if (TASK_TRIGGER_STAT_CANCELLED != atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), + TASK_TRIGGER_STAT_CANCELLED, + TASK_TRIGGER_STAT_FINISHED)) { + smaDebug("%s:%d rsma persistence start since active", __func__, __LINE__); + tdRSmaPersistTask(pRSmaStat); + taosTmrReset(tdRSmaPersistTrigger, RSMA_QTASK_PERSIST_MS, pRSmaStat, pRSmaStat->tmrHandle, &pRSmaStat->tmrId); + } else { + atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); + } + } break; + case TASK_TRIGGER_STAT_CANCELLED: { + atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_FINISHED); + smaDebug("%s:%d rsma persistence not start since cancelled and finished", __func__, __LINE__); + } break; + case TASK_TRIGGER_STAT_INACTIVE: { + smaDebug("%s:%d rsma persistence not start since inactive", __func__, __LINE__); + } break; + case TASK_TRIGGER_STAT_INIT: { + smaDebug("%s:%d rsma persistence not start since init", __func__, __LINE__); + } break; + default: { + smaWarn("%s:%d rsma persistence not start since unknown stat %" PRIi8, __func__, __LINE__, tmrStat); + } break; } - - taosTmrReset(tdRSmaPersistTrigger, 3600000, pRSmaStat, pRSmaStat->tmrHandle, &pRSmaStat->tmrId); } \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaUtil.c b/source/dnode/vnode/src/sma/smaUtil.c index 76690a3bde..85fddebf55 100644 --- a/source/dnode/vnode/src/sma/smaUtil.c +++ b/source/dnode/vnode/src/sma/smaUtil.c @@ -15,6 +15,8 @@ #include "sma.h" +// smaFileUtil ================ + #define TD_FILE_HEAD_SIZE 512 #define TD_FILE_STATE_OK 0 @@ -32,7 +34,7 @@ static int32_t tdEncodeTFInfo(void **buf, STFInfo *pInfo) { tlen += taosEncodeFixedU32(buf, pInfo->magic); tlen += taosEncodeFixedU32(buf, pInfo->ftype); tlen += taosEncodeFixedU32(buf, pInfo->fver); - tlen += taosEncodeFixedU64(buf, pInfo->fsize); + tlen += taosEncodeFixedI64(buf, pInfo->fsize); return tlen; } @@ -41,7 +43,7 @@ static void *tdDecodeTFInfo(void *buf, STFInfo *pInfo) { buf = taosDecodeFixedU32(buf, &(pInfo->magic)); buf = taosDecodeFixedU32(buf, &(pInfo->ftype)); buf = taosDecodeFixedU32(buf, &(pInfo->fver)); - buf = taosDecodeFixedU64(buf, &(pInfo->fsize)); + buf = taosDecodeFixedI64(buf, &(pInfo->fsize)); return buf; } @@ -235,4 +237,7 @@ int32_t tdCreateTFile(STFile *pTFile, STfs *pTfs, bool updateHeader, int8_t fTyp return 0; } -int32_t tdRemoveTFile(STFile *pTFile) { return tfsRemoveFile(TD_FILE_F(pTFile)); } \ No newline at end of file +int32_t tdRemoveTFile(STFile *pTFile) { return tfsRemoveFile(TD_FILE_F(pTFile)); } + +// smaXXXUtil ================ +// ... \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index ab31d65d68..bd40fd4a1f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -2876,6 +2876,30 @@ int32_t tsdbGetCtbIdList(SMeta* pMeta, int64_t suid, SArray* list) { return TSDB_CODE_SUCCESS; } +/** + * @brief Get all suids since suid + * + * @param pMeta + * @param suid return all suids in one vnode if suid is 0 + * @param list + * @return int32_t + */ +int32_t tsdbGetStbIdList(SMeta* pMeta, int64_t suid, SArray* list) { + SMStbCursor* pCur = metaOpenStbCursor(pMeta, suid); + + while (1) { + tb_uid_t id = metaStbCursorNext(pCur); + if (id == 0) { + break; + } + + taosArrayPush(list, &id); + } + + metaCloseStbCursor(pCur); + return TSDB_CODE_SUCCESS; +} + static void destroyHelper(void* param) { if (param == NULL) { return; diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 3715866bb8..dbbe3d3750 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -72,7 +72,12 @@ int vnodeBegin(SVnode *pVnode) { return 0; } -int vnodeShouldCommit(SVnode *pVnode) { return pVnode->inUse->size > pVnode->config.szBuf / 3; } +int vnodeShouldCommit(SVnode *pVnode) { + if (pVnode->inUse) { + return pVnode->inUse->size > pVnode->config.szBuf / 3; + } + return false; +} int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) { char fname[TSDB_FILENAME_LEN]; diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index dfc258b42b..2834e0a2e7 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -152,12 +152,13 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { return pVnode; _err: + if (pVnode->pSma) smaClose(pVnode->pSma); if (pVnode->pQuery) vnodeQueryClose(pVnode); if (pVnode->pTq) tqClose(pVnode->pTq); if (pVnode->pWal) walClose(pVnode->pWal); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); if (pVnode->pMeta) metaClose(pVnode->pMeta); - if (pVnode->pSma) smaClose(pVnode->pSma); + tsem_destroy(&(pVnode->canCommit)); taosMemoryFree(pVnode); @@ -166,13 +167,14 @@ _err: void vnodeClose(SVnode *pVnode) { if (pVnode) { + smaCloseEnv(pVnode->pSma); vnodeCommit(pVnode); vnodeSyncClose(pVnode); vnodeQueryClose(pVnode); walClose(pVnode->pWal); + smaCloseEx(pVnode->pSma); tqClose(pVnode->pTq); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); - smaClose(pVnode->pSma); metaClose(pVnode->pMeta); vnodeCloseBufPool(pVnode); // destroy handle diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 36f81e86ff..5b0dae00cf 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -808,6 +808,7 @@ int32_t getMaximumIdleDurationSec(); * ops: root operator * data: *data save the result of encode, need to be freed by caller * length: *length save the length of *data + * nOptrWithVal: *nOptrWithVal save the number of optr with value * return: result code, 0 means success */ int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t *length); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index f18da72f58..56cf6a5a72 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -2929,6 +2929,13 @@ int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* len int32_t totalSize = sizeof(int32_t) + sizeof(int32_t) + size * (sizeof(int32_t) + keyLen + sizeof(int32_t) + pSup->resultRowSize); + // no result + if (getTotalBufSize(pSup->pResultBuf) == 0) { + *result = NULL; + *length = 0; + return TSDB_CODE_SUCCESS; + } + *result = (char*)taosMemoryCalloc(1, totalSize); if (*result == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -4482,6 +4489,8 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) { } return code; } + + ASSERT(currLength >= 0); if (*result == NULL) { *result = (char*)taosMemoryCalloc(1, currLength + sizeof(int32_t)); @@ -4507,7 +4516,6 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) { taosMemoryFree(pCurrent); *length = *(int32_t*)(*result); } - for (int32_t i = 0; i < ops->numOfDownstream; ++i) { code = encodeOperator(ops->pDownstream[i], result, length); if (code != TDB_CODE_SUCCESS) { diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index 0c6cd80f44..291d38bdca 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -157,14 +157,14 @@ int32_t taosRenameFile(const char *oldName, const char *newName) { #ifdef WINDOWS bool code = MoveFileEx(oldName, newName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED); if (!code) { - printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno)); + printf("failed to rename file %s to %s, reason:%s\n", oldName, newName, strerror(errno)); } return !code; #else int32_t code = rename(oldName, newName); if (code < 0) { - printf("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno)); + printf("failed to rename file %s to %s, reason:%s\n", oldName, newName, strerror(errno)); } return code; From 393dbc5d2089abc6a8c602fe9eb8c09b153a3292 Mon Sep 17 00:00:00 2001 From: Yu Chen <74105241+yu285@users.noreply.github.com> Date: Sun, 26 Jun 2022 12:32:51 +0800 Subject: [PATCH 24/73] docs: update mnode description --- docs/en/21-tdinternal/01-arch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/21-tdinternal/01-arch.md b/docs/en/21-tdinternal/01-arch.md index d7d472eb98..44651c0496 100644 --- a/docs/en/21-tdinternal/01-arch.md +++ b/docs/en/21-tdinternal/01-arch.md @@ -22,7 +22,7 @@ A complete TDengine system runs on one or more physical nodes. Logically, it inc **Virtual node (vnode)**: To better support data sharding, load balancing and prevent data from overheating or skewing, data nodes are virtualized into multiple virtual nodes (vnode, V2, V3, V4, etc. in the figure). Each vnode is a relatively independent work unit, which is the basic unit of time-series data storage and has independent running threads, memory space and persistent storage path. A vnode contains a certain number of tables (data collection points). When a new table is created, the system checks whether a new vnode needs to be created. The number of vnodes that can be created on a data node depends on the capacity of the hardware of the physical node where the data node is located. A vnode belongs to only one DB, but a DB can have multiple vnodes. In addition to the stored time-series data, a vnode also stores the schema and tag values of the included tables. A virtual node is uniquely identified in the system by the EP of the data node and the VGroup ID to which it belongs and is created and managed by the management node. -**Management node (mnode)**: A virtual logical unit responsible for monitoring and maintaining the running status of all data nodes and load balancing among nodes (M in the figure). At the same time, the management node is also responsible for the storage and management of metadata (including users, databases, tables, static tags, etc.), so it is also called Meta Node. Multiple (up to 5) mnodes can be configured in a TDengine cluster, and they are automatically constructed into a virtual management node group (M0, M1, M2 in the figure). The leader/follower mechanism is adopted for the mnode group and the data synchronization is carried out in a strongly consistent way. Any data update operation can only be executed on the leader. The creation of mnode cluster is completed automatically by the system without manual intervention. There is at most one mnode on each dnode, which is uniquely identified by the EP of the data node to which it belongs. Each dnode automatically obtains the EP of the dnode where all mnodes in the whole cluster are located, through internal messaging interaction. +**Management node (mnode)**: A virtual logical unit responsible for monitoring and maintaining the running status of all data nodes and load balancing among nodes (M in the figure). At the same time, the management node is also responsible for the storage and management of metadata (including users, databases, tables, static tags, etc.), so it is also called Meta Node. Multiple (up to 3) mnodes can be configured in a TDengine cluster, and they are automatically constructed into a virtual management node group (M0, M1, M2 in the figure). The leader/follower mechanism is adopted for the mnode group and the data synchronization is carried out in a strongly consistent way. Any data update operation can only be executed on the leader. The creation of mnode cluster is completed automatically by the system without manual intervention. There is at most one mnode on each dnode, which is uniquely identified by the EP of the data node to which it belongs. Each dnode automatically obtains the EP of the dnode where all mnodes in the whole cluster are located, through internal messaging interaction. **Virtual node group (VGroup)**: Vnodes on different data nodes can form a virtual node group to ensure the high availability of the system. The virtual node group is managed in a leader/follower mechanism. Write operations can only be performed on the leader vnode, and then replicated to follower vnodes, thus ensuring that one single replica of data is copied on multiple physical nodes. The number of virtual nodes in a vgroup equals the number of data replicas. If the number of replicas of a DB is N, the system must have at least N data nodes. The number of replicas can be specified by the parameter `“replica”` when creating a DB, and the default is 1. Using the multi-replication feature of TDengine, the same high data reliability can be achieved without the need for expensive storage devices such as disk arrays. Virtual node groups are created and managed by the management node, and the management node assigns a system unique ID, aka VGroup ID. If two virtual nodes have the same vnode group ID, it means that they belong to the same group and the data is backed up to each other. The number of virtual nodes in a virtual node group can be dynamically changed, allowing only one, that is, no data replication. VGroup ID is never changed. Even if a virtual node group is deleted, its ID will not be reused. From 56997d20575e45fc763c4a5a092b0d643219458c Mon Sep 17 00:00:00 2001 From: Yu Chen <74105241+yu285@users.noreply.github.com> Date: Sun, 26 Jun 2022 12:17:52 +0800 Subject: [PATCH 25/73] docs: update docs --- docs/zh/21-tdinternal/01-arch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/21-tdinternal/01-arch.md b/docs/zh/21-tdinternal/01-arch.md index 433cb4808b..507ccea629 100644 --- a/docs/zh/21-tdinternal/01-arch.md +++ b/docs/zh/21-tdinternal/01-arch.md @@ -23,7 +23,7 @@ TDengine 分布式架构的逻辑结构图如下: **虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2,V3,V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一张新表时,系统会检查是否需要创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 -**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(开源版最多不超过 3 个)mnode,它们自动构建成为一个虚拟管理节点组(图中 M0,M1,M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步,任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 +**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过 3 个)mnode,它们自动构建成为一个虚拟管理节点组(图中 M0,M1,M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步,任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 **虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vgroup)来保证系统的高可靠。虚拟节点组内采取 master/slave 的方式进行管理。写操作只能在 master vnode 上进行,系统采用异步复制的方式将数据同步到 slave vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 VGroup ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。 From a9d65c3d9190a6e93d9040b88b699c33afb20479 Mon Sep 17 00:00:00 2001 From: cpwu Date: Mon, 27 Jun 2022 09:33:33 +0800 Subject: [PATCH 26/73] fix case --- tests/system-test/1-insert/time_range_wise.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index cc231908aa..89be562e57 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -586,8 +586,16 @@ class TDTestCase: tdLog.printNoPrefix("==========step1:create table in normal database") tdSql.prepare() self.__create_tb() - # self.__insert_data() - # self.all_test() + self.__insert_data() + self.all_test() + + # drop databases, create same name db、stb and sma index + tdSql.prepare() + self.__create_tb() + self.__insert_data() + self.all_test() + + return From ff72e66dba623ace3daf0c53469e80578b406677 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 27 Jun 2022 10:07:48 +0800 Subject: [PATCH 27/73] fix(query): support scalar function before applying interval aggregate. --- source/libs/executor/inc/executorimpl.h | 4 +-- source/libs/executor/src/executorimpl.c | 4 +-- source/libs/executor/src/scanoperator.c | 6 ++-- source/libs/executor/src/timewindowoperator.c | 31 ++++++++++++++++--- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index d8d231e952..2f613f528c 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -400,7 +400,7 @@ typedef struct SIntervalAggOperatorInfo { // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode SOptrBasicInfo binfo; // basic info SAggSupporter aggSup; // aggregate supporter - + SExprSupp scalarSupp; // supporter for perform scalar function SGroupResInfo groupResInfo; // multiple results build supporter SInterval interval; // interval info int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator. @@ -730,7 +730,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId, - STimeWindowAggSupp *pTwAggSupp, SExecTaskInfo* pTaskInfo, bool isStream); + STimeWindowAggSupp* pTwAggSupp, SIntervalPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, bool isStream); SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId, diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index f352049810..6fe37feb4b 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4216,8 +4216,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo int32_t tsSlotId = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; bool isStream = (QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type); - pOptr = - createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, &as, pTaskInfo, isStream); + pOptr = createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, &as, pIntervalPhyNode, + pTaskInfo, isStream); } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL == type) { SMergeAlignedIntervalPhysiNode* pIntervalPhyNode = (SMergeAlignedIntervalPhysiNode*)pPhyNode; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 7affac76d2..5bfb73271e 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -448,7 +448,7 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) { qDebug("%s start to repeat ascending order scan data blocks due to query func required", GET_TASKID(pTaskInfo)); for (int32_t i = 0; i < pTableScanInfo->cond.numOfTWindows; ++i) { STimeWindow* pWin = &pTableScanInfo->cond.twindows[i]; - qDebug("%s\t qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey); + qDebug("%s qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey); } // do prepare for the next round table scan operation tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0); @@ -467,7 +467,7 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) { qDebug("%s start to descending order scan data blocks due to query func required", GET_TASKID(pTaskInfo)); for (int32_t i = 0; i < pTableScanInfo->cond.numOfTWindows; ++i) { STimeWindow* pWin = &pTableScanInfo->cond.twindows[i]; - qDebug("%s\t qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey); + qDebug("%s qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey); } while (pTableScanInfo->scanTimes < total) { @@ -492,7 +492,7 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) { GET_TASKID(pTaskInfo)); for (int32_t i = 0; i < pTableScanInfo->cond.numOfTWindows; ++i) { STimeWindow* pWin = &pTableScanInfo->cond.twindows[i]; - qDebug("%s\t qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey); + qDebug("%s qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey); } tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0); pTableScanInfo->curTWinIdx = 0; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 48b0b1c071..2f4ae6c7c7 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -956,6 +956,12 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { getTableScanInfo(pOperator, &pInfo->order, &scanFlag); + if (pInfo->scalarSupp.pExprInfo != NULL) { + SExprSupp* pExprSup =& pInfo->scalarSupp; + projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, + pExprSup->numOfExprs, NULL); + } + // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, scanFlag, true); hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag, NULL); @@ -1324,6 +1330,12 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { break; } + if (pInfo->scalarSupp.pExprInfo != NULL) { + SExprSupp* pExprSup = &pInfo->scalarSupp; + projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, + pExprSup->numOfExprs, NULL); + } + if (pBlock->info.type == STREAM_REPROCESS) { doClearWindows(&pInfo->aggSup, &pOperator->exprSupp, &pInfo->interval, 0, pOperator->exprSupp.numOfExprs, pBlock, NULL); @@ -1446,18 +1458,27 @@ void increaseTs(SqlFunctionCtx* pCtx) { SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId, - STimeWindowAggSupp* pTwAggSupp, SExecTaskInfo* pTaskInfo, bool isStream) { + STimeWindowAggSupp* pTwAggSupp, SIntervalPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, bool isStream) { SIntervalAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SIntervalAggOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { goto _error; } - pInfo->win = pTaskInfo->window; - pInfo->order = TSDB_ORDER_ASC; - pInfo->interval = *pInterval; + pInfo->win = pTaskInfo->window; + pInfo->order = TSDB_ORDER_ASC; + pInfo->interval = *pInterval; pInfo->execModel = pTaskInfo->execModel; - pInfo->twAggSup = *pTwAggSupp; + pInfo->twAggSup = *pTwAggSupp; + + if (pPhyNode->window.pExprs != NULL) { + int32_t numOfScalar = 0; + SExprInfo* pScalarExprInfo = createExprInfo(pPhyNode->window.pExprs, NULL, &numOfScalar); + int32_t code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + } pInfo->primaryTsIndex = primaryTsSlotId; From a22814a5a7434df7f271a2a35e03afd083078997 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 27 Jun 2022 10:36:28 +0800 Subject: [PATCH 28/73] refactor(sync): optimized one replica --- source/libs/sync/inc/syncRaftLog.h | 7 +++++-- source/libs/sync/src/syncRaftLog.c | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/source/libs/sync/inc/syncRaftLog.h b/source/libs/sync/inc/syncRaftLog.h index f124867097..f3ed9e302b 100644 --- a/source/libs/sync/inc/syncRaftLog.h +++ b/source/libs/sync/inc/syncRaftLog.h @@ -29,9 +29,12 @@ extern "C" { #include "wal.h" typedef struct SSyncLogStoreData { - SSyncNode* pSyncNode; - SWal* pWal; + SSyncNode* pSyncNode; + SWal* pWal; + + TdThreadMutex mutex; SWalReadHandle* pWalHandle; + // SyncIndex beginIndex; // valid begin index, default 0, may be set beginIndex > 0 } SSyncLogStoreData; diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index cc606f4df8..d84c576714 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -257,6 +257,8 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, return -1; } + taosThreadMutexLock(&(pData->mutex)); + code = walReadWithHandle(pWalHandle, index); if (code != 0) { int32_t err = terrno; @@ -281,6 +283,7 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, terrno = saveErr; */ + taosThreadMutexUnlock(&(pData->mutex)); return code; } @@ -301,6 +304,7 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, terrno = saveErr; */ + taosThreadMutexUnlock(&(pData->mutex)); return code; } @@ -364,6 +368,7 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) { pData->pWal = pSyncNode->pWal; ASSERT(pData->pWal != NULL); + taosThreadMutexInit(&(pData->mutex), NULL); pData->pWalHandle = walOpenReadHandle(pData->pWal); ASSERT(pData->pWalHandle != NULL); @@ -408,9 +413,14 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) { void logStoreDestory(SSyncLogStore* pLogStore) { if (pLogStore != NULL) { SSyncLogStoreData* pData = pLogStore->data; + + taosThreadMutexLock(&(pData->mutex)); if (pData->pWalHandle != NULL) { walCloseReadHandle(pData->pWalHandle); + pData->pWalHandle = NULL; } + taosThreadMutexUnlock(&(pData->mutex)); + taosThreadMutexDestroy(&(pData->mutex)); taosMemoryFree(pLogStore->data); taosMemoryFree(pLogStore); @@ -460,6 +470,8 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) { SWal* pWal = pData->pWal; if (index >= SYNC_INDEX_BEGIN && index <= logStoreLastIndex(pLogStore)) { + taosThreadMutexLock(&(pData->mutex)); + // SWalReadHandle* pWalHandle = walOpenReadHandle(pWal); SWalReadHandle* pWalHandle = pData->pWalHandle; ASSERT(pWalHandle != NULL); @@ -503,6 +515,7 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) { terrno = saveErr; */ + taosThreadMutexUnlock(&(pData->mutex)); return pEntry; } else { From 2d4eff202b648b5a3d35f9674ad0d7e5e442f1fa Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Mon, 27 Jun 2022 10:58:38 +0800 Subject: [PATCH 29/73] test: add test case for tmq --- tests/system-test/7-tmq/tmqCheckData1.py | 180 +++++++++++++++++++++++ tests/system-test/fulltest.sh | 1 + 2 files changed, 181 insertions(+) create mode 100644 tests/system-test/7-tmq/tmqCheckData1.py diff --git a/tests/system-test/7-tmq/tmqCheckData1.py b/tests/system-test/7-tmq/tmqCheckData1.py new file mode 100644 index 0000000000..6cf849d1b9 --- /dev/null +++ b/tests/system-test/7-tmq/tmqCheckData1.py @@ -0,0 +1,180 @@ + +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def checkFileContent(self, consumerId, queryString): + buildPath = tdCom.getBuildPath() + cfgPath = tdCom.getClientCfgPath() + dstFile = '%s/../log/dstrows_%d.txt'%(cfgPath, consumerId) + cmdStr = '%s/build/bin/taos -c %s -s "%s >> %s"'%(buildPath, cfgPath, queryString, dstFile) + tdLog.info(cmdStr) + os.system(cmdStr) + + consumeRowsFile = '%s/../log/consumerid_%d.txt'%(cfgPath, consumerId) + tdLog.info("rows file: %s, %s"%(consumeRowsFile, dstFile)) + + consumeFile = open(consumeRowsFile, mode='r') + queryFile = open(dstFile, mode='r') + + # skip first line for it is schema + queryFile.readline() + + while True: + dst = queryFile.readline() + src = consumeFile.readline() + + if dst: + if dst != src: + tdLog.exit("consumerId %d consume rows is not match the rows by direct query"%consumerId) + else: + break + return + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db1', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + + topicNameList = ['topic1', 'topic2', 'topic3'] + expectRowsList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb") + tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + tdLog.info("insert data") + tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + + tdLog.info("create topics from stb with filter") + queryString = "select ts,c1,c2 from %s.%s" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as stable %s.%s" %(topicNameList[0], paraDict["dbName"],paraDict["stbName"]) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] + topicList = topicNameList[0] + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + if expectRowsList[0] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) + tdLog.exit("0 tmq consume rows error!") + + self.checkFileContent(consumerId, queryString) + + # reinit consume info, and start tmq_sim, then check consume result + tmqCom.initConsumerTable() + queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as database %s" %(topicNameList[1], paraDict['dbName']) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + consumerId = 1 + topicList = topicNameList[1] + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + if expectRowsList[1] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[1], resultList[0])) + tdLog.exit("1 tmq consume rows error!") + + self.checkFileContent(consumerId, queryString) + + # reinit consume info, and start tmq_sim, then check consume result + tmqCom.initConsumerTable() + queryString = "select * from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[2], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + consumerId = 2 + topicList = topicNameList[2] + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + if expectRowsList[2] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0])) + tdLog.exit("2 tmq consume rows error!") + + self.checkFileContent(consumerId, queryString) + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def run(self): + tdSql.prepare() + self.tmqCase1() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 571bb166e1..2e2e390d12 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -141,6 +141,7 @@ python3 ./test.py -f 7-tmq/tmqError.py python3 ./test.py -f 7-tmq/schema.py python3 ./test.py -f 7-tmq/stbFilter.py python3 ./test.py -f 7-tmq/tmqCheckData.py +python3 ./test.py -f 7-tmq/tmqCheckData1.py python3 ./test.py -f 7-tmq/tmqUdf.py #python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5 python3 ./test.py -f 7-tmq/tmqConsumerGroup.py From 9a24494922a30f2a656a3649944736237a9ceb6b Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 27 Jun 2022 11:07:07 +0800 Subject: [PATCH 30/73] fix: fix bug about memcpy overflow --- source/dnode/mnode/impl/src/mndShow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 029a1e6f8c..164bcc7d60 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -234,7 +234,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) { if (retrieveReq.user[0] != 0) { memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN); } else { - memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, TSDB_USER_LEN); + memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1); } if (mndCheckShowPrivilege(pMnode, pReq->info.conn.user, pShow->type, retrieveReq.db) != 0) { return -1; From 02e450c5903415263e88b216c134a7259eda8d6d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 27 Jun 2022 11:34:06 +0800 Subject: [PATCH 31/73] fix(query): fix invalid object type. --- source/libs/executor/src/timewindowoperator.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 5af12cafac..963e714972 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1377,12 +1377,6 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { break; } - if (pInfo->scalarSupp.pExprInfo != NULL) { - SExprSupp* pExprSup = &pInfo->scalarSupp; - projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, - pExprSup->numOfExprs, NULL); - } - if (pBlock->info.type == STREAM_CLEAR) { doClearWindows(&pInfo->aggSup, &pOperator->exprSupp, &pInfo->interval, 0, pOperator->exprSupp.numOfExprs, pBlock, NULL); @@ -1393,6 +1387,11 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { continue; } + if (pInfo->scalarSupp.pExprInfo != NULL) { + SExprSupp* pExprSup = &pInfo->scalarSupp; + projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL); + } + // The timewindow that overlaps the timestamps of the input pBlock need to be recalculated and return to the // caller. Note that all the time window are not close till now. // the pDataBlock are always the same one, no need to call this again @@ -2494,7 +2493,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { if (IS_FINAL_OP(pInfo)) { int32_t childIndex = getChildIndex(pBlock); SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); - SIntervalAggOperatorInfo* pChildInfo = pChildOp->info; + SStreamFinalIntervalOperatorInfo* pChildInfo = pChildOp->info; SExprSupp* pChildSup = &pChildOp->exprSupp; doClearWindows(&pChildInfo->aggSup, pChildSup, &pChildInfo->interval, pChildInfo->primaryTsIndex, From c22cbf026f89890191f47d350f5bbbf5ebd2f4d8 Mon Sep 17 00:00:00 2001 From: tangfangzhi Date: Mon, 27 Jun 2022 11:42:25 +0800 Subject: [PATCH 32/73] enh: print host ip address in Jenkins log --- Jenkinsfile2 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index f582461fb2..f618912295 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -338,6 +338,14 @@ pipeline { changeRequest() } steps { + script { + def linux_node_ip = sh ( + script: 'ip addr|grep 192|grep -v virbr|awk "{print \\\$2}"|sed "s/\\/.*//"', + returnStdout: true + ).trim() + echo "${linux_node_ip}" + echo "${WKDIR}/restore.sh -p ${BRANCH_NAME} -n ${BUILD_ID} -c {container name}" + } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { timeout(time: 120, unit: 'MINUTES'){ pre_test() From fb50977b44f4daa8f51757e3fa10661f4a3c1906 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Mon, 27 Jun 2022 14:07:42 +0800 Subject: [PATCH 33/73] fix: add taos_set_config() back (#14277) [TD-16828] --- include/client/taos.h | 1 + source/client/src/clientMain.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/client/taos.h b/include/client/taos.h index 5e7f12de0a..d31d5c582c 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -128,6 +128,7 @@ typedef struct setConfRet { DLL_EXPORT void taos_cleanup(void); DLL_EXPORT int taos_options(TSDB_OPTION option, const void *arg, ...); +DLL_EXPORT setConfRet taos_set_config(const char *config); DLL_EXPORT int taos_init(void); DLL_EXPORT TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port); DLL_EXPORT TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port); diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index bbd477fa3b..52574dcc9f 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -81,6 +81,19 @@ void taos_cleanup(void) { taosCloseLog(); } +static setConfRet taos_set_config_imp(const char *config){ + setConfRet ret = {SET_CONF_RET_SUCC, {0}}; + // TODO: need re-implementation + return ret; +} + +setConfRet taos_set_config(const char *config){ +// TODO pthread_mutex_lock(&setConfMutex); + setConfRet ret = taos_set_config_imp(config); +// pthread_mutex_unlock(&setConfMutex); + return ret; +} + TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) { tscDebug("try to connect to %s:%u, user:%s db:%s", ip, port, user, db); if (user == NULL) { From e6dd04f5739caaaf30eb292240036a0bd50b8c6c Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Mon, 27 Jun 2022 14:47:14 +0800 Subject: [PATCH 34/73] refactor: rsma restore --- include/common/tdataformat.h | 1 - include/common/tmsg.h | 2 +- source/common/src/tdataformat.c | 16 -------- source/common/src/tmsg.c | 4 +- source/dnode/mnode/impl/src/mndStb.c | 20 +++++----- source/dnode/vnode/inc/vnode.h | 5 +++ source/dnode/vnode/src/meta/metaEntry.c | 18 ++++++--- source/dnode/vnode/src/meta/metaQuery.c | 2 + source/dnode/vnode/src/meta/metaTable.c | 4 ++ source/dnode/vnode/src/sma/smaEnv.c | 12 +++--- source/dnode/vnode/src/sma/smaOpen.c | 49 +++++++++++++++++++++---- source/dnode/vnode/src/sma/smaRollup.c | 19 +++------- source/dnode/vnode/src/tsdb/tsdbRead.c | 3 ++ source/libs/executor/inc/executorimpl.h | 2 +- source/libs/executor/src/executorMain.c | 8 +++- source/libs/executor/src/executorimpl.c | 15 ++++++-- 16 files changed, 111 insertions(+), 69 deletions(-) diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index f9ede63f7f..8f7f22a6a0 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -78,7 +78,6 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag); int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag); int32_t tTagToValArray(const STag *pTag, SArray **ppArray); void debugPrintSTag(STag *pTag, const char *tag, int32_t ln); // TODO: remove -void debugCheckTags(STag *pTag); // TODO: remove // STRUCT ================= struct STColumn { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index a5688af18a..c5b0b89311 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1886,7 +1886,7 @@ typedef struct SVCreateStbReq { int8_t rollup; SSchemaWrapper schemaRow; SSchemaWrapper schemaTag; - SRSmaParam pRSmaParam; + SRSmaParam rsmaParam; } SVCreateStbReq; int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq); diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 8460a27a0e..7c1b31b6e4 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -862,21 +862,6 @@ void debugPrintSTag(STag *pTag, const char *tag, int32_t ln) { printf("\n"); } -void debugCheckTags(STag *pTag) { - switch (pTag->flags) { - case 0x0: - case 0x20: - case 0x40: - case 0x60: - break; - default: - ASSERT(0); - } - - ASSERT(pTag->nTag <= 128 && pTag->nTag >= 0); - ASSERT(pTag->ver <= 512 && pTag->ver >= 0); // temp condition for pTag->ver -} - static int32_t tPutTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson) { int32_t n = 0; @@ -999,7 +984,6 @@ int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag) { debugPrintSTag(*ppTag, __func__, __LINE__); #endif - debugCheckTags(*ppTag); // TODO: remove this line after debug return code; _err: diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 8a052026f2..e9b5c67d76 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4763,7 +4763,7 @@ int tEncodeSVCreateStbReq(SEncoder *pCoder, const SVCreateStbReq *pReq) { if (tEncodeSSchemaWrapper(pCoder, &pReq->schemaRow) < 0) return -1; if (tEncodeSSchemaWrapper(pCoder, &pReq->schemaTag) < 0) return -1; if (pReq->rollup) { - if (tEncodeSRSmaParam(pCoder, &pReq->pRSmaParam) < 0) return -1; + if (tEncodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1; } tEndEncode(pCoder); @@ -4779,7 +4779,7 @@ int tDecodeSVCreateStbReq(SDecoder *pCoder, SVCreateStbReq *pReq) { if (tDecodeSSchemaWrapper(pCoder, &pReq->schemaRow) < 0) return -1; if (tDecodeSSchemaWrapper(pCoder, &pReq->schemaTag) < 0) return -1; if (pReq->rollup) { - if (tDecodeSRSmaParam(pCoder, &pReq->pRSmaParam) < 0) return -1; + if (tDecodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1; } tEndDecode(pCoder); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 92f85ecd04..dd01a0fa16 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -427,17 +427,17 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt req.schemaTag.pSchema = pStb->pTags; if (req.rollup) { - req.pRSmaParam.maxdelay[0] = pStb->maxdelay[0]; - req.pRSmaParam.maxdelay[1] = pStb->maxdelay[1]; + req.rsmaParam.maxdelay[0] = pStb->maxdelay[0]; + req.rsmaParam.maxdelay[1] = pStb->maxdelay[1]; if (pStb->ast1Len > 0) { - if (mndConvertRsmaTask(&req.pRSmaParam.qmsg[0], &req.pRSmaParam.qmsgLen[0], pStb->pAst1, pStb->uid, - STREAM_TRIGGER_WINDOW_CLOSE, req.pRSmaParam.watermark[0]) < 0) { + if (mndConvertRsmaTask(&req.rsmaParam.qmsg[0], &req.rsmaParam.qmsgLen[0], pStb->pAst1, pStb->uid, + STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[0]) < 0) { goto _err; } } if (pStb->ast2Len > 0) { - if (mndConvertRsmaTask(&req.pRSmaParam.qmsg[1], &req.pRSmaParam.qmsgLen[1], pStb->pAst2, pStb->uid, - STREAM_TRIGGER_WINDOW_CLOSE, req.pRSmaParam.watermark[1]) < 0) { + if (mndConvertRsmaTask(&req.rsmaParam.qmsg[1], &req.rsmaParam.qmsgLen[1], pStb->pAst2, pStb->uid, + STREAM_TRIGGER_WINDOW_CLOSE, req.rsmaParam.watermark[1]) < 0) { goto _err; } } @@ -470,12 +470,12 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt tEncoderClear(&encoder); *pContLen = contLen; - taosMemoryFreeClear(req.pRSmaParam.qmsg[0]); - taosMemoryFreeClear(req.pRSmaParam.qmsg[1]); + taosMemoryFreeClear(req.rsmaParam.qmsg[0]); + taosMemoryFreeClear(req.rsmaParam.qmsg[1]); return pHead; _err: - taosMemoryFreeClear(req.pRSmaParam.qmsg[0]); - taosMemoryFreeClear(req.pRSmaParam.qmsg[1]); + taosMemoryFreeClear(req.rsmaParam.qmsg[0]); + taosMemoryFreeClear(req.rsmaParam.qmsg[1]); return NULL; } diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index c49b33beb2..5c2d2cd712 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -199,15 +199,20 @@ typedef struct { uint64_t groupId; } STableKeyInfo; +#define TABLE_ROLLUP_ON ((int8_t)0x1) +#define TABLE_IS_ROLLUP(FLG) (((FLG) & (TABLE_ROLLUP_ON)) != 0) +#define TABLE_SET_ROLLUP(FLG) ((FLG) |= TABLE_ROLLUP_ON) struct SMetaEntry { int64_t version; int8_t type; + int8_t flags; // TODO: need refactor? tb_uid_t uid; char *name; union { struct { SSchemaWrapper schemaRow; SSchemaWrapper schemaTag; + SRSmaParam rsmaParam; } stbEntry; struct { int64_t ctime; diff --git a/source/dnode/vnode/src/meta/metaEntry.c b/source/dnode/vnode/src/meta/metaEntry.c index acf5b0b613..23d7665ba3 100644 --- a/source/dnode/vnode/src/meta/metaEntry.c +++ b/source/dnode/vnode/src/meta/metaEntry.c @@ -24,22 +24,25 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) { if (tEncodeCStr(pCoder, pME->name) < 0) return -1; if (pME->type == TSDB_SUPER_TABLE) { + if (tEncodeI8(pCoder, pME->flags) < 0) return -1; // TODO: need refactor? if (tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaRow) < 0) return -1; if (tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag) < 0) return -1; + if (TABLE_IS_ROLLUP(pME->flags)) { + if (tEncodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam) < 0) return -1; + } } else if (pME->type == TSDB_CHILD_TABLE) { if (tEncodeI64(pCoder, pME->ctbEntry.ctime) < 0) return -1; if (tEncodeI32(pCoder, pME->ctbEntry.ttlDays) < 0) return -1; - if (tEncodeI32(pCoder, pME->ctbEntry.commentLen) < 0) return -1; + if (tEncodeI32v(pCoder, pME->ctbEntry.commentLen) < 0) return -1; if (pME->ctbEntry.commentLen > 0){ if (tEncodeCStr(pCoder, pME->ctbEntry.comment) < 0) return -1; } if (tEncodeI64(pCoder, pME->ctbEntry.suid) < 0) return -1; - debugCheckTags((STag*)pME->ctbEntry.pTags); // TODO: remove after debug if (tEncodeTag(pCoder, (const STag *)pME->ctbEntry.pTags) < 0) return -1; } else if (pME->type == TSDB_NORMAL_TABLE) { if (tEncodeI64(pCoder, pME->ntbEntry.ctime) < 0) return -1; if (tEncodeI32(pCoder, pME->ntbEntry.ttlDays) < 0) return -1; - if (tEncodeI32(pCoder, pME->ntbEntry.commentLen) < 0) return -1; + if (tEncodeI32v(pCoder, pME->ntbEntry.commentLen) < 0) return -1; if (pME->ntbEntry.commentLen > 0){ if (tEncodeCStr(pCoder, pME->ntbEntry.comment) < 0) return -1; } @@ -64,23 +67,26 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) { if (tDecodeCStr(pCoder, &pME->name) < 0) return -1; if (pME->type == TSDB_SUPER_TABLE) { + if (tDecodeI8(pCoder, &pME->flags) < 0) return -1; // TODO: need refactor? if (tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaRow) < 0) return -1; if (tDecodeSSchemaWrapperEx(pCoder, &pME->stbEntry.schemaTag) < 0) return -1; + if (TABLE_IS_ROLLUP(pME->flags)) { + if (tDecodeSRSmaParam(pCoder, &pME->stbEntry.rsmaParam) < 0) return -1; + } } else if (pME->type == TSDB_CHILD_TABLE) { if (tDecodeI64(pCoder, &pME->ctbEntry.ctime) < 0) return -1; if (tDecodeI32(pCoder, &pME->ctbEntry.ttlDays) < 0) return -1; - if (tDecodeI32(pCoder, &pME->ctbEntry.commentLen) < 0) return -1; + if (tDecodeI32v(pCoder, &pME->ctbEntry.commentLen) < 0) return -1; if (pME->ctbEntry.commentLen > 0){ if (tDecodeCStr(pCoder, &pME->ctbEntry.comment) < 0) return -1; } if (tDecodeI64(pCoder, &pME->ctbEntry.suid) < 0) return -1; if (tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags) < 0) return -1; // (TODO) - debugCheckTags((STag*)pME->ctbEntry.pTags); // TODO: remove after debug } else if (pME->type == TSDB_NORMAL_TABLE) { if (tDecodeI64(pCoder, &pME->ntbEntry.ctime) < 0) return -1; if (tDecodeI32(pCoder, &pME->ntbEntry.ttlDays) < 0) return -1; - if (tDecodeI32(pCoder, &pME->ntbEntry.commentLen) < 0) return -1; + if (tDecodeI32v(pCoder, &pME->ntbEntry.commentLen) < 0) return -1; if (pME->ntbEntry.commentLen > 0){ if (tDecodeCStr(pCoder, &pME->ntbEntry.comment) < 0) return -1; } diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index f57ee54400..85106f46c2 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -342,6 +342,7 @@ SMStbCursor *metaOpenStbCursor(SMeta *pMeta, tb_uid_t suid) { pStbCur = (SMStbCursor *)taosMemoryCalloc(1, sizeof(*pStbCur)); if (pStbCur == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } @@ -351,6 +352,7 @@ SMStbCursor *metaOpenStbCursor(SMeta *pMeta, tb_uid_t suid) { ret = tdbTbcOpen(pMeta->pSuidIdx, &pStbCur->pCur, NULL); if (ret < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; metaULock(pMeta); taosMemoryFree(pStbCur); return NULL; diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index ea425ca7de..a621b4ddb0 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -139,6 +139,10 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { me.name = pReq->name; me.stbEntry.schemaRow = pReq->schemaRow; me.stbEntry.schemaTag = pReq->schemaTag; + if (pReq->rollup) { + TABLE_SET_ROLLUP(me.flags); + me.stbEntry.rsmaParam = pReq->rsmaParam; + } if (metaHandleEntry(pMeta, &me) < 0) goto _err; diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index 1e8832615e..a5194d176e 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -174,11 +174,8 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) { // step 1: set persistence task cancelled atomic_store_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_CANCELLED); - // step 2: clean timer + // step 2: stop the persistence timer taosTmrStopA(&RSMA_TMR_ID(pStat)); - if (RSMA_TMR_HANDLE(pStat)) { - taosTmrCleanUp(RSMA_TMR_HANDLE(pStat)); - } // step 3: wait the persistence thread to finish int32_t nLoops = 0; @@ -194,7 +191,6 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) { sched_yield(); nLoops = 0; } - taosMsleep(1000); // TODO: remove this line when release } } @@ -219,7 +215,11 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) { sched_yield(); nLoops = 0; } - taosMsleep(1000); // TODO: remove this line when release + } + + // step 6: free the timer handle + if (RSMA_TMR_HANDLE(pStat)) { + taosTmrCleanUp(RSMA_TMR_HANDLE(pStat)); } } } diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index 2f40df8b45..681b9131cc 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -18,6 +18,7 @@ static int32_t smaEvalDays(SRetention *r, int8_t precision); static int32_t smaSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type); +static int32_t smaRestore(SSma *pSma); #define SMA_SET_KEEP_CFG(l) \ do { \ @@ -120,6 +121,12 @@ int32_t smaOpen(SVnode *pVnode) { } pVnode->pSma = pSma; + + // restore the sma + if (smaRestore(pSma) < 0) { + goto _err; + } + return 0; _err: taosMemoryFreeClear(pSma); @@ -127,7 +134,7 @@ _err: } int32_t smaCloseEnv(SSma *pSma) { - if(pSma) { + if (pSma) { SMA_TSMA_ENV(pSma) = tdFreeSmaEnv(SMA_TSMA_ENV(pSma)); SMA_RSMA_ENV(pSma) = tdFreeSmaEnv(SMA_RSMA_ENV(pSma)); } @@ -153,13 +160,41 @@ int32_t smaClose(SSma *pSma) { /** * @brief rsma env restore - * - * @param pSma - * @return int32_t + * + * @param pSma + * @return int32_t */ -int32_t smaRestore(SSma *pSma) { - if (!pSma) return 0; +static int32_t smaRestore(SSma *pSma) { // iterate all stables to restore the rsma env - + SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t)); + if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) { + smaError("failed to restore rsma since get stb id list error: %s", terrstr()); + return TSDB_CODE_FAILED; + } + + SMetaReader mr = {0}; + metaReaderInit(&mr, SMA_META(pSma), 0); + for (int32_t i = 0; i < taosArrayGetSize(suidList); ++i) { + tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i); + smaDebug("suid [%d] is %" PRIi64, i, suid); + if (metaGetTableEntryByUid(&mr, suid) < 0) { + metaReaderClear(&mr); + taosArrayDestroy(suidList); + smaError("failed to get table meta for %" PRIi64 " since %s", suid, terrstr()); + return TSDB_CODE_FAILED; + } + ASSERT(mr.me.type == TSDB_SUPER_TABLE); + if (TABLE_IS_ROLLUP(mr.me.flags)) { + SRSmaParam *param = &mr.me.stbEntry.rsmaParam; + for (int i = 0; i < 2; ++i) { + smaDebug("%s:%d table:%" PRIi64 " maxdelay[%d]:%" PRIi64 " watermark[%d]:%" PRIi64, __func__, __LINE__, suid, i, + param->maxdelay[i], i, param->watermark[i]); + } + } + } + + metaReaderClear(&mr); + taosArrayDestroy(suidList); + return TSDB_CODE_SUCCESS; } \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 020ee38db9..0f30aeea6a 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -246,7 +246,7 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { SMeta *pMeta = pVnode->pMeta; SMsgCb *pMsgCb = &pVnode->msgCb; - SRSmaParam *param = &pReq->pRSmaParam; + SRSmaParam *param = &pReq->rsmaParam; if ((param->qmsgLen[0] == 0) && (param->qmsgLen[1] == 0)) { smaWarn("vgId:%d, no qmsg1/qmsg2 for rollup stable %s %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); @@ -502,8 +502,10 @@ static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType) } taosMemoryFreeClear(pReq); + } else if (terrno == 0) { + smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level); } else { - smaDebug("vgId:%d, no rsma %" PRIi8 " data generated since %s", SMA_VID(pSma), pItem->level, tstrerror(terrno)); + smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, tstrerror(terrno)); } tdDestroySDataBlockArray(pResult); @@ -661,18 +663,6 @@ static void *tdRSmaPersistExec(void *param) { goto _end; } -#if 0 - SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t)); - if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) { - ASSERT(0); - } else { - for (int32_t i = 0; i < taosArrayGetSize(suidList); ++i) { - tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i); - smaDebug("suid [%d] is %" PRIi64, i, suid); - } - } -#endif - void *infoHash = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), NULL); if (!infoHash) { goto _end; @@ -852,6 +842,7 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) { } break; default: { smaWarn("%s:%d rsma persistence not start since unknown stat %" PRIi8, __func__, __LINE__, tmrStat); + ASSERT(0); } break; } } \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index bd40fd4a1f..03f18cc766 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -2886,6 +2886,9 @@ int32_t tsdbGetCtbIdList(SMeta* pMeta, int64_t suid, SArray* list) { */ int32_t tsdbGetStbIdList(SMeta* pMeta, int64_t suid, SArray* list) { SMStbCursor* pCur = metaOpenStbCursor(pMeta, suid); + if(!pCur) { + return TSDB_CODE_FAILED; + } while (1) { tb_uid_t id = metaStbCursorNext(pCur); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 5b0dae00cf..eecefe625c 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -811,7 +811,7 @@ int32_t getMaximumIdleDurationSec(); * nOptrWithVal: *nOptrWithVal save the number of optr with value * return: result code, 0 means success */ -int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t *length); +int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t *length, int32_t *nOptrWithVal); /* * ops: root operator, created by caller diff --git a/source/libs/executor/src/executorMain.c b/source/libs/executor/src/executorMain.c index a9e1e03178..e4c0959185 100644 --- a/source/libs/executor/src/executorMain.c +++ b/source/libs/executor/src/executorMain.c @@ -222,7 +222,13 @@ int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len) { return TSDB_CODE_INVALID_PARA; } - return encodeOperator(pTaskInfo->pRoot, pOutput, len); + int32_t nOptrWithVal = 0; + int32_t code = encodeOperator(pTaskInfo->pRoot, pOutput, len, &nOptrWithVal); + if ((code == TSDB_CODE_SUCCESS) && (nOptrWithVal = 0)) { + taosMemoryFreeClear(*pOutput); + *len = 0; + } + return code; } int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t len) { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 56cf6a5a72..0720e8d8c4 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4472,12 +4472,12 @@ int32_t rebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHa return 0; } -int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) { +int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length, int32_t* nOptrWithVal) { int32_t code = TDB_CODE_SUCCESS; char* pCurrent = NULL; int32_t currLength = 0; if (ops->fpSet.encodeResultRow) { - if (result == NULL || length == NULL) { + if (result == NULL || length == NULL || nOptrWithVal == NULL) { return TSDB_CODE_TSC_INVALID_INPUT; } code = ops->fpSet.encodeResultRow(ops, &pCurrent, &currLength); @@ -4488,8 +4488,13 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) { *result = NULL; } return code; + } else if (currLength == 0) { + ASSERT(!pCurrent); + goto _downstream; } - + + ++(*nOptrWithVal); + ASSERT(currLength >= 0); if (*result == NULL) { @@ -4516,8 +4521,10 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) { taosMemoryFree(pCurrent); *length = *(int32_t*)(*result); } + +_downstream: for (int32_t i = 0; i < ops->numOfDownstream; ++i) { - code = encodeOperator(ops->pDownstream[i], result, length); + code = encodeOperator(ops->pDownstream[i], result, length, nOptrWithVal); if (code != TDB_CODE_SUCCESS) { return code; } From 16b2d7932d90734bb053af65e9a224a1a5b061fa Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Mon, 27 Jun 2022 15:02:18 +0800 Subject: [PATCH 35/73] refactor: rsma restore --- source/dnode/vnode/src/sma/smaEnv.c | 2 +- source/dnode/vnode/src/sma/smaOpen.c | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index a5194d176e..febf70f737 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -217,7 +217,7 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) { } } - // step 6: free the timer handle + // step 6: cleanup the timer handle if (RSMA_TMR_HANDLE(pStat)) { taosTmrCleanUp(RSMA_TMR_HANDLE(pStat)); } diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index 681b9131cc..9212493ee7 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -18,7 +18,7 @@ static int32_t smaEvalDays(SRetention *r, int8_t precision); static int32_t smaSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type); -static int32_t smaRestore(SSma *pSma); +static int32_t rsmaRestore(SSma *pSma); #define SMA_SET_KEEP_CFG(l) \ do { \ @@ -101,6 +101,9 @@ int32_t smaOpen(SVnode *pVnode) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } + + pVnode->pSma = pSma; + pSma->pVnode = pVnode; taosThreadMutexInit(&pSma->mutex, NULL); pSma->locked = false; @@ -118,13 +121,11 @@ int32_t smaOpen(SVnode *pVnode) { ASSERT(0); } } - } - pVnode->pSma = pSma; - - // restore the sma - if (smaRestore(pSma) < 0) { - goto _err; + // restore the rsma + if (rsmaRestore(pSma) < 0) { + goto _err; + } } return 0; @@ -164,7 +165,9 @@ int32_t smaClose(SSma *pSma) { * @param pSma * @return int32_t */ -static int32_t smaRestore(SSma *pSma) { +static int32_t rsmaRestore(SSma *pSma) { + ASSERT(VND_IS_RSMA(pSma->pVnode)); + // iterate all stables to restore the rsma env SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t)); if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) { From 515109088f42922114555e1045d3c5869cd7d6e5 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 27 Jun 2022 15:08:13 +0800 Subject: [PATCH 36/73] feat(query): support mode function --- source/libs/function/inc/builtinsimpl.h | 5 +++++ source/libs/function/src/builtins.c | 24 +++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index 0820e884ce..f7e22cb151 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -191,6 +191,11 @@ bool getUniqueFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool uniqueFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); int32_t uniqueFunction(SqlFunctionCtx *pCtx); +bool getModeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool modeFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +int32_t modeFunction(SqlFunctionCtx *pCtx); +int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); + bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool twaFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); int32_t twaFunction(SqlFunctionCtx *pCtx); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index d41bc89a5f..c8e39db90c 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1045,20 +1045,28 @@ static int32_t translateFirstLastMerge(SFunctionNode* pFunc, char* pErrBuf, int3 return translateFirstLastImpl(pFunc, pErrBuf, len, false); } -static int32_t translateUnique(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { +static int32_t translateUniqueMode(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isUnique) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); } SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); if (!nodesExprHasColumn(pPara)) { - return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "The parameters of UNIQUE must contain columns"); + return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "The parameters of %s must contain columns", isUnique ? "UNIQUE" : "MODE"); } pFunc->node.resType = ((SExprNode*)pPara)->resType; return TSDB_CODE_SUCCESS; } +static int32_t translateUnique(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + return translateUniqueMode(pFunc, pErrBuf, len, true); +} + +static int32_t translateMode(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + return translateUniqueMode(pFunc, pErrBuf, len, false); +} + static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList); if (numOfParams == 0 || numOfParams > 2) { @@ -2109,7 +2117,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "unique", .type = FUNCTION_TYPE_UNIQUE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_WINDOW_FUNC | FUNC_MGT_FORBID_GROUP_BY_FUNC, .translateFunc = translateUnique, .getEnvFunc = getUniqueFuncEnv, @@ -2117,6 +2125,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .processFunc = uniqueFunction, .finalizeFunc = NULL }, + { + .name = "mode", + .type = FUNCTION_TYPE_MODE, + .classification = FUNC_MGT_AGG_FUNC, + .translateFunc = translateMode, + .getEnvFunc = getUniqueFuncEnv, + .initFunc = uniqueFunctionSetup, + .processFunc = uniqueFunction, + .finalizeFunc = functionFinalize, + }, { .name = "abs", .type = FUNCTION_TYPE_ABS, From 3fc60c81e5ebc5916a5e78be2739dfbba3dd8b20 Mon Sep 17 00:00:00 2001 From: tangfangzhi Date: Mon, 27 Jun 2022 15:14:28 +0800 Subject: [PATCH 37/73] ci: change build option to build taosAdapter --- tests/parallel_test/container_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/parallel_test/container_build.sh b/tests/parallel_test/container_build.sh index 3f23cd8b5f..f80c2b217f 100755 --- a/tests/parallel_test/container_build.sh +++ b/tests/parallel_test/container_build.sh @@ -52,7 +52,7 @@ fi docker run \ -v $REP_MOUNT_PARAM \ - --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_TOOLS=true;make -j $THREAD_COUNT" + --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true;make -j $THREAD_COUNT" ret=$? exit $ret From 8281176b0b8d5e31f02a65184fd34341871269a6 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Mon, 27 Jun 2022 15:22:56 +0800 Subject: [PATCH 38/73] other: code optimization --- source/dnode/vnode/src/sma/smaEnv.c | 7 ++---- source/dnode/vnode/src/sma/smaOpen.c | 4 +-- source/dnode/vnode/src/sma/smaRollup.c | 34 +++++++++++++------------- source/dnode/vnode/src/vnd/vnodeOpen.c | 2 +- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index febf70f737..7f115633b9 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -156,6 +156,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS static void tdDestroyTSmaStat(STSmaStat *pStat) { if (pStat) { + smaDebug("destroy tsma stat"); tDestroyTSma(pStat->pTSma); taosMemoryFreeClear(pStat->pTSma); taosMemoryFreeClear(pStat->pTSchema); @@ -170,7 +171,7 @@ static void *tdFreeTSmaStat(STSmaStat *pStat) { static void tdDestroyRSmaStat(SRSmaStat *pStat) { if (pStat) { - smaDebug("vgId:%d, %s:%d free rsma stat", SMA_VID(pStat->pSma), __func__, __LINE__); + smaDebug("vgId:%d destroy rsma stat", SMA_VID(pStat->pSma)); // step 1: set persistence task cancelled atomic_store_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_CANCELLED); @@ -245,16 +246,12 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) { if (pSmaStat) { if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - smaDebug("%s:%d destroy tsma stat", __func__, __LINE__); tdDestroyTSmaStat(SMA_TSMA_STAT(pSmaStat)); } else if (smaType == TSDB_SMA_TYPE_ROLLUP) { - smaDebug("%s:%d destroy rsma stat", __func__, __LINE__); tdDestroyRSmaStat(SMA_RSMA_STAT(pSmaStat)); } else { ASSERT(0); } - } else { - smaDebug("%s:%d no need to destroy rsma stat", __func__, __LINE__); } return TSDB_CODE_SUCCESS; } diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index 9212493ee7..fad31f92c0 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -190,8 +190,8 @@ static int32_t rsmaRestore(SSma *pSma) { if (TABLE_IS_ROLLUP(mr.me.flags)) { SRSmaParam *param = &mr.me.stbEntry.rsmaParam; for (int i = 0; i < 2; ++i) { - smaDebug("%s:%d table:%" PRIi64 " maxdelay[%d]:%" PRIi64 " watermark[%d]:%" PRIi64, __func__, __LINE__, suid, i, - param->maxdelay[i], i, param->watermark[i]); + smaDebug("vgId: %d table:%" PRIi64 " maxdelay[%d]:%" PRIi64 " watermark[%d]:%" PRIi64, TD_VID(pSma->pVnode), + suid, i, param->maxdelay[i], i, param->watermark[i]); } } } diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 0f30aeea6a..26b9a34fa3 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -49,10 +49,10 @@ static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId, // Note: free/kill may in RC qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle); if (otaskHandle && atomic_val_compare_exchange_ptr(taskHandle, otaskHandle, NULL)) { - smaDebug("vgId:%d, %s:%d free qTaskInfo_t %p of level %d", vgId, __func__, __LINE__, otaskHandle, level); + smaDebug("vgId:%d, free qTaskInfo_t %p of level %d", vgId, otaskHandle, level); qDestroyTask(otaskHandle); } else { - smaDebug("vgId:%d, %s:%d not free qTaskInfo_t %p of level %d", vgId, __func__, __LINE__, otaskHandle, level); + smaDebug("vgId:%d, not free qTaskInfo_t %p of level %d", vgId, otaskHandle, level); } } @@ -89,7 +89,7 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) { return TSDB_CODE_SUCCESS; } -static FORCE_INLINE int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids) { +static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids) { SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); SRSmaInfo *pRSmaInfo = NULL; @@ -528,16 +528,16 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { int8_t rsmaTriggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pStat)); if (rsmaTriggerStat == TASK_TRIGGER_STAT_CANCELLED || rsmaTriggerStat == TASK_TRIGGER_STAT_FINISHED) { - smaDebug("vgId:%d, %s:%d level %" PRIi8 " not fetch since stat is cancelled for table suid:%" PRIi64, SMA_VID(pSma), - __func__, __LINE__, pItem->level, pItem->pRsmaInfo->suid); + smaDebug("vgId:%d, level %" PRIi8 " not fetch since stat is cancelled for table suid:%" PRIi64, SMA_VID(pSma), + pItem->level, pItem->pRsmaInfo->suid); return; } int8_t fetchTriggerStat = atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE); if (fetchTriggerStat == TASK_TRIGGER_STAT_ACTIVE) { - smaDebug("vgId:%d, %s:%d level %" PRIi8 " stat is active for table suid:%" PRIi64, SMA_VID(pSma), __func__, - __LINE__, pItem->level, pItem->pRsmaInfo->suid); + smaDebug("vgId:%d, level %" PRIi8 " stat is active for table suid:%" PRIi64, SMA_VID(pSma), pItem->level, + pItem->pRsmaInfo->suid); tdRefSmaStat(pSma, (SSmaStat *)pStat); @@ -548,13 +548,13 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { tdUnRefSmaStat(pSma, (SSmaStat *)pStat); } else { - smaDebug("vgId:%d, %s:%d level %" PRIi8 " stat is inactive for table suid:%" PRIi64, SMA_VID(pSma), __func__, - __LINE__, pItem->level, pItem->pRsmaInfo->suid); + smaDebug("vgId:%d, level %" PRIi8 " stat is inactive for table suid:%" PRIi64, SMA_VID(pSma), pItem->level, + pItem->pRsmaInfo->suid); } } -static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem, - tb_uid_t suid, int8_t level) { +static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType, SRSmaInfoItem *pItem, tb_uid_t suid, + int8_t level) { if (!pItem || !pItem->taskInfo) { smaDebug("vgId:%d, no qTaskInfo to execute rsma %" PRIi8 " task for suid:%" PRIu64, SMA_VID(pSma), level, suid); return TSDB_CODE_SUCCESS; @@ -570,7 +570,7 @@ static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int3 tdFetchAndSubmitRSmaResult(pItem, STREAM_DATA_TYPE_SUBMIT_BLOCK); atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE); - smaDebug("vgId:%d, %s:%d process rsma insert", SMA_VID(pSma), __func__, __LINE__); + smaDebug("vgId:%d, process rsma insert", SMA_VID(pSma)); SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pStat = SMA_RSMA_STAT(pEnv->pStat); @@ -823,7 +823,7 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) { if (TASK_TRIGGER_STAT_CANCELLED != atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_CANCELLED, TASK_TRIGGER_STAT_FINISHED)) { - smaDebug("%s:%d rsma persistence start since active", __func__, __LINE__); + smaDebug("rsma persistence start since active"); tdRSmaPersistTask(pRSmaStat); taosTmrReset(tdRSmaPersistTrigger, RSMA_QTASK_PERSIST_MS, pRSmaStat, pRSmaStat->tmrHandle, &pRSmaStat->tmrId); } else { @@ -832,16 +832,16 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) { } break; case TASK_TRIGGER_STAT_CANCELLED: { atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_FINISHED); - smaDebug("%s:%d rsma persistence not start since cancelled and finished", __func__, __LINE__); + smaDebug("rsma persistence not start since cancelled and finished"); } break; case TASK_TRIGGER_STAT_INACTIVE: { - smaDebug("%s:%d rsma persistence not start since inactive", __func__, __LINE__); + smaDebug("rsma persistence not start since inactive"); } break; case TASK_TRIGGER_STAT_INIT: { - smaDebug("%s:%d rsma persistence not start since init", __func__, __LINE__); + smaDebug("rsma persistence not start since init"); } break; default: { - smaWarn("%s:%d rsma persistence not start since unknown stat %" PRIi8, __func__, __LINE__, tmrStat); + smaWarn("rsma persistence not start since unknown stat %" PRIi8, tmrStat); ASSERT(0); } break; } diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 2834e0a2e7..4d73dbc406 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -172,9 +172,9 @@ void vnodeClose(SVnode *pVnode) { vnodeSyncClose(pVnode); vnodeQueryClose(pVnode); walClose(pVnode->pWal); - smaCloseEx(pVnode->pSma); tqClose(pVnode->pTq); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); + smaCloseEx(pVnode->pSma); metaClose(pVnode->pMeta); vnodeCloseBufPool(pVnode); // destroy handle From 1627a53612e3ac0ba887cbb1738d54802d9833d5 Mon Sep 17 00:00:00 2001 From: cpwu Date: Mon, 27 Jun 2022 15:34:26 +0800 Subject: [PATCH 39/73] fix case --- tests/pytest/util/constant.py | 47 +++++++++++++++++-- tests/system-test/1-insert/time_range_wise.py | 47 +++++++++++++------ 2 files changed, 77 insertions(+), 17 deletions(-) diff --git a/tests/pytest/util/constant.py b/tests/pytest/util/constant.py index 49aa35996a..807398f70f 100644 --- a/tests/pytest/util/constant.py +++ b/tests/pytest/util/constant.py @@ -30,6 +30,47 @@ TAOS_PRECISION = ["ms", "us", "ns"] PRECISION_DEFAULT = "ms" PRECISION = PRECISION_DEFAULT +TAOS_KEYWORDS = [ + "ABORT", "CREATE", "IGNORE", "NULL", "STAR", + "ACCOUNT", "CTIME", "IMMEDIATE", "OF", "STATE", + "ACCOUNTS", "DATABASE", "IMPORT", "OFFSET", "STATEMENT", + "ADD", "DATABASES", "IN", "OR", "STATE_WINDOW", + "AFTER", "DAYS", "INITIALLY", "ORDER", "STORAGE", + "ALL", "DBS", "INSERT", "PARTITIONS", "STREAM", + "ALTER", "DEFERRED", "INSTEAD", "PASS", "STREAMS", + "AND", "DELIMITERS", "INT", "PLUS", "STRING", + "AS", "DESC", "INTEGER", "PPS", "SYNCDB", + "ASC", "DESCRIBE", "INTERVAL", "PRECISION", "TABLE", + "ATTACH", "DETACH", "INTO", "PREV", "TABLES", + "BEFORE", "DISTINCT", "IS", "PRIVILEGE", "TAG", + "BEGIN", "DIVIDE", "ISNULL", "QTIME", "TAGS", + "BETWEEN", "DNODE", "JOIN", "QUERIES", "TBNAME", + "BIGINT", "DNODES", "KEEP", "QUERY", "TIMES", + "BINARY", "DOT", "KEY", "QUORUM", "TIMESTAMP", + "BITAND", "DOUBLE", "KILL", "RAISE", "TINYINT", + "BITNOT", "DROP", "LE", "REM", "TOPIC", + "BITOR", "EACH", "LIKE", "REPLACE", "TOPICS", + "BLOCKS", "END", "LIMIT", "REPLICA", "TRIGGER", + "BOOL", "EQ", "LINEAR", "RESET", "TSERIES", + "BY", "EXISTS", "LOCAL", "RESTRICT", "UMINUS", + "CACHE", "EXPLAIN", "LP", "ROW", "UNION", + "CACHELAST", "FAIL", "LSHIFT", "RP", "UNSIGNED", + "CASCADE", "FILE", "LT", "RSHIFT", "UPDATE", + "CHANGE", "FILL", "MATCH", "SCORES", "UPLUS", + "CLUSTER", "FLOAT", "MAXROWS", "SELECT", "USE", + "COLON", "FOR", "MINROWS", "SEMI", "USER", + "COLUMN", "FROM", "MINUS", "SESSION", "USERS", + "COMMA", "FSYNC", "MNODES", "SET", "USING", + "COMP", "GE", "MODIFY", "SHOW", "VALUES", + "COMPACT", "GLOB", "MODULES", "SLASH", "VARIABLE", + "CONCAT", "GRANTS", "NCHAR", "SLIDING", "VARIABLES", + "CONFLICT", "GROUP", "NE", "SLIMIT", "VGROUPS", + "CONNECTION", "GT", "NONE", "SMALLINT", "VIEW", + "CONNECTIONS", "HAVING", "NOT", "SOFFSET", "VNODES", + "CONNS", "ID", "NOTNULL", "STABLE", "WAL", + "COPY", "IF", "NOW", "STABLES", "WHERE", +] + # basic data type boundary TINYINT_MAX = 127 TINYINT_MIN = -128 @@ -41,7 +82,7 @@ SMALLINT_MAX = 32767 SMALLINT_MIN = -32768 SMALLINT_UN_MAX = 65535 -MALLINT_UN_MIN = 0 +SMALLINT_UN_MIN = 0 INT_MAX = 2147483647 INT_MIN = -2147483648 @@ -63,8 +104,8 @@ DOUBLE_MIN = -1.7E+308 # schema boundary BINARY_LENGTH_MAX = 16374 -NCAHR_LENGTH_MAX_ = 4093 -DBNAME_LENGTH_MAX_ = 64 +NCAHR_LENGTH_MAX = 4093 +DBNAME_LENGTH_MAX = 64 STBNAME_LENGTH_MAX = 192 STBNAME_LENGTH_MIN = 1 diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index 89be562e57..ee94d6d44b 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -17,10 +17,10 @@ TINT_COL = "c_tint" FLOAT_COL = "c_float" DOUBLE_COL = "c_double" BOOL_COL = "c_bool" -TINT_UN_COL = "c_tint_un" -SINT_UN_COL = "c_sint_un" -BINT_UN_COL = "c_bint_un" -INT_UN_COL = "c_int_un" +TINT_UN_COL = "c_utint" +SINT_UN_COL = "c_usint" +BINT_UN_COL = "c_ubint" +INT_UN_COL = "c_uint" BINARY_COL = "c_binary" NCHAR_COL = "c_nchar" TS_COL = "c_ts" @@ -100,6 +100,7 @@ class SMAschema: show_msg : str = "INDEXES" show_oper : str = "FROM" dbname : str = None + rollup_db : bool = False def __post_init__(self): if isinstance(self.other, dict): @@ -157,6 +158,11 @@ class SMAschema: self.show_oper = v del self.other[k] + if k.lower() == "rollup_db" and isinstance(v, bool) and not self.rollup_db: + self.rollup_db = v + del self.other[k] + + # from ...pytest.util.sql import * # from ...pytest.util.constant import * @@ -166,7 +172,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), False) + tdSql.init(conn.cursor(), True) self.precision = "ms" self.sma_count = 0 self.sma_created_index = [] @@ -319,6 +325,10 @@ class TDTestCase: def __sma_create_check(self, sma:SMAschema): if self.updatecfgDict["querySmaOptimize"] == 0: return False + # # TODO: if database is a rollup-db, can not create sma index + # tdSql.query("select database()") + # if sma.rollup_db : + # return False tdSql.query("show stables") if not sma.tbname: return False @@ -332,7 +342,7 @@ class TDTestCase: return False if not sma.index_flag or not isinstance(sma.index_flag, str) or sma.index_flag.upper() != "SMA INDEX" : return False - if not sma.index_name or not isinstance(sma.index_name, str): + if not sma.index_name or not isinstance(sma.index_name, str) or sma.index_name.upper() in TAOS_KEYWORDS: return False if not sma.operator or not isinstance(sma.operator, str) or sma.operator.upper() != "ON": return False @@ -430,7 +440,6 @@ class TDTestCase: cur_sqls = [] # err_set # # case 1: required fields check - ### 1.1 create err_sqls.append( SMAschema(creation="", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) err_sqls.append( SMAschema(index_name="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) err_sqls.append( SMAschema(index_flag="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) @@ -439,6 +448,16 @@ class TDTestCase: err_sqls.append( SMAschema(func=("",),tbname=STBNAME ) ) err_sqls.append( SMAschema(interval=(""),tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + # # case 2: err fields + err_sqls.append( SMAschema(creation="show",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(creation="alter",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(creation="select",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + + err_sqls.append( SMAschema(index_flag="SMA INDEXES", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(index_flag="SMA INDEX ,", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + err_sqls.append( SMAschema(index_name="tbname", tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) + + # current_set cur_sqls.append( SMAschema(max_delay="",tbname=STBNAME, func=(f"min({INT_COL})",f"max({INT_COL})") ) ) @@ -474,8 +493,8 @@ class TDTestCase: err_sqls , cur_sqls = self.__drop_sma_sql for err_sql in err_sqls: self.sma_drop_check(err_sql) - for cur_sql in cur_sqls: - self.sma_drop_check(cur_sql) + # for cur_sql in cur_sqls: + # self.sma_drop_check(cur_sql) def all_test(self): self.test_create_sma() @@ -586,14 +605,14 @@ class TDTestCase: tdLog.printNoPrefix("==========step1:create table in normal database") tdSql.prepare() self.__create_tb() - self.__insert_data() + # self.__insert_data() self.all_test() # drop databases, create same name db、stb and sma index - tdSql.prepare() - self.__create_tb() - self.__insert_data() - self.all_test() + # tdSql.prepare() + # self.__create_tb() + # self.__insert_data() + # self.all_test() From 496c2ff7b397b08b19e388134a858555e31840fe Mon Sep 17 00:00:00 2001 From: cpwu Date: Mon, 27 Jun 2022 15:41:01 +0800 Subject: [PATCH 40/73] fix case --- tests/system-test/1-insert/time_range_wise.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index ee94d6d44b..d4434987a6 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -172,7 +172,7 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") - tdSql.init(conn.cursor(), True) + tdSql.init(conn.cursor(), False) self.precision = "ms" self.sma_count = 0 self.sma_created_index = [] From d4ba3e3dc60f77ed354e8615f7fbca7e14999d59 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Mon, 27 Jun 2022 15:44:14 +0800 Subject: [PATCH 41/73] test: add win newest test --- source/libs/parser/src/parUtil.c | 5 ++ tests/script/test-all.bat | 26 +++++--- tests/system-test/fulltest.bat | 102 ------------------------------- tests/system-test/test-all.bat | 27 +++++--- 4 files changed, 41 insertions(+), 119 deletions(-) delete mode 100644 tests/system-test/fulltest.bat diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index c4f4624355..202dd96581 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -337,7 +337,11 @@ int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen) { static bool isValidateTag(char* input) { if (!input) return false; for (size_t i = 0; i < strlen(input); ++i) { + #ifdef WINDOWS + if (input[i] < 0x20 || input[i] > 0x7E) return false; + #else if (isprint(input[i]) == 0) return false; + #endif } return true; } @@ -377,6 +381,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, SMs char* jsonKey = item->string; if (!isValidateTag(jsonKey)) { + fprintf(stdout,"%s(%d) %s %08" PRId64 "\n", __FILE__, __LINE__,__func__,taosGetSelfPthreadId());fflush(stdout); retCode = buildSyntaxErrMsg(pMsgBuf, "json key not validate", jsonKey); goto end; } diff --git a/tests/script/test-all.bat b/tests/script/test-all.bat index 7a1a4bc7fa..81c1f21c04 100644 --- a/tests/script/test-all.bat +++ b/tests/script/test-all.bat @@ -11,14 +11,17 @@ if not "%2" == "" ( ) for /F "usebackq tokens=*" %%i in (!caseFile!) do ( set line=%%i - if "!line:~,9!" == "./test.sh" ( - set /a a+=1 - echo !a! Processing %%i - call :GetTimeSeconds !time! - set time1=!_timeTemp! - echo Start at !time! - call !line:./test.sh=wtest.bat! > result_!a!.txt 2>error_!a!.txt - if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 && echo %%i >>failed.txt ) else ( call :colorEcho 0a "Success" &echo. ) + call :CheckSkipCase %%i + if !skipCase! == false ( + if "!line:~,9!" == "./test.sh" ( + set /a a+=1 + echo !a! Processing %%i + call :GetTimeSeconds !time! + set time1=!_timeTemp! + echo Start at !time! + call !line:./test.sh=wtest.bat! > result_!a!.txt 2>error_!a!.txt + if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 && echo %%i >>failed.txt ) else ( call :colorEcho 0a "Success" &echo. ) + ) ) ) exit !exitNum! @@ -56,3 +59,10 @@ for %%a in (%tt%) do ( ) set /a _timeTemp=(%hh%*60+%mm%)*60+%ss% goto :eof + +:CheckSkipCase +set skipCase=false +if "%*" == "./test.sh -f tsim/query/scalarFunction.sim" ( set skipCase=true ) +if "%*" == "./test.sh -f tsim/stream/distributeInterval0.sim" ( set skipCase=true ) +if "%*" == "./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim" ( set skipCase=true ) +:goto eof \ No newline at end of file diff --git a/tests/system-test/fulltest.bat b/tests/system-test/fulltest.bat deleted file mode 100644 index 59ddd3fb7d..0000000000 --- a/tests/system-test/fulltest.bat +++ /dev/null @@ -1,102 +0,0 @@ - -python3 .\test.py -f 0-others\taosShell.py -python3 .\test.py -f 0-others\taosShellError.py -python3 .\test.py -f 0-others\taosShellNetChk.py -python3 .\test.py -f 0-others\telemetry.py -python3 .\test.py -f 0-others\taosdMonitor.py -python3 .\test.py -f 0-others\udfTest.py -python3 .\test.py -f 0-others\udf_create.py -python3 .\test.py -f 0-others\udf_restart_taosd.py -python3 .\test.py -f 0-others\cachelast.py - -python3 .\test.py -f 0-others\user_control.py -python3 .\test.py -f 0-others\fsync.py - -python3 .\test.py -f 1-insert\influxdb_line_taosc_insert.py -python3 .\test.py -f 1-insert\opentsdb_telnet_line_taosc_insert.py -python3 .\test.py -f 1-insert\opentsdb_json_taosc_insert.py -@REM #python3 .\test.py -f 1-insert\test_stmt_muti_insert_query.py -python3 .\test.py -f 1-insert\alter_stable.py -python3 .\test.py -f 1-insert\alter_table.py -python3 .\test.py -f 2-query\between.py -python3 .\test.py -f 2-query\distinct.py -python3 .\test.py -f 2-query\varchar.py -python3 .\test.py -f 2-query\ltrim.py -python3 .\test.py -f 2-query\rtrim.py -python3 .\test.py -f 2-query\length.py -python3 .\test.py -f 2-query\char_length.py -python3 .\test.py -f 2-query\upper.py -python3 .\test.py -f 2-query\lower.py -python3 .\test.py -f 2-query\join.py -python3 .\test.py -f 2-query\join2.py -python3 .\test.py -f 2-query\cast.py -python3 .\test.py -f 2-query\union.py -python3 .\test.py -f 2-query\union1.py -python3 .\test.py -f 2-query\concat.py -python3 .\test.py -f 2-query\concat2.py -python3 .\test.py -f 2-query\concat_ws.py -python3 .\test.py -f 2-query\concat_ws2.py -python3 .\test.py -f 2-query\check_tsdb.py -python3 .\test.py -f 2-query\spread.py -python3 .\test.py -f 2-query\hyperloglog.py - -python3 .\test.py -f 2-query\timezone.py -python3 .\test.py -f 2-query\Now.py -python3 .\test.py -f 2-query\Today.py -python3 .\test.py -f 2-query\max.py -python3 .\test.py -f 2-query\min.py -python3 .\test.py -f 2-query\count.py -python3 .\test.py -f 2-query\last.py -python3 .\test.py -f 2-query\first.py -python3 .\test.py -f 2-query\To_iso8601.py -python3 .\test.py -f 2-query\To_unixtimestamp.py -python3 .\test.py -f 2-query\timetruncate.py -python3 .\test.py -f 2-query\diff.py -python3 .\test.py -f 2-query\Timediff.py - -python3 .\test.py -f 2-query\top.py -python3 .\test.py -f 2-query\bottom.py -python3 .\test.py -f 2-query\percentile.py -python3 .\test.py -f 2-query\apercentile.py -python3 .\test.py -f 2-query\abs.py -python3 .\test.py -f 2-query\ceil.py -python3 .\test.py -f 2-query\floor.py -python3 .\test.py -f 2-query\round.py -python3 .\test.py -f 2-query\log.py -python3 .\test.py -f 2-query\pow.py -python3 .\test.py -f 2-query\sqrt.py -python3 .\test.py -f 2-query\sin.py -python3 .\test.py -f 2-query\cos.py -python3 .\test.py -f 2-query\tan.py -python3 .\test.py -f 2-query\arcsin.py -python3 .\test.py -f 2-query\arccos.py -python3 .\test.py -f 2-query\arctan.py -python3 .\test.py -f 2-query\query_cols_tags_and_or.py -@REM # python3 .\test.py -f 2-query\nestedQuery.py -@REM # TD-15983 subquery output duplicate name column. -@REM # Please Xiangyang Guo modify the following script -@REM # python3 .\test.py -f 2-query\nestedQuery_str.py - -python3 .\test.py -f 2-query\avg.py -python3 .\test.py -f 2-query\elapsed.py -python3 .\test.py -f 2-query\csum.py -python3 .\test.py -f 2-query\mavg.py -python3 .\test.py -f 2-query\diff.py -python3 .\test.py -f 2-query\sample.py -python3 .\test.py -f 2-query\function_diff.py -python3 .\test.py -f 2-query\unique.py -python3 .\test.py -f 2-query\stateduration.py -python3 .\test.py -f 2-query\function_stateduration.py -python3 .\test.py -f 2-query\statecount.py - -python3 .\test.py -f 7-tmq\basic5.py -python3 .\test.py -f 7-tmq\subscribeDb.py -python3 .\test.py -f 7-tmq\subscribeDb0.py -python3 .\test.py -f 7-tmq\subscribeDb1.py -python3 .\test.py -f 7-tmq\subscribeStb.py -python3 .\test.py -f 7-tmq\subscribeStb0.py -python3 .\test.py -f 7-tmq\subscribeStb1.py -python3 .\test.py -f 7-tmq\subscribeStb2.py -python3 .\test.py -f 7-tmq\subscribeStb3.py -python3 .\test.py -f 7-tmq\subscribeStb4.py -python3 .\test.py -f 7-tmq\db.py \ No newline at end of file diff --git a/tests/system-test/test-all.bat b/tests/system-test/test-all.bat index adc9e0ce28..d4032cbc0d 100644 --- a/tests/system-test/test-all.bat +++ b/tests/system-test/test-all.bat @@ -6,19 +6,23 @@ if "%1" == "full" ( echo Windows Taosd Full Test set /a exitNum=0 del /Q /F failed.txt - set caseFile="fulltest.bat" + set caseFile="fulltest.sh" if not "%2" == "" ( set caseFile="%2" ) for /F "usebackq tokens=*" %%i in (!caseFile!) do ( - for /f "tokens=1* delims= " %%a in ("%%i") do if not "%%a" == "@REM" ( - set /a a+=1 - echo !a! Processing %%i - call :GetTimeSeconds !time! - set time1=!_timeTemp! - echo Start at !time! - call %%i ARG1 > result_!a!.txt 2>error_!a!.txt - if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 && echo %%i >>failed.txt ) else ( call :colorEcho 0a "Success" &echo. ) + call :CheckSkipCase %%i + if !skipCase! == false ( + set line=%%i + if "!line:~,7!" == "python3" ( + set /a a+=1 + echo !a! Processing %%i + call :GetTimeSeconds !time! + set time1=!_timeTemp! + echo Start at !time! + call %%i ARG1 > result_!a!.txt 2>error_!a!.txt + if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 && echo %%i >>failed.txt ) else ( call :colorEcho 0a "Success" &echo. ) + ) ) ) exit !exitNum! @@ -83,3 +87,8 @@ for %%a in (%tt%) do ( ) set /a _timeTemp=(%hh%*60+%mm%)*60+%ss% goto :eof + +:CheckSkipCase +set skipCase=false +if "%*" == "python3 ./test.py -f 1-insert/insertWithMoreVgroup.py" ( set skipCase=true ) +:goto eof \ No newline at end of file From 49ff32cda5fce4095eebb70187d2062d43b06b3a Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 27 Jun 2022 16:53:02 +0800 Subject: [PATCH 42/73] refactor(sync): add entries cache --- source/libs/sync/inc/syncRaftEntry.h | 25 ++ source/libs/sync/src/syncMain.c | 11 +- source/libs/sync/src/syncRaftEntry.c | 240 +++++++++++++++++++ source/libs/sync/src/syncRespMgr.c | 12 +- source/libs/sync/test/CMakeLists.txt | 14 ++ source/libs/sync/test/syncEntryCacheTest.cpp | 162 +++++++++++++ 6 files changed, 456 insertions(+), 8 deletions(-) create mode 100644 source/libs/sync/test/syncEntryCacheTest.cpp diff --git a/source/libs/sync/inc/syncRaftEntry.h b/source/libs/sync/inc/syncRaftEntry.h index b130186516..37f18a6388 100644 --- a/source/libs/sync/inc/syncRaftEntry.h +++ b/source/libs/sync/inc/syncRaftEntry.h @@ -56,6 +56,31 @@ void syncEntryPrint2(char* s, const SSyncRaftEntry* pObj); void syncEntryLog(const SSyncRaftEntry* pObj); void syncEntryLog2(char* s, const SSyncRaftEntry* pObj); +//----------------------------------- +typedef struct SRaftEntryCache { + SHashObj* pEntryHash; + int32_t maxCount; + int32_t currentCount; + TdThreadMutex mutex; + SSyncNode* pSyncNode; +} SRaftEntryCache; + +SRaftEntryCache* raftCacheCreate(SSyncNode* pSyncNode, int32_t maxCount); +void raftCacheDestroy(SRaftEntryCache* pCache); +int32_t raftCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry); +int32_t raftCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry); +int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry); +int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index); +int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry); +int32_t raftCacheClear(struct SRaftEntryCache* pCache); + +cJSON* raftCache2Json(SRaftEntryCache* pObj); +char* raftCache2Str(SRaftEntryCache* pObj); +void raftCachePrint(SRaftEntryCache* pObj); +void raftCachePrint2(char* s, SRaftEntryCache* pObj); +void raftCacheLog(SRaftEntryCache* pObj); +void raftCacheLog2(char* s, SRaftEntryCache* pObj); + #ifdef __cplusplus } #endif diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 3996193037..60f6ca7e7b 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -1355,11 +1355,16 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) { int32_t userStrLen = strlen(str); SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; - if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { + if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); } - SyncIndex logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); - SyncIndex logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); + + SyncIndex logLastIndex = SYNC_INDEX_INVALID; + SyncIndex logBeginIndex = SYNC_INDEX_INVALID; + if (pSyncNode->pLogStore != NULL) { + logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); + logBeginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); + } char* pCfgStr = syncCfg2SimpleStr(&(pSyncNode->pRaftCfg->cfg)); char* printStr = ""; diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index ff334a76bb..d221780ae1 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -180,3 +180,243 @@ void syncEntryLog2(char* s, const SSyncRaftEntry* pObj) { sTrace("syncEntryLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } + +//----------------------------------- +SRaftEntryCache* raftCacheCreate(SSyncNode* pSyncNode, int32_t maxCount) { + SRaftEntryCache* pCache = taosMemoryMalloc(sizeof(SRaftEntryCache)); + if (pCache == NULL) { + sError("vgId:%d raft cache create error", pSyncNode->vgId); + return NULL; + } + + pCache->pEntryHash = + taosHashInit(sizeof(SyncIndex), taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (pCache->pEntryHash == NULL) { + sError("vgId:%d raft cache create hash error", pSyncNode->vgId); + return NULL; + } + + taosThreadMutexInit(&(pCache->mutex), NULL); + pCache->maxCount = maxCount; + pCache->currentCount = 0; + pCache->pSyncNode = pSyncNode; + + return pCache; +} + +void raftCacheDestroy(SRaftEntryCache* pCache) { + if (pCache != NULL) { + taosThreadMutexLock(&(pCache->mutex)); + taosHashCleanup(pCache->pEntryHash); + taosThreadMutexUnlock(&(pCache->mutex)); + taosThreadMutexDestroy(&(pCache->mutex)); + taosMemoryFree(pCache); + } +} + +// success, return 1 +// max count, return 0 +// error, return -1 +int32_t raftCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry) { + taosThreadMutexLock(&(pCache->mutex)); + + if (pCache->currentCount >= pCache->maxCount) { + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; + } + + taosHashPut(pCache->pEntryHash, &(pEntry->index), sizeof(pEntry->index), pEntry, pEntry->bytes); + ++(pCache->currentCount); + + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "raft cache add, type:%s,%d, type2:%s,%d, index:%ld, bytes:%d", + TMSG_INFO(pEntry->msgType), pEntry->msgType, TMSG_INFO(pEntry->originalRpcType), pEntry->originalRpcType, + pEntry->index, pEntry->bytes); + syncNodeEventLog(pCache->pSyncNode, eventLog); + } while (0); + + taosThreadMutexUnlock(&(pCache->mutex)); + return 1; +} + +// success, return 0 +// error, return -1 +// not exist, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST +int32_t raftCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) { + if (ppEntry == NULL) { + return -1; + } + *ppEntry = NULL; + + taosThreadMutexLock(&(pCache->mutex)); + void* pTmp = taosHashGet(pCache->pEntryHash, &index, sizeof(index)); + if (pTmp != NULL) { + SSyncRaftEntry* pEntry = pTmp; + *ppEntry = taosMemoryMalloc(pEntry->bytes); + memcpy(*ppEntry, pTmp, pEntry->bytes); + + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "raft cache get, type:%s,%d, type2:%s,%d, index:%ld", + TMSG_INFO((*ppEntry)->msgType), (*ppEntry)->msgType, TMSG_INFO((*ppEntry)->originalRpcType), + (*ppEntry)->originalRpcType, (*ppEntry)->index); + syncNodeEventLog(pCache->pSyncNode, eventLog); + } while (0); + + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; + } + + taosThreadMutexUnlock(&(pCache->mutex)); + terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; + return -1; +} + +// success, return 0 +// error, return -1 +// not exist, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST +int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) { + if (ppEntry == NULL) { + return -1; + } + *ppEntry = NULL; + + taosThreadMutexLock(&(pCache->mutex)); + void* pTmp = taosHashGet(pCache->pEntryHash, &index, sizeof(index)); + if (pTmp != NULL) { + SSyncRaftEntry* pEntry = pTmp; + *ppEntry = pEntry; + + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "raft cache get, type:%s,%d, type2:%s,%d, index:%ld", + TMSG_INFO((*ppEntry)->msgType), (*ppEntry)->msgType, TMSG_INFO((*ppEntry)->originalRpcType), + (*ppEntry)->originalRpcType, (*ppEntry)->index); + syncNodeEventLog(pCache->pSyncNode, eventLog); + } while (0); + + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; + } + + taosThreadMutexUnlock(&(pCache->mutex)); + terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; + return -1; +} + +int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index) { + taosThreadMutexLock(&(pCache->mutex)); + taosHashRemove(pCache->pEntryHash, &index, sizeof(index)); + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; +} + +int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyncRaftEntry** ppEntry) { + if (ppEntry == NULL) { + return -1; + } + *ppEntry = NULL; + + taosThreadMutexLock(&(pCache->mutex)); + void* pTmp = taosHashGet(pCache->pEntryHash, &index, sizeof(index)); + if (pTmp != NULL) { + SSyncRaftEntry* pEntry = pTmp; + *ppEntry = taosMemoryMalloc(pEntry->bytes); + memcpy(*ppEntry, pTmp, pEntry->bytes); + + do { + char eventLog[128]; + snprintf(eventLog, sizeof(eventLog), "raft cache get-and-del, type:%s,%d, type2:%s,%d, index:%ld", + TMSG_INFO((*ppEntry)->msgType), (*ppEntry)->msgType, TMSG_INFO((*ppEntry)->originalRpcType), + (*ppEntry)->originalRpcType, (*ppEntry)->index); + syncNodeEventLog(pCache->pSyncNode, eventLog); + } while (0); + + taosHashRemove(pCache->pEntryHash, &index, sizeof(index)); + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; + } + + taosThreadMutexUnlock(&(pCache->mutex)); + terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; + return -1; +} + +int32_t raftCacheClear(struct SRaftEntryCache* pCache) { + taosThreadMutexLock(&(pCache->mutex)); + taosHashClear(pCache->pEntryHash); + taosThreadMutexUnlock(&(pCache->mutex)); + return 0; +} + +//----------------------------------- +cJSON* raftCache2Json(SRaftEntryCache* pCache) { + char u64buf[128] = {0}; + cJSON* pRoot = cJSON_CreateObject(); + + if (pCache != NULL) { + taosThreadMutexLock(&(pCache->mutex)); + + snprintf(u64buf, sizeof(u64buf), "%p", pCache->pSyncNode); + cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); + cJSON_AddNumberToObject(pRoot, "currentCount", pCache->currentCount); + cJSON_AddNumberToObject(pRoot, "maxCount", pCache->maxCount); + cJSON* pEntries = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "entries", pEntries); + + SSyncRaftEntry* pIter = (SSyncRaftEntry*)taosHashIterate(pCache->pEntryHash, NULL); + if (pIter != NULL) { + SSyncRaftEntry* pEntry = (SSyncRaftEntry*)pIter; + cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry)); + } + while (pIter) { + pIter = taosHashIterate(pCache->pEntryHash, pIter); + if (pIter != NULL) { + SSyncRaftEntry* pEntry = (SSyncRaftEntry*)pIter; + cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry)); + } + } + + taosThreadMutexUnlock(&(pCache->mutex)); + } + + cJSON* pJson = cJSON_CreateObject(); + cJSON_AddItemToObject(pJson, "SRaftEntryCache", pRoot); + return pJson; +} + +char* raftCache2Str(SRaftEntryCache* pCache) { + cJSON* pJson = raftCache2Json(pCache); + char* serialized = cJSON_Print(pJson); + cJSON_Delete(pJson); + return serialized; +} + +void raftCachePrint(SRaftEntryCache* pCache) { + char* serialized = raftCache2Str(pCache); + printf("raftCachePrint | len:%lu | %s \n", strlen(serialized), serialized); + fflush(NULL); + taosMemoryFree(serialized); +} + +void raftCachePrint2(char* s, SRaftEntryCache* pCache) { + char* serialized = raftCache2Str(pCache); + printf("raftCachePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + fflush(NULL); + taosMemoryFree(serialized); +} + +void raftCacheLog(SRaftEntryCache* pCache) { + char* serialized = raftCache2Str(pCache); + sTrace("raftCacheLog | len:%lu | %s", strlen(serialized), serialized); + taosMemoryFree(serialized); +} + +void raftCacheLog2(char* s, SRaftEntryCache* pCache) { + if (gRaftDetailLog) { + char* serialized = raftCache2Str(pCache); + sTraceLong("raftCacheLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + taosMemoryFree(serialized); + } +} \ No newline at end of file diff --git a/source/libs/sync/src/syncRespMgr.c b/source/libs/sync/src/syncRespMgr.c index 48c1b70a04..d2cbabe226 100644 --- a/source/libs/sync/src/syncRespMgr.c +++ b/source/libs/sync/src/syncRespMgr.c @@ -32,11 +32,13 @@ SSyncRespMgr *syncRespMgrCreate(void *data, int64_t ttl) { } void syncRespMgrDestroy(SSyncRespMgr *pObj) { - taosThreadMutexLock(&(pObj->mutex)); - taosHashCleanup(pObj->pRespHash); - taosThreadMutexUnlock(&(pObj->mutex)); - taosThreadMutexDestroy(&(pObj->mutex)); - taosMemoryFree(pObj); + if (pObj != NULL) { + taosThreadMutexLock(&(pObj->mutex)); + taosHashCleanup(pObj->pRespHash); + taosThreadMutexUnlock(&(pObj->mutex)); + taosThreadMutexDestroy(&(pObj->mutex)); + taosMemoryFree(pObj); + } } int64_t syncRespMgrAdd(SSyncRespMgr *pObj, SRespStub *pStub) { diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index 27084286da..bc63462a9e 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -17,6 +17,7 @@ add_executable(syncVotesRespondTest "") add_executable(syncIndexMgrTest "") add_executable(syncLogStoreTest "") add_executable(syncEntryTest "") +add_executable(syncEntryCacheTest "") add_executable(syncRequestVoteTest "") add_executable(syncRequestVoteReplyTest "") add_executable(syncAppendEntriesTest "") @@ -129,6 +130,10 @@ target_sources(syncEntryTest PRIVATE "syncEntryTest.cpp" ) +target_sources(syncEntryCacheTest + PRIVATE + "syncEntryCacheTest.cpp" +) target_sources(syncRequestVoteTest PRIVATE "syncRequestVoteTest.cpp" @@ -362,6 +367,11 @@ target_include_directories(syncEntryTest "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncEntryCacheTest + PUBLIC + "${TD_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_include_directories(syncRequestVoteTest PUBLIC "${TD_SOURCE_DIR}/include/libs/sync" @@ -610,6 +620,10 @@ target_link_libraries(syncEntryTest sync gtest_main ) +target_link_libraries(syncEntryCacheTest + sync + gtest_main +) target_link_libraries(syncRequestVoteTest sync gtest_main diff --git a/source/libs/sync/test/syncEntryCacheTest.cpp b/source/libs/sync/test/syncEntryCacheTest.cpp new file mode 100644 index 0000000000..787c08e507 --- /dev/null +++ b/source/libs/sync/test/syncEntryCacheTest.cpp @@ -0,0 +1,162 @@ +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncRaftLog.h" +#include "syncRaftStore.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +SSyncRaftEntry* createEntry(int i) { + int32_t dataLen = 20; + SSyncRaftEntry* pEntry = syncEntryBuild(dataLen); + assert(pEntry != NULL); + pEntry->msgType = 88; + pEntry->originalRpcType = 99; + pEntry->seqNum = 3; + pEntry->isWeak = true; + pEntry->term = 100 + i; + pEntry->index = i; + snprintf(pEntry->data, dataLen, "value%d", i); + + return pEntry; +} + +SSyncNode* createFakeNode() { + SSyncNode* pSyncNode = (SSyncNode*)taosMemoryMalloc(sizeof(SSyncNode)); + ASSERT(pSyncNode != NULL); + memset(pSyncNode, 0, sizeof(SSyncNode)); + + return pSyncNode; +} + +SRaftEntryCache* createCache(int maxCount) { + SSyncNode* pSyncNode = createFakeNode(); + ASSERT(pSyncNode != NULL); + + SRaftEntryCache* pCache = raftCacheCreate(pSyncNode, maxCount); + ASSERT(pCache != NULL); + + return pCache; +} + +void test1() { + int32_t code = 0; + SRaftEntryCache* pCache = createCache(5); + for (int i = 0; i < 5; ++i) { + SSyncRaftEntry* pEntry = createEntry(i); + code = raftCachePutEntry(pCache, pEntry); + ASSERT(code == 1); + syncEntryDestory(pEntry); + } + raftCacheLog2((char*)"==test1 write 5 entries==", pCache); + + SyncIndex index; + index = 1; + code = raftCacheDelEntry(pCache, index); + ASSERT(code == 0); + index = 3; + code = raftCacheDelEntry(pCache, index); + ASSERT(code == 0); + raftCacheLog2((char*)"==test1 delete 1,3==", pCache); + + code = raftCacheClear(pCache); + ASSERT(code == 0); + raftCacheLog2((char*)"==clear all==", pCache); +} + +void test2() { + int32_t code = 0; + SRaftEntryCache* pCache = createCache(5); + for (int i = 0; i < 5; ++i) { + SSyncRaftEntry* pEntry = createEntry(i); + code = raftCachePutEntry(pCache, pEntry); + ASSERT(code == 1); + syncEntryDestory(pEntry); + } + raftCacheLog2((char*)"==test2 write 5 entries==", pCache); + + SyncIndex index; + index = 1; + SSyncRaftEntry* pEntry; + code = raftCacheGetEntry(pCache, index, &pEntry); + ASSERT(code == 0); + syncEntryDestory(pEntry); + syncEntryLog2((char*)"==test2 get entry 1==", pEntry); + + index = 2; + code = raftCacheGetEntryP(pCache, index, &pEntry); + ASSERT(code == 0); + syncEntryLog2((char*)"==test2 get entry pointer 2==", pEntry); + + // not found + index = 8; + code = raftCacheGetEntry(pCache, index, &pEntry); + ASSERT(code == -1 && terrno == TSDB_CODE_WAL_LOG_NOT_EXIST); + sTrace("==test2 get entry 8 not found=="); + + // not found + index = 9; + code = raftCacheGetEntryP(pCache, index, &pEntry); + ASSERT(code == -1 && terrno == TSDB_CODE_WAL_LOG_NOT_EXIST); + sTrace("==test2 get entry pointer 9 not found=="); +} + +void test3() { + int32_t code = 0; + SRaftEntryCache* pCache = createCache(5); + for (int i = 0; i < 5; ++i) { + SSyncRaftEntry* pEntry = createEntry(i); + code = raftCachePutEntry(pCache, pEntry); + ASSERT(code == 1); + syncEntryDestory(pEntry); + } + for (int i = 6; i < 10; ++i) { + SSyncRaftEntry* pEntry = createEntry(i); + code = raftCachePutEntry(pCache, pEntry); + ASSERT(code == 0); + syncEntryDestory(pEntry); + } + raftCacheLog2((char*)"==test3 write 10 entries, max count is 5==", pCache); +} + +void test4() { + int32_t code = 0; + SRaftEntryCache* pCache = createCache(5); + for (int i = 0; i < 5; ++i) { + SSyncRaftEntry* pEntry = createEntry(i); + code = raftCachePutEntry(pCache, pEntry); + ASSERT(code == 1); + syncEntryDestory(pEntry); + } + raftCacheLog2((char*)"==test4 write 5 entries==", pCache); + + SyncIndex index; + index = 3; + SSyncRaftEntry* pEntry; + code = raftCacheGetAndDel(pCache, index, &pEntry); + ASSERT(code == 0); + syncEntryLog2((char*)"==test4 get-and-del entry 3==", pEntry); + raftCacheLog2((char*)"==test4 after get-and-del entry 3==", pCache); +} + +int main(int argc, char** argv) { + gRaftDetailLog = true; + tsAsyncLog = 0; + sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE + DEBUG_DEBUG; + + test1(); + test2(); + test3(); + test4(); + + return 0; +} From 5e7b7cb449f6b4044bbbae0e9778675fac63633f Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 27 Jun 2022 16:56:36 +0800 Subject: [PATCH 43/73] refactor(sync): add entries cache --- source/libs/sync/src/syncRaftEntry.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index d221780ae1..225360630c 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -308,6 +308,7 @@ int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyn int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index) { taosThreadMutexLock(&(pCache->mutex)); taosHashRemove(pCache->pEntryHash, &index, sizeof(index)); + --(pCache->currentCount); taosThreadMutexUnlock(&(pCache->mutex)); return 0; } @@ -334,6 +335,8 @@ int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyn } while (0); taosHashRemove(pCache->pEntryHash, &index, sizeof(index)); + --(pCache->currentCount); + taosThreadMutexUnlock(&(pCache->mutex)); return 0; } @@ -346,6 +349,7 @@ int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyn int32_t raftCacheClear(struct SRaftEntryCache* pCache) { taosThreadMutexLock(&(pCache->mutex)); taosHashClear(pCache->pEntryHash); + pCache->currentCount = 0; taosThreadMutexUnlock(&(pCache->mutex)); return 0; } From 007ebbd54a4fdb3dc8ba476406c53543bb6bd078 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 27 Jun 2022 17:10:38 +0800 Subject: [PATCH 44/73] enh: add retryCode for transaction --- source/dnode/mnode/impl/inc/mndTrans.h | 4 +- source/dnode/mnode/impl/src/mndTrans.c | 89 +++++++++++++------ source/dnode/mnode/impl/src/mndVgroup.c | 12 ++- tests/script/jenkins/basic.txt | 2 +- ...distribute_vgroup_replica3_v1_follower.sim | 4 +- 5 files changed, 76 insertions(+), 35 deletions(-) diff --git a/source/dnode/mnode/impl/inc/mndTrans.h b/source/dnode/mnode/impl/inc/mndTrans.h index bc2d5c82b1..1497bba11c 100644 --- a/source/dnode/mnode/impl/inc/mndTrans.h +++ b/source/dnode/mnode/impl/inc/mndTrans.h @@ -39,8 +39,10 @@ typedef struct { int32_t id; int32_t errCode; int32_t acceptableCode; - ETrnStage stage; + int32_t retryCode; ETrnAct actionType; + ETrnStage stage; + int8_t reserved; int8_t rawWritten; int8_t msgSent; int8_t msgReceived; diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index a9de1a05a7..16970e5d78 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -15,15 +15,15 @@ #define _DEFAULT_SOURCE #include "mndTrans.h" -#include "mndPrivilege.h" #include "mndConsumer.h" #include "mndDb.h" +#include "mndPrivilege.h" #include "mndShow.h" #include "mndSync.h" #include "mndUser.h" -#define TRANS_VER_NUMBER 1 -#define TRANS_ARRAY_SIZE 8 +#define TRANS_VER_NUMBER 1 +#define TRANS_ARRAY_SIZE 8 #define TRANS_RESERVE_SIZE 64 static SSdbRaw *mndTransActionEncode(STrans *pTrans); @@ -55,7 +55,7 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans); static bool mndCannotExecuteTransAction(SMnode *pMnode) { return !pMnode->deploy && !mndIsMaster(pMnode); } static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans); -static int32_t mndProcessTransReq(SRpcMsg *pReq); +static int32_t mndProcessTransTimer(SRpcMsg *pReq); static int32_t mndProcessTtl(SRpcMsg *pReq); static int32_t mndProcessKillTransReq(SRpcMsg *pReq); @@ -73,7 +73,7 @@ int32_t mndInitTrans(SMnode *pMnode) { .deleteFp = (SdbDeleteFp)mndTransActionDelete, }; - mndSetMsgHandle(pMnode, TDMT_MND_TRANS_TIMER, mndProcessTransReq); + mndSetMsgHandle(pMnode, TDMT_MND_TRANS_TIMER, mndProcessTransTimer); mndSetMsgHandle(pMnode, TDMT_MND_KILL_TRANS, mndProcessKillTransReq); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans); @@ -139,8 +139,10 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { SDB_SET_INT32(pRaw, dataPos, pAction->id, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->errCode, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAction->retryCode, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER) + SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER) if (pAction->actionType == TRANS_ACTION_RAW) { int32_t len = sdbGetRawTotalSize(pAction->pRaw); SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER) @@ -163,8 +165,10 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { SDB_SET_INT32(pRaw, dataPos, pAction->id, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->errCode, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAction->retryCode, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER) + SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER) if (pAction->actionType == TRANS_ACTION_RAW) { int32_t len = sdbGetRawTotalSize(pAction->pRaw); SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER) @@ -187,8 +191,10 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { SDB_SET_INT32(pRaw, dataPos, pAction->id, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->errCode, _OVER) SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER) + SDB_SET_INT32(pRaw, dataPos, pAction->retryCode, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER) SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER) + SDB_SET_INT8(pRaw, dataPos, pAction->reserved, _OVER) if (pAction->actionType == TRANS_ACTION_RAW) { int32_t len = sdbGetRawTotalSize(pAction->pRaw); SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER) @@ -291,10 +297,12 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER) + SDB_GET_INT32(pRaw, dataPos, &action.retryCode, _OVER) SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER) action.actionType = actionType; SDB_GET_INT8(pRaw, dataPos, &stage, _OVER) action.stage = stage; + SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER) if (action.actionType == TRANS_ACTION_RAW) { SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) @@ -324,10 +332,12 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER) + SDB_GET_INT32(pRaw, dataPos, &action.retryCode, _OVER) SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER) action.actionType = actionType; SDB_GET_INT8(pRaw, dataPos, &stage, _OVER) action.stage = stage; + SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER) if (action.actionType == TRANS_ACTION_RAW) { SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) @@ -357,10 +367,12 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER) SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER) + SDB_GET_INT32(pRaw, dataPos, &action.retryCode, _OVER) SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER) action.actionType = actionType; SDB_GET_INT8(pRaw, dataPos, &stage, _OVER) action.stage = stage; + SDB_GET_INT8(pRaw, dataPos, &action.reserved, _OVER) if (action.actionType) { SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER) SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER) @@ -463,15 +475,25 @@ static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) { if (fp) { (*fp)(pSdb->pMnode, pTrans->param, pTrans->paramLen); } + pTrans->startFunc = 0; } return 0; } static void mndTransDropData(STrans *pTrans) { - mndTransDropActions(pTrans->redoActions); - mndTransDropActions(pTrans->undoActions); - mndTransDropActions(pTrans->commitActions); + if (pTrans->redoActions != NULL) { + mndTransDropActions(pTrans->redoActions); + pTrans->redoActions = NULL; + } + if (pTrans->undoActions != NULL) { + mndTransDropActions(pTrans->undoActions); + pTrans->undoActions = NULL; + } + if (pTrans->commitActions != NULL) { + mndTransDropActions(pTrans->commitActions); + pTrans->commitActions = NULL; + } if (pTrans->rpcRsp != NULL) { taosMemoryFree(pTrans->rpcRsp); pTrans->rpcRsp = NULL; @@ -492,6 +514,7 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans, bool callFunc) { if (fp) { (*fp)(pSdb->pMnode, pTrans->param, pTrans->paramLen); } + pTrans->stopFunc = 0; } mndTransDropData(pTrans); @@ -805,7 +828,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { sendRsp = true; } } else { - if (pTrans->stage == TRN_STAGE_REDO_ACTION && pTrans->failedTimes > 3) { + if (pTrans->stage == TRN_STAGE_REDO_ACTION && pTrans->failedTimes > 6) { if (code == 0) code = TSDB_CODE_MND_TRANS_UNKNOW_ERROR; sendRsp = true; } @@ -875,8 +898,8 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) { pAction->errCode = pRsp->code; } - mDebug("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x", transId, mndTransStr(pAction->stage), action, - pRsp->code, pAction->acceptableCode); + mDebug("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, + mndTransStr(pAction->stage), action, pRsp->code, pAction->acceptableCode, pAction->retryCode); mndTransExecute(pMnode, pTrans); _OVER: @@ -884,6 +907,21 @@ _OVER: return 0; } +static void mndTransResetAction(SMnode *pMnode, STrans *pTrans, STransAction *pAction) { + pAction->rawWritten = 0; + pAction->msgSent = 0; + pAction->msgReceived = 0; + if (pAction->errCode == TSDB_CODE_RPC_REDIRECT || pAction->errCode == TSDB_CODE_SYN_NEW_CONFIG_ERROR || + pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR || pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) { + pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps; + mDebug("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage), + pAction->id, pAction->epSet.inUse); + } else { + mDebug("trans:%d, %s:%d execute status is reset", pTrans->id, mndTransStr(pAction->stage), pAction->id); + } + pAction->errCode = 0; +} + static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray) { int32_t numOfActions = taosArrayGetSize(pArray); @@ -894,18 +932,7 @@ static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray) continue; if (pAction->rawWritten && (pAction->errCode == 0 || pAction->errCode == pAction->acceptableCode)) continue; - pAction->rawWritten = 0; - pAction->msgSent = 0; - pAction->msgReceived = 0; - if (pAction->errCode == TSDB_CODE_RPC_REDIRECT || pAction->errCode == TSDB_CODE_SYN_NEW_CONFIG_ERROR || - pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR || pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) { - pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps; - mDebug("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage), - action, pAction->epSet.inUse); - } else { - mDebug("trans:%d, %s:%d execute status is reset", pTrans->id, mndTransStr(pAction->stage), action); - } - pAction->errCode = 0; + mndTransResetAction(pMnode, pTrans, pAction); } } @@ -1112,9 +1139,9 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) if (pAction->msgReceived) { if (pAction->errCode != 0 && pAction->errCode != pAction->acceptableCode) { code = pAction->errCode; - pAction->msgSent = 0; - pAction->msgReceived = 0; - mDebug("trans:%d, %s:%d execute status is reset", pTrans->id, mndTransStr(pAction->stage), action); + mndTransResetAction(pMnode, pTrans, pAction); + } else { + mDebug("trans:%d, %s:%d execute successfully", pTrans->id, mndTransStr(pAction->stage), action); } } else { code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -1123,6 +1150,8 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) if (pAction->rawWritten) { if (pAction->errCode != 0 && pAction->errCode != pAction->acceptableCode) { code = pAction->errCode; + } else { + mDebug("trans:%d, %s:%d write successfully", pTrans->id, mndTransStr(pAction->stage), action); } } } @@ -1156,9 +1185,15 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) } else if (code == TSDB_CODE_ACTION_IN_PROGRESS) { mDebug("trans:%d, %s:%d is in progress and wait it finish", pTrans->id, mndTransStr(pAction->stage), pAction->id); break; + } else if (code == pAction->retryCode) { + mDebug("trans:%d, %s:%d receive code:0x%x and retry", pTrans->id, mndTransStr(pAction->stage), pAction->id, code); + taosMsleep(300); + continue; } else { terrno = code; pTrans->code = code; + mDebug("trans:%d, %s:%d receive code:0x%x and wait another schedule, failedTimes:%d", pTrans->id, + mndTransStr(pAction->stage), pAction->id, code, pTrans->failedTimes); break; } } @@ -1343,7 +1378,7 @@ void mndTransExecute(SMnode *pMnode, STrans *pTrans) { mndTransSendRpcRsp(pMnode, pTrans); } -static int32_t mndProcessTransReq(SRpcMsg *pReq) { +static int32_t mndProcessTransTimer(SRpcMsg *pReq) { mndTransPullup(pReq->info.node); return 0; } diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 0e931e0a9c..0e3271a1bb 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -15,10 +15,10 @@ #define _DEFAULT_SOURCE #include "mndVgroup.h" -#include "mndPrivilege.h" #include "mndDb.h" #include "mndDnode.h" #include "mndMnode.h" +#include "mndPrivilege.h" #include "mndShow.h" #include "mndTrans.h" #include "mndUser.h" @@ -896,6 +896,8 @@ int32_t mndAddAlterVnodeConfirmAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD action.pCont = pHead; action.contLen = contLen; action.msgType = TDMT_VND_ALTER_CONFIRM; + // incorrect redirect result will cause this erro + action.retryCode = TSDB_CODE_VND_INVALID_VGROUP_ID; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pHead); @@ -942,6 +944,8 @@ static int32_t mndAddSetVnodeStandByAction(SMnode *pMnode, STrans *pTrans, SDbOb action.contLen = contLen; action.msgType = TDMT_SYNC_SET_VNODE_STANDBY; action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; + // Keep retrying until the target vnode is not the leader + action.retryCode = TSDB_CODE_SYN_IS_LEADER; if (isRedo) { if (mndTransAppendRedoAction(pTrans, &action) != 0) { @@ -1229,7 +1233,8 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) { } if (req.dnodeId1 == pVgroup->vnodeGid[0].dnodeId) { - terrno = TSDB_CODE_MND_VGROUP_UN_CHANGED; + // terrno = TSDB_CODE_MND_VGROUP_UN_CHANGED; + code = 0; goto _OVER; } @@ -1351,7 +1356,8 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) { } if (pNew1 == NULL && pOld1 == NULL && pNew2 == NULL && pOld2 == NULL && pNew3 == NULL && pOld3 == NULL) { - terrno = TSDB_CODE_MND_VGROUP_UN_CHANGED; + // terrno = TSDB_CODE_MND_VGROUP_UN_CHANGED; + code = 0; goto _OVER; } diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 1b61bd1890..76d2546dac 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -29,7 +29,7 @@ #./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim #./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim #./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim -#./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim +./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim # ---- insert diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim index 9b11e16616..00c6e8a98d 100644 --- a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim @@ -65,7 +65,7 @@ sql_error redistribute vgroup 3 dnode 6 dnode 3 dnode 4 # vgroup not exist sql_error redistribute vgroup 3 dnode 5 dnode 3 dnode 4 # un changed -sql_error redistribute vgroup 2 dnode 2 dnode 3 dnode 4 +# sql_error redistribute vgroup 2 dnode 2 dnode 3 dnode 4 # no enought vnodes sql_error redistribute vgroup 2 dnode 1 dnode 3 dnode 4 # offline vnodes @@ -176,8 +176,6 @@ if $rows != 1 then return -1 endi -return - print =============== step32: print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 5 From 11f8d302fa786dc832da0acec9e3d83f3b0ddf80 Mon Sep 17 00:00:00 2001 From: slzhou Date: Mon, 27 Jun 2022 17:51:50 +0800 Subject: [PATCH 45/73] feat: multiway merge handles group+mergekeys, group and only merge keys --- source/libs/executor/inc/executorimpl.h | 5 +- source/libs/executor/src/executil.c | 7 +- source/libs/executor/src/executorimpl.c | 12 +-- source/libs/executor/src/sortoperator.c | 123 ++++++++++++++---------- 4 files changed, 81 insertions(+), 66 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index a139b511a1..1cc3f9b874 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -730,10 +730,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode *pNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortPhyNode, SExecTaskInfo* pTaskInfo); - -SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams, int32_t numStreams, SSDataBlock* pInputBlock, - SSDataBlock* pResBlock, SArray* pSortInfo, SArray* pColMatchColInfo, - SExecTaskInfo* pTaskInfo); +SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** dowStreams, size_t numStreams, SMergePhysiNode* pMergePhysiNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pSortInfo, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 374a3a736d..be6ca5145a 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -159,7 +159,12 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo) { } SArray* createSortInfo(SNodeList* pNodeList) { - size_t numOfCols = LIST_LENGTH(pNodeList); + size_t numOfCols = 0; + if (pNodeList != NULL) { + numOfCols = LIST_LENGTH(pNodeList); + } else { + numOfCols = 0; + } SArray* pList = taosArrayInit(numOfCols, sizeof(SBlockOrderInfo)); if (pList == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 0978bf3f8b..17e5482b60 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4269,17 +4269,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOptr = createGroupSortOperatorInfo(ops[0], (SGroupSortPhysiNode*)pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE == type) { SMergePhysiNode* pMergePhyNode = (SMergePhysiNode*)pPhyNode; - - SDataBlockDescNode* pDescNode = pPhyNode->pOutputDataBlockDesc; - SSDataBlock* pResBlock = createResDataBlock(pDescNode); - - SArray* sortInfo = createSortInfo(pMergePhyNode->pMergeKeys); - int32_t numOfOutputCols = 0; - SArray* pColList = - extractColMatchInfo(pMergePhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); - SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0); - SSDataBlock* pInputDataBlock = createResDataBlock(pChildNode->pOutputDataBlockDesc); - pOptr = createMultiwaySortMergeOperatorInfo(ops, size, pInputDataBlock, pResBlock, sortInfo, pColList, pTaskInfo); + pOptr = createMultiwayMergeOperatorInfo(ops, size, pMergePhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION == type) { SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode; diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 96549ab6ae..44ff4c1c90 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -142,7 +142,7 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i SSDataBlock* loadNextDataBlock(void* param) { SOperatorInfo* pOperator = (SOperatorInfo*)param; - SSDataBlock *pBlock = pOperator->fpSet.getNextFn(pOperator); + SSDataBlock* pBlock = pOperator->fpSet.getNextFn(pOperator); return pBlock; } @@ -443,7 +443,7 @@ void destroyGroupSortOperatorInfo(void* param, int32_t numOfOutput) { SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSortPhysiNode* pSortPhyNode, SExecTaskInfo* pTaskInfo) { SGroupSortOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SGroupSortOperatorInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL /* || rowSize > 100 * 1024 * 1024*/) { goto _error; } @@ -475,8 +475,8 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort pOperator->exprSupp.numOfExprs = numOfCols; pOperator->pTaskInfo = pTaskInfo; - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, NULL, destroyGroupSortOperatorInfo, NULL, - NULL, getGroupSortExplainExecInfo); + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, NULL, destroyGroupSortOperatorInfo, + NULL, NULL, getGroupSortExplainExecInfo); int32_t code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -494,7 +494,7 @@ _error: //===================================================================================== // Multiway Sort Merge operator -typedef struct SMultiwaySortMergeOperatorInfo { +typedef struct SMultiwayMergeOperatorInfo { SOptrBasicInfo binfo; int32_t bufPageSize; @@ -504,16 +504,17 @@ typedef struct SMultiwaySortMergeOperatorInfo { SSortHandle* pSortHandle; SArray* pColMatchInfo; // for index map from table scan output - SSDataBlock* pInputBlock; - int64_t startTs; // sort start time - bool hasGroupId; - uint64_t groupId; - STupleHandle *prefetchedTuple; -} SMultiwaySortMergeOperatorInfo; + SSDataBlock* pInputBlock; + int64_t startTs; // sort start time + bool groupSort; + bool hasGroupId; + uint64_t groupId; + STupleHandle* prefetchedTuple; +} SMultiwayMergeOperatorInfo; -int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) { - SMultiwaySortMergeOperatorInfo* pInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; +int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) { + SMultiwayMergeOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; if (OPTR_IS_OPENED(pOperator)) { return TSDB_CODE_SUCCESS; @@ -527,8 +528,9 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) { pInfo->pInputBlock, pTaskInfo->id.str); tsortSetFetchRawDataFp(pInfo->pSortHandle, loadNextDataBlock, NULL, NULL); - tsortSetCompareGroupId(pInfo->pSortHandle, true); - + + tsortSetCompareGroupId(pInfo->pSortHandle, pInfo->groupSort); + for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) { SSortSource* ps = taosMemoryCalloc(1, sizeof(SSortSource)); ps->param = pOperator->pDownstream[i]; @@ -550,8 +552,8 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) { SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t capacity, SArray* pColMatchInfo, SOperatorInfo* pOperator) { - SMultiwaySortMergeOperatorInfo* pInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SMultiwayMergeOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; blockDataCleanup(pDataBlock); @@ -564,35 +566,46 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData while (1) { STupleHandle* pTupleHandle = NULL; - if (pInfo->prefetchedTuple == NULL) { + if (pInfo->groupSort) { + if (pInfo->prefetchedTuple == NULL) { + pTupleHandle = tsortNextTuple(pHandle); + } else { + pTupleHandle = pInfo->prefetchedTuple; + pInfo->groupId = tsortGetGroupId(pTupleHandle); + pInfo->prefetchedTuple = NULL; + } + } + else { pTupleHandle = tsortNextTuple(pHandle); - } else { - pTupleHandle = pInfo->prefetchedTuple; - pInfo->groupId = tsortGetGroupId(pTupleHandle); - pInfo->prefetchedTuple = NULL; + pInfo->groupId = 0; } if (pTupleHandle == NULL) { break; } - uint64_t tupleGroupId = tsortGetGroupId(pTupleHandle); - if (!pInfo->hasGroupId) { - pInfo->groupId = tupleGroupId; - pInfo->hasGroupId = true; - appendOneRowToDataBlock(p, pTupleHandle); - } else if (pInfo->groupId == tupleGroupId) { - appendOneRowToDataBlock(p, pTupleHandle); + if (pInfo->groupSort) + { + uint64_t tupleGroupId = tsortGetGroupId(pTupleHandle); + if (!pInfo->hasGroupId) { + pInfo->groupId = tupleGroupId; + pInfo->hasGroupId = true; + appendOneRowToDataBlock(p, pTupleHandle); + } else if (pInfo->groupId == tupleGroupId) { + appendOneRowToDataBlock(p, pTupleHandle); + } else { + pInfo->prefetchedTuple = pTupleHandle; + break; + } } else { - pInfo->prefetchedTuple = pTupleHandle; - break; + appendOneRowToDataBlock(p, pTupleHandle); } if (p->info.rows >= capacity) { break; } } - if (p->info.rows > 0) {// todo extract method + if (p->info.rows > 0) { // todo extract method blockDataEnsureCapacity(pDataBlock, p->info.rows); int32_t numOfCols = taosArrayGetSize(pColMatchInfo); for (int32_t i = 0; i < numOfCols; ++i) { @@ -614,13 +627,13 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData return (pDataBlock->info.rows > 0) ? pDataBlock : NULL; } -SSDataBlock* doMultiwaySortMerge(SOperatorInfo* pOperator) { +SSDataBlock* doMultiwayMerge(SOperatorInfo* pOperator) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SMultiwaySortMergeOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SMultiwayMergeOperatorInfo* pInfo = pOperator->info; int32_t code = pOperator->fpSet._openFn(pOperator); if (code != TSDB_CODE_SUCCESS) { @@ -637,8 +650,8 @@ SSDataBlock* doMultiwaySortMerge(SOperatorInfo* pOperator) { return pBlock; } -void destroyMultiwaySortMergeOperatorInfo(void* param, int32_t numOfOutput) { - SMultiwaySortMergeOperatorInfo* pInfo = (SMultiwaySortMergeOperatorInfo*)param; +void destroyMultiwayMergeOperatorInfo(void* param, int32_t numOfOutput) { + SMultiwayMergeOperatorInfo* pInfo = (SMultiwayMergeOperatorInfo*)param; pInfo->binfo.pRes = blockDataDestroy(pInfo->binfo.pRes); pInfo->pInputBlock = blockDataDestroy(pInfo->pInputBlock); @@ -646,11 +659,11 @@ void destroyMultiwaySortMergeOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pColMatchInfo); } -int32_t getMultiwaySortMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { +int32_t getMultiwayMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { ASSERT(pOptr != NULL); SSortExecInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortExecInfo)); - SMultiwaySortMergeOperatorInfo* pOperatorInfo = (SMultiwaySortMergeOperatorInfo*)pOptr->info; + SMultiwayMergeOperatorInfo* pOperatorInfo = (SMultiwayMergeOperatorInfo*)pOptr->info; *pInfo = tsortGetSortExecInfo(pOperatorInfo->pSortHandle); *pOptrExplain = pInfo; @@ -658,24 +671,35 @@ int32_t getMultiwaySortMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrEx return TSDB_CODE_SUCCESS; } -SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams, int32_t numStreams, - SSDataBlock* pInputBlock, SSDataBlock* pResBlock, SArray* pSortInfo, - SArray* pColMatchColInfo, SExecTaskInfo* pTaskInfo) { - SMultiwaySortMergeOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SMultiwaySortMergeOperatorInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - int32_t rowSize = pResBlock->info.rowSize; +SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size_t numStreams, + SMergePhysiNode* pMergePhyNode, SExecTaskInfo* pTaskInfo) { + SPhysiNode* pPhyNode = (SPhysiNode*)pMergePhyNode; + + SMultiwayMergeOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SMultiwayMergeOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + SDataBlockDescNode* pDescNode = pPhyNode->pOutputDataBlockDesc; + SSDataBlock* pResBlock = createResDataBlock(pDescNode); + + int32_t rowSize = pResBlock->info.rowSize; if (pInfo == NULL || pOperator == NULL || rowSize > 100 * 1024 * 1024) { goto _error; } + SArray* pSortInfo = createSortInfo(pMergePhyNode->pMergeKeys); + int32_t numOfOutputCols = 0; + SArray* pColMatchColInfo = + extractColMatchInfo(pMergePhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); + SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0); + SSDataBlock* pInputBlock = createResDataBlock(pChildNode->pOutputDataBlockDesc); initResultSizeInfo(pOperator, 1024); + pInfo->groupSort = pMergePhyNode->groupSort; pInfo->binfo.pRes = pResBlock; pInfo->pSortInfo = pSortInfo; pInfo->pColMatchInfo = pColMatchColInfo; pInfo->pInputBlock = pInputBlock; - pOperator->name = "MultiwaySortMerge"; + pOperator->name = "MultiwayMerge"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE; pOperator->blocking = false; pOperator->status = OP_NOT_OPENED; @@ -687,9 +711,8 @@ SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams, // one additional is reserved for merged result. pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); - pOperator->fpSet = - createOperatorFpSet(doOpenMultiwaySortMergeOperator, doMultiwaySortMerge, NULL, NULL, - destroyMultiwaySortMergeOperatorInfo, NULL, NULL, getMultiwaySortMergeExplainExecInfo); + pOperator->fpSet = createOperatorFpSet(doOpenMultiwayMergeOperator, doMultiwayMerge, NULL, NULL, + destroyMultiwayMergeOperatorInfo, NULL, NULL, getMultiwayMergeExplainExecInfo); int32_t code = appendDownstream(pOperator, downStreams, numStreams); if (code != TSDB_CODE_SUCCESS) { From bf442c20bc21d8243800913aa619c5a00639728e Mon Sep 17 00:00:00 2001 From: "wenzhouwww@live.cn" Date: Mon, 27 Jun 2022 17:54:20 +0800 Subject: [PATCH 46/73] test: add case for scalar support stable --- tests/system-test/2-query/abs.py | 18 ++++++++++++++++++ tests/system-test/2-query/arccos.py | 22 ++++++++++++++++++++++ tests/system-test/2-query/arcsin.py | 18 ++++++++++++++++++ tests/system-test/2-query/arctan.py | 18 ++++++++++++++++++ tests/system-test/2-query/ceil.py | 16 ++++++++++++++++ tests/system-test/2-query/cos.py | 17 +++++++++++++++++ tests/system-test/2-query/floor.py | 17 +++++++++++++++++ tests/system-test/2-query/log.py | 18 ++++++++++++++++-- tests/system-test/2-query/pow.py | 20 +++++++++++++++++++- tests/system-test/2-query/round.py | 18 ++++++++++++++++++ tests/system-test/2-query/sin.py | 17 +++++++++++++++++ tests/system-test/2-query/sqrt.py | 18 +++++++++++++++++- tests/system-test/2-query/tan.py | 18 ++++++++++++++++++ 13 files changed, 231 insertions(+), 4 deletions(-) diff --git a/tests/system-test/2-query/abs.py b/tests/system-test/2-query/abs.py index 244cccb041..937e1c7102 100644 --- a/tests/system-test/2-query/abs.py +++ b/tests/system-test/2-query/abs.py @@ -557,6 +557,20 @@ class TDTestCase: tdSql.query( "select abs(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1") + def support_super_table_test(self): + tdSql.execute(" use testdb ") + self.check_result_auto( " select c1 from stb1 order by ts " , "select abs(c1) from stb1 order by ts" ) + self.check_result_auto( " select c1 from stb1 order by tbname " , "select abs(c1) from stb1 order by tbname" ) + self.check_result_auto( " select c1 from stb1 where c1 > 0 order by tbname " , "select abs(c1) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select c1 from stb1 where c1 > 0 order by tbname " , "select abs(c1) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto( " select t1,c1 from stb1 order by ts " , "select t1, abs(c1) from stb1 order by ts" ) + self.check_result_auto( " select t2,c1 from stb1 order by tbname " , "select t2 ,abs(c1) from stb1 order by tbname" ) + self.check_result_auto( " select t3,c1 from stb1 where c1 > 0 order by tbname " , "select t3 ,abs(c1) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select t4,c1 from stb1 where c1 > 0 order by tbname " , "select t4 , abs(c1) from stb1 where c1 > 0 order by tbname" ) + pass + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -593,6 +607,10 @@ class TDTestCase: self.insert_datas_and_check_abs(self.tb_nums,self.row_nums,self.time_step) + tdLog.printNoPrefix("==========step8: check abs result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/arccos.py b/tests/system-test/2-query/arccos.py index e15f7675f2..edb9e25c11 100644 --- a/tests/system-test/2-query/arccos.py +++ b/tests/system-test/2-query/arccos.py @@ -479,6 +479,20 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_acos("select num1,num2 from tb3;" , "select acos(num1),acos(num2) from tb3") + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_acos( " select c5 from stb1 order by ts " , "select acos(c5) from stb1 order by ts" ) + self.check_result_auto_acos( " select c5 from stb1 order by tbname " , "select acos(c5) from stb1 order by tbname" ) + self.check_result_auto_acos( " select c5 from stb1 where c1 > 0 order by tbname " , "select acos(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_acos( " select c5 from stb1 where c1 > 0 order by tbname " , "select acos(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_acos( " select t1,c5 from stb1 order by ts " , "select acos(t1), acos(c5) from stb1 order by ts" ) + self.check_result_auto_acos( " select t1,c5 from stb1 order by tbname " , "select acos(t1) ,acos(c5) from stb1 order by tbname" ) + self.check_result_auto_acos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select acos(t1) ,acos(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_acos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select acos(t1) , acos(c5) from stb1 where c1 > 0 order by tbname" ) + pass + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -512,6 +526,14 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step7: acos filter query ============") + + self.abs_func_filter() + + tdLog.printNoPrefix("==========step8: check acos result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/arcsin.py b/tests/system-test/2-query/arcsin.py index ee134a56a8..faed5ef3c4 100644 --- a/tests/system-test/2-query/arcsin.py +++ b/tests/system-test/2-query/arcsin.py @@ -479,6 +479,20 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_asin("select num1,num2 from tb3;" , "select asin(num1),asin(num2) from tb3") + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_asin( " select c5 from stb1 order by ts " , "select asin(c5) from stb1 order by ts" ) + self.check_result_auto_asin( " select c5 from stb1 order by tbname " , "select asin(c5) from stb1 order by tbname" ) + self.check_result_auto_asin( " select c5 from stb1 where c1 > 0 order by tbname " , "select asin(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_asin( " select c5 from stb1 where c1 > 0 order by tbname " , "select asin(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_asin( " select t1,c5 from stb1 order by ts " , "select asin(t1), asin(c5) from stb1 order by ts" ) + self.check_result_auto_asin( " select t1,c5 from stb1 order by tbname " , "select asin(t1) ,asin(c5) from stb1 order by tbname" ) + self.check_result_auto_asin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select asin(t1) ,asin(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_asin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select asin(t1) , asin(c5) from stb1 where c1 > 0 order by tbname" ) + pass + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -512,6 +526,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step8: check asin result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/arctan.py b/tests/system-test/2-query/arctan.py index 1890c4605c..80d28b5ee5 100644 --- a/tests/system-test/2-query/arctan.py +++ b/tests/system-test/2-query/arctan.py @@ -476,6 +476,20 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_atan("select num1,num2 from tb3;" , "select atan(num1),atan(num2) from tb3") + + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_atan( " select c5 from stb1 order by ts " , "select atan(c5) from stb1 order by ts" ) + self.check_result_auto_atan( " select c5 from stb1 order by tbname " , "select atan(c5) from stb1 order by tbname" ) + self.check_result_auto_atan( " select c5 from stb1 where c1 > 0 order by tbname " , "select atan(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_atan( " select c5 from stb1 where c1 > 0 order by tbname " , "select atan(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_atan( " select t1,c5 from stb1 order by ts " , "select atan(t1), atan(c5) from stb1 order by ts" ) + self.check_result_auto_atan( " select t1,c5 from stb1 order by tbname " , "select atan(t1) ,atan(c5) from stb1 order by tbname" ) + self.check_result_auto_atan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select atan(t1) ,atan(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_atan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select atan(t1) , atan(c5) from stb1 where c1 > 0 order by tbname" ) + pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -509,6 +523,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step8: check arctan result of stable query ============") + + self.support_super_table_test() + def stop(self): diff --git a/tests/system-test/2-query/ceil.py b/tests/system-test/2-query/ceil.py index 4196a5a8ce..b269b54a17 100644 --- a/tests/system-test/2-query/ceil.py +++ b/tests/system-test/2-query/ceil.py @@ -427,6 +427,18 @@ class TDTestCase: self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select ceil(c1+1) ,ceil(c2) , ceil(c3*1) , ceil(c4/2), ceil(c5)/2, ceil(c6) from sub1_bound ") + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto( " select c5 from stb1 order by ts " , "select ceil(c5) from stb1 order by ts" ) + self.check_result_auto( " select c5 from stb1 order by tbname " , "select ceil(c5) from stb1 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select ceil(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select ceil(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto( " select t1,c5 from stb1 order by ts " , "select ceil(t1), ceil(c5) from stb1 order by ts" ) + self.check_result_auto( " select t1,c5 from stb1 order by tbname " , "select ceil(t1) ,ceil(c5) from stb1 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select ceil(t1) ,ceil(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select ceil(t1) , ceil(c5) from stb1 where c1 > 0 order by tbname" ) + pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -455,6 +467,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step7: check ceil result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/cos.py b/tests/system-test/2-query/cos.py index 0cb9f66937..1165d8d681 100644 --- a/tests/system-test/2-query/cos.py +++ b/tests/system-test/2-query/cos.py @@ -476,6 +476,19 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_cos("select num1,num2 from tb3;" , "select cos(num1),cos(num2) from tb3") + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_cos( " select c5 from stb1 order by ts " , "select cos(c5) from stb1 order by ts" ) + self.check_result_auto_cos( " select c5 from stb1 order by tbname " , "select cos(c5) from stb1 order by tbname" ) + self.check_result_auto_cos( " select c5 from stb1 where c1 > 0 order by tbname " , "select cos(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_cos( " select c5 from stb1 where c1 > 0 order by tbname " , "select cos(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_cos( " select t1,c5 from stb1 order by ts " , "select cos(t1), cos(c5) from stb1 order by ts" ) + self.check_result_auto_cos( " select t1,c5 from stb1 order by tbname " , "select cos(t1) ,cos(c5) from stb1 order by tbname" ) + self.check_result_auto_cos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select cos(t1) ,cos(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_cos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select cos(t1) , cos(c5) from stb1 where c1 > 0 order by tbname" ) + pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -509,6 +522,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step8: check cos result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/floor.py b/tests/system-test/2-query/floor.py index c955c24e05..7362191958 100644 --- a/tests/system-test/2-query/floor.py +++ b/tests/system-test/2-query/floor.py @@ -427,6 +427,19 @@ class TDTestCase: self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select floor(c1+1) ,floor(c2) , floor(c3*1) , floor(c4/2), floor(c5)/2, floor(c6) from sub1_bound ") + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto( " select c5 from stb1 order by ts " , "select floor(c5) from stb1 order by ts" ) + self.check_result_auto( " select c5 from stb1 order by tbname " , "select floor(c5) from stb1 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select floor(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select floor(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto( " select t1,c5 from stb1 order by ts " , "select floor(t1), floor(c5) from stb1 order by ts" ) + self.check_result_auto( " select t1,c5 from stb1 order by tbname " , "select floor(t1) ,floor(c5) from stb1 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select floor(t1) ,floor(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select floor(t1) , floor(c5) from stb1 where c1 > 0 order by tbname" ) + pass + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -454,6 +467,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step7: check floor result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/log.py b/tests/system-test/2-query/log.py index 907ba329ee..f9d6e91199 100644 --- a/tests/system-test/2-query/log.py +++ b/tests/system-test/2-query/log.py @@ -670,7 +670,19 @@ class TDTestCase: tdSql.checkData(0,2,math.log(32767.000000000,2)) tdSql.checkData(0,3,math.log(63.500000000,2)) tdSql.checkData(0,4,63.999401166) - + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_log2( " select c5 from stb1 order by ts " , "select log(c5,2) from stb1 order by ts" ) + self.check_result_auto_log2( " select c5 from stb1 order by tbname " , "select log(c5,2) from stb1 order by tbname" ) + self.check_result_auto_log2( " select c5 from stb1 where c1 > 0 order by tbname " , "select log(c5,2) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_log2( " select c5 from stb1 where c1 > 0 order by tbname " , "select log(c5,2) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_log2( " select t1,c5 from stb1 order by ts " , "select log(t1,2), log(c5,2) from stb1 order by ts" ) + self.check_result_auto_log2( " select t1,c5 from stb1 order by tbname " , "select log(t1,2) ,log(c5,2) from stb1 order by tbname" ) + self.check_result_auto_log2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select log(t1,2) ,log(c5,2) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_log2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select log(t1,2) , log(c5,2) from stb1 where c1 > 0 order by tbname" ) + pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -707,7 +719,9 @@ class TDTestCase: self.abs_func_filter() - + tdLog.printNoPrefix("==========step9: check log result of stable query ============") + + self.support_super_table_test() def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/pow.py b/tests/system-test/2-query/pow.py index 8b0137b411..c67162961b 100644 --- a/tests/system-test/2-query/pow.py +++ b/tests/system-test/2-query/pow.py @@ -606,7 +606,23 @@ class TDTestCase: tdSql.checkData(0,3,math.pow(63.500000000,2)) tdSql.checkData(0,5,None) + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_pow2( " select c5 from stb1 order by ts " , "select pow(c5,2) from stb1 order by ts" ) + self.check_result_auto_pow2( " select c5 from stb1 order by tbname " , "select pow(c5,2) from stb1 order by tbname" ) + self.check_result_auto_pow2( " select c5 from stb1 where c1 > 0 order by tbname " , "select pow(c5,2) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_pow2( " select c5 from stb1 where c1 > 0 order by tbname " , "select pow(c5,2) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_pow2( " select t1,c5 from stb1 order by ts " , "select pow(t1,2), pow(c5,2) from stb1 order by ts" ) + self.check_result_auto_pow2( " select t1,c5 from stb1 order by tbname " , "select pow(t1,2) ,pow(c5,2) from stb1 order by tbname" ) + self.check_result_auto_pow2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select pow(t1,2) ,pow(c5,2) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_pow2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select pow(t1,2) , pow(c5,2) from stb1 where c1 > 0 order by tbname" ) + pass + + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -642,7 +658,9 @@ class TDTestCase: self.abs_func_filter() - + tdLog.printNoPrefix("==========step9: check pow result of stable query ============") + + self.support_super_table_test() def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/round.py b/tests/system-test/2-query/round.py index 223e56bce6..cc272abf42 100644 --- a/tests/system-test/2-query/round.py +++ b/tests/system-test/2-query/round.py @@ -432,6 +432,20 @@ class TDTestCase: self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select round(c1+1) ,round(c2) , round(c3*1) , round(c4/2), round(c5)/2, round(c6) from sub1_bound ") + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto( " select c5 from stb1 order by ts " , "select round(c5) from stb1 order by ts" ) + self.check_result_auto( " select c5 from stb1 order by tbname " , "select round(c5) from stb1 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select round(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select round(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto( " select t1,c5 from stb1 order by ts " , "select round(t1), round(c5) from stb1 order by ts" ) + self.check_result_auto( " select t1,c5 from stb1 order by tbname " , "select round(t1) ,round(c5) from stb1 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select round(t1) ,round(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select round(t1) , round(c5) from stb1 where c1 > 0 order by tbname" ) + pass + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -459,6 +473,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step7: check round result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/2-query/sin.py b/tests/system-test/2-query/sin.py index 62d42a991e..2c4d90d3e7 100644 --- a/tests/system-test/2-query/sin.py +++ b/tests/system-test/2-query/sin.py @@ -476,6 +476,19 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_sin("select num1,num2 from tb3;" , "select sin(num1),sin(num2) from tb3") + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_sin( " select c5 from stb1 order by ts " , "select sin(c5) from stb1 order by ts" ) + self.check_result_auto_sin( " select c5 from stb1 order by tbname " , "select sin(c5) from stb1 order by tbname" ) + self.check_result_auto_sin( " select c5 from stb1 where c1 > 0 order by tbname " , "select sin(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sin( " select c5 from stb1 where c1 > 0 order by tbname " , "select sin(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_sin( " select t1,c5 from stb1 order by ts " , "select sin(t1), sin(c5) from stb1 order by ts" ) + self.check_result_auto_sin( " select t1,c5 from stb1 order by tbname " , "select sin(t1) ,sin(c5) from stb1 order by tbname" ) + self.check_result_auto_sin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sin(t1) ,sin(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sin( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sin(t1) , sin(c5) from stb1 where c1 > 0 order by tbname" ) + pass def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -509,6 +522,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step8: check sin result of stable query ============") + + self.support_super_table_test() + def stop(self): diff --git a/tests/system-test/2-query/sqrt.py b/tests/system-test/2-query/sqrt.py index 28e869e044..772056fd93 100644 --- a/tests/system-test/2-query/sqrt.py +++ b/tests/system-test/2-query/sqrt.py @@ -505,7 +505,19 @@ class TDTestCase: tdSql.checkData(0,2,math.sqrt(32767.000000000)) tdSql.checkData(0,3,math.sqrt(63.500000000)) - + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_sqrt( " select c5 from stb1 order by ts " , "select sqrt(c5) from stb1 order by ts" ) + self.check_result_auto_sqrt( " select c5 from stb1 order by tbname " , "select sqrt(c5) from stb1 order by tbname" ) + self.check_result_auto_sqrt( " select c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sqrt( " select c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_sqrt( " select t1,c5 from stb1 order by ts " , "select sqrt(t1), sqrt(c5) from stb1 order by ts" ) + self.check_result_auto_sqrt( " select t1,c5 from stb1 order by tbname " , "select sqrt(t1) ,sqrt(c5) from stb1 order by tbname" ) + self.check_result_auto_sqrt( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(t1) ,sqrt(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_sqrt( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select sqrt(t1) , sqrt(c5) from stb1 where c1 > 0 order by tbname" ) + pass + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -541,6 +553,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step9: check sqrt result of stable query ============") + + self.support_super_table_test() + def stop(self): diff --git a/tests/system-test/2-query/tan.py b/tests/system-test/2-query/tan.py index c8914d18c0..9610ffef24 100644 --- a/tests/system-test/2-query/tan.py +++ b/tests/system-test/2-query/tan.py @@ -476,6 +476,20 @@ class TDTestCase: tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2)) self.check_result_auto_tan("select num1,num2 from tb3;" , "select tan(num1),tan(num2) from tb3") + + def support_super_table_test(self): + tdSql.execute(" use db ") + self.check_result_auto_tan( " select c5 from stb1 order by ts " , "select tan(c5) from stb1 order by ts" ) + self.check_result_auto_tan( " select c5 from stb1 order by tbname " , "select tan(c5) from stb1 order by tbname" ) + self.check_result_auto_tan( " select c5 from stb1 where c1 > 0 order by tbname " , "select tan(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_tan( " select c5 from stb1 where c1 > 0 order by tbname " , "select tan(c5) from stb1 where c1 > 0 order by tbname" ) + + self.check_result_auto_tan( " select t1,c5 from stb1 order by ts " , "select tan(t1), tan(c5) from stb1 order by ts" ) + self.check_result_auto_tan( " select t1,c5 from stb1 order by tbname " , "select tan(t1) ,tan(c5) from stb1 order by tbname" ) + self.check_result_auto_tan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select tan(t1) ,tan(c5) from stb1 where c1 > 0 order by tbname" ) + self.check_result_auto_tan( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select tan(t1) , tan(c5) from stb1 where c1 > 0 order by tbname" ) + pass + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() @@ -509,6 +523,10 @@ class TDTestCase: self.abs_func_filter() + tdLog.printNoPrefix("==========step8: check tan result of stable query ============") + + self.support_super_table_test() + def stop(self): tdSql.close() From 2e2b28dbd2eea7a72fa39be18d667eaa011d2508 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 27 Jun 2022 18:28:51 +0800 Subject: [PATCH 47/73] enh: add retryCode for transaction --- source/dnode/mnode/impl/src/mndTrans.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 16970e5d78..b09ee5f608 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -1188,6 +1188,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans) } else if (code == pAction->retryCode) { mDebug("trans:%d, %s:%d receive code:0x%x and retry", pTrans->id, mndTransStr(pAction->stage), pAction->id, code); taosMsleep(300); + action--; continue; } else { terrno = code; From f4e2a419b46782d71105fb88f370038f749b0faf Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 27 Jun 2022 18:29:01 +0800 Subject: [PATCH 48/73] test: case for redistribute vgroup --- tests/script/jenkins/basic.txt | 2 + .../dnode/redistribute_vgroup_replica3_v2.sim | 245 +++++++++++++++++ .../dnode/redistribute_vgroup_replica3_v3.sim | 259 ++++++++++++++++++ 3 files changed, 506 insertions(+) create mode 100644 tests/script/tsim/dnode/redistribute_vgroup_replica3_v2.sim create mode 100644 tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 76d2546dac..7658d127a4 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -31,6 +31,8 @@ #./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v2.sim +./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v3.sim # ---- insert ./test.sh -f tsim/insert/basic0.sim diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v2.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v2.sim new file mode 100644 index 0000000000..6614009497 --- /dev/null +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v2.sim @@ -0,0 +1,245 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 +system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode5 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode6 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql connect +sql create user u1 pass 'taosdata' + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +sql create dnode $hostname port 7500 +sql create dnode $hostname port 7600 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 6 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +print =============== step2: create db +sql create database d1 vgroups 1 replica 3 + +system sh/exec.sh -n dnode5 -s start +system sh/exec.sh -n dnode6 -s start +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 6 then + return -1 +endi +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi +if $data(3)[4] != ready then + goto step2 +endi +if $data(4)[4] != ready then + goto step2 +endi +if $data(5)[4] != ready then + goto step2 +endi +if $data(6)[4] != ready then + goto step2 +endi + +print =============== step3: create database +$leaderExist = 0 +$leaderVnode = 0 +$follower1 = 0 +$follower2 = 0 + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $rows != 1 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 + $leaderVnode = 2 + $follower1 = 3 + $follower2 = 4 +endi +if $data(2)[6] == leader then + $leaderExist = 1 + $leaderVnode = 3 + $follower1 = 2 + $follower2 = 4 +endi +if $data(2)[8] == leader then + $leaderExist = 1 + $leaderVnode = 4 + $follower1 = 2 + $follower2 = 3 +endi +if $leaderExist != 1 then + goto step3 +endi + +print leader $leaderVnode +print follower1 $follower1 +print follower2 $follower2 + +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step40: +print redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode 6 +sql redistribute vgroup 2 dnode $leaderVnode dnode 5 dnode 6 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step41: +print redistribute vgroup 2 dnode 5 dnode $follower2 dnode $follower1 +sql redistribute vgroup 2 dnode 5 dnode $follower2 dnode $follower1 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step42: +print redistribute vgroup 2 dnode $follower2 dnode 6 dnode $leaderVnode +sql redistribute vgroup 2 dnode $follower2 dnode 6 dnode $leaderVnode +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step43: +print redistribute vgroup 2 dnode $follower1 dnode 5 dnode 6 +sql redistribute vgroup 2 dnode $follower1 dnode 5 dnode 6 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step44: +print redistribute vgroup 2 dnode $follower2 dnode 5 dnode $leaderVnode +sql redistribute vgroup 2 dnode $follower2 dnode 5 dnode $leaderVnode +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step45: +print redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 6 +sql redistribute vgroup 2 dnode $leaderVnode dnode $follower1 dnode 6 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step46: +print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 +sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step47: +print redistribute vgroup 2 dnode $follower1 dnode 6 dnode $leaderVnode +sql redistribute vgroup 2 dnode $follower1 dnode 6 dnode $leaderVnode +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim new file mode 100644 index 0000000000..a0a6d466ff --- /dev/null +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim @@ -0,0 +1,259 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/deploy.sh -n dnode6 -i 6 +system sh/deploy.sh -n dnode7 -i 7 +system sh/deploy.sh -n dnode8 -i 8 +system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode5 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode6 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode7 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode8 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql connect +sql create user u1 pass 'taosdata' + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +sql create dnode $hostname port 7500 +sql create dnode $hostname port 7600 +sql create dnode $hostname port 7700 +sql create dnode $hostname port 7800 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 8 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +print =============== step2: create db +sql create database d1 vgroups 1 replica 3 + +system sh/exec.sh -n dnode5 -s start +system sh/exec.sh -n dnode6 -s start +system sh/exec.sh -n dnode7 -s start +system sh/exec.sh -n dnode8 -s start +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 8 then + return -1 +endi +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi +if $data(3)[4] != ready then + goto step2 +endi +if $data(4)[4] != ready then + goto step2 +endi +if $data(5)[4] != ready then + goto step2 +endi +if $data(6)[4] != ready then + goto step2 +endi +if $data(7)[4] != ready then + goto step2 +endi +if $data(8)[4] != ready then + goto step2 +endi + +print =============== step3: create database +$leaderExist = 0 +$leaderVnode = 0 +$follower1 = 0 +$follower2 = 0 + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $rows != 1 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 + $leaderVnode = 2 + $follower1 = 3 + $follower2 = 4 +endi +if $data(2)[6] == leader then + $leaderExist = 1 + $leaderVnode = 3 + $follower1 = 2 + $follower2 = 4 +endi +if $data(2)[8] == leader then + $leaderExist = 1 + $leaderVnode = 4 + $follower1 = 2 + $follower2 = 3 +endi +if $leaderExist != 1 then + goto step3 +endi + +print leader $leaderVnode +print follower1 $follower1 +print follower2 $follower2 + +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step40: +print redistribute vgroup 2 dnode 7 dnode 5 dnode 6 +sql redistribute vgroup 2 dnode 7 dnode 5 dnode 6 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step41: +print redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1 +sql redistribute vgroup 2 dnode $leaderVnode dnode $follower2 dnode $follower1 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step42: +print redistribute vgroup 2 dnode 7 dnode 6 dnode 8 +sql redistribute vgroup 2 dnode 7 dnode 6 dnode 8 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step43: +print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 +sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step44: +print redistribute vgroup 2 dnode 6 dnode 7 dnode $leaderVnode +sql redistribute vgroup 2 dnode 6 dnode 7 dnode $leaderVnode +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step45: +print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 8 +sql redistribute vgroup 2dnode $follower1 dnode $follower2 dnode 8 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step46: +print redistribute vgroup 2 dnode $leaderVnode dnode 6 dnode 5 +sql redistribute vgroup 2 dnode $leaderVnode dnode 6 dnode 5 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step47: +print redistribute vgroup 2 dnode $follower1 dnode 7 dnode 8 +sql redistribute vgroup 2 dnode $follower1 dnode 7 dnode 8 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT +system sh/exec.sh -n dnode5 -s stop -x SIGINT From 8088b67dc905dc87da0479620b02890368c8acc8 Mon Sep 17 00:00:00 2001 From: slzhou Date: Mon, 27 Jun 2022 19:07:37 +0800 Subject: [PATCH 49/73] feat: add merge projects optimization --- source/libs/planner/src/planOptimizer.c | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index f1cad6010c..8420f40ec9 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1235,6 +1235,45 @@ static int32_t eliminateSetOpOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLo return eliminateSetOpOptimizeImpl(pCxt, pLogicSubplan, pSetOpNode); } +//=================================================================================================================== +// merge projects +static bool mergeProjectsMayBeOptimized(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren)) { + return false; + } + SLogicNode *pChild = (SLogicNode*)nodesListGetNode(pNode->pChildren, 0); + if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pChild) || 1 < LIST_LENGTH(pChild->pChildren) || + NULL != pChild->pConditions || NULL != pNode->pLimit || NULL != pNode->pSlimit) { + return false; + } + return true; +} + +typedef struct SMergeProjectionsContext { + +} SMergeProjectionsContext; + +static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) { + return DEAL_RES_CONTINUE; +} + +static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pProjectNode) { + SProjectLogicNode* pProject = (SProjectLogicNode*)pProjectNode; + SProjectLogicNode* pChild = (SProjectLogicNode*)nodesListGetNode(pProjectNode->pChildren, 0); + SMergeProjectionsContext cxt = {}; + nodesRewriteExprs(pChild->pProjections, mergeProjectionsExpr, &cxt); + return TSDB_CODE_SUCCESS; +} + +static int32_t mergeProjectsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { + SLogicNode* pProjectNode = optFindPossibleNode(pLogicSubplan->pNode, mergeProjectsMayBeOptimized); + if (NULL == pProjectNode) { + return TSDB_CODE_SUCCESS; + } + + return mergeProjectsOptimizeImpl(pCxt, pLogicSubplan, pProjectNode); +} + // clang-format off static const SOptimizeRule optimizeRuleSet[] = { {.pName = "OptimizeScanData", .optimizeFunc = osdOptimize}, @@ -1242,8 +1281,11 @@ static const SOptimizeRule optimizeRuleSet[] = { {.pName = "OrderByPrimaryKey", .optimizeFunc = opkOptimize}, {.pName = "SmaIndex", .optimizeFunc = smaOptimize}, {.pName = "PartitionTags", .optimizeFunc = partTagsOptimize}, + {.pName = "MergeProjects", .optimizeFunc = mergeProjectsOptimize}, {.pName = "EliminateProject", .optimizeFunc = eliminateProjOptimize}, {.pName = "EliminateSetOperator", .optimizeFunc = eliminateSetOpOptimize} + {.pName = "EliminateSetOperator", .optimizeFunc = eliminateSetOpOptimize}, + {.pName = "RewriteTail", .optimizeFunc = rewriteTailOptimize}, }; // clang-format on From 50e347e197c0cff00b5d5f6c1b4db9c99b0a0664 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 27 Jun 2022 19:21:26 +0800 Subject: [PATCH 50/73] test: case for redistribute vgroup --- tests/script/jenkins/basic.txt | 1 + .../dnode/redistribute_vgroup_replica1.sim | 178 ++++++++++++++++++ .../dnode/redistribute_vgroup_replica3_v3.sim | 4 + 3 files changed, 183 insertions(+) create mode 100644 tests/script/tsim/dnode/redistribute_vgroup_replica1.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 7658d127a4..181342b4b7 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -29,6 +29,7 @@ #./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim #./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim #./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim +./test.sh -f tsim/dnode/redistribute_vgroup_replica1.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v2.sim diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica1.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica1.sim new file mode 100644 index 0000000000..d3b5a02a23 --- /dev/null +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica1.sim @@ -0,0 +1,178 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sql connect +sql create user u1 pass 'taosdata' + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi + +print =============== step2: create db +sql create database d1 vgroups 1 replica 1 + +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +if $rows != 4 then + return -1 +endi +if $data(1)[4] != ready then + goto step2 +endi +if $data(2)[4] != ready then + goto step2 +endi +if $data(3)[4] != ready then + goto step2 +endi +if $data(4)[4] != ready then + goto step2 +endi + +print =============== step3: create database +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step40: +print redistribute vgroup 2 dnode 3 +sql redistribute vgroup 2 dnode 3 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step41: +print redistribute vgroup 2 dnode 4 +sql redistribute vgroup 2 dnode 4 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step42: +print redistribute vgroup 2 dnode 2 +sql redistribute vgroup 2 dnode 2 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step43: +print redistribute vgroup 2 dnode 3 +sql redistribute vgroup 2 dnode 3 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step44: +print redistribute vgroup 2 dnode 4 +sql redistribute vgroup 2 dnode 4 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step45: +print redistribute vgroup 2 dnode 2 +sql redistribute vgroup 2 dnode 2 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step46: +print redistribute vgroup 2 dnode 3 +sql redistribute vgroup 2 dnode 3 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +print =============== step47: +print redistribute vgroup 2 dnode 2 +sql redistribute vgroup 2 dnode 2 +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 + +sql show d1.tables +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim index a0a6d466ff..c78d90e352 100644 --- a/tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim +++ b/tests/script/tsim/dnode/redistribute_vgroup_replica3_v3.sim @@ -208,6 +208,10 @@ if $rows != 1 then return -1 endi + +return + + print =============== step44: print redistribute vgroup 2 dnode 6 dnode 7 dnode $leaderVnode sql redistribute vgroup 2 dnode 6 dnode 7 dnode $leaderVnode From 14209eeec6ed1c40307240798713b3b80c814668 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 27 Jun 2022 19:34:50 +0800 Subject: [PATCH 51/73] feat: add no retry to query --- include/libs/transport/trpc.h | 2 +- source/client/src/clientEnv.c | 5 ++++- source/dnode/mgmt/node_mgmt/src/dmTransport.c | 5 ++++- source/libs/function/src/udfd.c | 7 +++++-- source/libs/transport/inc/transportInt.h | 2 +- source/libs/transport/src/trans.c | 5 ----- source/libs/transport/src/transCli.c | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index c2c1a3534d..2b8c6a895e 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -69,7 +69,7 @@ typedef struct SRpcMsg { } SRpcMsg; typedef void (*RpcCfp)(void *parent, SRpcMsg *, SEpSet *rf); -typedef bool (*RpcRfp)(int32_t code); +typedef bool (*RpcRfp)(int32_t code, tmsg_t msgType); typedef struct SRpcInit { char localFqdn[TSDB_FQDN_LEN]; diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index d7bf4b60f1..8e0556125a 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -84,9 +84,12 @@ void closeTransporter(STscObj *pTscObj) { rpcClose(pTscObj->pAppInfo->pTransporter); } -static bool clientRpcRfp(int32_t code) { +static bool clientRpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) { + if (msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH) { + return false; + } return true; } else { return false; diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index a4745abd5b..7e31cc3144 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -248,9 +248,12 @@ static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { } } -static bool rpcRfp(int32_t code) { +static bool rpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) { + if (msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH) { + return false; + } return true; } else { return false; diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 983cffe9dc..364ee0692f 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -110,7 +110,7 @@ static void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); static int32_t udfdFillUdfInfoFromMNode(void *clientRpc, char *udfName, SUdf *udf); static int32_t udfdConnectToMnode(); static int32_t udfdLoadUdf(char *udfName, SUdf *udf); -static bool udfdRpcRfp(int32_t code); +static bool udfdRpcRfp(int32_t code, tmsg_t msgType); static int initEpSetFromCfg(const char *firstEp, const char *secondEp, SCorEpSet *pEpSet); static int32_t udfdOpenClientRpc(); static int32_t udfdCloseClientRpc(); @@ -546,9 +546,12 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) { } return 0; } -static bool udfdRpcRfp(int32_t code) { +static bool udfdRpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY) { + if (msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH) { + return false; + } return true; } else { return false; diff --git a/source/libs/transport/inc/transportInt.h b/source/libs/transport/inc/transportInt.h index c328629c4b..462debb247 100644 --- a/source/libs/transport/inc/transportInt.h +++ b/source/libs/transport/inc/transportInt.h @@ -52,7 +52,7 @@ typedef struct { char user[TSDB_UNI_LEN]; // meter ID void (*cfp)(void* parent, SRpcMsg*, SEpSet*); - bool (*retry)(int32_t code); + bool (*retry)(int32_t code, tmsg_t msgType); int index; void* parent; diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 4f7b19b539..cc2e95cfb3 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -164,11 +164,6 @@ void rpcSetDefaultAddr(void* thandle, const char* ip, const char* fqdn) { transSetDefaultAddr(thandle, ip, fqdn); } -// void rpcSetMsgTraceId(SRpcMsg* pMsg, STraceId uid) { -// SRpcHandleInfo* pInfo = &pMsg->info; -// pInfo->traceId = uid; -//} - int32_t rpcInit() { // impl later return 0; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 7374d1fffc..ab08ce82a8 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -1030,7 +1030,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { */ STransConnCtx* pCtx = pMsg->ctx; int32_t code = pResp->code; - if (pTransInst->retry != NULL && pTransInst->retry(code)) { + if (pTransInst->retry != NULL && pTransInst->retry(code, pResp->msgType - 1)) { pMsg->sent = 0; pCtx->retryCnt += 1; if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { From f9e80a8e2b458e6c1b626294a370c042c113e0f7 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 27 Jun 2022 19:41:13 +0800 Subject: [PATCH 52/73] fix(query): add mode function --- include/util/taoserror.h | 4 +- source/libs/function/src/builtins.c | 8 +- source/libs/function/src/builtinsimpl.c | 104 ++++++++++++++++++++++-- 3 files changed, 104 insertions(+), 12 deletions(-) diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 8af5945300..8565eea63b 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -25,7 +25,7 @@ extern "C" { // clang-format off #define TAOS_DEF_ERROR_CODE(mod, code) ((int32_t)((0x80000000 | ((mod)<<16) | (code)))) - + #define TAOS_SYSTEM_ERROR(code) (0x80ff0000 | (code)) #define TAOS_SUCCEEDED(err) ((err) >= 0) #define TAOS_FAILED(err) ((err) < 0) @@ -35,7 +35,7 @@ const char* terrstr(); int32_t* taosGetErrno(); #define terrno (*taosGetErrno()) - + #define TSDB_CODE_SUCCESS 0 #define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index c8e39db90c..699a050aea 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -2130,10 +2130,10 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .type = FUNCTION_TYPE_MODE, .classification = FUNC_MGT_AGG_FUNC, .translateFunc = translateMode, - .getEnvFunc = getUniqueFuncEnv, - .initFunc = uniqueFunctionSetup, - .processFunc = uniqueFunction, - .finalizeFunc = functionFinalize, + .getEnvFunc = getModeFuncEnv, + .initFunc = modeFunctionSetup, + .processFunc = modeFunction, + .finalizeFunc = modeFinalize, }, { .name = "abs", diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index c4d3a26ab4..ca663ff809 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -32,6 +32,7 @@ #define TAIL_MAX_OFFSET 100 #define UNIQUE_MAX_RESULT_SIZE (1024 * 1024 * 10) +#define MODE_MAX_RESULT_SIZE UNIQUE_MAX_RESULT_SIZE #define HLL_BUCKET_BITS 14 // The bits of the bucket #define HLL_DATA_BITS (64 - HLL_BUCKET_BITS) @@ -246,6 +247,19 @@ typedef struct SUniqueInfo { char pItems[]; } SUniqueInfo; +typedef struct SModeItem { + int64_t count; + char data[]; +} SModeItem; + +typedef struct SModeInfo { + int32_t numOfPoints; + uint8_t colType; + int16_t colBytes; + SHashObj* pHash; + char pItems[]; +} SModeInfo; + typedef struct SDerivInfo { double prevValue; // previous value TSKEY prevTs; // previous timestamp @@ -4694,21 +4708,99 @@ int32_t uniqueFunction(SqlFunctionCtx* pCtx) { return pInfo->numOfPoints; } -int32_t uniqueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { +bool getModeFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { + pEnv->calcMemSize = sizeof(SModeInfo) + MODE_MAX_RESULT_SIZE; + return true; +} + +bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { + if (!functionSetup(pCtx, pResInfo)) { + return false; + } + + SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + pInfo->numOfPoints = 0; + pInfo->colType = pCtx->resDataInfo.type; + pInfo->colBytes = pCtx->resDataInfo.bytes; + if (pInfo->pHash != NULL) { + taosHashClear(pInfo->pHash); + } else { + pInfo->pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + } + return true; +} + +static void doModeAdd(SModeInfo* pInfo, char* data, bool isNull) { + // ignore null elements + if (isNull) { + return; + } + + int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; + SModeItem* pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); + if (pHashItem == NULL) { + int32_t size = sizeof(SModeItem) + pInfo->colBytes; + SModeItem* pItem = (SModeItem*)(pInfo->pItems + pInfo->numOfPoints * size); + memcpy(pItem->data, data, pInfo->colBytes); + pItem->count += 1; + + taosHashPut(pInfo->pHash, data, hashKeyBytes, (char*)pItem, sizeof(SModeItem*)); + pInfo->numOfPoints++; + } else { + pHashItem->count += 1; + } +} + +int32_t modeFunction(SqlFunctionCtx* pCtx) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - SUniqueInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + + SInputColumnInfoData* pInput = &pCtx->input; + + SColumnInfoData* pInputCol = pInput->pData[0]; + SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; + + int32_t startOffset = pCtx->offset; + for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) { + char* data = colDataGetData(pInputCol, i); + doModeAdd(pInfo, data, colDataIsNull_s(pInputCol, i)); + + if (sizeof(SModeInfo) + pInfo->numOfPoints * (sizeof(SModeItem) + pInfo->colBytes) >= MODE_MAX_RESULT_SIZE) { + taosHashCleanup(pInfo->pHash); + return TSDB_CODE_OUT_OF_MEMORY; + } + } + + return TSDB_CODE_SUCCESS; +} + +int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); int32_t slotId = pCtx->pExpr->base.resSchema.slotId; SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + int32_t currentRow = pBlock->info.rows; - for (int32_t i = 0; i < pResInfo->numOfRes; ++i) { - SUniqueItem* pItem = (SUniqueItem*)(pInfo->pItems + i * (sizeof(SUniqueItem) + pInfo->colBytes)); - colDataAppend(pCol, i, pItem->data, false); - // TODO: handle ts output + int32_t resIndex; + int32_t maxCount = 0; + for (int32_t i = 0; i < pInfo->numOfPoints; ++i) { + SModeItem* pItem = (SModeItem*)(pInfo->pItems + i * (sizeof(SModeItem) + pInfo->colBytes)); + if (pItem->count > maxCount) { + maxCount = pItem->count; + resIndex = i; + } else if (pItem->count == maxCount) { + colDataAppendNULL(pCol, currentRow); + return pResInfo->numOfRes; + } } + SModeItem* pResItem = (SModeItem*)(pInfo->pItems + resIndex * (sizeof(SModeItem) + pInfo->colBytes)); + colDataAppend(pCol, currentRow, pResItem->data, false); + return pResInfo->numOfRes; } + bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(STwaInfo); return true; From a6dc29ef9edda779bdfbd8b7ea0fa23728a1c610 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 27 Jun 2022 19:47:37 +0800 Subject: [PATCH 53/73] fix: drop dnode --- source/dnode/mnode/impl/src/mndVgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 0e3271a1bb..10d11f6ae4 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1007,7 +1007,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, mInfo("vgId:%d, will add 1 vnodes", pVgroup->vgId); if (mndAddVnodeToVgroup(pMnode, &newVg, pArray) != 0) return -1; - if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[1], true) != 0) return -1; + if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVg, &newVg.vnodeGid[newVg.replica - 1], true) != 0) return -1; if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVg, TDMT_VND_ALTER_REPLICA) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1; From 838dcfedad73928061b87b3fb9cf78051d7c9c32 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 27 Jun 2022 20:01:01 +0800 Subject: [PATCH 54/73] test: case for drop dnode --- tests/script/jenkins/basic.txt | 6 +- .../drop_dnode_has_multi_vnode_replica3.sim | 270 ++++++++++++++++-- .../dnode/drop_dnode_has_vnode_replica3.sim | 98 ++++++- 3 files changed, 331 insertions(+), 43 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 181342b4b7..19237d2fe5 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -26,9 +26,9 @@ ./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim ./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim ./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica1.sim -#./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim -#./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim -#./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim +./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim +./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim +./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica1.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim diff --git a/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim index 35a2466297..8169830790 100644 --- a/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim +++ b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim @@ -28,7 +28,7 @@ step1: sql show dnodes print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 -if $rows != 3 then +if $rows != 5 then return -1 endi if $data(1)[4] != ready then @@ -49,6 +49,128 @@ endi print =============== step3 create database sql create database d1 vgroups 4 replica 3 + +print =============== step32 wait vgroup2 +$x = 0 +step32: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step32 +endi + +print =============== step33 wait vgroup3 +$x = 0 +step33: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step33 +endi + +print =============== step34 wait vgroup4 +$x = 0 +step34: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step34 +endi + +print =============== step35 wait vgroup5 +$x = 0 +step35: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step35 +endi + +print =============== step36: create table sql use d1 sql create table d1.st (ts timestamp, i int) tags (j int) sql create table d1.c1 using st tags(1) @@ -57,21 +179,6 @@ if $rows != 1 then return -1 endi -sql show d1.vgroups -print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] -if $rows != 1 then - return -1 -endi -if $data(2)[3] != 2 then - return -1 -endi -if $data(2)[5] != 3 then - return -1 -endi -if $data(2)[7] != 4 then - return -1 -endi - print =============== step4: drop dnode 2 system sh/exec.sh -n dnode5 -s start $x = 0 @@ -85,7 +192,7 @@ step4: sql show dnodes print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 -if $rows != 3 then +if $rows != 5 then return -1 endi if $data(1)[4] != ready then @@ -115,21 +222,132 @@ if $rows != 4 then return -1 endi -print show d1.vgroups -sql show d1.vgroups -print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] -if $rows != 1 then - return -1 -endi - - print =============== step6: select data sql show d1.tables if $rows != 1 then return -1 endi -return +print =============== step62 wait vgroup2 +$x = 0 +step62: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step62 +endi + +print =============== step63 wait vgroup3 +$x = 0 +step63: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step63 +endi + +print =============== step64 wait vgroup4 +$x = 0 +step64: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step64 +endi + +print =============== step35 wait vgroup5 +$x = 0 +step65: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step65 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim b/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim index 3ea351f7a7..4855f4dccf 100644 --- a/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim +++ b/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim @@ -49,6 +49,50 @@ endi print =============== step3 create database sql create database d1 vgroups 1 replica 3 +$leaderExist = 0 +$leaderVnode = 0 +$follower1 = 0 +$follower2 = 0 + +$x = 0 +step3: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $rows != 1 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 + $leaderVnode = 2 + $follower1 = 3 + $follower2 = 4 +endi +if $data(2)[6] == leader then + $leaderExist = 1 + $leaderVnode = 3 + $follower1 = 2 + $follower2 = 4 +endi +if $data(2)[8] == leader then + $leaderExist = 1 + $leaderVnode = 4 + $follower1 = 2 + $follower2 = 3 +endi +if $leaderExist != 1 then + goto step3 +endi + +print leader $leaderVnode +print follower1 $follower1 +print follower2 $follower2 + sql use d1 sql create table d1.st (ts timestamp, i int) tags (j int) sql create table d1.c1 using st tags(1) @@ -72,13 +116,6 @@ if $data(2)[7] != 4 then return -1 endi -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT - - -return - - print =============== step4: drop dnode 2 system sh/exec.sh -n dnode5 -s start $x = 0 @@ -92,7 +129,7 @@ step4: sql show dnodes print ===> $data00 $data01 $data02 $data03 $data04 $data05 print ===> $data10 $data11 $data12 $data13 $data14 $data15 -if $rows != 3 then +if $rows != 5 then return -1 endi if $data(1)[4] != ready then @@ -116,8 +153,11 @@ sql drop dnode 2 print show dnodes; sql show dnodes; -print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] -print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 if $rows != 4 then return -1 endi @@ -128,9 +168,9 @@ print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] if $rows != 1 then return -1 endi -#if $data(2)[3] != 3 then -# return -1 -#endi +if $data(2)[3] != 5 then + return -1 +endi print =============== step6: select data sql show d1.tables @@ -138,7 +178,37 @@ if $rows != 1 then return -1 endi -return +$leaderExist = 0 +$leaderVnode = 0 +$follower1 = 0 +$follower2 = 0 + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +if $rows != 1 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step6 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT From 572a56c3cf56e629eb7a83f580815dcc2cc68c91 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 27 Jun 2022 20:05:32 +0800 Subject: [PATCH 55/73] test: minor changes --- .../dnode/drop_dnode_has_multi_vnode_replica3.sim | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim index 8169830790..e1b7c4a3a4 100644 --- a/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim +++ b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim @@ -222,12 +222,6 @@ if $rows != 4 then return -1 endi -print =============== step6: select data -sql show d1.tables -if $rows != 1 then - return -1 -endi - print =============== step62 wait vgroup2 $x = 0 step62: @@ -348,6 +342,13 @@ if $leaderExist != 1 then goto step65 endi +print =============== step7: select data +print ===> $data00 $data01 +sql show d1.tables +if $rows != 1 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT From fc286f7c87c5cc14503422536131cab1dac92402 Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Mon, 27 Jun 2022 20:18:45 +0800 Subject: [PATCH 56/73] ci(stream): add retrive ci --- .../tsim/stream/distributeInterval0.sim | 2 +- .../stream/distributeIntervalRetrive0.sim | 291 ++++++++++++++++++ ...utesession0.sim => distributeSession0.sim} | 0 3 files changed, 292 insertions(+), 1 deletion(-) create mode 100644 tests/script/tsim/stream/distributeIntervalRetrive0.sim rename tests/script/tsim/stream/{distributesession0.sim => distributeSession0.sim} (100%) diff --git a/tests/script/tsim/stream/distributeInterval0.sim b/tests/script/tsim/stream/distributeInterval0.sim index 8936655974..a59e989d80 100644 --- a/tests/script/tsim/stream/distributeInterval0.sim +++ b/tests/script/tsim/stream/distributeInterval0.sim @@ -41,7 +41,7 @@ sql create table ts1 using st tags(1,1,1); sql create table ts2 using st tags(2,2,2); sql create table ts3 using st tags(3,2,2); sql create table ts4 using st tags(4,2,2); -sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); +sql create stream stream_t1 trigger at_once watermark 1d into streamtST1 as select _wstartts, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); sleep 1000 diff --git a/tests/script/tsim/stream/distributeIntervalRetrive0.sim b/tests/script/tsim/stream/distributeIntervalRetrive0.sim new file mode 100644 index 0000000000..cde5c7058f --- /dev/null +++ b/tests/script/tsim/stream/distributeIntervalRetrive0.sim @@ -0,0 +1,291 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 + +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +sql create dnode $hostname2 port 7200 + +system sh/exec.sh -n dnode2 -s start + +print ===== step1 +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi + +print ===== step2 + +sql create database test vgroups 4; +sql use test; +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table ts1 using st tags(1,1,1); +sql create table ts2 using st tags(2,2,2); +sql create table ts3 using st tags(3,2,2); +sql create table ts4 using st tags(4,2,2); +sql create stream stream_t1 trigger at_once into streamtST1 as select _wstartts, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); + +sleep 1000 + +sql insert into ts1 values(1648791213001,1,12,3,1.0); +sql insert into ts2 values(1648791213001,1,12,3,1.0); +sql insert into ts1 values(1648791213002,NULL,NULL,NULL,NULL); +sql insert into ts2 values(1648791213002,NULL,NULL,NULL,NULL); + +sql insert into ts1 values(1648791223002,2,2,3,1.1); +sql insert into ts1 values(1648791233003,3,2,3,2.1); +sql insert into ts2 values(1648791243004,4,2,43,73.1); + +sql insert into ts1 values(1648791213002,24,22,23,4.1) (1648791243005,4,20,3,3.1); + +sleep 1000 + +sql insert into ts3 values(1648791213001,12,12,13,14.1) (1648791243005,14,30,30,30.1); + +$loop_count = 0 +loop1: +sleep 1000 +sql select * from streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 5 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 14 then + print =====data02=$data02 + goto loop1 +endi + +# row 1 +if $data11 != 1 then + print =====data11=$data11 + goto loop1 +endi + +if $data12 != 2 then + print =====data12=$data12 + goto loop1 +endi + +#row2 +if $data21 != 1 then + print =====data21=$data21 + goto loop1 +endi + +if $data22 != 3 then + print =====data22=$data22 + goto loop1 +endi + +#row 3 +if $data31 != 3 then + print =====data31=$data31 + goto loop1 +endi + +if $data32 != 22 then + print =====data32=$data32 + goto loop1 +endi + +print loop1 over + +sql insert into ts1 values(1648791223008,4,2,30,3.1) (1648791213009,4,2,3,3.1) (1648791233010,4,2,3,3.1) (1648791243011,4,2,3,3.1)(1648791243012,34,32,33,3.1); + +$loop_count = 0 +loop2: +sleep 1000 +sql select * from streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 6 then + print =====data01=$data01 + goto loop2 +endi + +if $data02 != 18 then + print =====data02=$data02 + goto loop2 +endi + +# row 1 +if $data11 != 2 then + print =====data11=$data11 + goto loop2 +endi + +if $data12 != 6 then + print =====data12=$data12 + goto loop2 +endi + +#row2 +if $data21 != 2 then + print =====data21=$data21 + goto loop2 +endi + +if $data22 != 7 then + print =====data22=$data22 + goto loop2 +endi + +#row 3 +if $data31 != 5 then + print =====data31=$data31 + goto loop2 +endi + +if $data32 != 60 then + print =====data32=$data32 + goto loop2 +endi + +print loop2 over + +sql insert into ts4 values(1648791223008,4,2,30,3.1) (1648791213009,4,2,3,3.1) (1648791233010,4,2,3,3.1); + +$loop_count = 0 +loop3: +sleep 1000 +sql select * from streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 7 then + print =====data01=$data01 + goto loop3 +endi + +if $data02 != 22 then + print =====data02=$data02 + goto loop3 +endi + +# row 1 +if $data11 != 3 then + print =====data11=$data11 + goto loop3 +endi + +if $data12 != 10 then + print =====data12=$data12 + goto loop3 +endi + +#row2 +if $data21 != 3 then + print =====data21=$data21 + goto loop3 +endi + +if $data22 != 11 then + print =====data22=$data22 + goto loop3 +endi + +#row 3 +if $data31 != 5 then + print =====data31=$data31 + goto loop3 +endi + +if $data32 != 60 then + print =====data32=$data32 + goto loop3 +endi + +print loop3 over + +$loop_count = 0 +loop4: +sleep 1000 +sql select * from streamtST1; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 7 then + print =====data01=$data01 + goto loop4 +endi + +if $data02 != 22 then + print =====data02=$data02 + goto loop4 +endi + +# row 1 +if $data11 != 3 then + print =====data11=$data11 + goto loop4 +endi + +if $data12 != 10 then + print =====data12=$data12 + goto loop4 +endi + +#row2 +if $data21 != 3 then + print =====data21=$data21 + goto loop4 +endi + +if $data22 != 11 then + print =====data22=$data22 + goto loop4 +endi + +#row 3 +if $data31 != 5 then + print =====data31=$data31 + goto loop4 +endi + +if $data32 != 60 then + print =====data32=$data32 + goto loop4 +endi + +print loop4 over + +system sh/stop_dnodes.sh diff --git a/tests/script/tsim/stream/distributesession0.sim b/tests/script/tsim/stream/distributeSession0.sim similarity index 100% rename from tests/script/tsim/stream/distributesession0.sim rename to tests/script/tsim/stream/distributeSession0.sim From 2647ec21e0f415cf9417fa041ff24e1ba334ab95 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 27 Jun 2022 20:23:08 +0800 Subject: [PATCH 57/73] refactor(sync): add comments in snapshot --- source/libs/sync/inc/syncSnapshot.h | 44 ++++--- source/libs/sync/src/syncSnapshot.c | 194 +++++++++++++++++----------- 2 files changed, 141 insertions(+), 97 deletions(-) diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index f00dfe6f50..55e0755a89 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -35,12 +35,13 @@ extern "C" { #define SYNC_SNAPSHOT_RETRY_MS 5000 +//--------------------------------------------------- typedef struct SSyncSnapshotSender { bool start; int32_t seq; int32_t ack; - void * pReader; - void * pCurrentBlock; + void *pReader; + void *pCurrentBlock; int32_t blockLen; SSnapshot snapshot; SSyncCfg lastConfig; @@ -59,33 +60,36 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot void snapshotSenderStop(SSyncSnapshotSender *pSender); int32_t snapshotSend(SSyncSnapshotSender *pSender); int32_t snapshotReSend(SSyncSnapshotSender *pSender); -cJSON * snapshotSender2Json(SSyncSnapshotSender *pSender); -char * snapshotSender2Str(SSyncSnapshotSender *pSender); -char * snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event); +cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender); +char *snapshotSender2Str(SSyncSnapshotSender *pSender); +char *snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event); + +//--------------------------------------------------- typedef struct SSyncSnapshotReceiver { - bool start; - - int32_t ack; - void * pWriter; - SyncTerm term; - SyncTerm privateTerm; - SSnapshot snapshot; - - SSyncNode *pSyncNode; + bool start; + int32_t ack; + void *pWriter; + SyncTerm term; + SyncTerm privateTerm; + SSnapshot snapshot; SRaftId fromId; + SSyncNode *pSyncNode; } SSyncSnapshotReceiver; SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId fromId); void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver); -void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg); -bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver); -void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver, bool apply); -cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver); -char * snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver); -char * snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event); +void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg); +bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver); +void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver, bool apply); +cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver); +char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver); +char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event); + +//--------------------------------------------------- +// on message int32_t syncNodeOnSnapshotSendCb(SSyncNode *ths, SyncSnapshotSend *pMsg); int32_t syncNodeOnSnapshotRspCb(SSyncNode *ths, SyncSnapshotRsp *pMsg); diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 0feaf532bb..39e972c4c4 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -21,6 +21,7 @@ #include "syncUtil.h" #include "wal.h" +//---------------------------------- static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg); @@ -49,7 +50,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &(pSender->snapshot)); pSender->finish = false; } else { - sError("snapshotSenderCreate cannot create sender"); + sError("vgId:%d cannot create snapshot sender", pSyncNode->vgId); } return pSender; @@ -57,39 +58,59 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI void snapshotSenderDestroy(SSyncSnapshotSender *pSender) { if (pSender != NULL) { + // free current block if (pSender->pCurrentBlock != NULL) { taosMemoryFree(pSender->pCurrentBlock); + pSender->pCurrentBlock = NULL; } + + // close reader + if (pSender->pReader != NULL) { + int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader); + ASSERT(ret == 0); + pSender->pReader = NULL; + } + + // free sender taosMemoryFree(pSender); } } bool snapshotSenderIsStart(SSyncSnapshotSender *pSender) { return pSender->start; } -// begin send snapshot (current term, seq begin) +// begin send snapshot by snapshot, pReader void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void *pReader) { ASSERT(!snapshotSenderIsStart(pSender)); - pSender->seq = SYNC_SNAPSHOT_SEQ_BEGIN; - pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID; - // init snapshot and reader ASSERT(pSender->pReader == NULL); pSender->pReader = pReader; pSender->snapshot = snapshot; + // init current block if (pSender->pCurrentBlock != NULL) { taosMemoryFree(pSender->pCurrentBlock); } pSender->blockLen = 0; + // update term + pSender->term = pSender->pSyncNode->pRaftStore->currentTerm; + ++(pSender->privateTerm); + + // update state + pSender->finish = false; + pSender->start = true; + pSender->seq = SYNC_SNAPSHOT_SEQ_BEGIN; + pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID; + + // init last config if (pSender->snapshot.lastConfigIndex != SYNC_INDEX_INVALID) { int32_t code = 0; SSyncRaftEntry *pEntry = NULL; + bool getLastConfig = false; + code = pSender->pSyncNode->pLogStore->syncLogGetEntry(pSender->pSyncNode->pLogStore, pSender->snapshot.lastConfigIndex, &pEntry); - - bool getLastConfig = false; if (code == 0) { ASSERT(pEntry != NULL); @@ -112,29 +133,29 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void } } + // last config not found in wal, update to -1 if (!getLastConfig) { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "snapshot sender update lcindex from %ld to -1", - pSender->snapshot.lastConfigIndex); - pSender->snapshot.lastConfigIndex = -1; - - char *eventLog = snapshotSender2SimpleStr(pSender, logBuf); - syncNodeEventLog(pSender->pSyncNode, eventLog); - taosMemoryFree(eventLog); - + SyncIndex oldLastConfigIndex = pSender->snapshot.lastConfigIndex; + SyncIndex newLastConfigIndex = SYNC_INDEX_INVALID; + pSender->snapshot.lastConfigIndex = SYNC_INDEX_INVALID; memset(&(pSender->lastConfig), 0, sizeof(SSyncCfg)); + + // event log + do { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "snapshot sender update lcindex from %ld to %ld", oldLastConfigIndex, + newLastConfigIndex); + char *eventLog = snapshotSender2SimpleStr(pSender, logBuf); + syncNodeEventLog(pSender->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } } else { + // no last config memset(&(pSender->lastConfig), 0, sizeof(SSyncCfg)); } - pSender->sendingMS = SYNC_SNAPSHOT_RETRY_MS; - pSender->term = pSender->pSyncNode->pRaftStore->currentTerm; - ++(pSender->privateTerm); - pSender->finish = false; - pSender->start = true; - // build begin msg SyncSnapshotSend *pMsg = syncSnapshotSendBuild(0, pSender->pSyncNode->vgId); pMsg->srcId = pSender->pSyncNode->myRaftId; @@ -151,40 +172,39 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void SRpcMsg rpcMsg; syncSnapshotSend2RpcMsg(pMsg, &rpcMsg); syncNodeSendMsgById(&(pMsg->destId), pSender->pSyncNode, &rpcMsg); - - char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender send"); - syncNodeEventLog(pSender->pSyncNode, eventLog); - taosMemoryFree(eventLog); - syncSnapshotSendDestroy(pMsg); + + // event log + do { + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender send"); + syncNodeEventLog(pSender->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } void snapshotSenderStop(SSyncSnapshotSender *pSender) { + // close reader if (pSender->pReader != NULL) { int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader); ASSERT(ret == 0); pSender->pReader = NULL; } + // free current block if (pSender->pCurrentBlock != NULL) { taosMemoryFree(pSender->pCurrentBlock); pSender->pCurrentBlock = NULL; pSender->blockLen = 0; } + // update flag pSender->start = false; - - if (gRaftDetailLog) { - char *s = snapshotSender2Str(pSender); - sInfo("snapshotSenderStop %s", s); - taosMemoryFree(s); - } } -// when sender receiver ack, call this function to send msg from seq +// when sender receive ack, call this function to send msg from seq // seq = ack + 1, already updated int32_t snapshotSend(SSyncSnapshotSender *pSender) { - // free memory last time (seq - 1) + // free memory last time (current seq - 1) if (pSender->pCurrentBlock != NULL) { taosMemoryFree(pSender->pCurrentBlock); pSender->pCurrentBlock = NULL; @@ -198,7 +218,7 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) { if (pSender->blockLen > 0) { // has read data } else { - // read finish + // read finish, update seq to end pSender->seq = SYNC_SNAPSHOT_SEQ_END; } @@ -219,25 +239,28 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) { SRpcMsg rpcMsg; syncSnapshotSend2RpcMsg(pMsg, &rpcMsg); syncNodeSendMsgById(&(pMsg->destId), pSender->pSyncNode, &rpcMsg); - - if (pSender->seq == SYNC_SNAPSHOT_SEQ_END) { - char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender finish"); - syncNodeEventLog(pSender->pSyncNode, eventLog); - taosMemoryFree(eventLog); - - } else { - char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender sending"); - syncNodeEventLog(pSender->pSyncNode, eventLog); - taosMemoryFree(eventLog); - } - syncSnapshotSendDestroy(pMsg); + + // event log + do { + char *eventLog = NULL; + if (pSender->seq == SYNC_SNAPSHOT_SEQ_END) { + eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender finish"); + } else { + eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender sending"); + } + syncNodeEventLog(pSender->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); + return 0; } // send snapshot data from cache int32_t snapshotReSend(SSyncSnapshotSender *pSender) { - if (pSender->pCurrentBlock != NULL) { + // send current block data + if (pSender->pCurrentBlock != NULL && pSender->blockLen > 0) { + // build msg SyncSnapshotSend *pMsg = syncSnapshotSendBuild(pSender->blockLen, pSender->pSyncNode->vgId); pMsg->srcId = pSender->pSyncNode->myRaftId; pMsg->destId = (pSender->pSyncNode->replicasId)[pSender->replicaIndex]; @@ -249,16 +272,20 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { pMsg->seq = pSender->seq; memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen); + // send msg SRpcMsg rpcMsg; syncSnapshotSend2RpcMsg(pMsg, &rpcMsg); syncNodeSendMsgById(&(pMsg->destId), pSender->pSyncNode, &rpcMsg); - - char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender resend"); - syncNodeEventLog(pSender->pSyncNode, eventLog); - taosMemoryFree(eventLog); - syncSnapshotSendDestroy(pMsg); + + // event log + do { + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender resend"); + syncNodeEventLog(pSender->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } + return 0; } @@ -294,7 +321,6 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) { snprintf(u64buf, sizeof(u64buf), "%lu", pSender->snapshot.lastApplyTerm); cJSON_AddStringToObject(pSnapshot, "lastApplyTerm", u64buf); cJSON_AddItemToObject(pRoot, "snapshot", pSnapshot); - snprintf(u64buf, sizeof(u64buf), "%lu", pSender->sendingMS); cJSON_AddStringToObject(pRoot, "sendingMS", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSender->pSyncNode); @@ -314,17 +340,17 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) { char *snapshotSender2Str(SSyncSnapshotSender *pSender) { cJSON *pJson = snapshotSender2Json(pSender); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } char *snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event) { int32_t len = 256; - char * s = taosMemoryMalloc(len); + char *s = taosMemoryMalloc(len); SRaftId destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; - char host[128]; + char host[64]; uint16_t port; syncUtilU642Addr(destId.addr, host, sizeof(host), &port); @@ -355,12 +381,12 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from pReceiver->term = pSyncNode->pRaftStore->currentTerm; pReceiver->privateTerm = 0; pReceiver->snapshot.data = NULL; - pReceiver->snapshot.lastApplyIndex = -1; + pReceiver->snapshot.lastApplyIndex = SYNC_INDEX_INVALID; pReceiver->snapshot.lastApplyTerm = 0; - pReceiver->snapshot.lastConfigIndex = -1; + pReceiver->snapshot.lastConfigIndex = SYNC_INDEX_INVALID; } else { - sInfo("snapshotReceiverCreate cannot create receiver"); + sError("vgId:%d cannot create snapshot receiver", pSyncNode->vgId); } return pReceiver; @@ -368,29 +394,55 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) { if (pReceiver != NULL) { + // close writer + if (pReceiver->pWriter != NULL) { + int32_t ret = + pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false); + ASSERT(ret == 0); + pReceiver->pWriter = NULL; + } + + // free receiver taosMemoryFree(pReceiver); } } bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver) { return pReceiver->start; } -// begin receive snapshot msg (current term, seq begin) +// static do start +// receive first snapshot data +// privateTerm, pBeginMsg static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg) { + // update state pReceiver->term = pReceiver->pSyncNode->pRaftStore->currentTerm; pReceiver->privateTerm = privateTerm; pReceiver->ack = SYNC_SNAPSHOT_SEQ_BEGIN; pReceiver->fromId = pBeginMsg->srcId; + // update snapshot pReceiver->snapshot.lastApplyIndex = pBeginMsg->lastIndex; pReceiver->snapshot.lastApplyTerm = pBeginMsg->lastTerm; pReceiver->snapshot.lastConfigIndex = pBeginMsg->lastConfigIndex; + // write data ASSERT(pReceiver->pWriter == NULL); int32_t ret = pReceiver->pSyncNode->pFsm->FpSnapshotStartWrite(pReceiver->pSyncNode->pFsm, &(pReceiver->pWriter)); ASSERT(ret == 0); } +static void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver) { + // force close, abandon incomplete data + if (pReceiver->pWriter != NULL) { + int32_t ret = + pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false); + ASSERT(ret == 0); + pReceiver->pWriter = NULL; + } + + pReceiver->start = false; +} + // if receiver receive msg from seq = SYNC_SNAPSHOT_SEQ_BEGIN, start receiver // if already start, force close, start again void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg) { @@ -413,12 +465,6 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTer snapshotReceiverDoStart(pReceiver, privateTerm, pBeginMsg); pReceiver->start = true; } - - if (gRaftDetailLog) { - char *s = snapshotReceiver2Str(pReceiver); - sInfo("snapshotReceiverStart %s", s); - taosMemoryFree(s); - } } void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver, bool apply) { @@ -434,12 +480,6 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver, bool apply) { if (apply) { // ++(pReceiver->privateTerm); } - - if (gRaftDetailLog) { - char *s = snapshotReceiver2Str(pReceiver); - sInfo("snapshotReceiverStop %s", s); - taosMemoryFree(s); - } } cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { @@ -461,7 +501,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { cJSON_AddStringToObject(pFromId, "addr", u64buf); { uint64_t u64 = pReceiver->fromId.addr; - cJSON * pTmp = pFromId; + cJSON *pTmp = pFromId; char host[128] = {0}; uint16_t port; syncUtilU642Addr(u64, host, sizeof(host), &port); @@ -494,14 +534,14 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) { char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver) { cJSON *pJson = snapshotReceiver2Json(pReceiver); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event) { int32_t len = 256; - char * s = taosMemoryMalloc(len); + char *s = taosMemoryMalloc(len); SRaftId fromId = pReceiver->fromId; char host[128]; From 3d323f56886325bc76799f7025dcac9042a4b601 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 27 Jun 2022 20:55:17 +0800 Subject: [PATCH 58/73] enh: adjust vgroup before commit --- source/dnode/mnode/impl/src/mndVgroup.c | 81 ++++- tests/script/jenkins/basic.txt | 1 + tests/script/tsim/dnode/balance_replica1.sim | 1 - tests/script/tsim/dnode/balance_replica3.sim | 362 +++++++++++++++++++ 4 files changed, 424 insertions(+), 21 deletions(-) create mode 100644 tests/script/tsim/dnode/balance_replica3.sim diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 10d11f6ae4..7a0687c515 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1021,10 +1021,19 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1; - SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); - if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) return -1; - sdbSetRawStatus(pRaw, SDB_STATUS_READY); - pRaw = NULL; + { + SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) return -1; + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + pRaw = NULL; + } + + { + SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) return -1; + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + pRaw = NULL; + } mInfo("vgId:%d, vgroup info after move, replica:%d", newVg.vgId, newVg.replica); for (int32_t i = 0; i < newVg.replica; ++i) { @@ -1172,10 +1181,19 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, if (mndAddDecVgroupReplicaFromTrans(pMnode, pTrans, pDb, &newVg, pOld3->id) != 0) goto _OVER; } - pRaw = mndVgroupActionEncode(&newVg); - if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; - sdbSetRawStatus(pRaw, SDB_STATUS_READY); - pRaw = NULL; + { + pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER; + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + pRaw = NULL; + } + + { + pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER; + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + pRaw = NULL; + } mInfo("vgId:%d, vgroup info after redistribute, replica:%d", newVg.vgId, newVg.replica); for (int32_t i = 0; i < newVg.replica; ++i) { @@ -1430,13 +1448,25 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, S } else { } - SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup); - if (pVgRaw == NULL) return -1; - if (mndTransAppendCommitlog(pTrans, pVgRaw) != 0) { - sdbFreeRaw(pVgRaw); - return -1; + { + SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup); + if (pVgRaw == NULL) return -1; + if (mndTransAppendRedolog(pTrans, pVgRaw) != 0) { + sdbFreeRaw(pVgRaw); + return -1; + } + sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); + } + + { + SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup); + if (pVgRaw == NULL) return -1; + if (mndTransAppendCommitlog(pTrans, pVgRaw) != 0) { + sdbFreeRaw(pVgRaw); + return -1; + } + sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); } - sdbSetRawStatus(pVgRaw, SDB_STATUS_READY); } return 0; @@ -1544,12 +1574,23 @@ static int32_t mndSetBalanceVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SD if (mndAddIncVgroupReplicaToTrans(pMnode, pTrans, pDb, &newVg, pDst->id) != 0) return -1; if (mndAddDecVgroupReplicaFromTrans(pMnode, pTrans, pDb, &newVg, pSrc->id) != 0) return -1; - SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); - if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) { - sdbFreeRaw(pRaw); - return -1; + { + SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) { + sdbFreeRaw(pRaw); + return -1; + } + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + } + + { + SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) { + sdbFreeRaw(pRaw); + return -1; + } + sdbSetRawStatus(pRaw, SDB_STATUS_READY); } - sdbSetRawStatus(pRaw, SDB_STATUS_READY); mInfo("vgId:%d, vgroup info after balance, replica:%d", newVg.vgId, newVg.replica); for (int32_t i = 0; i < newVg.replica; ++i) { @@ -1630,7 +1671,7 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) { return -1; } } else { - mDebug("trans:%d, no vgroup need to balance vgroup any more", pTrans->id); + mDebug("trans:%d, no vgroup need to balance any more", pTrans->id); break; } } diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 19237d2fe5..d3a6a0d102 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -22,6 +22,7 @@ # ---- dnode ./test.sh -f tsim/dnode/balance_replica1.sim +#./test.sh -f tsim/dnode/balance_replica3.sim ./test.sh -f tsim/dnode/create_dnode.sim ./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim ./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim diff --git a/tests/script/tsim/dnode/balance_replica1.sim b/tests/script/tsim/dnode/balance_replica1.sim index 14f3f130fb..998d0654ab 100644 --- a/tests/script/tsim/dnode/balance_replica1.sim +++ b/tests/script/tsim/dnode/balance_replica1.sim @@ -117,7 +117,6 @@ if $rows != 6 then return -1 endi -return system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/balance_replica3.sim b/tests/script/tsim/dnode/balance_replica3.sim new file mode 100644 index 0000000000..b8996e259d --- /dev/null +++ b/tests/script/tsim/dnode/balance_replica3.sim @@ -0,0 +1,362 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/cfg.sh -n dnode1 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode2 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode3 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode4 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode5 -c transPullupInterval -v 1 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql connect + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +sql create dnode $hostname port 7500 + +$x = 0 +step1: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 5 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi + +print =============== step2: create db +sql create database d1 vgroups 4 replica 3 + +print =============== step32 wait vgroup2 +$x = 0 +step32: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step32 +endi + +print =============== step33 wait vgroup3 +$x = 0 +step33: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step33 +endi + +print =============== step34 wait vgroup4 +$x = 0 +step34: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step34 +endi + +print =============== step35 wait vgroup5 +$x = 0 +step35: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step35 +endi + +print =============== step36: create table +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql create table d1.c2 using st tags(1) +sql create table d1.c3 using st tags(1) +sql create table d1.c4 using st tags(1) +sql create table d1.c5 using st tags(1) +sql create table d1.c6 using st tags(1) +sql show d1.tables +if $rows != 6 then + return -1 +endi + +print =============== step4: start dnode5 +system sh/exec.sh -n dnode5 -s start +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 +print ===> $data40 $data41 $data42 $data43 $data44 $data45 +if $rows != 5 then + return -1 +endi +if $data(1)[4] != ready then + goto step4 +endi +if $data(2)[4] != ready then + goto step4 +endi +if $data(3)[4] != ready then + goto step4 +endi +if $data(4)[4] != ready then + goto step4 +endi +if $data(5)[4] != ready then + goto step4 +endi + +print =============== step5: balance +sql balance vgroup + +print =============== step62 wait vgroup2 +$x = 0 +step62: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(2)[4] == leader then + $leaderExist = 1 +endi +if $data(2)[6] == leader then + $leaderExist = 1 +endi +if $data(2)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step62 +endi + +print =============== step63 wait vgroup3 +$x = 0 +step63: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(3)[4] == leader then + $leaderExist = 1 +endi +if $data(3)[6] == leader then + $leaderExist = 1 +endi +if $data(3)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step63 +endi + +print =============== step64 wait vgroup4 +$x = 0 +step64: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step64 +endi + +print =============== step65 wait vgroup5 +$x = 0 +step65: + $x = $x + 1 + sleep 1000 + if $x == 60 then + print ====> db not ready! + return -1 + endi +sql show d1.vgroups +print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 +print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 +if $rows != 4 then + return -1 +endi +if $data(4)[4] == leader then + $leaderExist = 1 +endi +if $data(4)[6] == leader then + $leaderExist = 1 +endi +if $data(4)[8] == leader then + $leaderExist = 1 +endi +if $leaderExist != 1 then + goto step65 +endi + + + +print =============== step7: select data + +sql show d1.tables +print rows $rows +if $rows != 6 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT From 06e8ba9f143428d5faeab1c358a67bcfdac2a348 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Mon, 27 Jun 2022 20:56:37 +0800 Subject: [PATCH 59/73] os: win shell catch ctrl-c --- include/os/osSystem.h | 3 +++ source/os/src/osSystem.c | 9 ++++++--- tools/shell/src/shellArguments.c | 4 ++-- tools/shell/src/shellCommand.c | 5 ++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/os/osSystem.h b/include/os/osSystem.h index 6770be6e46..581e688ccb 100644 --- a/include/os/osSystem.h +++ b/include/os/osSystem.h @@ -29,6 +29,9 @@ extern "C" { #define tcgetattr TCGETATTR_FUNC_TAOS_FORBID #endif +#define TAOS_CONSOLE_PROMPT_HEADER "taos> " +#define TAOS_CONSOLE_PROMPT_CONTINUE " -> " + typedef struct TdCmd *TdCmdPtr; TdCmdPtr taosOpenCmd(const char* cmd); diff --git a/source/os/src/osSystem.c b/source/os/src/osSystem.c index ba07b6c3dd..9c66ac1df8 100644 --- a/source/os/src/osSystem.c +++ b/source/os/src/osSystem.c @@ -18,6 +18,10 @@ #include "os.h" #if defined(WINDOWS) +BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) { + printf("\n" TAOS_CONSOLE_PROMPT_HEADER); + return TRUE; +} #elif defined(_TD_DARWIN_64) #else #include @@ -124,7 +128,7 @@ int taosSetConsoleEcho(bool on) { void taosSetTerminalMode() { #if defined(WINDOWS) - // assert(0); + SetConsoleCtrlHandler(CtrlHandler, TRUE); #else struct termios newtio; @@ -158,7 +162,6 @@ void taosSetTerminalMode() { int32_t taosGetOldTerminalMode() { #if defined(WINDOWS) - // assert(0); #else /* Make sure stdin is a terminal. */ if (!isatty(STDIN_FILENO)) { @@ -176,7 +179,7 @@ int32_t taosGetOldTerminalMode() { void taosResetTerminalMode() { #if defined(WINDOWS) - // assert(0); + SetConsoleCtrlHandler(CtrlHandler, FALSE); #else if (tcsetattr(0, TCSANOW, &oldtio) != 0) { fprintf(stderr, "Fail to reset the terminal properties!\n"); diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c index cd6613b17a..2037f67089 100644 --- a/tools/shell/src/shellArguments.c +++ b/tools/shell/src/shellArguments.c @@ -339,8 +339,8 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) { shell.info.clientVersion = "Welcome to the TDengine shell from %s, Client Version:%s\n" "Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.\n\n"; - shell.info.promptHeader = "taos> "; - shell.info.promptContinue = " -> "; + shell.info.promptHeader = TAOS_CONSOLE_PROMPT_HEADER; + shell.info.promptContinue = TAOS_CONSOLE_PROMPT_CONTINUE; shell.info.promptSize = 6; snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), "version: %s", version); diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index f236c1eb88..9cb3541017 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -411,8 +411,9 @@ char taosGetConsoleChar() { static char mbStr[5]; static unsigned long bufLen = 0; static uint16_t bufIndex = 0, mbStrIndex = 0, mbStrLen = 0; - if (bufLen == 0) { + while (bufLen == 0) { ReadConsoleW(console, buf, SHELL_INPUT_MAX_COMMAND_SIZE, &bufLen, NULL); + if (bufLen > 0 && buf[0] == 0) bufLen = 0; bufIndex = 0; } if (mbStrLen == 0){ @@ -466,6 +467,8 @@ int32_t shellReadCommand(char *command) { } else if (c < '\033') { // Ctrl keys. TODO: Implement ctrl combinations switch (c) { + case 0: + break; case 1: // ctrl A shellPositionCursorHome(&cmd); break; From 3a712fb5d1f474e568e916d12dc32f271ae7125d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 27 Jun 2022 21:17:38 +0800 Subject: [PATCH 60/73] fix: balance vgroup --- source/dnode/mnode/impl/src/mndVgroup.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 7a0687c515..d42016e6a0 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1599,7 +1599,8 @@ static int32_t mndSetBalanceVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SD return 0; } -static int32_t mndBalanceVgroupBetweenDnode(SMnode *pMnode, STrans *pTrans, SDnodeObj *pSrc, SDnodeObj *pDst) { +static int32_t mndBalanceVgroupBetweenDnode(SMnode *pMnode, STrans *pTrans, SDnodeObj *pSrc, SDnodeObj *pDst, + SHashObj *pBalancedVgroups) { void *pIter = NULL; int32_t code = -1; SSdb *pSdb = pMnode->pSdb; @@ -1608,6 +1609,10 @@ static int32_t mndBalanceVgroupBetweenDnode(SMnode *pMnode, STrans *pTrans, SDno SVgObj *pVgroup = NULL; pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); if (pIter == NULL) break; + if (taosHashGet(pBalancedVgroups, &pVgroup->vgId, sizeof(int32_t)) != NULL) { + sdbRelease(pSdb, pVgroup); + continue; + } bool existInSrc = false; bool existInDst = false; @@ -1624,6 +1629,9 @@ static int32_t mndBalanceVgroupBetweenDnode(SMnode *pMnode, STrans *pTrans, SDno SDbObj *pDb = mndAcquireDb(pMnode, pVgroup->dbName); code = mndSetBalanceVgroupInfoToTrans(pMnode, pTrans, pDb, pVgroup, pSrc, pDst); + if (code == 0) { + code = taosHashPut(pBalancedVgroups, &pVgroup->vgId, sizeof(int32_t), &pVgroup->vgId, sizeof(int32_t)); + } mndReleaseDb(pMnode, pDb); sdbRelease(pSdb, pVgroup); sdbCancelFetch(pSdb, pIter); @@ -1637,6 +1645,10 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) { int32_t code = -1; int32_t numOfVgroups = 0; STrans *pTrans = NULL; + SHashObj *pBalancedVgroups = NULL; + + pBalancedVgroups = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (pBalancedVgroups == NULL) goto _OVER; pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq); if (pTrans == NULL) goto _OVER; @@ -1660,15 +1672,15 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) { pDst->id, dstScore); if (srcScore > dstScore - 0.000001) { - code = mndBalanceVgroupBetweenDnode(pMnode, pTrans, pSrc, pDst); + code = mndBalanceVgroupBetweenDnode(pMnode, pTrans, pSrc, pDst, pBalancedVgroups); if (code == 0) { pSrc->numOfVnodes--; pDst->numOfVnodes++; numOfVgroups++; continue; } else { - mError("trans:%d, failed to balance vgroup from dnode:%d to dnode:%d", pTrans->id, pSrc->id, pDst->id); - return -1; + mDebug("trans:%d, no vgroup need to balance from dnode:%d to dnode:%d", pTrans->id, pSrc->id, pDst->id); + break; } } else { mDebug("trans:%d, no vgroup need to balance any more", pTrans->id); From 23a9c8f3172dfb319d09ff8354ccbc471d40e167 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Mon, 27 Jun 2022 21:25:34 +0800 Subject: [PATCH 61/73] refactor: rsma restore and code optimization --- source/dnode/vnode/src/inc/sma.h | 11 +- source/dnode/vnode/src/sma/smaOpen.c | 36 +-- source/dnode/vnode/src/sma/smaRollup.c | 349 +++++++++++++++++++++++-- source/dnode/vnode/src/sma/smaUtil.c | 7 +- 4 files changed, 337 insertions(+), 66 deletions(-) diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 956e451b58..4b42ab5263 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -176,15 +176,18 @@ static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) { static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType); void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType); +void *tdFreeRSmaInfo(SRSmaInfo *pInfo); -void *tdFreeRSmaInfo(SRSmaInfo *pInfo); - +int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName); +int32_t tdProcessRSmaRestoreImpl(SSma *pSma); int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg); int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg); int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days); // smaFileUtil ================ +#define TD_FILE_HEAD_SIZE 512 + typedef struct STFInfo STFInfo; typedef struct STFile STFile; @@ -220,12 +223,14 @@ int64_t tdReadTFile(STFile *pTFile, void *buf, int64_t nbyte); int64_t tdSeekTFile(STFile *pTFile, int64_t offset, int whence); int64_t tdWriteTFile(STFile *pTFile, void *buf, int64_t nbyte); int64_t tdAppendTFile(STFile *pTFile, void *buf, int64_t nbyte, int64_t *offset); +int64_t tdGetTFileSize(STFile *pTFile, int64_t *size); int32_t tdRemoveTFile(STFile *pTFile); int32_t tdLoadTFileHeader(STFile *pTFile, STFInfo *pInfo); int32_t tdUpdateTFileHeader(STFile *pTFile); void tdUpdateTFileMagic(STFile *pTFile, void *pCksm); void tdCloseTFile(STFile *pTFile); -void tdGetVndFileName(int32_t vid, const char *dname, const char *fname, char *outputName); + +void tdGetVndFileName(int32_t vid, const char *dname, const char *fname, char *outputName); #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index fad31f92c0..88ed7426f7 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -123,14 +123,15 @@ int32_t smaOpen(SVnode *pVnode) { } // restore the rsma +#if 0 if (rsmaRestore(pSma) < 0) { goto _err; } +#endif } return 0; _err: - taosMemoryFreeClear(pSma); return -1; } @@ -168,36 +169,5 @@ int32_t smaClose(SSma *pSma) { static int32_t rsmaRestore(SSma *pSma) { ASSERT(VND_IS_RSMA(pSma->pVnode)); - // iterate all stables to restore the rsma env - SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t)); - if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) { - smaError("failed to restore rsma since get stb id list error: %s", terrstr()); - return TSDB_CODE_FAILED; - } - - SMetaReader mr = {0}; - metaReaderInit(&mr, SMA_META(pSma), 0); - for (int32_t i = 0; i < taosArrayGetSize(suidList); ++i) { - tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i); - smaDebug("suid [%d] is %" PRIi64, i, suid); - if (metaGetTableEntryByUid(&mr, suid) < 0) { - metaReaderClear(&mr); - taosArrayDestroy(suidList); - smaError("failed to get table meta for %" PRIi64 " since %s", suid, terrstr()); - return TSDB_CODE_FAILED; - } - ASSERT(mr.me.type == TSDB_SUPER_TABLE); - if (TABLE_IS_ROLLUP(mr.me.flags)) { - SRSmaParam *param = &mr.me.stbEntry.rsmaParam; - for (int i = 0; i < 2; ++i) { - smaDebug("vgId: %d table:%" PRIi64 " maxdelay[%d]:%" PRIi64 " watermark[%d]:%" PRIi64, TD_VID(pSma->pVnode), - suid, i, param->maxdelay[i], i, param->watermark[i]); - } - } - } - - metaReaderClear(&mr); - taosArrayDestroy(suidList); - - return TSDB_CODE_SUCCESS; + return tdProcessRSmaRestoreImpl(pSma); } \ No newline at end of file diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 26b9a34fa3..4f593c33da 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -15,10 +15,14 @@ #include "sma.h" -#define RSMA_QTASK_PERSIST_MS 7200000 +#define RSMA_QTASKINFO_PERSIST_MS 7200000 +#define RSMA_QTASKINFO_BUFSIZE 32768 typedef enum { TD_QTASK_TMP_FILE = 0, TD_QTASK_CUR_FILE } TD_QTASK_FILE_T; static const char *tdQTaskInfoFname[] = {"qtaskinfo.t", "qtaskinfo"}; +typedef struct SRSmaQTaskInfoItem SRSmaQTaskInfoItem; +typedef struct SRSmaQTaskFIter SRSmaQTaskFIter; + static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid); static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids); static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaInfo *pRSmaInfo, SReadHandle *handle, @@ -27,6 +31,13 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType tb_uid_t suid, int8_t level); static void tdRSmaFetchTrigger(void *param, void *tmrId); static void tdRSmaPersistTrigger(void *param, void *tmrId); +static void *tdRSmaPersistExec(void *param); +static void tdRSmaQTaskGetFName(int32_t vid, int8_t ftype, char *outputName); + +static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskFIter *pIter, STFile *pTFile); +static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskFIter *pIter, bool *isFinish); +static int32_t tdRSmaQTaskInfoIterNext(SRSmaQTaskFIter *pIter, SRSmaQTaskInfoItem *pItem, bool *isEnd); +static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *infoItem); struct SRSmaInfoItem { SRSmaInfo *pRsmaInfo; @@ -45,6 +56,24 @@ struct SRSmaInfo { SRSmaInfoItem items[TSDB_RETENTION_L2]; }; +struct SRSmaQTaskInfoItem { + int32_t len; + int8_t type; + int64_t suid; + void *qTaskInfo; +}; + +struct SRSmaQTaskFIter { + STFile *pTFile; + int64_t offset; + int64_t fsize; + int32_t nBytes; + int32_t nAlloc; + char *buf; + // ------------ + int32_t nBufPos; +}; + static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) { // Note: free/kill may in RC qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle); @@ -230,26 +259,21 @@ _err: } /** - * @brief Check and init qTaskInfo_t, only applicable to stable with SRSmaParam. + * @brief for rsam create or restore * - * @param pTsdb - * @param pMeta - * @param pReq + * @param pSma + * @param param + * @param suid + * @param tbName * @return int32_t */ -int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { - SSma *pSma = pVnode->pSma; - if (!pReq->rollup) { - smaTrace("vgId:%d, return directly since no rollup for stable %s %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); - return TSDB_CODE_SUCCESS; - } - - SMeta *pMeta = pVnode->pMeta; - SMsgCb *pMsgCb = &pVnode->msgCb; - SRSmaParam *param = &pReq->rsmaParam; +int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName) { + SVnode *pVnode = pSma->pVnode; + SMeta *pMeta = pVnode->pMeta; + SMsgCb *pMsgCb = &pVnode->msgCb; if ((param->qmsgLen[0] == 0) && (param->qmsgLen[1] == 0)) { - smaWarn("vgId:%d, no qmsg1/qmsg2 for rollup stable %s %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); + smaDebug("vgId:%d, no qmsg1/qmsg2 for rollup table %s %" PRIi64, SMA_VID(pSma), tbName, suid); return TSDB_CODE_SUCCESS; } @@ -262,10 +286,10 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv); SRSmaInfo *pRSmaInfo = NULL; - pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &pReq->suid, sizeof(tb_uid_t)); + pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t)); if (pRSmaInfo) { ASSERT(0); // TODO: free original pRSmaInfo is exists abnormally - smaWarn("vgId:%d, rsma info already exists for stb: %s, %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); + smaDebug("vgId:%d, rsma info already exists for table %s, %" PRIi64, SMA_VID(pSma), tbName, suid); return TSDB_CODE_SUCCESS; } @@ -289,14 +313,14 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { .vnode = pVnode, }; - STSchema *pTSchema = metaGetTbTSchema(SMA_META(pSma), pReq->suid, -1); + STSchema *pTSchema = metaGetTbTSchema(SMA_META(pSma), suid, -1); if (!pTSchema) { terrno = TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION; goto _err; } pRSmaInfo->pTSchema = pTSchema; pRSmaInfo->pSma = pSma; - pRSmaInfo->suid = pReq->suid; + pRSmaInfo->suid = suid; if (tdSetRSmaInfoItemParams(pSma, param, pRSmaInfo, &handle, 0) < 0) { goto _err; @@ -306,16 +330,16 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { goto _err; } - if (taosHashPut(RSMA_INFO_HASH(pStat), &pReq->suid, sizeof(tb_uid_t), &pRSmaInfo, sizeof(pRSmaInfo)) < 0) { + if (taosHashPut(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t), &pRSmaInfo, sizeof(pRSmaInfo)) < 0) { goto _err; } else { - smaDebug("vgId:%d, register rsma info succeed for suid:%" PRIi64, SMA_VID(pSma), pReq->suid); + smaDebug("vgId:%d, register rsma info succeed for suid:%" PRIi64, SMA_VID(pSma), suid); } // start the persist timer if (TASK_TRIGGER_STAT_INIT == atomic_val_compare_exchange_8(RSMA_TRIGGER_STAT(pStat), TASK_TRIGGER_STAT_INIT, TASK_TRIGGER_STAT_ACTIVE)) { - taosTmrStart(tdRSmaPersistTrigger, RSMA_QTASK_PERSIST_MS, pStat, RSMA_TMR_HANDLE(pStat)); + taosTmrStart(tdRSmaPersistTrigger, RSMA_QTASKINFO_PERSIST_MS, pStat, RSMA_TMR_HANDLE(pStat)); } return TSDB_CODE_SUCCESS; @@ -325,6 +349,24 @@ _err: return TSDB_CODE_FAILED; } +/** + * @brief Check and init qTaskInfo_t, only applicable to stable with SRSmaParam. + * + * @param pTsdb + * @param pMeta + * @param pReq + * @return int32_t + */ +int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) { + SSma *pSma = pVnode->pSma; + if (!pReq->rollup) { + smaTrace("vgId:%d, return directly since no rollup for stable %s %" PRIi64, SMA_VID(pSma), pReq->name, pReq->suid); + return TSDB_CODE_SUCCESS; + } + + return tdProcessRSmaCreateImpl(pSma, &pReq->rsmaParam, pReq->suid, pReq->name); +} + /** * @brief store suid/[uids], prefer to use array and then hash * @@ -647,7 +689,7 @@ int32_t tdProcessRSmaSubmit(SSma *pSma, void *pMsg, int32_t inputType) { return TSDB_CODE_SUCCESS; } -void tdRSmaQTaskGetFName(int32_t vid, int8_t ftype, char *outputName) { +static void tdRSmaQTaskGetFName(int32_t vid, int8_t ftype, char *outputName) { tdGetVndFileName(vid, "rsma", tdQTaskInfoFname[ftype], outputName); } @@ -690,7 +732,7 @@ static void *tdRSmaPersistExec(void *param) { } char *pOutput = NULL; int32_t len = 0; - int8_t type = 0; + int8_t type = (int8_t)(i + 1); if (qSerializeTaskStatus(taskInfo, &pOutput, &len) < 0) { smaError("vgId:%d, table %" PRIi64 " level %d serialize rsma task failed since %s", vid, pRSmaInfo->suid, i + 1, terrstr(terrno)); @@ -726,8 +768,9 @@ static void *tdRSmaPersistExec(void *param) { isFileCreated = true; } - len += (sizeof(len) + sizeof(pRSmaInfo->suid)); + len += (sizeof(len)+ sizeof(type) + sizeof(pRSmaInfo->suid)); tdAppendTFile(&tFile, &len, sizeof(len), &toffset); + tdAppendTFile(&tFile, &type, sizeof(type), &toffset); tdAppendTFile(&tFile, &pRSmaInfo->suid, sizeof(pRSmaInfo->suid), &toffset); tdAppendTFile(&tFile, pOutput, len, &toffset); @@ -824,8 +867,12 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) { TASK_TRIGGER_STAT_CANCELLED, TASK_TRIGGER_STAT_FINISHED)) { smaDebug("rsma persistence start since active"); + + // start persist task tdRSmaPersistTask(pRSmaStat); - taosTmrReset(tdRSmaPersistTrigger, RSMA_QTASK_PERSIST_MS, pRSmaStat, pRSmaStat->tmrHandle, &pRSmaStat->tmrId); + + taosTmrReset(tdRSmaPersistTrigger, RSMA_QTASKINFO_PERSIST_MS, pRSmaStat, pRSmaStat->tmrHandle, + &pRSmaStat->tmrId); } else { atomic_store_8(RSMA_RUNNING_STAT(pRSmaStat), 0); } @@ -845,4 +892,250 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) { ASSERT(0); } break; } -} \ No newline at end of file +} + +int32_t tdProcessRSmaRestoreImpl(SSma *pSma) { + SVnode *pVnode = pSma->pVnode; + + // step 1: iterate all stables to restore the rsma env + + SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t)); + if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) { + smaError("vgId:%d, failed to restore rsma since get stb id list error: %s", TD_VID(pVnode), terrstr()); + return TSDB_CODE_FAILED; + } + + if (taosArrayGetSize(suidList) == 0) { + smaDebug("vgId:%d no need to restore rsma since empty stb id list", TD_VID(pVnode)); + return TSDB_CODE_SUCCESS; + } + + SMetaReader mr = {0}; + metaReaderInit(&mr, SMA_META(pSma), 0); + for (int32_t i = 0; i < taosArrayGetSize(suidList); ++i) { + tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i); + smaDebug("suid [%d] is %" PRIi64, i, suid); + if (metaGetTableEntryByUid(&mr, suid) < 0) { + smaError("vgId:%d failed to get table meta for %" PRIi64 " since %s", TD_VID(pVnode), suid, terrstr()); + goto _err; + } + ASSERT(mr.me.type == TSDB_SUPER_TABLE); + ASSERT(mr.me.uid == suid); + if (TABLE_IS_ROLLUP(mr.me.flags)) { + SRSmaParam *param = &mr.me.stbEntry.rsmaParam; + for (int i = 0; i < 2; ++i) { + smaDebug("vgId: %d table:%" PRIi64 " maxdelay[%d]:%" PRIi64 " watermark[%d]:%" PRIi64, TD_VID(pSma->pVnode), + suid, i, param->maxdelay[i], i, param->watermark[i]); + } + if (tdProcessRSmaCreateImpl(pSma, &mr.me.stbEntry.rsmaParam, suid, mr.me.name) < 0) { + smaError("vgId:%d failed to retore rsma env for %" PRIi64 " since %s", TD_VID(pVnode), suid, terrstr()); + goto _err; + } + } + } + + // step 2: retrieve qtaskinfo object from the rsma/qtaskinfo file and restore + STFile tFile = {0}; + char qTaskInfoFName[TSDB_FILENAME_LEN]; + + tdRSmaQTaskGetFName(TD_VID(pVnode), TD_QTASK_CUR_FILE, qTaskInfoFName); + if (tdInitTFile(&tFile, pVnode->pTfs, qTaskInfoFName) < 0) { + goto _err; + } + if (tdOpenTFile(&tFile, TD_FILE_READ) < 0) { + goto _err; + } + SRSmaQTaskFIter fIter = {0}; + if (tdRSmaQTaskInfoIterInit(&fIter, &tFile) < 0) { + goto _err; + } + SRSmaQTaskInfoItem infoItem = {0}; + bool isEnd = false; + int32_t code = 0; + while ((code = tdRSmaQTaskInfoIterNext(&fIter, &infoItem, &isEnd)) == 0) { + if (isEnd) { + break; + } + if((code = tdRSmaQTaskInfoItemRestore(pSma, &infoItem)) < 0){ + break; + } + } + if (code < 0) goto _err; + + metaReaderClear(&mr); + taosArrayDestroy(suidList); + return TSDB_CODE_SUCCESS; +_err: + ASSERT(0); + metaReaderClear(&mr); + taosArrayDestroy(suidList); + smaError("failed to restore rsma info since %s", terrstr()); + return TSDB_CODE_FAILED; +} + +static int32_t tdRSmaQTaskInfoItemRestore(SSma *pSma, const SRSmaQTaskInfoItem *infoItem) { + SRSmaStat *pStat = (SRSmaStat *)SMA_ENV_STAT((SSmaEnv *)pSma->pRSmaEnv); + SRSmaInfo *pRSmaInfo = NULL; + void *qTaskInfo = NULL; + + pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &infoItem->suid, sizeof(infoItem->suid)); + + if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) { + smaDebug("vgId:%d, no restore as no rsma info for suid:%" PRIu64, SMA_VID(pSma), infoItem->suid); + return TSDB_CODE_SUCCESS; + } + + if (infoItem->type == 1) { + qTaskInfo = pRSmaInfo->items[0].taskInfo; + } else if (infoItem->type == 2) { + qTaskInfo = pRSmaInfo->items[1].taskInfo; + } else { + ASSERT(0); + } + + if (!qTaskInfo) { + smaDebug("vgId:%d, no restore as NULL rsma qTaskInfo for suid:%" PRIu64, SMA_VID(pSma), infoItem->suid); + return TSDB_CODE_SUCCESS; + } + + if (qDeserializeTaskStatus(qTaskInfo, infoItem->qTaskInfo, infoItem->len) < 0) { + smaError("vgId:%d, restore rsma failed for suid:%" PRIi64 " level %d since %s", SMA_VID(pSma), infoItem->suid, + infoItem->type, terrstr(terrno)); + return TSDB_CODE_FAILED; + } + smaDebug("vgId:%d, restore rsma success for suid:%" PRIi64 " level %d", SMA_VID(pSma), infoItem->suid, + infoItem->type); + + return TSDB_CODE_SUCCESS; +} + +static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskFIter *pIter, STFile *pTFile) { + memset(pIter, 0, sizeof(*pIter)); + pIter->pTFile = pTFile; + pIter->offset = TD_FILE_HEAD_SIZE; + + if (tdGetTFileSize(pTFile, &pIter->fsize) < 0) { + return TSDB_CODE_FAILED; + } + + if ((pIter->fsize - TD_FILE_HEAD_SIZE) < RSMA_QTASKINFO_BUFSIZE) { + pIter->nAlloc = pIter->fsize - TD_FILE_HEAD_SIZE; + } else { + pIter->nAlloc = RSMA_QTASKINFO_BUFSIZE; + } + + if (pIter->nAlloc < TD_FILE_HEAD_SIZE) { + pIter->nAlloc = TD_FILE_HEAD_SIZE; + } + + pIter->buf = taosMemoryMalloc(pIter->nAlloc); + if (!pIter->buf) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_FAILED; + } + + return TSDB_CODE_SUCCESS; +} + +static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskFIter *pIter, bool *isFinish) { + STFile *pTFile = pIter->pTFile; + int64_t nBytes = RSMA_QTASKINFO_BUFSIZE; + + if (pIter->offset >= pIter->fsize) { + *isFinish = true; + return TSDB_CODE_SUCCESS; + } + + if ((pIter->fsize - pIter->offset) < RSMA_QTASKINFO_BUFSIZE) { + nBytes = pIter->fsize - pIter->offset; + } + + if (tdSeekTFile(pTFile, pIter->offset, SEEK_SET) < 0) { + ASSERT(0); + return TSDB_CODE_FAILED; + } + + if (tdReadTFile(pTFile, pIter->buf, nBytes) != nBytes) { + ASSERT(0); + return TSDB_CODE_FAILED; + } + + int32_t infoLen = 0; + taosDecodeFixedI32(pIter->buf, &infoLen); + if (infoLen > nBytes) { + ASSERT(infoLen > RSMA_QTASKINFO_BUFSIZE); + pIter->nAlloc = infoLen; + void *pBuf = taosMemoryRealloc(pIter->buf, infoLen); + if (!pBuf) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_FAILED; + } + pIter->buf = pBuf; + nBytes = infoLen; + + if (tdSeekTFile(pTFile, pIter->offset, SEEK_SET)) { + ASSERT(0); + return TSDB_CODE_FAILED; + } + + if (tdReadTFile(pTFile, pIter->buf, nBytes) != nBytes) { + ASSERT(0); + return TSDB_CODE_FAILED; + } + } + + pIter->offset += nBytes; + pIter->nBytes = nBytes; + pIter->nBufPos = 0; + + return TSDB_CODE_SUCCESS; +} + +static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) { + return lenWithHead - sizeof(int32_t) - sizeof(int8_t) - sizeof(int64_t); +} + +static int32_t tdRSmaQTaskInfoIterNext(SRSmaQTaskFIter *pIter, SRSmaQTaskInfoItem *pItem, bool *isEnd) { + + while (1) { + // block iter + bool isFinish = false; + if (tdRSmaQTaskInfoIterNextBlock(pIter, &isFinish) < 0) { + ASSERT(0); + return TSDB_CODE_FAILED; + } + if (isFinish) { + *isEnd = true; + return TSDB_CODE_SUCCESS; + } + + // consume the block + int32_t qTaskInfoLenWithHead = 0; + pIter->buf = taosDecodeFixedI32(pIter->buf, &qTaskInfoLenWithHead); + if(qTaskInfoLenWithHead < 0) { + terrno = TSDB_CODE_TDB_FILE_CORRUPTED; + return TSDB_CODE_FAILED; + } + while (1) { + if ((pIter->nBufPos + qTaskInfoLenWithHead) <= pIter->nBytes) { + pIter->buf = taosDecodeFixedI8(pIter->buf, &pItem->type); + pIter->buf = taosDecodeFixedI64(pIter->buf, &pItem->suid); + pItem->qTaskInfo = pIter->buf; + pItem->len = tdRSmaQTaskInfoContLen(qTaskInfoLenWithHead); + // do the restore job + printf("%s:%d ###### restore the qtask info offset:%" PRIi64 "\n", __func__, __LINE__, pIter->offset); + + pIter->buf = POINTER_SHIFT(pIter->buf, pItem->len); + pIter->nBufPos += qTaskInfoLenWithHead; + + pIter->buf = taosDecodeFixedI32(pIter->buf, &qTaskInfoLenWithHead); + continue; + } + // prepare and load next block in the file + pIter->offset -= (pIter->nBytes - pIter->nBufPos); + break; + } + } + + return TSDB_CODE_SUCCESS; +} diff --git a/source/dnode/vnode/src/sma/smaUtil.c b/source/dnode/vnode/src/sma/smaUtil.c index 85fddebf55..1f60da0b0a 100644 --- a/source/dnode/vnode/src/sma/smaUtil.c +++ b/source/dnode/vnode/src/sma/smaUtil.c @@ -17,8 +17,6 @@ // smaFileUtil ================ -#define TD_FILE_HEAD_SIZE 512 - #define TD_FILE_STATE_OK 0 #define TD_FILE_STATE_BAD 1 @@ -71,6 +69,11 @@ int64_t tdSeekTFile(STFile *pTFile, int64_t offset, int whence) { return loffset; } +int64_t tdGetTFileSize(STFile *pTFile, int64_t *size) { + ASSERT(TD_FILE_OPENED(pTFile)); + return taosFStatFile(pTFile->pFile, size, NULL); +} + int64_t tdReadTFile(STFile *pTFile, void *buf, int64_t nbyte) { ASSERT(TD_FILE_OPENED(pTFile)); From 771801e2afd000d1d22491144b72a3f1f6ad4590 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Mon, 27 Jun 2022 21:35:17 +0800 Subject: [PATCH 62/73] refactor: rsma restore --- source/dnode/vnode/src/sma/smaRollup.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index cf83da6f32..ed5b6f4055 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -74,6 +74,12 @@ struct SRSmaQTaskFIter { int32_t nBufPos; }; +static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) { + return lenWithHead - sizeof(int32_t) - sizeof(int8_t) - sizeof(int64_t); +} + +static FORCE_INLINE void tdRSmaQTaskInfoIterDestroy(SRSmaQTaskFIter *pIter) { taosMemoryFreeClear(pIter->buf); } + static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) { // Note: free/kill may in RC qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle); @@ -768,7 +774,7 @@ static void *tdRSmaPersistExec(void *param) { isFileCreated = true; } - len += (sizeof(len)+ sizeof(type) + sizeof(pRSmaInfo->suid)); + len += (sizeof(len) + sizeof(type) + sizeof(pRSmaInfo->suid)); tdAppendTFile(&tFile, &len, sizeof(len), &toffset); tdAppendTFile(&tFile, &type, sizeof(type), &toffset); tdAppendTFile(&tFile, &pRSmaInfo->suid, sizeof(pRSmaInfo->suid), &toffset); @@ -956,11 +962,15 @@ int32_t tdProcessRSmaRestoreImpl(SSma *pSma) { if (isEnd) { break; } - if((code = tdRSmaQTaskInfoItemRestore(pSma, &infoItem)) < 0){ + if ((code = tdRSmaQTaskInfoItemRestore(pSma, &infoItem)) < 0) { break; } } - if (code < 0) goto _err; + tdRSmaQTaskInfoIterDestroy(&fIter); + + if (code < 0) { + goto _err; + } metaReaderClear(&mr); taosArrayDestroy(suidList); @@ -1091,12 +1101,7 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskFIter *pIter, bool *isFini return TSDB_CODE_SUCCESS; } -static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) { - return lenWithHead - sizeof(int32_t) - sizeof(int8_t) - sizeof(int64_t); -} - static int32_t tdRSmaQTaskInfoIterNext(SRSmaQTaskFIter *pIter, SRSmaQTaskInfoItem *pItem, bool *isEnd) { - while (1) { // block iter bool isFinish = false; @@ -1112,7 +1117,7 @@ static int32_t tdRSmaQTaskInfoIterNext(SRSmaQTaskFIter *pIter, SRSmaQTaskInfoIte // consume the block int32_t qTaskInfoLenWithHead = 0; pIter->buf = taosDecodeFixedI32(pIter->buf, &qTaskInfoLenWithHead); - if(qTaskInfoLenWithHead < 0) { + if (qTaskInfoLenWithHead < 0) { terrno = TSDB_CODE_TDB_FILE_CORRUPTED; return TSDB_CODE_FAILED; } From c39a997f19f4fb356114c7716814cb127c8ab089 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Mon, 27 Jun 2022 21:37:09 +0800 Subject: [PATCH 63/73] test: add test case for tmq --- tests/system-test/7-tmq/stbTagFilter.py | 113 ++++++++++++++++++++++++ tests/system-test/7-tmq/tmqCommon.py | 17 ++-- 2 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 tests/system-test/7-tmq/stbTagFilter.py diff --git a/tests/system-test/7-tmq/stbTagFilter.py b/tests/system-test/7-tmq/stbTagFilter.py new file mode 100644 index 0000000000..2a2cb40c09 --- /dev/null +++ b/tests/system-test/7-tmq/stbTagFilter.py @@ -0,0 +1,113 @@ + +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db2', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1},{'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 10, + 'rowsPerTbl': 1000, + 'batchNum': 10, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + + topicNameList = ['topic1'] + expectRowsList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb") + tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'], ctbNum=paraDict['ctbNum'], ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("insert data") + tmqCom.asyncInsertData(paraDict) + + tdLog.info("create topics from stb with filter") + # queryString = "select ts, sin(c1), pow(c2,3) from %s.%s where t2 == 'beijing' or t2 == 'changsha'" %(paraDict['dbName'], paraDict['stbName']) + queryString = "select * from %s.%s where t2 == 'beijing' or t2 == 'changsha'" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + + # start tmq consume processor + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2 + topicList = topicNameList[0] + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:2000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + # tmqCom.getStartCommitNotifyFromTmqsim() + tmqCom.getStartConsumeNotifyFromTmqsim() + tdLog.info("create some new ctb") + paraDict['ctbStartIdx'] = paraDict['ctbStartIdx'] + paraDict['ctbNum'] + tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'], ctbNum=paraDict['ctbNum'], ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("insert data into new ctb") + pThread = tmqCom.asyncInsertData(paraDict) + + pThread.join() + tdLog.info("wait insert end") + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + if expectRowsList[0] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) + tdLog.exit("0 tmq consume rows error!") + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def run(self): + tdSql.prepare() + self.tmqCase1() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmqCommon.py b/tests/system-test/7-tmq/tmqCommon.py index 788ae3474c..9254f57c40 100644 --- a/tests/system-test/7-tmq/tmqCommon.py +++ b/tests/system-test/7-tmq/tmqCommon.py @@ -159,7 +159,7 @@ class TMQCom: tdLog.debug("complete to create %s.%s" %(dbName, stbName)) return - def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1): + def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1,ctbStartIdx=0): tsql.execute("use %s" %dbName) pre_create = "create table" sql = pre_create @@ -168,8 +168,10 @@ class TMQCom: tagValue = 'beijing' if (i % 2 == 0): tagValue = 'shanghai' + elif (i % 3 == 0): + tagValue = 'changsha' - sql += " %s%d using %s tags(%d, '%s')"%(ctbPrefix,i,stbName,i+1, tagValue) + sql += " %s%d using %s tags(%d, '%s')"%(ctbPrefix,i+ctbStartIdx,stbName,i+ctbStartIdx+1, tagValue) if (i > 0) and (i%100 == 0): tsql.execute(sql) sql = pre_create @@ -235,7 +237,7 @@ class TMQCom: tdLog.debug("insert data ............ [OK]") return - def insert_data_2(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs): + def insert_data_2(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs,ctbStartIdx=0): tdLog.debug("start to insert data ............") tsql.execute("use %s" %dbName) pre_insert = "insert into " @@ -245,7 +247,7 @@ class TMQCom: startTs = int(round(t * 1000)) #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) for i in range(ctbNum): - sql += " %s%d values "%(ctbPrefix,i) + sql += " %s%d values "%(ctbPrefix,i+ctbStartIdx) for j in range(rowsPerTbl): if (j % 2 == 0): sql += "(%d, %d, %d, 'tmqrow_%d', now) "%(startTs + j, j, j, j) @@ -254,7 +256,7 @@ class TMQCom: if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): tsql.execute(sql) if j < rowsPerTbl - 1: - sql = "insert into %s%d values " %(ctbPrefix,i) + sql = "insert into %s%d values " %(ctbPrefix,i+ctbStartIdx) else: sql = "insert into " #end sql @@ -354,7 +356,10 @@ class TMQCom: def threadFunctionForInsert(self, **paraDict): # create new connector for new tdSql instance in my thread newTdSql = tdCom.newTdSql() - self.insert_data_2(newTdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + if 'ctbStartIdx' in paraDict.keys(): + self.insert_data_2(newTdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"],paraDict["ctbStartIdx"]) + else: + self.insert_data_2(newTdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) return def asyncInsertData(self, paraDict): From 24a9d3e51617046fc43e1b8fb7e5b03e29cf7b11 Mon Sep 17 00:00:00 2001 From: jiacy-jcy Date: Tue, 28 Jun 2022 10:05:37 +0800 Subject: [PATCH 64/73] update alter_table.py and common.py --- tests/pytest/util/common.py | 10 +- tests/system-test/1-insert/alter_table.py | 515 +++++++++++----------- 2 files changed, 266 insertions(+), 259 deletions(-) diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index b43f87be29..e9db4a5da3 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -637,5 +637,13 @@ class TDCom: column_value_str = ", ".join(str(v) for v in column_value_list) insert_sql = f'insert into {dbname}.{tbname} values ({column_value_str});' tsql.execute(insert_sql) - + def getOneRow(self, location, containElm): + res_list = list() + if 0 <= location < tdSql.queryRows: + for row in tdSql.queryResult: + if row[location] == containElm: + res_list.append(row) + return res_list + else: + tdLog.exit(f"getOneRow out of range: row_index={location} row_count={self.query_row}") tdCom = TDCom() diff --git a/tests/system-test/1-insert/alter_table.py b/tests/system-test/1-insert/alter_table.py index a4e40d1b0b..0f7a830634 100644 --- a/tests/system-test/1-insert/alter_table.py +++ b/tests/system-test/1-insert/alter_table.py @@ -16,273 +16,272 @@ import string from util.log import * from util.cases import * from util.sql import * +from util import constant +from util.common import * +from util.sqlset import * class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) + self.setsql = TDSetSql() + self.ntbname = 'ntb' + self.stbname = 'stb' + self.binary_length = 20 # the length of binary for column_dict + self.nchar_length = 20 # the length of nchar for column_dict + self.column_dict = { + 'ts' : 'timestamp', + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': f'binary({self.binary_length})', + 'col13': f'nchar({self.nchar_length})' + } + self.tag_dict = { + 'ts_tag' : 'timestamp', + 't1': 'tinyint', + 't2': 'smallint', + 't3': 'int', + 't4': 'bigint', + 't5': 'tinyint unsigned', + 't6': 'smallint unsigned', + 't7': 'int unsigned', + 't8': 'bigint unsigned', + 't9': 'float', + 't10': 'double', + 't11': 'bool', + 't12': f'binary({self.binary_length})', + 't13': f'nchar({self.nchar_length})' + } + self.tag_list = [ + f'now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据"' + ] + self.tbnum = 1 + self.values_list = [ + f'now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据"' + ] + self.column_add_dict = { + 'col_time' : 'timestamp', + 'col_tinyint' : 'tinyint', + 'col_smallint' : 'smallint', + 'col_int' : 'int', + 'col_bigint' : 'bigint', + 'col_untinyint' : 'tinyint unsigned', + 'col_smallint' : 'smallint unsigned', + 'col_int' : 'int unsigned', + 'col_bigint' : 'bigint unsigned', + 'col_bool' : 'bool', + 'col_float' : 'float', + 'col_double' : 'double', + 'col_binary' : f'binary({constant.BINARY_LENGTH_MAX})', + 'col_nchar' : f'nchar({constant.NCAHR_LENGTH_MAX})' - def get_long_name(self, length, mode="mixed"): - """ - generate long name - mode could be numbers/letters/letters_mixed/mixed - """ - if mode == "numbers": - population = string.digits - elif mode == "letters": - population = string.ascii_letters.lower() - elif mode == "letters_mixed": - population = string.ascii_letters.upper() + string.ascii_letters.lower() - else: - population = string.ascii_letters.lower() + string.digits - return "".join(random.choices(population, k=length)) - - def alter_tb_tag_check(self): - tag_tinyint = random.randint(-127,129) - tag_int = random.randint(-2147483648,2147483647) - tag_smallint = random.randint(-32768,32768) - tag_bigint = random.randint(-2147483648,2147483647) - tag_untinyint = random.randint(0,256) - tag_unsmallint = random.randint(0,65536) - tag_unint = random.randint(0,4294967296) - tag_unbigint = random.randint(0,2147483647) - tag_binary = self.get_long_name(length=10, mode="letters") - tag_nchar = self.get_long_name(length=10, mode="letters") - dbname = self.get_long_name(length=10, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - stbname = self.get_long_name(length=3, mode="letters") - tbname = self.get_long_name(length=3, mode="letters") - tdSql.execute(f'create stable if not exists {dbname}.{stbname} (col_ts timestamp, c1 int) tags (tag_ts timestamp, t1 tinyint, t2 smallint, t3 int, \ - t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20))') - tdSql.execute(f'create table if not exists {dbname}.{tbname} using {dbname}.{stbname} tags(now, 1, 2, 3, 4, 5, 6, 7, 8, 9.9, 10.1, True,"abc123","涛思数据")') - tdSql.execute(f'insert into {dbname}.{tbname} values(now, 1)') - tdSql.execute(f'alter table {dbname}.{tbname} set tag tag_ts = 1640966400000') - tdSql.execute(f'alter table {dbname}.{tbname} set tag `t1` = 11') - tdSql.query(f'select * from {dbname}.{stbname}') - tdSql.checkData(0,3,11) - tdSql.execute(f'alter table {dbname}.{tbname} set tag t1 = {tag_tinyint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t2 = {tag_smallint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t3 = {tag_int}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t4 = {tag_bigint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t5 = {tag_untinyint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t6 = {tag_unsmallint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t7 = {tag_unint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t8 = {tag_unbigint}') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t11 = false') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t12 = "{tag_binary}"') - tdSql.execute(f'alter table {dbname}.{tbname} set tag t13 = "{tag_nchar}"') - tdSql.query(f'select * from {dbname}.{stbname}') - # bug TD-15899 - tdSql.checkData(0,2,'2022-01-01 00:00:00.000') - tdSql.checkData(0,3,tag_tinyint) - tdSql.checkData(0,4,tag_smallint) - tdSql.checkData(0,5,tag_int) - tdSql.checkData(0,6,tag_bigint) - tdSql.checkData(0,7,tag_untinyint) - tdSql.checkData(0,8,tag_unsmallint) - tdSql.checkData(0,9,tag_unint) - tdSql.checkData(0,10,tag_unbigint) + } + def alter_check_ntb(self): - tdSql.checkData(0,13,False) - tdSql.checkData(0,14,tag_binary) - tdSql.checkData(0,15,tag_nchar) + tdSql.prepare() + tdSql.execute(self.setsql.set_create_normaltable_sql(self.ntbname,self.column_dict)) + for i in self.values_list: + tdSql.execute(f'insert into {self.ntbname} values({i})') + for key,values in self.column_add_dict.items(): + tdSql.execute(f'alter table {self.ntbname} add column {key} {values}') + tdSql.query(f'describe {self.ntbname}') + tdSql.checkRows(len(self.column_dict)+1) + tdSql.query(f'select {key} from {self.ntbname}') + tdSql.checkRows(len(self.values_list)) + tdSql.execute(f'alter table {self.ntbname} drop column {key}') + tdSql.query(f'describe {self.ntbname}') + tdSql.checkRows(len(self.column_dict)) + tdSql.error(f'select {key} from {self.ntbname} ') + for key,values in self.column_dict.items(): + if 'binary' in values.lower(): + v = f'binary({self.binary_length+1})' + v_error = f'binary({self.binary_length-1})' + tdSql.error(f'alter table {self.ntbname} modify column {key} {v_error}') + tdSql.execute(f'alter table {self.ntbname} modify column {key} {v}') + tdSql.query(f'describe {self.ntbname}') + result = tdCom.getOneRow(1,'VARCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + elif 'nchar' in values.lower(): + v = f'nchar({self.binary_length+1})' + v_error = f'nchar({self.binary_length-1})' + tdSql.error(f'alter table {self.ntbname} modify column {key} {v_error}') + tdSql.execute(f'alter table {self.ntbname} modify column {key} {v}') + tdSql.query(f'describe {self.ntbname}') + result = tdCom.getOneRow(1,'NCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + else: + for v in self.column_dict.values(): + tdSql.error(f'alter table {self.ntbname} modify column {key} {v}') + for key,values in self.column_dict.items(): + rename_str = f'{tdCom.getLongName(constant.COL_NAME_LENGTH_MAX,"letters")}' + tdSql.execute(f'alter table {self.ntbname} rename column {key} {rename_str}') + tdSql.query(f'select {rename_str} from {self.ntbname}') + tdSql.checkRows(1) + + def alter_check_tb(self): + tag_tinyint = random.randint(constant.TINYINT_MIN,constant.TINYINT_MAX) + tag_smallint = random.randint(constant.SMALLINT_MIN,constant.SMALLINT_MAX) + tag_int = random.randint(constant.INT_MIN,constant.INT_MAX) + tag_bigint = random.randint(constant.BIGINT_MIN,constant.BIGINT_MAX) + tag_untinyint = random.randint(constant.TINYINT_UN_MIN,constant.TINYINT_UN_MAX) + tag_unsmallint = random.randint(constant.SMALLINT_UN_MIN,constant.SMALLINT_UN_MAX) + tag_unint = random.randint(constant.INT_UN_MIN,constant.INT_MAX) + tag_unbigint = random.randint(constant.BIGINT_UN_MIN,constant.BIGINT_UN_MAX) + tag_bool = random.randint(0,100)%2 + tag_float = random.uniform(constant.FLOAT_MIN,constant.FLOAT_MAX) + tag_double = random.uniform(constant.DOUBLE_MIN*(1E-300),constant.DOUBLE_MAX*(1E-300)) + tag_binary = tdCom.getLongName(self.binary_length) + tag_nchar = tdCom.getLongName(self.binary_length) + modify_column_dict = { + 'ts1' : 'timestamp', + 'c1': 'tinyint', + 'c2': 'smallint', + 'c3': 'int', + 'c4': 'bigint', + 'c5': 'tinyint unsigned', + 'c6': 'smallint unsigned', + 'c7': 'int unsigned', + 'c8': 'bigint unsigned', + 'c9': 'float', + 'c10': 'double', + 'c11': 'bool', + 'c12': f'binary({self.binary_length})', + 'c13': f'nchar({self.nchar_length})' + } + tdSql.prepare() + tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict)) + for i in range(self.tbnum): + tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({self.tag_list[i]})') + for j in self.values_list: + tdSql.execute(f'insert into {self.stbname}_{i} values({j})') + for i in range(self.tbnum): + for k,v in modify_column_dict.items(): + tdSql.error(f'alter table {self.stbname}_{i} add column {k} {v}') + for k in self.column_dict.keys(): + tdSql.error(f'alter table {self.stbname}_{i} drop column {k}') + for k,v in self.column_dict.items(): + if 'binary' in v.lower(): + values = [f'binary({self.binary_length+1})', f'binary({self.binary_length-1})'] + for j in values: + tdSql.error(f'alter table {self.stbname}_{i} modify {k} {j}') + elif 'nchar' in v.lower(): + values = [f'nchar({self.nchar_length+1})', f'binary({self.nchar_length-1})'] + for j in values: + tdSql.error(f'alter table {self.stbname}_{i} modify {k} {j}') + else: + for values in self.column_dict.values(): + tdSql.error(f'alter table {self.stbname}_{i} modify column {k} {values}') + for k,v in self.tag_dict.items(): + if v.lower() == 'tinyint': + self.tag_check(i,k,tag_tinyint) + elif v.lower() == 'smallint': + self.tag_check(i,k,tag_smallint) + elif v.lower() == 'int': + self.tag_check(i,k,tag_int) + elif v.lower() == 'bigint': + self.tag_check(i,k,tag_bigint) + elif v.lower() == 'tinyint unsigned': + self.tag_check(i,k,tag_untinyint) + elif v.lower() == 'smallint unsigned': + self.tag_check(i,k,tag_unsmallint) + elif v.lower() == 'int unsigned': + self.tag_check(i,k,tag_unint) + elif v.lower() == 'bigint unsigned': + self.tag_check(i,k,tag_unbigint) + elif v.lower() == 'bool': + self.tag_check(i,k,tag_bool) + elif v.lower() == 'float': + tdSql.execute(f'alter table {self.stbname}_{i} set tag {k} = {tag_float}') + tdSql.query(f'select {k} from {self.stbname}_{i}') + if abs(tdSql.queryResult[0][0] - tag_float)/tag_float<=0.0001: + tdSql.checkEqual(tdSql.queryResult[0][0],tdSql.queryResult[0][0]) + else: + tdLog.exit(f'select {k} from {self.stbname}_{i},data check failure') + elif v.lower() == 'double': + tdSql.execute(f'alter table {self.stbname}_{i} set tag {k} = {tag_double}') + tdSql.query(f'select {k} from {self.stbname}_{i}') + if abs(tdSql.queryResult[0][0] - tag_double)/tag_double<=0.0001: + tdSql.checkEqual(tdSql.queryResult[0][0],tdSql.queryResult[0][0]) + else: + tdLog.exit(f'select {k} from {self.stbname}_{i},data check failure') + elif 'binary' in v.lower(): + tdSql.execute(f'alter table {self.stbname}_{i} set tag {k} = "{tag_binary}"') + tdSql.query(f'select {k} from {self.stbname}_{i}') + tdSql.checkData(0,0,tag_binary) + elif 'nchar' in v.lower(): + tdSql.execute(f'alter table {self.stbname}_{i} set tag {k} = "{tag_nchar}"') + tdSql.query(f'select {k} from {self.stbname}_{i}') + tdSql.checkData(0,0,tag_nchar) + + def tag_check(self,tb_no,tag,values): + tdSql.execute(f'alter table {self.stbname}_{tb_no} set tag {tag} = {values}') + tdSql.query(f'select {tag} from {self.stbname}_{tb_no}') + tdSql.checkData(0,0,values) + def alter_check_stb(self): + tdSql.prepare() + tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict)) + for i in range(self.tbnum): + tdSql.execute(f'create table {self.stbname}_{i} using {self.stbname} tags({self.tag_list[i]})') + for j in self.values_list: + tdSql.execute(f'insert into {self.stbname}_{i} values({j})') + for key,values in self.column_add_dict.items(): + tdSql.execute(f'alter table {self.stbname} add column {key} {values}') + tdSql.query(f'describe {self.stbname}') + tdSql.checkRows(len(self.column_dict)+len(self.tag_dict)+1) + for i in range(self.tbnum): + tdSql.query(f'describe {self.stbname}_{i}') + tdSql.checkRows(len(self.column_dict)+len(self.tag_dict)+1) + tdSql.query(f'select {key} from {self.stbname}_{i}') + tdSql.checkRows(len(self.values_list)) + tdSql.execute(f'alter table {self.stbname} drop column {key}') + tdSql.query(f'describe {self.stbname}') + tdSql.checkRows(len(self.column_dict)+len(self.tag_dict)) + for i in range(self.tbnum): + tdSql.query(f'describe {self.stbname}_{i}') + tdSql.checkRows(len(self.column_dict)+len(self.tag_dict)) + tdSql.error(f'select {key} from {self.stbname} ') + for key,values in self.column_dict.items(): + if 'binary' in values.lower(): + v = f'binary({self.binary_length+1})' + v_error = f'binary({self.binary_length-1})' + tdSql.error(f'alter table {self.stbname} modify column {key} {v_error}') + tdSql.execute(f'alter table {self.stbname} modify column {key} {v}') + tdSql.query(f'describe {self.stbname}') + result = tdCom.getOneRow(1,'VARCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + for i in range(self.tbnum): + tdSql.query(f'describe {self.stbname}_{i}') + result = tdCom.getOneRow(1,'VARCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + elif 'nchar' in values.lower(): + v = f'nchar({self.binary_length+1})' + v_error = f'nchar({self.binary_length-1})' + tdSql.error(f'alter table {self.stbname} modify column {key} {v_error}') + tdSql.execute(f'alter table {self.stbname} modify column {key} {v}') + tdSql.query(f'describe {self.stbname}') + result = tdCom.getOneRow(1,'NCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + for i in range(self.tbnum): + tdSql.query(f'describe {self.stbname}') + result = tdCom.getOneRow(1,'NCHAR') + tdSql.checkEqual(result[0][2],self.binary_length+1) + else: + for v in self.column_dict.values(): + tdSql.error(f'alter table {self.stbname} modify column {key} {v}') - # bug TD-16211 insert length more than setting binary and nchar - # error_tag_binary = self.get_long_name(length=21, mode="letters") - # error_tag_nchar = self.get_long_name(length=21, mode="letters") - # tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{error_tag_binary}"') - # tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{error_tag_nchar}"') - error_tag_binary = self.get_long_name(length=25, mode="letters") - error_tag_nchar = self.get_long_name(length=25, mode="letters") - tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{error_tag_binary}"') - tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{error_tag_nchar}"') - # bug TD-16210 modify binary to nchar - tdSql.error(f'alter table {dbname}.{tbname} modify tag t12 nchar(10)') - tdSql.execute(f"drop database {dbname}") - def alter_ntb_column_check(self): - ''' - alter ntb column check - ''' - dbname = self.get_long_name(length=10, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - tbname = self.get_long_name(length=3, mode="letters") - tdLog.info('------------------normal table column check---------------------') - tdLog.info(f'-----------------create normal table {tbname}-------------------') - tdSql.execute(f'create table if not exists {dbname}.{tbname} (ts timestamp, c1 tinyint, c2 smallint, c3 int, \ - c4 bigint, c5 tinyint unsigned, c6 smallint unsigned, c7 int unsigned, c8 bigint unsigned, c9 float, c10 double, c11 bool,c12 binary(20),c13 nchar(20))') - tdSql.execute(f'insert into {dbname}.{tbname} values (now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")') - # bug TD-15757 - tdSql.execute(f'alter table {dbname}.{tbname} add column c14 int') - tdSql.query(f'select c14 from {dbname}.{tbname}') - tdSql.checkRows(1) - tdSql.execute(f'alter table {dbname}.{tbname} add column `c15` int') - tdSql.query(f'select c15 from {dbname}.{tbname}') - tdSql.checkRows(1) - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkRows(16) - tdSql.execute(f'alter table {dbname}.{tbname} drop column c14') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkRows(15) - tdSql.execute(f'alter table {dbname}.{tbname} drop column `c15`') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkRows(14) - #! TD-16422 - # tdSql.execute(f'alter table {dbname}.{tbname} add column c16 binary(10)') - # tdSql.query(f'describe {dbname}.{tbname}') - # tdSql.checkRows(15) - # tdSql.checkEqual(tdSql.queryResult[14][2],10) - # tdSql.execute(f'alter table {dbname}.{tbname} drop column c16') - - # tdSql.execute(f'alter table {dbname}.{tbname} add column c16 nchar(10)') - # tdSql.query(f'describe {dbname}.{tbname}') - # tdSql.checkRows(15) - # tdSql.checkEqual(tdSql.queryResult[14][2],10) - # tdSql.execute(f'alter table {dbname}.{tbname} drop column c16') - - - tdSql.execute(f'alter table {dbname}.{tbname} modify column c12 binary(30)') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(12,2,30) - tdSql.execute(f'alter table {dbname}.{tbname} modify column `c12` binary(35)') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(12,2,35) - tdSql.error(f'alter table {dbname}.{tbname} modify column c12 binary(34)') - tdSql.error(f'alter table {dbname}.{tbname} modify column c12 nchar(10)') - tdSql.error(f'alter table {dbname}.{tbname} modify column c12 int') - tdSql.execute(f'alter table {dbname}.{tbname} modify column c13 nchar(30)') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(13,2,30) - tdSql.execute(f'alter table {dbname}.{tbname} modify column `c13` nchar(35)') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(13,2,35) - tdSql.error(f'alter table {dbname}.{tbname} modify column c13 nchar(34)') - tdSql.error(f'alter table {dbname}.{tbname} modify column c13 binary(10)') - tdSql.execute(f'alter table {dbname}.{tbname} rename column c1 c21') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(1,0,'c21') - # !bug TD-16423 - # tdSql.error(f'select c1 from {dbname}.{tbname}') - # tdSql.query(f'select c21 from {dbname}.{tbname}') - # tdSql.checkData(0,1,1) - tdSql.execute(f'alter table {dbname}.{tbname} rename column `c21` c1') - tdSql.query(f'describe {dbname}.{tbname}') - tdSql.checkData(1,0,'c1') - # !bug TD-16423 - # tdSql.error(f'select c1 from {dbname}.{tbname}') - # tdSql.query(f'select c1 from {dbname}.{tbname}') - # tdSql.checkData(0,1,1) - tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bigint') - tdSql.error(f'alter table {dbname}.{tbname} modify column c1 double') - tdSql.error(f'alter table {dbname}.{tbname} modify column c4 int') - tdSql.error(f'alter table {dbname}.{tbname} modify column `c1` double') - tdSql.error(f'alter table {dbname}.{tbname} modify column c9 double') - tdSql.error(f'alter table {dbname}.{tbname} modify column c10 float') - tdSql.error(f'alter table {dbname}.{tbname} modify column c1 bool') - tdSql.error(f'alter table {dbname}.{tbname} modify column c1 binary(10)') - tdSql.execute(f'drop database {dbname}') - def alter_stb_column_check(self): - dbname = self.get_long_name(length=10, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - stbname = self.get_long_name(length=3, mode="letters") - tbname = self.get_long_name(length=3, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - tdSql.execute(f'use {dbname}') - tdSql.execute( - f'create table {stbname} (ts timestamp, c1 tinyint, c2 smallint, c3 int, \ - c4 bigint, c5 tinyint unsigned, c6 smallint unsigned, c7 int unsigned, c8 bigint unsigned, c9 float, c10 double, c11 bool,c12 binary(20),c13 nchar(20)) tags(t0 int) ') - tdSql.execute(f'create table {tbname} using {stbname} tags(1)') - tdSql.execute(f'insert into {tbname} values (now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")') - tdSql.execute(f'alter table {stbname} add column c14 int') - tdSql.query(f'select c14 from {stbname}') - tdSql.checkRows(1) - tdSql.execute(f'alter table {stbname} add column `c15` int') - tdSql.query(f'select c15 from {stbname}') - tdSql.checkRows(1) - tdSql.query(f'describe {stbname}') - tdSql.checkRows(17) - tdSql.execute(f'alter table {stbname} drop column c14') - tdSql.query(f'describe {stbname}') - tdSql.checkRows(16) - tdSql.execute(f'alter table {stbname} drop column `c15`') - tdSql.query(f'describe {stbname}') - tdSql.checkRows(15) - tdSql.execute(f'alter table {stbname} modify column c12 binary(30)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(12,2,30) - tdSql.execute(f'alter table {stbname} modify column `c12` binary(35)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(12,2,35) - tdSql.error(f'alter table {stbname} modify column `c12` binary(34)') - tdSql.execute(f'alter table {stbname} modify column c13 nchar(30)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(13,2,30) - tdSql.error(f'alter table {stbname} modify column c13 nchar(29)') - tdSql.error(f'alter table {stbname} rename column c1 c21') - tdSql.error(f'alter table {stbname} modify column c1 int') - tdSql.error(f'alter table {stbname} modify column c4 int') - tdSql.error(f'alter table {stbname} modify column c8 int') - tdSql.error(f'alter table {stbname} modify column c1 unsigned int') - tdSql.error(f'alter table {stbname} modify column c9 double') - tdSql.error(f'alter table {stbname} modify column c10 float') - tdSql.error(f'alter table {stbname} modify column c11 int') - tdSql.execute(f'drop database {dbname}') - def alter_stb_tag_check(self): - dbname = self.get_long_name(length=10, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - stbname = self.get_long_name(length=3, mode="letters") - tbname = self.get_long_name(length=3, mode="letters") - tdSql.execute(f'create database if not exists {dbname}') - tdSql.execute(f'use {dbname}') - tdSql.execute( - f'create table {stbname} (ts timestamp, c1 int) tags(ts_tag timestamp, t1 tinyint, t2 smallint, t3 int, \ - t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20)) ') - tdSql.execute(f'create table {tbname} using {stbname} tags(now,1,2,3,4,5,6,7,8,9.9,10.1,true,"abcd","涛思数据")') - tdSql.execute(f'insert into {tbname} values(now,1)') - - tdSql.execute(f'alter table {stbname} add tag t14 int') - tdSql.query(f'select t14 from {stbname}') - tdSql.checkRows(1) - tdSql.execute(f'alter table {stbname} add tag `t15` int') - tdSql.query(f'select t14 from {stbname}') - tdSql.checkRows(1) - tdSql.query(f'describe {stbname}') - tdSql.checkRows(18) - tdSql.execute(f'alter table {stbname} drop tag t14') - tdSql.query(f'describe {stbname}') - tdSql.checkRows(17) - tdSql.execute(f'alter table {stbname} drop tag `t15`') - tdSql.query(f'describe {stbname}') - tdSql.checkRows(16) - tdSql.execute(f'alter table {stbname} modify tag t12 binary(30)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(14,2,30) - tdSql.execute(f'alter table {stbname} modify tag `t12` binary(35)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(14,2,35) - tdSql.error(f'alter table {stbname} modify tag `t12` binary(34)') - tdSql.execute(f'alter table {stbname} modify tag t13 nchar(30)') - tdSql.query(f'describe {stbname}') - tdSql.checkData(15,2,30) - tdSql.error(f'alter table {stbname} modify tag t13 nchar(29)') - tdSql.execute(f'alter table {stbname} rename tag t1 t21') - tdSql.query(f'describe {stbname}') - tdSql.checkData(3,0,'t21') - tdSql.execute(f'alter table {stbname} rename tag `t21` t1') - tdSql.query(f'describe {stbname}') - tdSql.checkData(3,0,'t1') - - for i in ['bigint','unsigned int','float','double','binary(10)','nchar(10)']: - for j in [1,2,3]: - tdSql.error(f'alter table {stbname} modify tag t{j} {i}') - for i in ['int','unsigned int','float','binary(10)','nchar(10)']: - tdSql.error(f'alter table {stbname} modify tag t8 {i}') - tdSql.error(f'alter table {stbname} modify tag t4 int') - tdSql.execute(f'drop database {dbname}') def run(self): - self.alter_tb_tag_check() - self.alter_ntb_column_check() - self.alter_stb_column_check() - self.alter_stb_tag_check() + self.alter_check_ntb() + self.alter_check_tb() + self.alter_check_stb() def stop(self): tdSql.close() From 0c5342730c6d0d072e788abfce39fbef24cf0de8 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 28 Jun 2022 10:34:51 +0800 Subject: [PATCH 65/73] feat: refactor rpc code --- source/libs/transport/inc/transComm.h | 2 +- source/libs/transport/src/transCli.c | 10 +++++----- source/libs/transport/src/transComm.c | 2 +- source/libs/transport/src/transSvr.c | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 963a85922f..55db0b129a 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -229,7 +229,7 @@ typedef struct { SAsyncPool* transCreateAsyncPool(uv_loop_t* loop, int sz, void* arg, AsyncCB cb); void transDestroyAsyncPool(SAsyncPool* pool); -int transSendAsync(SAsyncPool* pool, queue* mq); +int transAsyncSend(SAsyncPool* pool, queue* mq); #define TRANS_DESTROY_ASYNC_POOL_MSG(pool, msgType, freeFunc) \ do { \ diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index ab08ce82a8..aba2e6957b 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -967,7 +967,7 @@ void cliSendQuit(SCliThrd* thrd) { // cli can stop gracefully SCliMsg* msg = taosMemoryCalloc(1, sizeof(SCliMsg)); msg->type = Quit; - transSendAsync(thrd->asyncPool, &msg->q); + transAsyncSend(thrd->asyncPool, &msg->q); } void cliWalkCb(uv_handle_t* handle, void* arg) { if (!uv_is_closing(handle)) { @@ -1138,7 +1138,7 @@ void transReleaseCliHandle(void* handle) { cmsg->msg = tmsg; cmsg->type = Release; - transSendAsync(pThrd->asyncPool, &cmsg->q); + transAsyncSend(pThrd->asyncPool, &cmsg->q); return; } @@ -1171,7 +1171,7 @@ void transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra STraceId* trace = &pReq->info.traceId; tGTrace("%s send request at thread:%08" PRId64 ", dst: %s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); - ASSERT(transSendAsync(pThrd->asyncPool, &(cliMsg->q)) == 0); + ASSERT(transAsyncSend(pThrd->asyncPool, &(cliMsg->q)) == 0); return; } @@ -1205,7 +1205,7 @@ void transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransM tGTrace("%s send request at thread:%08" PRId64 ", dst: %s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); - transSendAsync(pThrd->asyncPool, &(cliMsg->q)); + transAsyncSend(pThrd->asyncPool, &(cliMsg->q)); tsem_wait(sem); tsem_destroy(sem); taosMemoryFree(sem); @@ -1234,7 +1234,7 @@ void transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) { SCliThrd* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[i]; tDebug("%s update epset at thread:%08" PRId64 "", pTransInst->label, thrd->pid); - transSendAsync(thrd->asyncPool, &(cliMsg->q)); + transAsyncSend(thrd->asyncPool, &(cliMsg->q)); } } #endif diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index bff7d79bd3..fbe0951a46 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -202,7 +202,7 @@ void transDestroyAsyncPool(SAsyncPool* pool) { taosMemoryFree(pool->asyncs); taosMemoryFree(pool); } -int transSendAsync(SAsyncPool* pool, queue* q) { +int transAsyncSend(SAsyncPool* pool, queue* q) { int idx = pool->index; idx = idx % pool->nAsync; // no need mutex here diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 892d32696e..08363b3c7c 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -999,7 +999,7 @@ void sendQuitToWorkThrd(SWorkThrd* pThrd) { SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg)); msg->type = Quit; tDebug("server send quit msg to work thread"); - transSendAsync(pThrd->asyncPool, &msg->q); + transAsyncSend(pThrd->asyncPool, &msg->q); } void transCloseServer(void* arg) { @@ -1070,7 +1070,7 @@ void transReleaseSrvHandle(void* handle) { m->type = Release; tTrace("%s conn %p start to release", transLabel(pThrd->pTransInst), exh->handle); - transSendAsync(pThrd->asyncPool, &m->q); + transAsyncSend(pThrd->asyncPool, &m->q); transReleaseExHandle(refMgt, refId); return; _return1: @@ -1099,7 +1099,7 @@ void transSendResponse(const STransMsg* msg) { STraceId* trace = (STraceId*)&msg->info.traceId; tGTrace("conn %p start to send resp (1/2)", exh->handle); - transSendAsync(pThrd->asyncPool, &m->q); + transAsyncSend(pThrd->asyncPool, &m->q); transReleaseExHandle(refMgt, refId); return; _return1: @@ -1128,7 +1128,7 @@ void transRegisterMsg(const STransMsg* msg) { m->type = Register; tTrace("%s conn %p start to register brokenlink callback", transLabel(pThrd->pTransInst), exh->handle); - transSendAsync(pThrd->asyncPool, &m->q); + transAsyncSend(pThrd->asyncPool, &m->q); transReleaseExHandle(refMgt, refId); return; From 4d05053e66f86cc1322d0d53c0a0ff0e511bd925 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 27 Jun 2022 19:41:13 +0800 Subject: [PATCH 66/73] fix(query): add mode function --- source/libs/function/src/builtinsimpl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index ca663ff809..06f24f39e7 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -4737,17 +4737,17 @@ static void doModeAdd(SModeInfo* pInfo, char* data, bool isNull) { } int32_t hashKeyBytes = IS_VAR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; - SModeItem* pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); + SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); if (pHashItem == NULL) { int32_t size = sizeof(SModeItem) + pInfo->colBytes; SModeItem* pItem = (SModeItem*)(pInfo->pItems + pInfo->numOfPoints * size); memcpy(pItem->data, data, pInfo->colBytes); pItem->count += 1; - taosHashPut(pInfo->pHash, data, hashKeyBytes, (char*)pItem, sizeof(SModeItem*)); + taosHashPut(pInfo->pHash, data, hashKeyBytes, &pItem, sizeof(SModeItem*)); pInfo->numOfPoints++; } else { - pHashItem->count += 1; + (*pHashItem)->count += 1; } } @@ -4771,6 +4771,8 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) { } } + SET_VAL(pResInfo, 1, 1); + return TSDB_CODE_SUCCESS; } @@ -4789,13 +4791,12 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { maxCount = pItem->count; resIndex = i; } else if (pItem->count == maxCount) { - colDataAppendNULL(pCol, currentRow); - return pResInfo->numOfRes; + resIndex = -1; } } SModeItem* pResItem = (SModeItem*)(pInfo->pItems + resIndex * (sizeof(SModeItem) + pInfo->colBytes)); - colDataAppend(pCol, currentRow, pResItem->data, false); + colDataAppend(pCol, currentRow, pResItem->data, (resIndex == -1) ? true : false); return pResInfo->numOfRes; } From f80af20d3b864fb5941b4a3e0f7c243c680115e0 Mon Sep 17 00:00:00 2001 From: slzhou Date: Tue, 28 Jun 2022 10:55:34 +0800 Subject: [PATCH 67/73] fix: add merge parent project and child project optimization --- source/libs/planner/src/planOptimizer.c | 48 ++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 9481c26d7a..eb0f02c92c 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1375,19 +1375,57 @@ static bool mergeProjectsMayBeOptimized(SLogicNode* pNode) { } typedef struct SMergeProjectionsContext { - + SProjectLogicNode* pChildProj; + int32_t errCode; } SMergeProjectionsContext; static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) { + SMergeProjectionsContext* pCxt = pContext; + SProjectLogicNode* pChildProj = pCxt->pChildProj; + if (QUERY_NODE_COLUMN == nodeType(*pNode)) { + SNode* pTarget; + FOREACH(pTarget, ((SLogicNode*)pChildProj)->pTargets) { + if (nodesEqualNode(pTarget, *pNode)) { + SNode* pProjection; + FOREACH(pProjection, pChildProj->pProjections) { + if (0 == strcmp(((SColumnNode*)pTarget)->colName, ((SExprNode*)pProjection)->aliasName)) { + SNode* pExpr = nodesCloneNode(pProjection); + if (pExpr == NULL) { + pCxt->errCode = terrno; + return DEAL_RES_ERROR; + } + nodesDestroyNode(*pNode); + *pNode = pExpr; + } + } + } + } + return DEAL_RES_IGNORE_CHILD; + } return DEAL_RES_CONTINUE; } static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pProjectNode) { SProjectLogicNode* pProject = (SProjectLogicNode*)pProjectNode; - SProjectLogicNode* pChild = (SProjectLogicNode*)nodesListGetNode(pProjectNode->pChildren, 0); - SMergeProjectionsContext cxt = {}; - nodesRewriteExprs(pChild->pProjections, mergeProjectionsExpr, &cxt); - return TSDB_CODE_SUCCESS; + SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pProjectNode->pChildren, 0); + SMergeProjectionsContext cxt = {.pChildProj = (SProjectLogicNode*)pChild}; + + nodesRewriteExprs(pProject->pProjections, mergeProjectionsExpr, &cxt); + int32_t code = cxt.errCode; + if (TSDB_CODE_SUCCESS == code) { + if (1 == LIST_LENGTH(pChild->pChildren)) { + SLogicNode* pGrandChild = (SLogicNode*)nodesListGetNode(pChild->pChildren, 0); + code = replaceLogicNode(pLogicSubplan, pChild, pGrandChild); + } else { // no grand child + NODES_CLEAR_LIST(pProjectNode->pChildren); + } + } + + if (TSDB_CODE_SUCCESS == code) { + NODES_CLEAR_LIST(pChild->pChildren); + } + nodesDestroyNode((SNode*)pChild); + return code; } static int32_t mergeProjectsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { From 97bddc916edd99dd6f6bf0d7f389e888de88b81e Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Tue, 28 Jun 2022 11:00:45 +0800 Subject: [PATCH 68/73] test: sim test timeout --- tests/script/test-all.bat | 2 +- tests/script/wtest.bat | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/script/test-all.bat b/tests/script/test-all.bat index 81c1f21c04..1c698449c6 100644 --- a/tests/script/test-all.bat +++ b/tests/script/test-all.bat @@ -19,7 +19,7 @@ for /F "usebackq tokens=*" %%i in (!caseFile!) do ( call :GetTimeSeconds !time! set time1=!_timeTemp! echo Start at !time! - call !line:./test.sh=wtest.bat! > result_!a!.txt 2>error_!a!.txt + call !line:./test.sh=wtest.bat! > result_!a!.txt 2>error_!a!.txt || set /a errorlevel=8 if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && set /a exitNum=8 && echo %%i >>failed.txt ) else ( call :colorEcho 0a "Success" &echo. ) ) ) diff --git a/tests/script/wtest.bat b/tests/script/wtest.bat index 79daf01295..25c344577a 100644 --- a/tests/script/wtest.bat +++ b/tests/script/wtest.bat @@ -56,8 +56,14 @@ echo charset UTF-8 >> %TAOS_CFG% set "FILE_NAME=testSuite.sim" if "%1" == "-f" set "FILE_NAME=%2" +set FILE_NAME=%FILE_NAME:/=\% + +start cmd /k "timeout /t 600 && taskkill /f /im tsim.exe & exit /b" rem echo FILE_NAME: %FILE_NAME% echo ExcuteCmd: %tsim% -c %CFG_DIR% -f %FILE_NAME% +set result=false +%TSIM% -c %CFG_DIR% -f %FILE_NAME% && set result=true -%TSIM% -c %CFG_DIR% -f %FILE_NAME% \ No newline at end of file +tasklist | grep timeout && taskkill /f /im timeout.exe +if "%result%" == "true" ( exit /b ) else ( exit /b 8 ) \ No newline at end of file From 4c410bd5eceda845ed6850d986cbe516f7a4cc80 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Tue, 28 Jun 2022 11:33:14 +0800 Subject: [PATCH 69/73] refactor(sync): refactor snapshot code --- source/libs/sync/inc/syncSnapshot.h | 4 +- source/libs/sync/src/syncAppendEntriesReply.c | 28 +- source/libs/sync/src/syncSnapshot.c | 247 ++++++++++++------ 3 files changed, 168 insertions(+), 111 deletions(-) diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index 55e0755a89..14688f8912 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -57,7 +57,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI void snapshotSenderDestroy(SSyncSnapshotSender *pSender); bool snapshotSenderIsStart(SSyncSnapshotSender *pSender); void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void *pReader); -void snapshotSenderStop(SSyncSnapshotSender *pSender); +void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish); int32_t snapshotSend(SSyncSnapshotSender *pSender); int32_t snapshotReSend(SSyncSnapshotSender *pSender); @@ -82,7 +82,7 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver); void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg); bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver); -void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver, bool apply); +void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver); cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver); char *snapshotReceiver2Str(SSyncSnapshotReceiver *pReceiver); diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index b7122b9c52..10f2745651 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -240,7 +240,10 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(pMsg->srcId)); ASSERT(pSender != NULL); - SSnapshot snapshot; + SSnapshot snapshot = {.data = NULL, + .lastApplyIndex = SYNC_INDEX_INVALID, + .lastApplyTerm = 0, + .lastConfigIndex = SYNC_INDEX_INVALID}; void* pReader = NULL; ths->pFsm->FpGetSnapshot(ths->pFsm, &snapshot, NULL, &pReader); if (snapshot.lastApplyIndex >= SYNC_INDEX_BEGIN && nextIndex <= snapshot.lastApplyIndex + 1 && @@ -249,10 +252,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries ASSERT(pReader != NULL); snapshotSenderStart(pSender, snapshot, pReader); - char* eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender start"); - syncNodeEventLog(ths, eventLog); - taosMemoryFree(eventLog); - } else { // no snapshot if (pReader != NULL) { @@ -260,23 +259,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries } } - /* - bool hasSnapshot = syncNodeHasSnapshot(ths); - SSnapshot snapshot; - ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot); - - // start sending snapshot first time - // start here, stop by receiver - if (hasSnapshot && nextIndex <= snapshot.lastApplyIndex + 1 && !snapshotSenderIsStart(pSender) && - pMsg->privateTerm < pSender->privateTerm) { - snapshotSenderStart(pSender); - - char* eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender start"); - syncNodeEventLog(ths, eventLog); - taosMemoryFree(eventLog); - } - */ - SyncIndex sentryIndex = pSender->snapshot.lastApplyIndex + 1; // update nextIndex to sentryIndex @@ -300,5 +282,5 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries syncIndexMgrLog2("recv sync-append-entries-reply, after pNextIndex:", ths->pNextIndex); syncIndexMgrLog2("recv sync-append-entries-reply, after pMatchIndex:", ths->pMatchIndex); - return ret; + return 0; } \ No newline at end of file diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 39e972c4c4..7b15be2d14 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -24,6 +24,7 @@ //---------------------------------- static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg); +static void snapshotReceiverGotData(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg); //---------------------------------- SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaIndex) { @@ -50,7 +51,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &(pSender->snapshot)); pSender->finish = false; } else { - sError("vgId:%d cannot create snapshot sender", pSyncNode->vgId); + sError("vgId:%d, cannot create snapshot sender", pSyncNode->vgId); } return pSender; @@ -127,7 +128,7 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void syncEntryDestory(pEntry); } else { if (pSender->snapshot.lastConfigIndex == pSender->pSyncNode->pRaftCfg->lastConfigIndex) { - sTrace("vgId:%d sync sender get cfg from local", pSender->pSyncNode->vgId); + sTrace("vgId:%d, sync sender get cfg from local", pSender->pSyncNode->vgId); pSender->lastConfig = pSender->pSyncNode->pRaftCfg->cfg; getLastConfig = true; } @@ -176,13 +177,13 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshot snapshot, void // event log do { - char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender send"); + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender start"); syncNodeEventLog(pSender->pSyncNode, eventLog); taosMemoryFree(eventLog); } while (0); } -void snapshotSenderStop(SSyncSnapshotSender *pSender) { +void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { // close reader if (pSender->pReader != NULL) { int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader); @@ -199,6 +200,14 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender) { // update flag pSender->start = false; + pSender->finish = finish; + + // event log + do { + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender stop"); + syncNodeEventLog(pSender->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } // when sender receive ack, call this function to send msg from seq @@ -386,7 +395,7 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from pReceiver->snapshot.lastConfigIndex = SYNC_INDEX_INVALID; } else { - sError("vgId:%d cannot create snapshot receiver", pSyncNode->vgId); + sError("vgId:%d, cannot create snapshot receiver", pSyncNode->vgId); } return pReceiver; @@ -409,9 +418,9 @@ void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) { bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver) { return pReceiver->start; } -// static do start +// static do start by privateTerm, pBeginMsg // receive first snapshot data -// privateTerm, pBeginMsg +// write first block data static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg) { // update state @@ -419,6 +428,7 @@ static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncTerm p pReceiver->privateTerm = privateTerm; pReceiver->ack = SYNC_SNAPSHOT_SEQ_BEGIN; pReceiver->fromId = pBeginMsg->srcId; + pReceiver->start = true; // update snapshot pReceiver->snapshot.lastApplyIndex = pBeginMsg->lastIndex; @@ -429,8 +439,16 @@ static void snapshotReceiverDoStart(SSyncSnapshotReceiver *pReceiver, SyncTerm p ASSERT(pReceiver->pWriter == NULL); int32_t ret = pReceiver->pSyncNode->pFsm->FpSnapshotStartWrite(pReceiver->pSyncNode->pFsm, &(pReceiver->pWriter)); ASSERT(ret == 0); + + // event log + do { + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver start"); + syncNodeEventLog(pReceiver->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } +// force stop static void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver) { // force close, abandon incomplete data if (pReceiver->pWriter != NULL) { @@ -441,33 +459,35 @@ static void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceiver) { } pReceiver->start = false; + + // event log + do { + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver force stop"); + syncNodeEventLog(pReceiver->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } // if receiver receive msg from seq = SYNC_SNAPSHOT_SEQ_BEGIN, start receiver // if already start, force close, start again void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateTerm, SyncSnapshotSend *pBeginMsg) { if (!snapshotReceiverIsStart(pReceiver)) { - // start + // first start snapshotReceiverDoStart(pReceiver, privateTerm, pBeginMsg); - pReceiver->start = true; } else { // already start - sInfo("snapshot recv, receiver already start"); + sInfo("vgId:%d, snapshot recv, receiver already start", pReceiver->pSyncNode->vgId); // force close, abandon incomplete data - int32_t ret = - pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false); - ASSERT(ret == 0); - pReceiver->pWriter = NULL; + snapshotReceiverForceStop(pReceiver); // start again snapshotReceiverDoStart(pReceiver, privateTerm, pBeginMsg); - pReceiver->start = true; } } -void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver, bool apply) { +void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { if (pReceiver->pWriter != NULL) { int32_t ret = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, false); @@ -477,8 +497,69 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver, bool apply) { pReceiver->start = false; - if (apply) { - // ++(pReceiver->privateTerm); + // event log + do { + SSnapshot snapshot; + pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver stop"); + syncNodeEventLog(pReceiver->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); +} + +static void snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { + ASSERT(pMsg->seq == SYNC_SNAPSHOT_SEQ_END); + + if (pReceiver->pWriter != NULL) { + int32_t code = 0; + if (pMsg->dataLen > 0) { + code = pReceiver->pSyncNode->pFsm->FpSnapshotDoWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, pMsg->data, + pMsg->dataLen); + ASSERT(code == 0); + } + + code = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, true); + ASSERT(code == 0); + pReceiver->pWriter = NULL; + } + + pReceiver->ack = SYNC_SNAPSHOT_SEQ_END; + + // update commit index + if (pReceiver->snapshot.lastApplyIndex > pReceiver->pSyncNode->commitIndex) { + pReceiver->pSyncNode->commitIndex = pReceiver->snapshot.lastApplyIndex; + } + + // reset wal + pReceiver->pSyncNode->pLogStore->syncLogRestoreFromSnapshot(pReceiver->pSyncNode->pLogStore, pMsg->lastIndex); + + // event log + do { + SSnapshot snapshot; + pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver got last data, finish, apply snapshot"); + syncNodeEventLog(pReceiver->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); +} + +static void snapshotReceiverGotData(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg) { + ASSERT(pMsg->seq == pReceiver->ack + 1); + + if (pReceiver->pWriter != NULL) { + if (pMsg->dataLen > 0) { + int32_t code = pReceiver->pSyncNode->pFsm->FpSnapshotDoWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, + pMsg->data, pMsg->dataLen); + ASSERT(code == 0); + } + pReceiver->ack = pMsg->seq; + + // event log + do { + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver receiving"); + syncNodeEventLog(pReceiver->pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } } @@ -560,33 +641,20 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { // get receiver SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; bool needRsp = false; - int32_t writeCode = 0; // state, term, seq/ack if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) { if (pMsg->term == pSyncNode->pRaftStore->currentTerm) { if (pMsg->seq == SYNC_SNAPSHOT_SEQ_BEGIN) { - // begin + // begin, no data snapshotReceiverStart(pReceiver, pMsg->privateTerm, pMsg); - pReceiver->ack = pMsg->seq; needRsp = true; - char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver begin"); - syncNodeEventLog(pSyncNode, eventLog); - taosMemoryFree(eventLog); - } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) { // end, finish FSM - writeCode = pSyncNode->pFsm->FpSnapshotDoWrite(pSyncNode->pFsm, pReceiver->pWriter, pMsg->data, pMsg->dataLen); - ASSERT(writeCode == 0); - - pSyncNode->pFsm->FpSnapshotStopWrite(pSyncNode->pFsm, pReceiver->pWriter, true); - if (pReceiver->snapshot.lastApplyIndex > pReceiver->pSyncNode->commitIndex) { - pReceiver->pSyncNode->commitIndex = pReceiver->snapshot.lastApplyIndex; - } - - // pSyncNode->pLogStore->syncLogSetBeginIndex(pSyncNode->pLogStore, pMsg->lastIndex + 1); - pSyncNode->pLogStore->syncLogRestoreFromSnapshot(pSyncNode->pLogStore, pMsg->lastIndex); + snapshotReceiverFinish(pReceiver, pMsg); + snapshotReceiverStop(pReceiver); + needRsp = true; // maybe update lastconfig if (pMsg->lastConfigIndex >= SYNC_INDEX_BEGIN) { @@ -601,89 +669,74 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { syncNodeDoConfigChange(pSyncNode, &newSyncCfg, pMsg->lastConfigIndex); } - SSnapshot snapshot; - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); - - do { - char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver finish, apply snapshot"); - syncNodeEventLog(pSyncNode, eventLog); - taosMemoryFree(eventLog); - } while (0); - - pReceiver->pWriter = NULL; - snapshotReceiverStop(pReceiver, true); - pReceiver->ack = pMsg->seq; - needRsp = true; - - do { - char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver stop"); - syncNodeEventLog(pSyncNode, eventLog); - taosMemoryFree(eventLog); - } while (0); - } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_FORCE_CLOSE) { - pSyncNode->pFsm->FpSnapshotStopWrite(pSyncNode->pFsm, pReceiver->pWriter, false); - snapshotReceiverStop(pReceiver, false); + // force close + snapshotReceiverForceStop(pReceiver); needRsp = false; - do { - char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver force close"); - syncNodeEventLog(pSyncNode, eventLog); - taosMemoryFree(eventLog); - } while (0); - } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) { // transfering if (pMsg->seq == pReceiver->ack + 1) { - writeCode = - pSyncNode->pFsm->FpSnapshotDoWrite(pSyncNode->pFsm, pReceiver->pWriter, pMsg->data, pMsg->dataLen); - ASSERT(writeCode == 0); - pReceiver->ack = pMsg->seq; + snapshotReceiverGotData(pReceiver, pMsg); } needRsp = true; - do { - char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver receiving"); - syncNodeEventLog(pSyncNode, eventLog); - taosMemoryFree(eventLog); - } while (0); - } else { ASSERT(0); } + // send ack if (needRsp) { + // build msg SyncSnapshotRsp *pRspMsg = syncSnapshotRspBuild(pSyncNode->vgId); pRspMsg->srcId = pSyncNode->myRaftId; pRspMsg->destId = pMsg->srcId; pRspMsg->term = pSyncNode->pRaftStore->currentTerm; pRspMsg->lastIndex = pMsg->lastIndex; pRspMsg->lastTerm = pMsg->lastTerm; - pRspMsg->ack = pReceiver->ack; - pRspMsg->code = writeCode; - pRspMsg->privateTerm = pReceiver->privateTerm; + pRspMsg->ack = pReceiver->ack; // receiver maybe already closed + pRspMsg->code = 0; + pRspMsg->privateTerm = pReceiver->privateTerm; // receiver maybe already closed + // send msg SRpcMsg rpcMsg; syncSnapshotRsp2RpcMsg(pRspMsg, &rpcMsg); syncNodeSendMsgById(&(pRspMsg->destId), pSyncNode, &rpcMsg); - syncSnapshotRspDestroy(pRspMsg); } + } else { + // error log + do { + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver term not equal"); + syncNodeErrorLog(pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } } else { - syncNodeLog2("syncNodeOnSnapshotSendCb not follower", pSyncNode); + // error log + do { + char *eventLog = snapshotReceiver2SimpleStr(pReceiver, "snapshot receiver not follower"); + syncNodeErrorLog(pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); } return 0; } +static void snapshotSenderUpdateProgress(SSyncSnapshotSender *pSender, SyncSnapshotRsp *pMsg) { + ASSERT(pMsg->ack == pSender->seq); + pSender->ack = pMsg->ack; + ++(pSender->seq); +} + // sender receives ack, set seq = ack + 1, send msg from seq // if ack == SYNC_SNAPSHOT_SEQ_END, stop sender int32_t syncNodeOnSnapshotRspCb(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) { // if already drop replica, do not process if (!syncNodeInRaftGroup(pSyncNode, &(pMsg->srcId)) && pSyncNode->state == TAOS_SYNC_STATE_LEADER) { - sInfo("recv SyncSnapshotRsp maybe replica already dropped"); - return 0; + sError("vgId:%d, recv sync-snapshot-rsp, maybe replica already dropped", pSyncNode->vgId); + return -1; } // get sender @@ -695,27 +748,49 @@ int32_t syncNodeOnSnapshotRspCb(SSyncNode *pSyncNode, SyncSnapshotRsp *pMsg) { if (pMsg->term == pSyncNode->pRaftStore->currentTerm) { // receiver ack is finish, close sender if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) { - pSender->finish = true; - snapshotSenderStop(pSender); + snapshotSenderStop(pSender, true); return 0; } // send next msg if (pMsg->ack == pSender->seq) { // update sender ack - pSender->ack = pMsg->ack; - (pSender->seq)++; + snapshotSenderUpdateProgress(pSender, pMsg); snapshotSend(pSender); } else if (pMsg->ack == pSender->seq - 1) { snapshotReSend(pSender); } else { - ASSERT(0); + do { + char logBuf[64]; + snprintf(logBuf, sizeof(logBuf), "error ack, recv ack:%d, my seq:%d", pMsg->ack, pSender->seq); + char *eventLog = snapshotSender2SimpleStr(pSender, logBuf); + syncNodeErrorLog(pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); + + return -1; } + } else { + // error log + do { + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender term not equal"); + syncNodeErrorLog(pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); + + return -1; } } else { - syncNodeLog2("syncNodeOnSnapshotRspCb not leader", pSyncNode); + // error log + do { + char *eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender not leader"); + syncNodeErrorLog(pSyncNode, eventLog); + taosMemoryFree(eventLog); + } while (0); + + return -1; } return 0; From acb7f040aa04f9cd795dc4e802f9c9245fb32e50 Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Tue, 28 Jun 2022 11:48:10 +0800 Subject: [PATCH 70/73] fix(stream): taosd crash when partition by tbname --- source/libs/executor/src/executorimpl.c | 3 +-- tests/script/jenkins/basic.txt | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 17e5482b60..ad0d5c1447 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -273,8 +273,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR } // 1. close current opened time window - if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId && - pResult->offset != pResultRowInfo->cur.offset))) { + if (pResultRowInfo->cur.pageId != -1 && ((pResult == NULL) || (pResult->pageId != pResultRowInfo->cur.pageId))) { SResultRowPosition pos = pResultRowInfo->cur; SFilePage* pPage = getBufPage(pResultBuf, pos.pageId); releaseBufPage(pResultBuf, pPage); diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index d3a6a0d102..ab5117ced8 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -85,6 +85,7 @@ ./test.sh -f tsim/stream/basic1.sim ./test.sh -f tsim/stream/basic2.sim ./test.sh -f tsim/stream/distributeInterval0.sim +# ./test.sh -f tsim/stream/distributeIntervalRetrive0.sim # ./test.sh -f tsim/stream/distributesession0.sim # ./test.sh -f tsim/stream/session0.sim ./test.sh -f tsim/stream/session1.sim From 20533da6d09d267246838e5bc1000d48f1be8a3e Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Tue, 28 Jun 2022 11:52:46 +0800 Subject: [PATCH 71/73] test: sim test timeout --- tests/script/wtest.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/script/wtest.bat b/tests/script/wtest.bat index 25c344577a..e3bbff9db5 100644 --- a/tests/script/wtest.bat +++ b/tests/script/wtest.bat @@ -58,7 +58,7 @@ set "FILE_NAME=testSuite.sim" if "%1" == "-f" set "FILE_NAME=%2" set FILE_NAME=%FILE_NAME:/=\% -start cmd /k "timeout /t 600 && taskkill /f /im tsim.exe & exit /b" +start cmd /k "timeout /t 600 /NOBREAK && taskkill /f /im tsim.exe & exit /b" rem echo FILE_NAME: %FILE_NAME% echo ExcuteCmd: %tsim% -c %CFG_DIR% -f %FILE_NAME% From 9540d1eac9df7d577ced628bb11b3ea0860ff1b1 Mon Sep 17 00:00:00 2001 From: slzhou Date: Tue, 28 Jun 2022 11:54:16 +0800 Subject: [PATCH 72/73] feat: udf can be compiled outside TDengine --- include/libs/function/taosudf.h | 266 +++++++++++++++++++++++++++++++ include/libs/function/tudf.h | 228 +------------------------- source/libs/function/test/udf1.c | 6 +- source/libs/function/test/udf2.c | 8 +- 4 files changed, 276 insertions(+), 232 deletions(-) create mode 100644 include/libs/function/taosudf.h diff --git a/include/libs/function/taosudf.h b/include/libs/function/taosudf.h new file mode 100644 index 0000000000..5e84b87a81 --- /dev/null +++ b/include/libs/function/taosudf.h @@ -0,0 +1,266 @@ +/* +* 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 . +*/ + +#ifndef TDENGINE_TAOSUDF_H +#define TDENGINE_TAOSUDF_H + +#include +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__GNUC__) +#define FORCE_INLINE inline __attribute__((always_inline)) +#else +#define FORCE_INLINE +#endif +typedef struct SUdfColumnMeta { + int16_t type; + int32_t bytes; + uint8_t precision; + uint8_t scale; +} SUdfColumnMeta; + +typedef struct SUdfColumnData { + int32_t numOfRows; + int32_t rowsAlloc; + union { + struct { + int32_t nullBitmapLen; + char *nullBitmap; + int32_t dataLen; + char *data; + } fixLenCol; + + struct { + int32_t varOffsetsLen; + int32_t *varOffsets; + int32_t payloadLen; + char *payload; + int32_t payloadAllocLen; + } varLenCol; + }; +} SUdfColumnData; + + +typedef struct SUdfColumn { + SUdfColumnMeta colMeta; + bool hasNull; + SUdfColumnData colData; +} SUdfColumn; + +typedef struct SUdfDataBlock { + int32_t numOfRows; + int32_t numOfCols; + SUdfColumn **udfCols; +} SUdfDataBlock; + +typedef struct SUdfInterBuf { + int32_t bufLen; + char* buf; + int8_t numOfResult; //zero or one +} SUdfInterBuf; +typedef void *UdfcFuncHandle; + +// dynamic lib init and destroy +typedef int32_t (*TUdfInitFunc)(); +typedef int32_t (*TUdfDestroyFunc)(); + +#define UDF_MEMORY_EXP_GROWTH 1.5 +#define NBIT (3u) +#define BitPos(_n) ((_n) & ((1 << NBIT) - 1)) +#define BMCharPos(bm_, r_) ((bm_)[(r_) >> NBIT]) +#define BitmapLen(_n) (((_n) + ((1 << NBIT) - 1)) >> NBIT) + +#define udfColDataIsNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] == -1) +#define udfColDataIsNull_f(pColumn, row) ((BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) & (1u << (7u - BitPos(row)))) == (1u << (7u - BitPos(row)))) +#define udfColDataSetNull_f(pColumn, row) \ + do { \ + BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) |= (1u << (7u - BitPos(row))); \ + } while (0) + +#define udfColDataSetNotNull_f(pColumn, r_) \ + do { \ + BMCharPos(pColumn->colData.fixLenCol.nullBitmap, r_) &= ~(1u << (7u - BitPos(r_))); \ + } while (0) +#define udfColDataSetNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] = -1) + +typedef uint16_t VarDataLenT; // maxVarDataLen: 32767 +#define VARSTR_HEADER_SIZE sizeof(VarDataLenT) +#define varDataLen(v) ((VarDataLenT *)(v))[0] +#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE) +#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v)) +#define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v)) +#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE)) +#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len)) +#define IS_VAR_DATA_TYPE(t) \ + (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON)) +#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR)) + + +static FORCE_INLINE char* udfColDataGetData(const SUdfColumn* pColumn, int32_t row) { + if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { + return pColumn->colData.varLenCol.payload + pColumn->colData.varLenCol.varOffsets[row]; + } else { + return pColumn->colData.fixLenCol.data + pColumn->colMeta.bytes * row; + } +} + +static FORCE_INLINE bool udfColDataIsNull(const SUdfColumn* pColumn, int32_t row) { + if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { + if (pColumn->colMeta.type == TSDB_DATA_TYPE_JSON) { + if (udfColDataIsNull_var(pColumn, row)) { + return true; + } + char* data = udfColDataGetData(pColumn, row); + return (*data == TSDB_DATA_TYPE_NULL); + } else { + return udfColDataIsNull_var(pColumn, row); + } + } else { + return udfColDataIsNull_f(pColumn, row); + } +} + +static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t newCapacity) { + SUdfColumnMeta *meta = &pColumn->colMeta; + SUdfColumnData *data = &pColumn->colData; + + if (newCapacity== 0 || newCapacity <= data->rowsAlloc) { + return TSDB_CODE_SUCCESS; + } + + int allocCapacity = (data->rowsAlloc< 8) ? 8 : data->rowsAlloc; + while (allocCapacity < newCapacity) { + allocCapacity *= UDF_MEMORY_EXP_GROWTH; + } + + if (IS_VAR_DATA_TYPE(meta->type)) { + char* tmp = (char*)realloc(data->varLenCol.varOffsets, sizeof(int32_t) * allocCapacity); + if (tmp == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + data->varLenCol.varOffsets = (int32_t*)tmp; + data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity; + // for payload, add data in udfColDataAppend + } else { + char* tmp = (char*)realloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity)); + if (tmp == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + data->fixLenCol.nullBitmap = tmp; + data->fixLenCol.nullBitmapLen = BitmapLen(allocCapacity); + if (meta->type == TSDB_DATA_TYPE_NULL) { + return TSDB_CODE_SUCCESS; + } + + tmp = (char*)realloc(data->fixLenCol.data, allocCapacity* meta->bytes); + if (tmp == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + data->fixLenCol.data = tmp; + data->fixLenCol.dataLen = allocCapacity* meta->bytes; + } + + data->rowsAlloc = allocCapacity; + + return TSDB_CODE_SUCCESS; +} + +static FORCE_INLINE void udfColDataSetNull(SUdfColumn* pColumn, int32_t row) { + udfColEnsureCapacity(pColumn, row+1); + if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { + udfColDataSetNull_var(pColumn, row); + } else { + udfColDataSetNull_f(pColumn, row); + } + pColumn->hasNull = true; +} + +static FORCE_INLINE int32_t udfColDataSet(SUdfColumn* pColumn, uint32_t currentRow, const char* pData, bool isNull) { + SUdfColumnMeta *meta = &pColumn->colMeta; + SUdfColumnData *data = &pColumn->colData; + udfColEnsureCapacity(pColumn, currentRow+1); + bool isVarCol = IS_VAR_DATA_TYPE(meta->type); + if (isNull) { + udfColDataSetNull(pColumn, currentRow); + } else { + if (!isVarCol) { + udfColDataSetNotNull_f(pColumn, currentRow); + memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes); + } else { + int32_t dataLen = varDataTLen(pData); + if (meta->type == TSDB_DATA_TYPE_JSON) { + if (*pData == TSDB_DATA_TYPE_NULL) { + dataLen = 0; + } else if (*pData == TSDB_DATA_TYPE_NCHAR) { + dataLen = varDataTLen(pData + sizeof(char)); + } else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) { + dataLen = sizeof(int64_t); + } else if (*pData == TSDB_DATA_TYPE_BOOL) { + dataLen = sizeof(char); + } + dataLen += sizeof(char); + } + + if (data->varLenCol.payloadAllocLen < data->varLenCol.payloadLen + dataLen) { + uint32_t newSize = data->varLenCol.payloadAllocLen; + if (newSize <= 1) { + newSize = 8; + } + + while (newSize < data->varLenCol.payloadLen + dataLen) { + newSize = newSize * UDF_MEMORY_EXP_GROWTH; + } + + char *buf = (char*)realloc(data->varLenCol.payload, newSize); + if (buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + data->varLenCol.payload = buf; + data->varLenCol.payloadAllocLen = newSize; + } + + uint32_t len = data->varLenCol.payloadLen; + data->varLenCol.varOffsets[currentRow] = len; + + memcpy(data->varLenCol.payload + len, pData, dataLen); + data->varLenCol.payloadLen += dataLen; + } + } + data->numOfRows = (currentRow + 1 > data->numOfRows) ? (currentRow+1) : data->numOfRows; + return 0; +} + +typedef int32_t (*TUdfScalarProcFunc)(SUdfDataBlock* block, SUdfColumn *resultCol); + +typedef int32_t (*TUdfAggStartFunc)(SUdfInterBuf *buf); +typedef int32_t (*TUdfAggProcessFunc)(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf); +typedef int32_t (*TUdfAggFinishFunc)(SUdfInterBuf* buf, SUdfInterBuf *resultData); + +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_TAOSUDF_H diff --git a/include/libs/function/tudf.h b/include/libs/function/tudf.h index 28b1fbe8ce..b4c05fea87 100644 --- a/include/libs/function/tudf.h +++ b/include/libs/function/tudf.h @@ -16,6 +16,13 @@ #ifndef TDENGINE_TUDF_H #define TDENGINE_TUDF_H +#undef malloc +#define malloc malloc +#undef free +#define free free +#undef realloc +#define alloc alloc +#include #include #include @@ -36,56 +43,6 @@ extern "C" { #endif #define UDF_DNODE_ID_ENV_NAME "DNODE_ID" -//====================================================================================== -//begin API to taosd and qworker - -typedef struct SUdfColumnMeta { - int16_t type; - int32_t bytes; - uint8_t precision; - uint8_t scale; -} SUdfColumnMeta; - -typedef struct SUdfColumnData { - int32_t numOfRows; - int32_t rowsAlloc; - union { - struct { - int32_t nullBitmapLen; - char *nullBitmap; - int32_t dataLen; - char *data; - } fixLenCol; - - struct { - int32_t varOffsetsLen; - int32_t *varOffsets; - int32_t payloadLen; - char *payload; - int32_t payloadAllocLen; - } varLenCol; - }; -} SUdfColumnData; - - -typedef struct SUdfColumn { - SUdfColumnMeta colMeta; - bool hasNull; - SUdfColumnData colData; -} SUdfColumn; - -typedef struct SUdfDataBlock { - int32_t numOfRows; - int32_t numOfCols; - SUdfColumn **udfCols; -} SUdfDataBlock; - -typedef struct SUdfInterBuf { - int32_t bufLen; - char* buf; - int8_t numOfResult; //zero or one -} SUdfInterBuf; -typedef void *UdfcFuncHandle; //low level APIs /** @@ -127,177 +84,6 @@ int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock); int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, SScalarParam *output); int32_t cleanUpUdfs(); -// end API to taosd and qworker -//============================================================================================================================= -// begin API to UDF writer. - -// dynamic lib init and destroy -typedef int32_t (*TUdfInitFunc)(); -typedef int32_t (*TUdfDestroyFunc)(); - -//TODO: add API to check function arguments type, number etc. - -#define UDF_MEMORY_EXP_GROWTH 1.5 - -#define udfColDataIsNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] == -1) -#define udfColDataIsNull_f(pColumn, row) ((BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) & (1u << (7u - BitPos(row)))) == (1u << (7u - BitPos(row)))) -#define udfColDataSetNull_f(pColumn, row) \ - do { \ - BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) |= (1u << (7u - BitPos(row))); \ - } while (0) - -#define udfColDataSetNotNull_f(pColumn, r_) \ - do { \ - BMCharPos(pColumn->colData.fixLenCol.nullBitmap, r_) &= ~(1u << (7u - BitPos(r_))); \ - } while (0) -#define udfColDataSetNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] = -1) - - -static FORCE_INLINE char* udfColDataGetData(const SUdfColumn* pColumn, int32_t row) { - if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { - return pColumn->colData.varLenCol.payload + pColumn->colData.varLenCol.varOffsets[row]; - } else { - return pColumn->colData.fixLenCol.data + pColumn->colMeta.bytes * row; - } -} - -static FORCE_INLINE bool udfColDataIsNull(const SUdfColumn* pColumn, int32_t row) { - if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { - if (pColumn->colMeta.type == TSDB_DATA_TYPE_JSON) { - if (udfColDataIsNull_var(pColumn, row)) { - return true; - } - char* data = udfColDataGetData(pColumn, row); - return (*data == TSDB_DATA_TYPE_NULL); - } else { - return udfColDataIsNull_var(pColumn, row); - } - } else { - return udfColDataIsNull_f(pColumn, row); - } -} - -static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t newCapacity) { - SUdfColumnMeta *meta = &pColumn->colMeta; - SUdfColumnData *data = &pColumn->colData; - - if (newCapacity== 0 || newCapacity <= data->rowsAlloc) { - return TSDB_CODE_SUCCESS; - } - - int allocCapacity = TMAX(data->rowsAlloc, 8); - while (allocCapacity < newCapacity) { - allocCapacity *= UDF_MEMORY_EXP_GROWTH; - } - - if (IS_VAR_DATA_TYPE(meta->type)) { - char* tmp = taosMemoryRealloc(data->varLenCol.varOffsets, sizeof(int32_t) * allocCapacity); - if (tmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - data->varLenCol.varOffsets = (int32_t*)tmp; - data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity; - // for payload, add data in udfColDataAppend - } else { - char* tmp = taosMemoryRealloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity)); - if (tmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - data->fixLenCol.nullBitmap = tmp; - data->fixLenCol.nullBitmapLen = BitmapLen(allocCapacity); - if (meta->type == TSDB_DATA_TYPE_NULL) { - return TSDB_CODE_SUCCESS; - } - - tmp = taosMemoryRealloc(data->fixLenCol.data, allocCapacity* meta->bytes); - if (tmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - data->fixLenCol.data = tmp; - data->fixLenCol.dataLen = allocCapacity* meta->bytes; - } - - data->rowsAlloc = allocCapacity; - - return TSDB_CODE_SUCCESS; -} - -static FORCE_INLINE void udfColDataSetNull(SUdfColumn* pColumn, int32_t row) { - udfColEnsureCapacity(pColumn, row+1); - if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { - udfColDataSetNull_var(pColumn, row); - } else { - udfColDataSetNull_f(pColumn, row); - } - pColumn->hasNull = true; -} - -static FORCE_INLINE int32_t udfColDataSet(SUdfColumn* pColumn, uint32_t currentRow, const char* pData, bool isNull) { - SUdfColumnMeta *meta = &pColumn->colMeta; - SUdfColumnData *data = &pColumn->colData; - udfColEnsureCapacity(pColumn, currentRow+1); - bool isVarCol = IS_VAR_DATA_TYPE(meta->type); - if (isNull) { - udfColDataSetNull(pColumn, currentRow); - } else { - if (!isVarCol) { - colDataSetNotNull_f(data->fixLenCol.nullBitmap, currentRow); - memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes); - } else { - int32_t dataLen = varDataTLen(pData); - if (meta->type == TSDB_DATA_TYPE_JSON) { - if (*pData == TSDB_DATA_TYPE_NULL) { - dataLen = 0; - } else if (*pData == TSDB_DATA_TYPE_NCHAR) { - dataLen = varDataTLen(pData + CHAR_BYTES); - } else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) { - dataLen = LONG_BYTES; - } else if (*pData == TSDB_DATA_TYPE_BOOL) { - dataLen = CHAR_BYTES; - } - dataLen += CHAR_BYTES; - } - - if (data->varLenCol.payloadAllocLen < data->varLenCol.payloadLen + dataLen) { - uint32_t newSize = data->varLenCol.payloadAllocLen; - if (newSize <= 1) { - newSize = 8; - } - - while (newSize < data->varLenCol.payloadLen + dataLen) { - newSize = newSize * UDF_MEMORY_EXP_GROWTH; - } - - char *buf = taosMemoryRealloc(data->varLenCol.payload, newSize); - if (buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - data->varLenCol.payload = buf; - data->varLenCol.payloadAllocLen = newSize; - } - - uint32_t len = data->varLenCol.payloadLen; - data->varLenCol.varOffsets[currentRow] = len; - - memcpy(data->varLenCol.payload + len, pData, dataLen); - data->varLenCol.payloadLen += dataLen; - } - } - data->numOfRows = TMAX(currentRow + 1, data->numOfRows); - return 0; -} - -typedef int32_t (*TUdfScalarProcFunc)(SUdfDataBlock* block, SUdfColumn *resultCol); - -typedef int32_t (*TUdfAggStartFunc)(SUdfInterBuf *buf); -typedef int32_t (*TUdfAggProcessFunc)(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf); -typedef int32_t (*TUdfAggFinishFunc)(SUdfInterBuf* buf, SUdfInterBuf *resultData); - - -// end API to UDF writer -//======================================================================================================================= #ifdef __cplusplus } diff --git a/source/libs/function/test/udf1.c b/source/libs/function/test/udf1.c index 9443d5cb94..dfbae357ef 100644 --- a/source/libs/function/test/udf1.c +++ b/source/libs/function/test/udf1.c @@ -2,12 +2,8 @@ #include #include -#include "tudf.h" +#include "taosudf.h" -#undef malloc -#define malloc malloc -#undef free -#define free free DLL_EXPORT int32_t udf1_init() { return 0; diff --git a/source/libs/function/test/udf2.c b/source/libs/function/test/udf2.c index 1c270f5cf4..975832209e 100644 --- a/source/libs/function/test/udf2.c +++ b/source/libs/function/test/udf2.c @@ -1,13 +1,9 @@ #include #include #include +#include -#include "tudf.h" - -#undef malloc -#define malloc malloc -#undef free -#define free free +#include "taosudf.h" DLL_EXPORT int32_t udf2_init() { return 0; From 4110c0049739804159c6c66fff8b10c67598dd58 Mon Sep 17 00:00:00 2001 From: slzhou Date: Tue, 28 Jun 2022 11:58:39 +0800 Subject: [PATCH 73/73] fix: initialize errCode of SMergeProjectsContext --- source/libs/planner/src/planOptimizer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index eb0f02c92c..638e3f5604 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1405,19 +1405,19 @@ static EDealRes mergeProjectionsExpr(SNode** pNode, void* pContext) { return DEAL_RES_CONTINUE; } -static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pProjectNode) { - SProjectLogicNode* pProject = (SProjectLogicNode*)pProjectNode; - SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pProjectNode->pChildren, 0); - SMergeProjectionsContext cxt = {.pChildProj = (SProjectLogicNode*)pChild}; +static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan, SLogicNode* pSelfNode) { + SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pSelfNode->pChildren, 0); + SMergeProjectionsContext cxt = {.pChildProj = (SProjectLogicNode*)pChild, .errCode = TSDB_CODE_SUCCESS}; - nodesRewriteExprs(pProject->pProjections, mergeProjectionsExpr, &cxt); + nodesRewriteExprs(((SProjectLogicNode*)pSelfNode)->pProjections, mergeProjectionsExpr, &cxt); int32_t code = cxt.errCode; + if (TSDB_CODE_SUCCESS == code) { if (1 == LIST_LENGTH(pChild->pChildren)) { SLogicNode* pGrandChild = (SLogicNode*)nodesListGetNode(pChild->pChildren, 0); code = replaceLogicNode(pLogicSubplan, pChild, pGrandChild); } else { // no grand child - NODES_CLEAR_LIST(pProjectNode->pChildren); + NODES_CLEAR_LIST(pSelfNode->pChildren); } }