diff --git a/README.md b/README.md index 05c1c075f0..885f91cb4e 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,12 @@ [![Build status](https://ci.appveyor.com/api/projects/status/kf3pwh2or5afsgl9/branch/master?svg=true)](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master) [![Coverage Status](https://coveralls.io/repos/github/taosdata/TDengine/badge.svg?branch=develop)](https://coveralls.io/github/taosdata/TDengine?branch=develop) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4201/badge)](https://bestpractices.coreinfrastructure.org/projects/4201) +
+[![Twitter Follow](https://img.shields.io/twitter/follow/tdenginedb?label=TDengine&style=social)](https://twitter.com/tdenginedb) +[![YouTube Channel](https://img.shields.io/badge/Subscribe_@tdengine--white?logo=youtube&style=social)](https://www.youtube.com/@tdengine) +[![Discord Community](https://img.shields.io/badge/Join_Discord--white?logo=discord&style=social)](https://discord.com/invite/VZdSuUg4pS) +[![LinkedIn](https://img.shields.io/badge/Follow_LinkedIn--white?logo=linkedin&style=social)](https://www.linkedin.com/company/tdengine) +[![StackOverflow](https://img.shields.io/badge/Ask_StackOverflow--white?logo=stackoverflow&style=social&logoColor=orange)](https://stackoverflow.com/questions/tagged/tdengine) English | [简体中文](README-CN.md) | [TDengine Cloud](https://cloud.tdengine.com) | [Learn more about TSDB](https://tdengine.com/tsdb/) diff --git a/cmake/cmake.version b/cmake/cmake.version index a4c783b6c8..a30618157b 100644 --- a/cmake/cmake.version +++ b/cmake/cmake.version @@ -2,7 +2,7 @@ IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "3.0.2.4") + SET(TD_VER_NUMBER "3.0.2.5") ENDIF () IF (DEFINED VERCOMPATIBLE) diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in index 13b247770e..8df50af03c 100644 --- a/cmake/taosadapter_CMakeLists.txt.in +++ b/cmake/taosadapter_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taosadapter ExternalProject_Add(taosadapter GIT_REPOSITORY https://github.com/taosdata/taosadapter.git - GIT_TAG 213f8b3 + GIT_TAG db6c843 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index a69e1578c0..48f31c6daf 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG 7d24ed5 + GIT_TAG e04f39b SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/docs/en/12-taos-sql/06-select.md b/docs/en/12-taos-sql/06-select.md index c087a9e9fb..485779f55f 100644 --- a/docs/en/12-taos-sql/06-select.md +++ b/docs/en/12-taos-sql/06-select.md @@ -12,6 +12,7 @@ SELECT [DISTINCT] select_list from_clause [WHERE condition] [partition_by_clause] + [interp_clause] [window_clause] [group_by_clause] [order_by_clasue] @@ -52,8 +53,11 @@ window_clause: { | STATE_WINDOW(col) | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)] +interp_clause: + RANGE(ts_val, ts_val), EVERY(every_val), FILL(fill_mod_and_val) + partition_by_clause: - PARTITION BY expr [, expr] ... + PARTITION BY expr [, expr] ... group_by_clause: GROUP BY expr [, expr] ... HAVING condition diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index f0daf4b82a..8ab5176aab 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -872,9 +872,9 @@ INTERP(expr) - `INTERP` is used to get the value that matches the specified time slice from a column. If no such value exists an interpolation value will be returned based on `FILL` parameter. - The input data of `INTERP` is the value of the specified column and a `where` clause can be used to filter the original data. If no `where` condition is specified then all original data is the input. - `INTERP` must be used along with `RANGE`, `EVERY`, `FILL` keywords. -- The output time range of `INTERP` is specified by `RANGE(timestamp1,timestamp2)` parameter, with timestamp1<=timestamp2. timestamp1 is the starting point of the output time range and must be specified. timestamp2 is the ending point of the output time range and must be specified. -- The number of rows in the result set of `INTERP` is determined by the parameter `EVERY`. Starting from timestamp1, one interpolation is performed for every time interval specified `EVERY` parameter. The parameter `EVERY` must be an integer, with no quotes, with a time unit of: b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), or w(week). For example, `EVERY(500a)` will interpolate every 500 milliseconds. -- Interpolation is performed based on `FILL` parameter. +- The output time range of `INTERP` is specified by `RANGE(timestamp1,timestamp2)` parameter, with timestamp1 <= timestamp2. timestamp1 is the starting point of the output time range and must be specified. timestamp2 is the ending point of the output time range and must be specified. +- The number of rows in the result set of `INTERP` is determined by the parameter `EVERY(time_unit)`. Starting from timestamp1, one interpolation is performed for every time interval specified `time_unit` parameter. The parameter `time_unit` must be an integer, with no quotes, with a time unit of: a(millisecond)), s(second), m(minute), h(hour), d(day), or w(week). For example, `EVERY(500a)` will interpolate every 500 milliseconds. +- Interpolation is performed based on `FILL` parameter. For more information about FILL clause, see [FILL Clause](../distinguished/#fill-clause). - `INTERP` can only be used to interpolate in single timeline. So it must be used with `partition by tbname` when it's used on a STable. - Pseudo column `_irowts` can be used along with `INTERP` to return the timestamps associated with interpolation points(support after version 3.0.1.4). diff --git a/docs/examples/go/go.mod b/docs/examples/go/go.mod index 2bc1a74cb6..716a0ef5dc 100644 --- a/docs/examples/go/go.mod +++ b/docs/examples/go/go.mod @@ -2,5 +2,5 @@ module goexample go 1.17 -require github.com/taosdata/driver-go/v3 3.0 +require github.com/taosdata/driver-go/v3 v3.1.0 diff --git a/docs/examples/python/conn_native_pandas.py b/docs/examples/python/conn_native_pandas.py index 56942ef570..f3bab15efb 100644 --- a/docs/examples/python/conn_native_pandas.py +++ b/docs/examples/python/conn_native_pandas.py @@ -1,8 +1,11 @@ import pandas -from sqlalchemy import create_engine +from sqlalchemy import create_engine, text engine = create_engine("taos://root:taosdata@localhost:6030/power") -df = pandas.read_sql("SELECT * FROM meters", engine) +conn = engine.connect() +df = pandas.read_sql(text("SELECT * FROM power.meters"), conn) +conn.close() + # print index print(df.index) diff --git a/docs/examples/python/conn_rest_pandas.py b/docs/examples/python/conn_rest_pandas.py index 0164080cd5..1b207d6ff1 100644 --- a/docs/examples/python/conn_rest_pandas.py +++ b/docs/examples/python/conn_rest_pandas.py @@ -1,8 +1,10 @@ import pandas -from sqlalchemy import create_engine +from sqlalchemy import create_engine, text engine = create_engine("taosrest://root:taosdata@localhost:6041") -df: pandas.DataFrame = pandas.read_sql("SELECT * FROM power.meters", engine) +conn = engine.connect() +df: pandas.DataFrame = pandas.read_sql(text("SELECT * FROM power.meters"), conn) +conn.close() # print index print(df.index) diff --git a/docs/examples/python/connect_rest_examples.py b/docs/examples/python/connect_rest_examples.py index 900ec1022e..0f8625ae53 100644 --- a/docs/examples/python/connect_rest_examples.py +++ b/docs/examples/python/connect_rest_examples.py @@ -1,24 +1,25 @@ # ANCHOR: connect from taosrest import connect, TaosRestConnection, TaosRestCursor -conn: TaosRestConnection = connect(url="http://localhost:6041", - user="root", - password="taosdata", - timeout=30) +conn = connect(url="http://localhost:6041", + user="root", + password="taosdata", + timeout=30) # ANCHOR_END: connect # ANCHOR: basic # create STable -cursor: TaosRestCursor = conn.cursor() +cursor = conn.cursor() cursor.execute("DROP DATABASE IF EXISTS power") cursor.execute("CREATE DATABASE power") -cursor.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)") +cursor.execute( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)") # insert data -cursor.execute("""INSERT INTO power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) - power.d1002 USING power.meters TAGS(California.SanFrancisco, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) - power.d1003 USING power.meters TAGS(California.LosAngeles, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) - power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)""") +cursor.execute("""INSERT INTO power.d1001 USING power.meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) + power.d1002 USING power.meters TAGS('California.SanFrancisco', 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) + power.d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) + power.d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)""") print("inserted row count:", cursor.rowcount) # query data @@ -28,7 +29,7 @@ print("queried row count:", cursor.rowcount) # get column names from cursor column_names = [meta[0] for meta in cursor.description] # get rows -data: list[tuple] = cursor.fetchall() +data = cursor.fetchall() print(column_names) for row in data: print(row) diff --git a/docs/examples/python/connection_usage_native_reference.py b/docs/examples/python/connection_usage_native_reference.py index 4803511e42..0a23c5f95b 100644 --- a/docs/examples/python/connection_usage_native_reference.py +++ b/docs/examples/python/connection_usage_native_reference.py @@ -8,7 +8,7 @@ conn.execute("CREATE DATABASE test") # change database. same as execute "USE db" conn.select_db("test") conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)") -affected_row: int = conn.execute("INSERT INTO t1 USING weather TAGS(1) VALUES (now, 23.5) (now+1m, 23.5) (now+2m 24.4)") +affected_row = conn.execute("INSERT INTO t1 USING weather TAGS(1) VALUES (now, 23.5) (now+1m, 23.5) (now+2m, 24.4)") print("affected_row", affected_row) # output: # affected_row 3 @@ -16,10 +16,10 @@ print("affected_row", affected_row) # ANCHOR: query # Execute a sql and get its result set. It's useful for SELECT statement -result: taos.TaosResult = conn.query("SELECT * from weather") +result = conn.query("SELECT * from weather") # Get fields from result -fields: taos.field.TaosFields = result.fields +fields = result.fields for field in fields: print(field) # {name: ts, type: 9, bytes: 8} @@ -42,4 +42,4 @@ print(data) # ANCHOR_END: query -conn.close() +conn.close() \ No newline at end of file diff --git a/docs/examples/python/fast_write_example.py b/docs/examples/python/fast_write_example.py index c9d606388f..626e3310b1 100644 --- a/docs/examples/python/fast_write_example.py +++ b/docs/examples/python/fast_write_example.py @@ -1,15 +1,14 @@ # install dependencies: # recommend python >= 3.8 -# pip3 install faster-fifo # import logging import math +import multiprocessing import sys import time import os -from multiprocessing import Process -from faster_fifo import Queue +from multiprocessing import Process, Queue from mockdatasource import MockDataSource from queue import Empty from typing import List @@ -22,8 +21,7 @@ TABLE_COUNT = 1000 QUEUE_SIZE = 1000000 MAX_BATCH_SIZE = 3000 -read_processes = [] -write_processes = [] +_DONE_MESSAGE = '__DONE__' def get_connection(): @@ -44,41 +42,64 @@ def get_connection(): # ANCHOR: read -def run_read_task(task_id: int, task_queues: List[Queue]): +def run_read_task(task_id: int, task_queues: List[Queue], infinity): table_count_per_task = TABLE_COUNT // READ_TASK_COUNT - data_source = MockDataSource(f"tb{task_id}", table_count_per_task) + data_source = MockDataSource(f"tb{task_id}", table_count_per_task, infinity) try: for batch in data_source: + if isinstance(batch, tuple): + batch = [batch] for table_id, rows in batch: # hash data to different queue i = table_id % len(task_queues) # block putting forever when the queue is full - task_queues[i].put_many(rows, block=True, timeout=-1) + for row in rows: + task_queues[i].put(row) + if not infinity: + for queue in task_queues: + queue.put(_DONE_MESSAGE) except KeyboardInterrupt: pass + finally: + logging.info('read task over') # ANCHOR_END: read + # ANCHOR: write -def run_write_task(task_id: int, queue: Queue): +def run_write_task(task_id: int, queue: Queue, done_queue: Queue): from sql_writer import SQLWriter log = logging.getLogger(f"WriteTask-{task_id}") writer = SQLWriter(get_connection) lines = None try: while True: - try: - # get as many as possible - lines = queue.get_many(block=False, max_messages_to_get=MAX_BATCH_SIZE) + over = False + lines = [] + for _ in range(MAX_BATCH_SIZE): + try: + line = queue.get_nowait() + if line == _DONE_MESSAGE: + over = True + break + if line: + lines.append(line) + except Empty: + time.sleep(0.1) + if len(lines) > 0: writer.process_lines(lines) - except Empty: - time.sleep(0.01) + if over: + done_queue.put(_DONE_MESSAGE) + break except KeyboardInterrupt: pass except BaseException as e: log.debug(f"lines={lines}") raise e + finally: + writer.close() + log.debug('write task over') # ANCHOR_END: write @@ -103,47 +124,64 @@ def set_global_config(): # ANCHOR: monitor -def run_monitor_process(): +def run_monitor_process(done_queue: Queue): log = logging.getLogger("DataBaseMonitor") - conn = get_connection() - conn.execute("DROP DATABASE IF EXISTS test") - conn.execute("CREATE DATABASE test") - conn.execute("CREATE STABLE test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " - "TAGS (location BINARY(64), groupId INT)") + conn = None + try: + conn = get_connection() - def get_count(): - res = conn.query("SELECT count(*) FROM test.meters") - rows = res.fetch_all() - return rows[0][0] if rows else 0 + def get_count(): + res = conn.query("SELECT count(*) FROM test.meters") + rows = res.fetch_all() + return rows[0][0] if rows else 0 - last_count = 0 - while True: - time.sleep(10) - count = get_count() - log.info(f"count={count} speed={(count - last_count) / 10}") - last_count = count + last_count = 0 + while True: + try: + done = done_queue.get_nowait() + if done == _DONE_MESSAGE: + break + except Empty: + pass + time.sleep(10) + count = get_count() + log.info(f"count={count} speed={(count - last_count) / 10}") + last_count = count + finally: + conn.close() # ANCHOR_END: monitor # ANCHOR: main -def main(): +def main(infinity): set_global_config() logging.info(f"READ_TASK_COUNT={READ_TASK_COUNT}, WRITE_TASK_COUNT={WRITE_TASK_COUNT}, " f"TABLE_COUNT={TABLE_COUNT}, QUEUE_SIZE={QUEUE_SIZE}, MAX_BATCH_SIZE={MAX_BATCH_SIZE}") - monitor_process = Process(target=run_monitor_process) + conn = get_connection() + conn.execute("DROP DATABASE IF EXISTS test") + conn.execute("CREATE DATABASE IF NOT EXISTS test") + conn.execute("CREATE STABLE IF NOT EXISTS test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " + "TAGS (location BINARY(64), groupId INT)") + conn.close() + + done_queue = Queue() + monitor_process = Process(target=run_monitor_process, args=(done_queue,)) monitor_process.start() - time.sleep(3) # waiting for database ready. + logging.debug(f"monitor task started with pid {monitor_process.pid}") task_queues: List[Queue] = [] + write_processes = [] + read_processes = [] + # create task queues for i in range(WRITE_TASK_COUNT): - queue = Queue(max_size_bytes=QUEUE_SIZE) + queue = Queue() task_queues.append(queue) # create write processes for i in range(WRITE_TASK_COUNT): - p = Process(target=run_write_task, args=(i, task_queues[i])) + p = Process(target=run_write_task, args=(i, task_queues[i], done_queue)) p.start() logging.debug(f"WriteTask-{i} started with pid {p.pid}") write_processes.append(p) @@ -151,13 +189,19 @@ def main(): # create read processes for i in range(READ_TASK_COUNT): queues = assign_queues(i, task_queues) - p = Process(target=run_read_task, args=(i, queues)) + p = Process(target=run_read_task, args=(i, queues, infinity)) p.start() logging.debug(f"ReadTask-{i} started with pid {p.pid}") read_processes.append(p) try: monitor_process.join() + for p in read_processes: + p.join() + for p in write_processes: + p.join() + time.sleep(1) + return except KeyboardInterrupt: monitor_process.terminate() [p.terminate() for p in read_processes] @@ -176,5 +220,6 @@ def assign_queues(read_task_id, task_queues): if __name__ == '__main__': - main() + multiprocessing.set_start_method('spawn') + main(False) # ANCHOR_END: main diff --git a/docs/examples/python/kafka_example.py b/docs/examples/python/kafka_example.py index 735059eec0..a89287d372 100644 --- a/docs/examples/python/kafka_example.py +++ b/docs/examples/python/kafka_example.py @@ -26,7 +26,8 @@ class Consumer(object): 'bath_consume': True, 'batch_size': 1000, 'async_model': True, - 'workers': 10 + 'workers': 10, + 'testing': False } LOCATIONS = ['California.SanFrancisco', 'California.LosAngles', 'California.SanDiego', 'California.SanJose', @@ -46,11 +47,12 @@ class Consumer(object): def __init__(self, **configs): self.config: dict = self.DEFAULT_CONFIGS self.config.update(configs) - self.consumer = KafkaConsumer( - self.config.get('kafka_topic'), # topic - bootstrap_servers=self.config.get('kafka_brokers'), - group_id=self.config.get('kafka_group_id'), - ) + if not self.config.get('testing'): + self.consumer = KafkaConsumer( + self.config.get('kafka_topic'), # topic + bootstrap_servers=self.config.get('kafka_brokers'), + group_id=self.config.get('kafka_group_id'), + ) self.taos = taos.connect( host=self.config.get('taos_host'), user=self.config.get('taos_user'), @@ -60,7 +62,7 @@ class Consumer(object): ) if self.config.get('async_model'): self.pool = ThreadPoolExecutor(max_workers=self.config.get('workers')) - self.tasks: list[Future] = [] + self.tasks = [] # tags and table mapping # key: {location}_{groupId} value: self.tag_table_mapping = {} i = 0 @@ -104,8 +106,8 @@ class Consumer(object): for task in self.tasks: while not task.done(): pass - if self.pool is not None: - self.pool.shutdown() + if self.pool is not None: + self.pool.shutdown() # clean data if self.config.get('clean_after_testing'): @@ -115,14 +117,14 @@ class Consumer(object): if self.taos is not None: self.taos.close() - def _run(self, f: Callable[[ConsumerRecord], bool]): + def _run(self, f): for message in self.consumer: if self.config.get('async_model'): self.pool.submit(f(message)) else: f(message) - def _run_batch(self, f: Callable[[list[list[ConsumerRecord]]], None]): + def _run_batch(self, f): while True: messages = self.consumer.poll(timeout_ms=500, max_records=self.config.get('batch_size')) if messages: @@ -140,7 +142,7 @@ class Consumer(object): logging.info('## insert sql %s', sql) return self.taos.execute(sql=sql) == 1 - def _to_taos_batch(self, messages: list[list[ConsumerRecord]]): + def _to_taos_batch(self, messages): sql = self._build_sql_batch(messages=messages) if len(sql) == 0: # decode error, skip return @@ -162,7 +164,7 @@ class Consumer(object): table_name = self._get_table_name(location=location, group_id=group_id) return self.INSERT_PART_SQL.format(table_name, ts, current, voltage, phase) - def _build_sql_batch(self, messages: list[list[ConsumerRecord]]) -> str: + def _build_sql_batch(self, messages) -> str: sql_list = [] for partition_messages in messages: for message in partition_messages: @@ -186,7 +188,55 @@ def _get_location_and_group(key: str) -> (str, int): return fields[0], fields[1] +def test_to_taos(consumer: Consumer): + msg = { + 'location': 'California.SanFrancisco', + 'groupId': 1, + 'ts': '2022-12-06 15:13:38.643', + 'current': 3.41, + 'voltage': 105, + 'phase': 0.02027, + } + record = ConsumerRecord(checksum=None, headers=None, offset=1, key=None, value=json.dumps(msg), partition=1, + topic='test', serialized_key_size=None, serialized_header_size=None, + serialized_value_size=None, timestamp=time.time(), timestamp_type=None) + assert consumer._to_taos(message=record) + + +def test_to_taos_batch(consumer: Consumer): + records = [ + [ + ConsumerRecord(checksum=None, headers=None, offset=1, key=None, + value=json.dumps({'location': 'California.SanFrancisco', + 'groupId': 1, + 'ts': '2022-12-06 15:13:38.643', + 'current': 3.41, + 'voltage': 105, + 'phase': 0.02027, }), + partition=1, topic='test', serialized_key_size=None, serialized_header_size=None, + serialized_value_size=None, timestamp=time.time(), timestamp_type=None), + ConsumerRecord(checksum=None, headers=None, offset=1, key=None, + value=json.dumps({'location': 'California.LosAngles', + 'groupId': 2, + 'ts': '2022-12-06 15:13:39.643', + 'current': 3.41, + 'voltage': 102, + 'phase': 0.02027, }), + partition=1, topic='test', serialized_key_size=None, serialized_header_size=None, + serialized_value_size=None, timestamp=time.time(), timestamp_type=None), + ] + ] + + consumer._to_taos_batch(messages=records) + + if __name__ == '__main__': - consumer = Consumer(async_model=True) + consumer = Consumer(async_model=True, testing=True) + # init env consumer.init_env() - consumer.consume() \ No newline at end of file + # consumer.consume() + # test build sql + # test build sql batch + test_to_taos(consumer) + test_to_taos_batch(consumer) + \ No newline at end of file diff --git a/docs/examples/python/mockdatasource.py b/docs/examples/python/mockdatasource.py index 1c516a800e..15a7d2ff8c 100644 --- a/docs/examples/python/mockdatasource.py +++ b/docs/examples/python/mockdatasource.py @@ -10,13 +10,14 @@ class MockDataSource: "9.4,118,0.141,California.SanFrancisco,4" ] - def __init__(self, tb_name_prefix, table_count): + def __init__(self, tb_name_prefix, table_count, infinity=True): self.table_name_prefix = tb_name_prefix + "_" self.table_count = table_count self.max_rows = 10000000 self.current_ts = round(time.time() * 1000) - self.max_rows * 100 # [(tableId, tableName, values),] self.data = self._init_data() + self.infinity = infinity def _init_data(self): lines = self.samples * (self.table_count // 5 + 1) @@ -28,14 +29,19 @@ class MockDataSource: def __iter__(self): self.row = 0 - return self + if not self.infinity: + return iter(self._iter_data()) + else: + return self def __next__(self): """ next 1000 rows for each table. return: {tableId:[row,...]} """ - # generate 1000 timestamps + return self._iter_data() + + def _iter_data(self): ts = [] for _ in range(1000): self.current_ts += 100 @@ -47,3 +53,10 @@ class MockDataSource: rows = [table_name + ',' + t + ',' + values for t in ts] result.append((table_id, rows)) return result + + +if __name__ == '__main__': + datasource = MockDataSource('t', 10, False) + for data in datasource: + print(data) + \ No newline at end of file diff --git a/docs/examples/python/sql_writer.py b/docs/examples/python/sql_writer.py index 758167376b..db51bb7174 100644 --- a/docs/examples/python/sql_writer.py +++ b/docs/examples/python/sql_writer.py @@ -10,6 +10,7 @@ class SQLWriter: self._tb_tags = {} self._conn = get_connection_func() self._max_sql_length = self.get_max_sql_length() + self._conn.execute("create database if not exists test") self._conn.execute("USE test") def get_max_sql_length(self): @@ -20,7 +21,7 @@ class SQLWriter: return int(r[1]) return 1024 * 1024 - def process_lines(self, lines: str): + def process_lines(self, lines: [str]): """ :param lines: [[tbName,ts,current,voltage,phase,location,groupId]] """ @@ -60,6 +61,7 @@ class SQLWriter: buf.append(q) sql_len += len(q) sql += " ".join(buf) + self.create_tables() self.execute_sql(sql) self._tb_values.clear() @@ -88,3 +90,23 @@ class SQLWriter: except BaseException as e: self.log.error("Execute SQL: %s", sql) raise e + + def close(self): + if self._conn: + self._conn.close() + + +if __name__ == '__main__': + def get_connection_func(): + conn = taos.connect() + return conn + + + writer = SQLWriter(get_connection_func=get_connection_func) + writer.execute_sql( + "create stable if not exists meters (ts timestamp, current float, voltage int, phase float) " + "tags (location binary(64), groupId int)") + writer.execute_sql( + "INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) " + "VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32)") + \ No newline at end of file diff --git a/docs/examples/python/tmq_example.py b/docs/examples/python/tmq_example.py index a4625ca11a..32778e9f25 100644 --- a/docs/examples/python/tmq_example.py +++ b/docs/examples/python/tmq_example.py @@ -1,58 +1,55 @@ +from taos.tmq import Consumer import taos -from taos.tmq import * - -conn = taos.connect() - -print("init") -conn.execute("drop topic if exists topic_ctb_column") -conn.execute("drop database if exists py_tmq") -conn.execute("create database if not exists py_tmq vgroups 2") -conn.select_db("py_tmq") -conn.execute( - "create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)" -) -conn.execute("create table if not exists tb1 using stb1 tags(1)") -conn.execute("create table if not exists tb2 using stb1 tags(2)") -conn.execute("create table if not exists tb3 using stb1 tags(3)") - -print("create topic") -conn.execute( - "create topic if not exists topic_ctb_column as select ts, c1, c2, c3 from stb1" -) - -print("build consumer") -conf = TaosTmqConf() -conf.set("group.id", "tg2") -conf.set("td.connect.user", "root") -conf.set("td.connect.pass", "taosdata") -conf.set("enable.auto.commit", "true") -def tmq_commit_cb_print(tmq, resp, offset, param=None): - print(f"commit: {resp}, tmq: {tmq}, offset: {offset}, param: {param}") +def init_tmq_env(db, topic): + conn = taos.connect() + conn.execute("drop topic if exists {}".format(topic)) + conn.execute("drop database if exists {}".format(db)) + conn.execute("create database if not exists {}".format(db)) + conn.select_db(db) + conn.execute( + "create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))") + conn.execute("create table if not exists tb1 using stb1 tags(1, 't1')") + conn.execute("create table if not exists tb2 using stb1 tags(2, 't2')") + conn.execute("create table if not exists tb3 using stb1 tags(3, 't3')") + conn.execute("create topic if not exists {} as select ts, c1, c2, c3 from stb1".format(topic)) + conn.execute("insert into tb1 values (now, 1, 1.0, 'tmq test')") + conn.execute("insert into tb2 values (now, 2, 2.0, 'tmq test')") + conn.execute("insert into tb3 values (now, 3, 3.0, 'tmq test')") -conf.set_auto_commit_cb(tmq_commit_cb_print, None) -tmq = conf.new_consumer() +def cleanup(db, topic): + conn = taos.connect() + conn.execute("drop topic if exists {}".format(topic)) + conn.execute("drop database if exists {}".format(db)) -print("build topic list") -topic_list = TaosTmqList() -topic_list.append("topic_ctb_column") +if __name__ == '__main__': + init_tmq_env("tmq_test", "tmq_test_topic") # init env + consumer = Consumer( + { + "group.id": "tg2", + "td.connect.user": "root", + "td.connect.pass": "taosdata", + "enable.auto.commit": "true", + } + ) + consumer.subscribe(["tmq_test_topic"]) -print("basic consume loop") -tmq.subscribe(topic_list) + try: + while True: + res = consumer.poll(1) + if not res: + break + err = res.error() + if err is not None: + raise err + val = res.value() -sub_list = tmq.subscription() - -print("subscribed topics: ", sub_list) - -while 1: - res = tmq.poll(1000) - if res: - topic = res.get_topic_name() - vg = res.get_vgroup_id() - db = res.get_db_name() - print(f"topic: {topic}\nvgroup id: {vg}\ndb: {db}") - for row in res: - print(row) + for block in val: + print(block.fetchall()) + finally: + consumer.unsubscribe() + consumer.close() + cleanup("tmq_test", "tmq_test_topic") \ No newline at end of file diff --git a/docs/zh/12-taos-sql/06-select.md b/docs/zh/12-taos-sql/06-select.md index 3b681f401c..b9b26279e6 100644 --- a/docs/zh/12-taos-sql/06-select.md +++ b/docs/zh/12-taos-sql/06-select.md @@ -13,6 +13,7 @@ SELECT [DISTINCT] select_list from_clause [WHERE condition] [partition_by_clause] + [interp_clause] [window_clause] [group_by_clause] [order_by_clasue] @@ -53,8 +54,11 @@ window_clause: { | STATE_WINDOW(col) | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)] +interp_clause: + RANGE(ts_val, ts_val), EVERY(every_val), FILL(fill_mod_and_val) + partition_by_clause: - PARTITION BY expr [, expr] ... + PARTITION BY expr [, expr] ... group_by_clause: GROUP BY expr [, expr] ... HAVING condition diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index afe90b8a93..c44c09d10c 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -875,9 +875,9 @@ INTERP(expr) - INTERP 用于在指定时间断面获取指定列的记录值,如果该时间断面不存在符合条件的行数据,那么会根据 FILL 参数的设定进行插值。 - INTERP 的输入数据为指定列的数据,可以通过条件语句(where 子句)来对原始列数据进行过滤,如果没有指定过滤条件则输入为全部数据。 - INTERP 需要同时与 RANGE,EVERY 和 FILL 关键字一起使用。 -- INTERP 的输出时间范围根据 RANGE(timestamp1,timestamp2)字段来指定,需满足 timestamp1<=timestamp2。其中 timestamp1(必选值)为输出时间范围的起始值,即如果 timestamp1 时刻符合插值条件则 timestamp1 为输出的第一条记录,timestamp2(必选值)为输出时间范围的结束值,即输出的最后一条记录的 timestamp 不能大于 timestamp2。 -- INTERP 根据 EVERY 字段来确定输出时间范围内的结果条数,即从 timestamp1 开始每隔固定长度的时间(EVERY 值)进行插值。 -- INTERP 根据 FILL 字段来决定在每个符合输出条件的时刻如何进行插值。 +- INTERP 的输出时间范围根据 RANGE(timestamp1,timestamp2)字段来指定,需满足 timestamp1 <= timestamp2。其中 timestamp1(必选值)为输出时间范围的起始值,即如果 timestamp1 时刻符合插值条件则 timestamp1 为输出的第一条记录,timestamp2(必选值)为输出时间范围的结束值,即输出的最后一条记录的 timestamp 不能大于 timestamp2。 +- INTERP 根据 EVERY(time_unit) 字段来确定输出时间范围内的结果条数,即从 timestamp1 开始每隔固定长度的时间(time_unit 值)进行插值,time_unit 可取值时间单位:1a(毫秒),1s(秒),1m(分),1h(小时),1d(天),1w(周)。例如 EVERY(500a) 将对于指定数据每500毫秒间隔进行一次插值. +- INTERP 根据 FILL 字段来决定在每个符合输出条件的时刻如何进行插值。关于 FILL 子句如何使用请参考 [FILL 子句](../distinguished/#fill-子句) - INTERP 只能在一个时间序列内进行插值,因此当作用于超级表时必须跟 partition by tbname 一起使用。 - INTERP 可以与伪列 _irowts 一起使用,返回插值点所对应的时间戳(3.0.1.4版本以后支持)。 diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 0cc9fb8619..0703dc6099 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -58,7 +58,7 @@ extern int32_t tMsgDict[]; #define TMSG_INFO(TYPE) \ ((TYPE) < TDMT_DND_MAX_MSG || (TYPE) < TDMT_MND_MAX_MSG || (TYPE) < TDMT_VND_MAX_MSG || (TYPE) < TDMT_SCH_MAX_MSG || \ (TYPE) < TDMT_STREAM_MAX_MSG || (TYPE) < TDMT_MON_MAX_MSG || (TYPE) < TDMT_SYNC_MAX_MSG) || \ - (TYPE) < TDMT_VND_STREAM_MSG || (TYPE) < TDMT_VND_TMQ_MSG \ + (TYPE) < TDMT_VND_STREAM_MSG || (TYPE) < TDMT_VND_TMQ_MSG || (TYPE) < TDMT_VND_TMQ_MAX_MSG \ ? tMsgInfo[tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE)] \ : 0 @@ -144,12 +144,14 @@ typedef enum _mgmt_table { #define TSDB_ALTER_TABLE_UPDATE_OPTIONS 9 #define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME 10 -#define TSDB_FILL_NONE 0 -#define TSDB_FILL_NULL 1 -#define TSDB_FILL_SET_VALUE 2 -#define TSDB_FILL_LINEAR 3 -#define TSDB_FILL_PREV 4 -#define TSDB_FILL_NEXT 5 +#define TSDB_FILL_NONE 0 +#define TSDB_FILL_NULL 1 +#define TSDB_FILL_NULL_F 2 +#define TSDB_FILL_SET_VALUE 3 +#define TSDB_FILL_SET_VALUE_F 4 +#define TSDB_FILL_LINEAR 5 +#define TSDB_FILL_PREV 6 +#define TSDB_FILL_NEXT 7 #define TSDB_ALTER_USER_PASSWD 0x1 #define TSDB_ALTER_USER_SUPERUSER 0x2 @@ -1752,6 +1754,7 @@ typedef struct { #define STREAM_FILL_HISTORY_ON 1 #define STREAM_FILL_HISTORY_OFF 0 #define STREAM_DEFAULT_FILL_HISTORY STREAM_FILL_HISTORY_OFF +#define STREAM_DEFAULT_IGNORE_UPDATE 0 typedef struct { char name[TSDB_STREAM_FNAME_LEN]; @@ -1769,6 +1772,7 @@ typedef struct { SArray* pTags; // array of SField // 3.0.20 int64_t checkpointFreq; // ms + int8_t igUpdate; } SCMCreateStreamReq; typedef struct { diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 0192bbf486..1d69e129f4 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -209,134 +209,136 @@ #define TK_IGNORE 191 #define TK_EXPIRED 192 #define TK_FILL_HISTORY 193 -#define TK_SUBTABLE 194 -#define TK_KILL 195 -#define TK_CONNECTION 196 -#define TK_TRANSACTION 197 -#define TK_BALANCE 198 -#define TK_VGROUP 199 -#define TK_MERGE 200 -#define TK_REDISTRIBUTE 201 -#define TK_SPLIT 202 -#define TK_DELETE 203 -#define TK_INSERT 204 -#define TK_NULL 205 -#define TK_NK_QUESTION 206 -#define TK_NK_ARROW 207 -#define TK_ROWTS 208 -#define TK_QSTART 209 -#define TK_QEND 210 -#define TK_QDURATION 211 -#define TK_WSTART 212 -#define TK_WEND 213 -#define TK_WDURATION 214 -#define TK_IROWTS 215 -#define TK_CAST 216 -#define TK_NOW 217 -#define TK_TODAY 218 -#define TK_TIMEZONE 219 -#define TK_CLIENT_VERSION 220 -#define TK_SERVER_VERSION 221 -#define TK_SERVER_STATUS 222 -#define TK_CURRENT_USER 223 -#define TK_COUNT 224 -#define TK_LAST_ROW 225 -#define TK_CASE 226 -#define TK_END 227 -#define TK_WHEN 228 -#define TK_THEN 229 -#define TK_ELSE 230 -#define TK_BETWEEN 231 -#define TK_IS 232 -#define TK_NK_LT 233 -#define TK_NK_GT 234 -#define TK_NK_LE 235 -#define TK_NK_GE 236 -#define TK_NK_NE 237 -#define TK_MATCH 238 -#define TK_NMATCH 239 -#define TK_CONTAINS 240 -#define TK_IN 241 -#define TK_JOIN 242 -#define TK_INNER 243 -#define TK_SELECT 244 -#define TK_DISTINCT 245 -#define TK_WHERE 246 -#define TK_PARTITION 247 -#define TK_BY 248 -#define TK_SESSION 249 -#define TK_STATE_WINDOW 250 -#define TK_SLIDING 251 -#define TK_FILL 252 -#define TK_VALUE 253 -#define TK_NONE 254 -#define TK_PREV 255 -#define TK_LINEAR 256 -#define TK_NEXT 257 -#define TK_HAVING 258 -#define TK_RANGE 259 -#define TK_EVERY 260 -#define TK_ORDER 261 -#define TK_SLIMIT 262 -#define TK_SOFFSET 263 -#define TK_LIMIT 264 -#define TK_OFFSET 265 -#define TK_ASC 266 -#define TK_NULLS 267 -#define TK_ABORT 268 -#define TK_AFTER 269 -#define TK_ATTACH 270 -#define TK_BEFORE 271 -#define TK_BEGIN 272 -#define TK_BITAND 273 -#define TK_BITNOT 274 -#define TK_BITOR 275 -#define TK_BLOCKS 276 -#define TK_CHANGE 277 -#define TK_COMMA 278 -#define TK_COMPACT 279 -#define TK_CONCAT 280 -#define TK_CONFLICT 281 -#define TK_COPY 282 -#define TK_DEFERRED 283 -#define TK_DELIMITERS 284 -#define TK_DETACH 285 -#define TK_DIVIDE 286 -#define TK_DOT 287 -#define TK_EACH 288 -#define TK_FAIL 289 -#define TK_FILE 290 -#define TK_FOR 291 -#define TK_GLOB 292 -#define TK_ID 293 -#define TK_IMMEDIATE 294 -#define TK_IMPORT 295 -#define TK_INITIALLY 296 -#define TK_INSTEAD 297 -#define TK_ISNULL 298 -#define TK_KEY 299 -#define TK_MODULES 300 -#define TK_NK_BITNOT 301 -#define TK_NK_SEMI 302 -#define TK_NOTNULL 303 -#define TK_OF 304 -#define TK_PLUS 305 -#define TK_PRIVILEGE 306 -#define TK_RAISE 307 -#define TK_REPLACE 308 -#define TK_RESTRICT 309 -#define TK_ROW 310 -#define TK_SEMI 311 -#define TK_STAR 312 -#define TK_STATEMENT 313 -#define TK_STRICT 314 -#define TK_STRING 315 -#define TK_TIMES 316 -#define TK_UPDATE 317 -#define TK_VALUES 318 -#define TK_VARIABLE 319 -#define TK_VIEW 320 -#define TK_WAL 321 +#define TK_UPDATE 194 +#define TK_SUBTABLE 195 +#define TK_KILL 196 +#define TK_CONNECTION 197 +#define TK_TRANSACTION 198 +#define TK_BALANCE 199 +#define TK_VGROUP 200 +#define TK_MERGE 201 +#define TK_REDISTRIBUTE 202 +#define TK_SPLIT 203 +#define TK_DELETE 204 +#define TK_INSERT 205 +#define TK_NULL 206 +#define TK_NK_QUESTION 207 +#define TK_NK_ARROW 208 +#define TK_ROWTS 209 +#define TK_QSTART 210 +#define TK_QEND 211 +#define TK_QDURATION 212 +#define TK_WSTART 213 +#define TK_WEND 214 +#define TK_WDURATION 215 +#define TK_IROWTS 216 +#define TK_CAST 217 +#define TK_NOW 218 +#define TK_TODAY 219 +#define TK_TIMEZONE 220 +#define TK_CLIENT_VERSION 221 +#define TK_SERVER_VERSION 222 +#define TK_SERVER_STATUS 223 +#define TK_CURRENT_USER 224 +#define TK_COUNT 225 +#define TK_LAST_ROW 226 +#define TK_CASE 227 +#define TK_END 228 +#define TK_WHEN 229 +#define TK_THEN 230 +#define TK_ELSE 231 +#define TK_BETWEEN 232 +#define TK_IS 233 +#define TK_NK_LT 234 +#define TK_NK_GT 235 +#define TK_NK_LE 236 +#define TK_NK_GE 237 +#define TK_NK_NE 238 +#define TK_MATCH 239 +#define TK_NMATCH 240 +#define TK_CONTAINS 241 +#define TK_IN 242 +#define TK_JOIN 243 +#define TK_INNER 244 +#define TK_SELECT 245 +#define TK_DISTINCT 246 +#define TK_WHERE 247 +#define TK_PARTITION 248 +#define TK_BY 249 +#define TK_SESSION 250 +#define TK_STATE_WINDOW 251 +#define TK_SLIDING 252 +#define TK_FILL 253 +#define TK_VALUE 254 +#define TK_VALUE_F 255 +#define TK_NONE 256 +#define TK_PREV 257 +#define TK_NULL_F 258 +#define TK_LINEAR 259 +#define TK_NEXT 260 +#define TK_HAVING 261 +#define TK_RANGE 262 +#define TK_EVERY 263 +#define TK_ORDER 264 +#define TK_SLIMIT 265 +#define TK_SOFFSET 266 +#define TK_LIMIT 267 +#define TK_OFFSET 268 +#define TK_ASC 269 +#define TK_NULLS 270 +#define TK_ABORT 271 +#define TK_AFTER 272 +#define TK_ATTACH 273 +#define TK_BEFORE 274 +#define TK_BEGIN 275 +#define TK_BITAND 276 +#define TK_BITNOT 277 +#define TK_BITOR 278 +#define TK_BLOCKS 279 +#define TK_CHANGE 280 +#define TK_COMMA 281 +#define TK_COMPACT 282 +#define TK_CONCAT 283 +#define TK_CONFLICT 284 +#define TK_COPY 285 +#define TK_DEFERRED 286 +#define TK_DELIMITERS 287 +#define TK_DETACH 288 +#define TK_DIVIDE 289 +#define TK_DOT 290 +#define TK_EACH 291 +#define TK_FAIL 292 +#define TK_FILE 293 +#define TK_FOR 294 +#define TK_GLOB 295 +#define TK_ID 296 +#define TK_IMMEDIATE 297 +#define TK_IMPORT 298 +#define TK_INITIALLY 299 +#define TK_INSTEAD 300 +#define TK_ISNULL 301 +#define TK_KEY 302 +#define TK_MODULES 303 +#define TK_NK_BITNOT 304 +#define TK_NK_SEMI 305 +#define TK_NOTNULL 306 +#define TK_OF 307 +#define TK_PLUS 308 +#define TK_PRIVILEGE 309 +#define TK_RAISE 310 +#define TK_REPLACE 311 +#define TK_RESTRICT 312 +#define TK_ROW 313 +#define TK_SEMI 314 +#define TK_STAR 315 +#define TK_STATEMENT 316 +#define TK_STRICT 317 +#define TK_STRING 318 +#define TK_TIMES 319 +#define TK_VALUES 320 +#define TK_VARIABLE 321 +#define TK_VIEW 322 +#define TK_WAL 323 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 9ca6a7a9fa..411c7d5e8b 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -218,6 +218,7 @@ bool fmIsKeepOrderFunc(int32_t funcId); bool fmIsCumulativeFunc(int32_t funcId); bool fmIsInterpPseudoColumnFunc(int32_t funcId); bool fmIsGroupKeyFunc(int32_t funcId); +bool fmIsBlockDistFunc(int32_t funcId); void getLastCacheDataType(SDataType* pType); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index b1054e7b85..de27806912 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -389,6 +389,7 @@ typedef struct SStreamOptions { SNode* pDeleteMark; int8_t fillHistory; int8_t ignoreExpired; + int8_t ignoreUpdate; } SStreamOptions; typedef struct SCreateStreamStmt { diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index d885665117..80fa0d3e78 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -93,6 +93,7 @@ typedef struct SScanLogicNode { int64_t watermark; int64_t deleteMark; int8_t igExpired; + int8_t igCheckUpdate; SArray* pSmaIndexes; SNodeList* pGroupTags; bool groupSort; @@ -217,6 +218,7 @@ typedef struct SWindowLogicNode { int64_t watermark; int64_t deleteMark; int8_t igExpired; + int8_t igCheckUpdate; EWindowAlgorithm windowAlgo; EOrder inputTsOrder; EOrder outputTsOrder; @@ -357,6 +359,7 @@ typedef struct STableScanPhysiNode { int64_t watermark; int8_t igExpired; bool assignBlockUid; + int8_t igCheckUpdate; } STableScanPhysiNode; typedef STableScanPhysiNode STableSeqScanPhysiNode; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 48b98fcf33..e291051351 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -226,8 +226,10 @@ typedef struct SIntervalWindowNode { typedef enum EFillMode { FILL_MODE_NONE = 1, FILL_MODE_VALUE, + FILL_MODE_VALUE_F, FILL_MODE_PREV, FILL_MODE_NULL, + FILL_MODE_NULL_F, FILL_MODE_LINEAR, FILL_MODE_NEXT } EFillMode; diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index f7bd68393e..41c0e98084 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -36,6 +36,7 @@ typedef struct SPlanContext { int64_t watermark; int64_t deleteMark; int8_t igExpired; + int8_t igCheckUpdate; char* pMsg; int32_t msgLen; const char* pUser; diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index a1ae1e429d..1eed342f8c 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -191,6 +191,7 @@ int32_t walApplyVer(SWal *, int64_t ver); // read SWalReader *walOpenReader(SWal *, SWalFilterCond *pCond); void walCloseReader(SWalReader *pRead); +void walReadReset(SWalReader *pReader); int32_t walReadVer(SWalReader *pRead, int64_t ver); int32_t walReadSeekVer(SWalReader *pRead, int64_t ver); int32_t walNextValidMsg(SWalReader *pRead); @@ -201,6 +202,7 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead); int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead); int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead); +SWalRef *walRefFirstVer(SWal *, SWalRef *); SWalRef *walRefCommittedVer(SWal *); SWalRef *walOpenRef(SWal *); diff --git a/include/os/osFile.h b/include/os/osFile.h index ae77e0f27a..0e93002706 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -110,6 +110,8 @@ bool taosValidFile(TdFilePtr pFile); int32_t taosGetErrorFile(TdFilePtr pFile); +int32_t taosCompressFile(char *srcFileName, char *destFileName); + #ifdef __cplusplus } #endif diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 51f336c3aa..21d299f28d 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -355,6 +355,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_STREAM_MUST_BE_DELETED TAOS_DEF_ERROR_CODE(0, 0x03F3) #define TSDB_CODE_MND_STREAM_TASK_DROPPED TAOS_DEF_ERROR_CODE(0, 0x03F4) #define TSDB_CODE_MND_MULTI_REPLICA_SOURCE_DB TAOS_DEF_ERROR_CODE(0, 0x03F5) +#define TSDB_CODE_MND_TOO_MANY_STREAMS TAOS_DEF_ERROR_CODE(0, 0x03F6) // mnode-sma #define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480) diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 4be179b04d..dfdbaa6fdd 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -210,8 +210,8 @@ function install_bin() { [ -x ${install_main_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || : [ -x ${install_main_dir}/bin/${udfdName} ] && ${csudo}ln -s ${install_main_dir}/bin/${udfdName} ${bin_link_dir}/${udfdName} || : [ -x ${install_main_dir}/bin/${adapterName} ] && ${csudo}ln -s ${install_main_dir}/bin/${adapterName} ${bin_link_dir}/${adapterName} || : - [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || : - [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || : + [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || : + [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || : [ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || : [ -x ${install_main_dir}/bin/${xname} ] && ${csudo}ln -s ${install_main_dir}/bin/${xname} ${bin_link_dir}/${xname} || : [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : @@ -746,7 +746,7 @@ function is_version_compatible() { deb_erase() { confirm="" while [ "" == "${confirm}" ]; do - echo -e -n "${RED}Exist tdengine deb detected, do you want to remove it? [yes|no] ${NC}:" + echo -e -n "${RED}Existing TDengine deb is detected, do you want to remove it? [yes|no] ${NC}:" read confirm if [ "yes" == "$confirm" ]; then ${csudo}dpkg --remove tdengine ||: @@ -760,7 +760,7 @@ deb_erase() { rpm_erase() { confirm="" while [ "" == "${confirm}" ]; do - echo -e -n "${RED}Exist tdengine rpm detected, do you want to remove it? [yes|no] ${NC}:" + echo -e -n "${RED}Existing TDengine rpm is detected, do you want to remove it? [yes|no] ${NC}:" read confirm if [ "yes" == "$confirm" ]; then ${csudo}rpm -e tdengine ||: @@ -787,7 +787,7 @@ function updateProduct() { if echo $osinfo | grep -qwi "centos"; then rpm -q tdengine 2>&1 > /dev/null && rpm_erase tdengine ||: elif echo $osinfo | grep -qwi "ubuntu"; then - dpkg -l tdengine 2>&1 > /dev/null && deb_erase tdengine ||: + dpkg -l tdengine 2>&1 | grep ii > /dev/null && deb_erase tdengine ||: fi tar -zxf ${tarName} diff --git a/packaging/tools/make_install.bat b/packaging/tools/make_install.bat index c19519f9a1..993a8a19ee 100644 --- a/packaging/tools/make_install.bat +++ b/packaging/tools/make_install.bat @@ -2,12 +2,20 @@ for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a" -goto %1 +if "%1" NEQ "" goto %1 + :needAdmin if exist C:\\TDengine\\data\\dnode\\dnodeCfg.json ( echo The default data directory C:/TDengine/data contains old data of tdengine 2.x, please clear it before installing! ) + +rem // stop and delete service +mshta vbscript:createobject("shell.application").shellexecute("%~s0",":stop_delete","","runas",1)(window.close) +echo This might take a few moment to accomplish deleting service taosd/taosadapter ... +call :check_svc taosd +call :check_svc taosadapter + set source_dir=%2 set source_dir=%source_dir:/=\\% set binary_dir=%3 @@ -60,7 +68,6 @@ if exist %binary_dir%\\build\\bin\\taosdump.exe ( copy %binary_dir%\\build\\bin\\taosd.exe %target_dir% > nul copy %binary_dir%\\build\\bin\\udfd.exe %target_dir% > nul - if exist %binary_dir%\\build\\bin\\taosadapter.exe ( copy %binary_dir%\\build\\bin\\taosadapter.exe %target_dir% > nul ) @@ -80,22 +87,23 @@ goto :eof :hasAdmin -sc query "taosd" && sc stop taosd && sc delete taosd -sc query "taosadapter" && sc stop taosadapter && sc delete taosd +call :stop_delete +call :check_svc taosd +call :check_svc taosadapter copy /y C:\\TDengine\\driver\\taos.dll C:\\Windows\\System32 > nul if exist C:\\TDengine\\driver\\taosws.dll ( copy /y C:\\TDengine\\driver\\taosws.dll C:\\Windows\\System32 > nul ) -sc query "taosd" >nul || sc create "taosd" binPath= "C:\\TDengine\\taosd.exe --win_service" start= DEMAND -sc query "taosadapter" >nul || sc create "taosadapter" binPath= "C:\\TDengine\\taosadapter.exe" start= DEMAND +rem // create services +sc create "taosd" binPath= "C:\\TDengine\\taosd.exe --win_service" start= DEMAND +sc create "taosadapter" binPath= "C:\\TDengine\\taosadapter.exe" start= DEMAND set "env=HKLM\System\CurrentControlSet\Control\Session Manager\Environment" for /f "tokens=2*" %%I in ('reg query "%env%" /v Path ^| findstr /i "\"') do ( - rem // make addition persistent through reboots - reg add "%env%" /f /v Path /t REG_EXPAND_SZ /d "%%J;C:\TDengine" + call :append_if_not_exists %%J rem // apply change to the current process for %%a in ("%%J;C:\TDengine") do path %%~a @@ -105,3 +113,36 @@ rem // use setx to set a temporary throwaway value to trigger a WM_SETTINGCHANGE rem // applies change to new console windows without requiring a reboot (setx /m foo bar & reg delete "%env%" /f /v foo) >NUL 2>NUL +goto :end + +:append_if_not_exists +set "_origin_paths=%*" +set "_paths=%*" +set "_found=0" +:loop +for /f "tokens=1* delims=;" %%x in ("%_paths%") do ( + if "%%x" EQU "C:\TDengine" ( + set "_found=1" + ) else ( + set "_paths=%%y" + goto :loop + ) +) +if "%_found%" == "0" ( + rem // make addition persistent through reboots + reg add "%env%" /f /v Path /t REG_EXPAND_SZ /d "%_origin_paths%;C:\TDengine" +) +exit /B 0 + +:stop_delete +sc stop taosd +sc delete taosd +sc stop taosadapter +sc delete taosadapter +exit /B 0 + +:check_svc +sc query %1 >nul 2>nul && goto :check_svc %1 +exit /B 0 + +:end diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 0c445c7fbf..d0cfd38fb9 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -62,4 +62,4 @@ target_link_libraries( if(${BUILD_TEST}) ADD_SUBDIRECTORY(test) -endif(${BUILD_TEST}) \ No newline at end of file +endif(${BUILD_TEST}) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index b5b99e92b0..67fa1e7781 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -138,6 +138,12 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas p->mgmtEp = epSet; taosThreadMutexInit(&p->qnodeMutex, NULL); p->pTransporter = openTransporter(user, secretEncrypt, tsNumOfCores / 2); + if (p->pTransporter == NULL) { + taosThreadMutexUnlock(&appInfo.mutex); + taosMemoryFreeClear(key); + taosMemoryFree(p); + return NULL; + } p->pAppHbMgr = appHbMgrInit(p, key); if (NULL == p->pAppHbMgr) { destroyAppInst(p); @@ -1402,8 +1408,6 @@ int32_t doProcessMsgFromServer(void* param) { tscError("0x%" PRIx64 " rsp msg:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%" PRIx64, pRequest->self, TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed / 1000, pRequest->requestId); } - - taosReleaseRef(clientReqRefPool, pSendInfo->requestObjRefId); } } @@ -1423,6 +1427,11 @@ int32_t doProcessMsgFromServer(void* param) { } pSendInfo->fp(pSendInfo->param, &buf, pMsg->code); + + if (pTscObj) { + taosReleaseRef(clientReqRefPool, pSendInfo->requestObjRefId); + } + rpcFreeCont(pMsg->pCont); destroySendMsgInfo(pSendInfo); @@ -1460,6 +1469,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { tscError("failed to sched msg to tsc, tsc ready to quit"); rpcFreeCont(pMsg->pCont); taosMemoryFree(arg->pEpset); + destroySendMsgInfo(pMsg->info.ahandle); taosMemoryFree(arg); } } diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index c24aa536c2..0694f4c457 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -149,17 +149,8 @@ typedef struct { int64_t endTime; } SSmlCostInfo; -typedef struct { - SRequestObj *request; - tsem_t sem; - int32_t cnt; - int32_t total; - TdThreadSpinlock lock; -} Params; - typedef struct { int64_t id; - Params *params; SMLProtocolType protocol; int8_t precision; @@ -178,7 +169,6 @@ typedef struct { SQuery *pQuery; SSmlCostInfo cost; - int32_t affectedRows; SSmlMsgBuf msgBuf; SHashObj *dumplicateKey; // for dumplicate key SArray *colsContainer; // for cols parse, if dataFormat == false @@ -1513,7 +1503,6 @@ static void smlDestroyInfo(SSmlHandle *info) { if (!info->dataFormat) { taosArrayDestroy(info->colsContainer); } - destroyRequest(info->pRequest); cJSON_Delete(info->root); taosMemoryFreeClear(info); @@ -2351,20 +2340,11 @@ static int32_t smlInsertData(SSmlHandle *info) { } info->cost.insertRpcTime = taosGetTimestampUs(); - // launchQueryImpl(info->pRequest, info->pQuery, false, NULL); - // info->affectedRows = taos_affected_rows(info->pRequest); - // return info->pRequest->code; - SAppClusterSummary *pActivity = &info->taos->pAppInfo->summary; atomic_add_fetch_64((int64_t *)&pActivity->numOfInsertsReq, 1); - SSqlCallbackWrapper *pWrapper = (SSqlCallbackWrapper *)taosMemoryCalloc(1, sizeof(SSqlCallbackWrapper)); - if (pWrapper == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pWrapper->pRequest = info->pRequest; - launchAsyncQuery(info->pRequest, info->pQuery, NULL, pWrapper); - return TSDB_CODE_SUCCESS; + launchQueryImpl(info->pRequest, info->pQuery, true, NULL); + return info->pRequest->code; } static void smlPrintStatisticInfo(SSmlHandle *info) { @@ -2498,48 +2478,13 @@ static int32_t isSchemalessDb(STscObj *taos, SRequestObj *request) { return TSDB_CODE_SUCCESS; } -static void smlInsertCallback(void *param, void *res, int32_t code) { - SRequestObj *pRequest = (SRequestObj *)res; - SSmlHandle *info = (SSmlHandle *)param; - int32_t rows = taos_affected_rows(pRequest); - - uDebug("SML:0x%" PRIx64 " result. code:%d, msg:%s", info->id, pRequest->code, pRequest->msgBuf); - Params *pParam = info->params; - // lock - taosThreadSpinLock(&pParam->lock); - pParam->cnt++; - if (code != TSDB_CODE_SUCCESS) { - pParam->request->code = code; - pParam->request->body.resInfo.numOfRows += rows; - } else { - pParam->request->body.resInfo.numOfRows += info->affectedRows; - } - // unlock - taosThreadSpinUnlock(&pParam->lock); - - if (pParam->cnt == pParam->total) { - tsem_post(&pParam->sem); - } - uDebug("SML:0x%" PRIx64 " insert finished, code: %d, rows: %d, total: %d", info->id, code, rows, info->affectedRows); - info->cost.endTime = taosGetTimestampUs(); - info->cost.code = code; - smlPrintStatisticInfo(info); - smlDestroyInfo(info); -} - TAOS_RES *taos_schemaless_insert_inner(SRequestObj *request, char *lines[], char *rawLine, char *rawLineEnd, int numLines, int protocol, int precision, int32_t ttl) { - int batchs = 0; STscObj *pTscObj = request->pTscObj; - + SSmlHandle *info = NULL; pTscObj->schemalessType = 1; SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf}; - Params params = {0}; - params.request = request; - tsem_init(¶ms.sem, 0, 0); - taosThreadSpinInit(&(params.lock), 0); - if (request->pDb == NULL) { request->code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; smlBuildInvalidDataMsg(&msg, "Database not specified", NULL); @@ -2573,65 +2518,24 @@ TAOS_RES *taos_schemaless_insert_inner(SRequestObj *request, char *lines[], char goto end; } - batchs = ceil(((double)numLines) / tsSmlBatchSize); - params.total = batchs; - for (int i = 0; i < batchs; ++i) { - SRequestObj *req = (SRequestObj *)createRequest(pTscObj->id, TSDB_SQL_INSERT, 0); - if (!req) { - request->code = TSDB_CODE_OUT_OF_MEMORY; - uError("SML:taos_schemaless_insert error request is null"); - goto end; - } - SSmlHandle *info = smlBuildSmlInfo(pTscObj, req, (SMLProtocolType)protocol, precision); - if (!info) { - request->code = TSDB_CODE_OUT_OF_MEMORY; - uError("SML:taos_schemaless_insert error SSmlHandle is null"); - goto end; - } - - info->isRawLine = (rawLine == NULL); - info->ttl = ttl; - - int32_t perBatch = tsSmlBatchSize; - - if (numLines > perBatch) { - numLines -= perBatch; - } else { - perBatch = numLines; - numLines = 0; - } - - info->params = ¶ms; - info->affectedRows = perBatch; - info->pRequest->body.queryFp = smlInsertCallback; - info->pRequest->body.param = info; - int32_t code = smlProcess(info, lines, rawLine, rawLineEnd, perBatch); - if (lines) { - lines += perBatch; - } - if (rawLine) { - int num = 0; - while (rawLine < rawLineEnd) { - if (*(rawLine++) == '\n') { - num++; - } - if (num == perBatch) { - break; - } - } - } - if (code != TSDB_CODE_SUCCESS) { - info->pRequest->body.queryFp(info, req, code); - } + info = smlBuildSmlInfo(pTscObj, request, (SMLProtocolType)protocol, precision); + if (!info) { + request->code = TSDB_CODE_OUT_OF_MEMORY; + uError("SML:taos_schemaless_insert error SSmlHandle is null"); + goto end; } - tsem_wait(¶ms.sem); + + info->isRawLine = (rawLine == NULL); + info->ttl = ttl; + request->code = smlProcess(info, lines, rawLine, rawLineEnd, numLines); end: - taosThreadSpinDestroy(¶ms.lock); - tsem_destroy(¶ms.sem); - // ((STscObj *)taos)->schemalessType = 0; - pTscObj->schemalessType = 1; - uDebug("resultend:%s", request->msgBuf); + uDebug("SML:0x%" PRIx64 " insert finished, code: %d", info->id, request->code); + info->cost.endTime = taosGetTimestampUs(); + info->cost.code = request->code; + smlPrintStatisticInfo(info); + smlDestroyInfo(info); + return (TAOS_RES *)request; } diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 90c405c204..22739108e2 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -1891,9 +1891,6 @@ int32_t tmq_consumer_close(tmq_t* tmq) { } tmq_list_destroy(lst); - - /*return rsp;*/ - return 0; } taosRemoveRef(tmqMgmt.rsetId, tmq->refId); return 0; diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 82202b8820..a75411a854 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -112,7 +112,7 @@ void createNewTable(TAOS* pConn, int32_t index) { } taos_free_result(pRes); - for(int32_t i = 0; i < 20; i += 20) { + for(int32_t i = 0; i < 2000; i += 20) { char sql[1024] = {0}; sprintf(sql, "insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" @@ -692,6 +692,7 @@ TEST(testCase, insert_test) { taos_free_result(pRes); taos_close(pConn); } +#endif TEST(testCase, projection_query_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); @@ -725,7 +726,7 @@ TEST(testCase, projection_query_tables) { } taos_free_result(pRes); - for (int32_t i = 0; i < 200000; ++i) { + for (int32_t i = 0; i < 2; ++i) { printf("create table :%d\n", i); createNewTable(pConn, i); } @@ -751,6 +752,7 @@ TEST(testCase, projection_query_tables) { taos_close(pConn); } +#if 0 TEST(testCase, tsbs_perf_test) { TdThread qid[20] = {0}; @@ -760,8 +762,6 @@ TEST(testCase, tsbs_perf_test) { getchar(); } -#endif - TEST(testCase, projection_query_stables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); @@ -790,7 +790,6 @@ TEST(testCase, projection_query_stables) { taos_close(pConn); } -#if 0 TEST(testCase, agg_query_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); @@ -831,7 +830,7 @@ TEST(testCase, async_api_test) { ASSERT_NE(pConn, nullptr); taos_query(pConn, "use abc1"); -#if 0 + TAOS_RES* pRes = taos_query(pConn, "insert into tu(ts) values('2022-02-27 12:12:61')"); if (taos_errno(pRes) != 0) { printf("failed, reason:%s\n", taos_errstr(pRes)); @@ -854,7 +853,6 @@ TEST(testCase, async_api_test) { printf("%s\n", str); memset(str, 0, sizeof(str)); } -#endif taos_query_a(pConn, "select count(*) from tu", queryCallback, pConn); getchar(); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 891f5e21ab..ec617163a2 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5425,6 +5425,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; if (tEncodeCStr(&encoder, pField->name) < 0) return -1; } + if (tEncodeI8(&encoder, pReq->igUpdate) < 0) return -1; tEndEncode(&encoder); @@ -5486,6 +5487,8 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea } } + if (tDecodeI8(&decoder, &pReq->igUpdate) < 0) return -1; + tEndDecode(&decoder); tDecoderClear(&decoder); diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 16fe6c1b91..cf4eaaf7d1 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -167,6 +167,7 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TTL_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_SMA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_TMQ_SUBSCRIBE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index 095857825d..b0810d528f 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -49,7 +49,7 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { pMsg->info.node = pMgmt->pMnode; const STraceId *trace = &pMsg->info.traceId; - dGTrace("msg:%p, get from mnode queue", pMsg); + dGTrace("msg:%p, get from mnode queue, type:%s", pMsg, TMSG_INFO(pMsg->msgType)); int32_t code = mndProcessRpcMsg(pMsg); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 99ba9b9b3b..951544c766 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -79,8 +79,6 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) { void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { char path[TSDB_FILENAME_LEN] = {0}; - vnodeProposeCommitOnNeed(pVnode->pImpl); - taosThreadRwlockWrlock(&pMgmt->lock); taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t)); taosThreadRwlockUnlock(&pMgmt->lock); diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 2f824b48b4..6f6f801c39 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -648,6 +648,7 @@ typedef struct { int64_t checkpointFreq; // ms int64_t currentTick; // do not serialize int64_t deleteMark; + int8_t igCheckUpdate; } SStreamObj; int32_t tEncodeSStreamObj(SEncoder* pEncoder, const SStreamObj* pObj); diff --git a/source/dnode/mnode/impl/inc/mndTrans.h b/source/dnode/mnode/impl/inc/mndTrans.h index 07066d2251..d6e5d322ba 100644 --- a/source/dnode/mnode/impl/inc/mndTrans.h +++ b/source/dnode/mnode/impl/inc/mndTrans.h @@ -81,7 +81,7 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans); int32_t mndTransProcessRsp(SRpcMsg *pRsp); void mndTransPullup(SMnode *pMnode); int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans); -void mndTransExecute(SMnode *pMnode, STrans *pTrans); +void mndTransExecute(SMnode *pMnode, STrans *pTrans, bool isLeader); int32_t mndSetRpcInfoForDbTrans(SMnode *pMnode, SRpcMsg *pMsg, EOperType oper, const char *dbname); #ifdef __cplusplus diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 3bbf4a4279..1aa2fa997b 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -836,10 +836,13 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, char *addedTopic = strdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0)); // not exist in current topic + bool existing = false; #if 1 for (int32_t i = 0; i < taosArrayGetSize(pOldConsumer->currentTopics); i++) { char *topic = taosArrayGetP(pOldConsumer->currentTopics, i); - ASSERT(strcmp(topic, addedTopic) != 0); + if (strcmp(topic, addedTopic) == 0) { + existing = true; + } } #endif @@ -854,8 +857,10 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, } // add to current topic - taosArrayPush(pOldConsumer->currentTopics, &addedTopic); - taosArraySort(pOldConsumer->currentTopics, taosArrayCompareString); + if (!existing) { + taosArrayPush(pOldConsumer->currentTopics, &addedTopic); + taosArraySort(pOldConsumer->currentTopics, taosArrayCompareString); + } // set status if (taosArrayGetSize(pOldConsumer->rebNewTopics) == 0 && taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0) { diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index a5f77513de..75177f4158 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -78,6 +78,7 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) { // 3.0.20 if (tEncodeI64(pEncoder, pObj->checkpointFreq) < 0) return -1; + if (tEncodeI8(pEncoder, pObj->igCheckUpdate) < 0) return -1; tEndEncode(pEncoder); return pEncoder->pos; @@ -145,6 +146,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj, int32_t sver) { // 3.0.20 if (sver >= 2) { if (tDecodeI64(pDecoder, &pObj->checkpointFreq) < 0) return -1; + if (tDecodeI8(pDecoder, &pObj->igCheckUpdate) < 0) return -1; } tEndDecode(pDecoder); return 0; @@ -489,7 +491,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) { tlen += tEncodeSMqConsumerEp(buf, pConsumerEp); cnt++; } - if(cnt != sz) return -1; + if (cnt != sz) return -1; tlen += taosEncodeArray(buf, pSub->unassignedVgs, (FEncode)tEncodeSMqVgEp); tlen += taosEncodeString(buf, pSub->dbName); return tlen; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index d504a94700..471c53b2f5 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -41,6 +41,7 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq); static int32_t mndProcessCreateStbReq(SRpcMsg *pReq); static int32_t mndProcessAlterStbReq(SRpcMsg *pReq); static int32_t mndProcessDropStbReq(SRpcMsg *pReq); +static int32_t mndProcessDropTtltbReq(SRpcMsg *pReq); static int32_t mndProcessTableMetaReq(SRpcMsg *pReq); static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextStb(SMnode *pMnode, void *pIter); @@ -64,6 +65,7 @@ int32_t mndInitStb(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessAlterStbReq); mndSetMsgHandle(pMnode, TDMT_MND_DROP_STB, mndProcessDropStbReq); mndSetMsgHandle(pMnode, TDMT_VND_CREATE_STB_RSP, mndTransProcessRsp); + mndSetMsgHandle(pMnode, TDMT_VND_DROP_TTL_TABLE_RSP, mndProcessDropTtltbReq); mndSetMsgHandle(pMnode, TDMT_VND_ALTER_STB_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_VND_DROP_STB_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_MND_TABLE_META, mndProcessTableMetaReq); @@ -2176,6 +2178,10 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName, return 0; } +static int32_t mndProcessDropTtltbReq(SRpcMsg *pRsp) { + return 0; +} + static int32_t mndProcessDropStbReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; int32_t code = -1; diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 83ed6eea78..61e9fc5366 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -31,6 +31,8 @@ #define MND_STREAM_VER_NUMBER 2 #define MND_STREAM_RESERVE_SIZE 64 +#define MND_STREAM_MAX_NUM 10 + static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream); static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream); static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pStream, SStreamObj *pNewStream); @@ -295,6 +297,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, pObj->triggerParam = pCreate->maxDelay; pObj->watermark = pCreate->watermark; pObj->fillHistory = pCreate->fillHistory; + pObj->igCheckUpdate = pCreate->igUpdate; memcpy(pObj->sourceDb, pCreate->sourceDB, TSDB_DB_FNAME_LEN); SDbObj *pSourceDb = mndAcquireDb(pMnode, pCreate->sourceDB); @@ -343,6 +346,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, .triggerType = pObj->trigger == STREAM_TRIGGER_MAX_DELAY ? STREAM_TRIGGER_WINDOW_CLOSE : pObj->trigger, .watermark = pObj->watermark, .igExpired = pObj->igExpired, + .igCheckUpdate = pObj->igCheckUpdate, }; // using ast and param to build physical plan @@ -625,6 +629,35 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { goto _OVER; } + { + int32_t numOfStream = 0; + + SStreamObj *pStream = NULL; + void *pIter = NULL; + + while (1) { + pIter = sdbFetch(pMnode->pSdb, SDB_STREAM, pIter, (void **)&pStream); + if (pIter == NULL) { + if (numOfStream > MND_STREAM_MAX_NUM) { + mError("too many streams, no more than 10 for each database"); + terrno = TSDB_CODE_MND_TOO_MANY_STREAMS; + goto _OVER; + } + break; + } + + if (pStream->sourceDbUid == streamObj.sourceDbUid) { + ++numOfStream; + } + sdbRelease(pMnode->pSdb, pStream); + if (numOfStream > MND_STREAM_MAX_NUM) { + mError("too many streams, no more than 10 for each database"); + terrno = TSDB_CODE_MND_TOO_MANY_STREAMS; + goto _OVER; + } + } + } + pDb = mndAcquireDb(pMnode, streamObj.sourceDb); if (pDb->cfg.replications != 1) { mError("stream source db must have only 1 replica, but %s has %d", pDb->name, pDb->cfg.replications); diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 6b675586e4..1dc9ae9c4b 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -85,7 +85,11 @@ int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta pRaw, pMgmt->transSec, pMgmt->transSeq); if (pMeta->code == 0) { - sdbWriteWithoutFree(pMnode->pSdb, pRaw); + int32_t code = sdbWriteWithoutFree(pMnode->pSdb, pRaw); + if (code != 0) { + mError("trans:%d, failed to write to sdb since %s", transId, terrstr()); + return 0; + } sdbSetApplyInfo(pMnode->pSdb, pMeta->index, pMeta->term, pMeta->lastConfigIndex); } @@ -110,8 +114,9 @@ int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta taosThreadMutexUnlock(&pMgmt->lock); STrans *pTrans = mndAcquireTrans(pMnode, transId); if (pTrans != NULL) { - mInfo("trans:%d, execute in mnode which not leader or sync timeout", transId); - mndTransExecute(pMnode, pTrans); + mInfo("trans:%d, execute in mnode which not leader or sync timeout, createTime:%" PRId64 " saved trans:%d", + transId, pTrans->createdTime, pMgmt->transId); + mndTransExecute(pMnode, pTrans, false); mndReleaseTrans(pMnode, pTrans); // sdbWriteFile(pMnode->pSdb, SDB_WRITE_DELTA); } else { @@ -368,7 +373,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { taosThreadMutexLock(&pMgmt->lock); pMgmt->errCode = 0; - if (pMgmt->transId != 0) { + if (pMgmt->transId != 0 /* && pMgmt->transId != transId*/) { mError("trans:%d, can't be proposed since trans:%d already waiting for confirm", transId, pMgmt->transId); taosThreadMutexUnlock(&pMgmt->lock); rpcFreeCont(req.pCont); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index dfcd55bcba..6bb286cd6f 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -572,8 +572,20 @@ static void mndTransUpdateActions(SArray *pOldArray, SArray *pNewArray) { } static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) { - mTrace("trans:%d, perform update action, old row:%p stage:%s, new row:%p stage:%s", pOld->id, pOld, - mndTransStr(pOld->stage), pNew, mndTransStr(pNew->stage)); + mTrace("trans:%d, perform update action, old row:%p stage:%s create:%" PRId64 ", new row:%p stage:%s create:%" PRId64, + pOld->id, pOld, mndTransStr(pOld->stage), pOld->createdTime, pNew, mndTransStr(pNew->stage), + pNew->createdTime); + + if (pOld->createdTime != pNew->createdTime) { + mError("trans:%d, failed to perform update action since createTime not match, old row:%p stage:%s create:%" PRId64 + ", new row:%p stage:%s create:%" PRId64, + pOld->id, pOld, mndTransStr(pOld->stage), pOld->createdTime, pNew, mndTransStr(pNew->stage), + pNew->createdTime); + // only occured while sync timeout + terrno = TSDB_CODE_MND_TRNAS_SYNC_TIMEOUT; + return -1; + } + mndTransUpdateActions(pOld->redoActions, pNew->redoActions); mndTransUpdateActions(pOld->undoActions, pNew->undoActions); mndTransUpdateActions(pOld->commitActions, pNew->commitActions); @@ -779,16 +791,18 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) { } (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY); - mInfo("trans:%d, sync to other mnodes, stage:%s", pTrans->id, mndTransStr(pTrans->stage)); + mInfo("trans:%d, sync to other mnodes, stage:%s createTime:%" PRId64, pTrans->id, mndTransStr(pTrans->stage), + pTrans->createdTime); int32_t code = mndSyncPropose(pMnode, pRaw, pTrans->id); if (code != 0) { - mError("trans:%d, failed to sync, errno:%s code:%s", pTrans->id, terrstr(), tstrerror(code)); + mError("trans:%d, failed to sync, errno:%s code:%s createTime:%" PRId64 " saved trans:%d", pTrans->id, terrstr(), + tstrerror(code), pTrans->createdTime, pMnode->syncMgmt.transId); sdbFreeRaw(pRaw); return -1; } sdbFreeRaw(pRaw); - mInfo("trans:%d, sync finished", pTrans->id); + mInfo("trans:%d, sync finished, createTime:%" PRId64, pTrans->id, pTrans->createdTime); return 0; } @@ -891,7 +905,7 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) { pTrans->rpcRsp = NULL; pTrans->rpcRspLen = 0; - mndTransExecute(pMnode, pNew); + mndTransExecute(pMnode, pNew, true); mndReleaseTrans(pMnode, pNew); return 0; } @@ -1054,7 +1068,7 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) { mInfo("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); + mndTransExecute(pMnode, pTrans, true); _OVER: mndReleaseTrans(pMnode, pTrans); @@ -1483,15 +1497,17 @@ static bool mndTransPerfromFinishedStage(SMnode *pMnode, STrans *pTrans) { mError("trans:%d, failed to write sdb since %s", pTrans->id, terrstr()); } - mInfo("trans:%d, execute finished, code:0x%x, failedTimes:%d", pTrans->id, pTrans->code, pTrans->failedTimes); + mInfo("trans:%d, execute finished, code:0x%x, failedTimes:%d createTime:%" PRId64, pTrans->id, pTrans->code, + pTrans->failedTimes, pTrans->createdTime); return continueExec; } -void mndTransExecute(SMnode *pMnode, STrans *pTrans) { +void mndTransExecute(SMnode *pMnode, STrans *pTrans, bool isLeader) { bool continueExec = true; while (continueExec) { - mInfo("trans:%d, continue to execute, stage:%s", pTrans->id, mndTransStr(pTrans->stage)); + mInfo("trans:%d, continue to execute, stage:%s createTime:%" PRId64 " leader:%d", pTrans->id, + mndTransStr(pTrans->stage), pTrans->createdTime, isLeader); pTrans->lastExecTime = taosGetTimestampMs(); switch (pTrans->stage) { case TRN_STAGE_PREPARE: @@ -1501,13 +1517,23 @@ void mndTransExecute(SMnode *pMnode, STrans *pTrans) { continueExec = mndTransPerformRedoActionStage(pMnode, pTrans); break; case TRN_STAGE_COMMIT: - continueExec = mndTransPerformCommitStage(pMnode, pTrans); + if (isLeader) { + continueExec = mndTransPerformCommitStage(pMnode, pTrans); + } else { + mInfo("trans:%d, can not commit since not leader", pTrans->id); + continueExec = false; + } break; case TRN_STAGE_COMMIT_ACTION: continueExec = mndTransPerformCommitActionStage(pMnode, pTrans); break; case TRN_STAGE_ROLLBACK: - continueExec = mndTransPerformRollbackStage(pMnode, pTrans); + if (isLeader) { + continueExec = mndTransPerformRollbackStage(pMnode, pTrans); + } else { + mInfo("trans:%d, can not rollback since not leader", pTrans->id); + continueExec = false; + } break; case TRN_STAGE_UNDO_ACTION: continueExec = mndTransPerformUndoActionStage(pMnode, pTrans); @@ -1550,7 +1576,7 @@ int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans) { pAction->errCode = 0; } - mndTransExecute(pMnode, pTrans); + mndTransExecute(pMnode, pTrans, true); return 0; } @@ -1608,7 +1634,7 @@ void mndTransPullup(SMnode *pMnode) { int32_t *pTransId = taosArrayGet(pArray, i); STrans *pTrans = mndAcquireTrans(pMnode, *pTransId); if (pTrans != NULL) { - mndTransExecute(pMnode, pTrans); + mndTransExecute(pMnode, pTrans, true); } mndReleaseTrans(pMnode, pTrans); } diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 860db20fa8..1d2f4da26b 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -93,6 +93,8 @@ int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t ver) { pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle); ASSERT(pTask->exec.executor); + streamSetupTrigger(pTask); + return 0; } diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index a4cbfe60f7..3b7687359c 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -178,7 +178,6 @@ int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableL void tsdbReaderClose(STsdbReader *pReader); bool tsdbNextDataBlock(STsdbReader *pReader); -void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow); int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SSDataBlock *pDataBlock, bool *allHave); SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList); int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 5a2e462c8c..ec66e581ef 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -202,6 +202,7 @@ int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol uint8_t **ppBuf); int32_t tsdbDecmprColData(uint8_t *pIn, SBlockCol *pBlockCol, int8_t cmprAlg, int32_t nVal, SColData *pColData, uint8_t **ppBuf); +int32_t tRowInfoCmprFn(const void *p1, const void *p2); // tsdbMemTable ============================================================================================== // SMemTable int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable); @@ -320,6 +321,8 @@ struct STsdb { STsdbFS fs; SLRUCache *lruCache; TdThreadMutex lruMutex; + SLRUCache *biCache; + TdThreadMutex biMutex; }; struct TSDBKEY { @@ -745,6 +748,9 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr, int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, SCacheRowsReader *pr, LRUHandle **h); int32_t tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h); +int32_t tsdbCacheGetBlockIdx(SLRUCache *pCache, SDataFReader *pFileReader, LRUHandle **handle); +int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h); + int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey); int32_t tsdbCacheDeleteLast(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey); int32_t tsdbCacheDelete(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 75367883f1..2501af7f04 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -247,7 +247,7 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader); int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData); // STsdbSnapWriter ======================================== int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter); -int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData); +int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, SSnapDataHdr* pHdr); int32_t tsdbSnapWriterPrepareClose(STsdbSnapWriter* pWriter); int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback); // STqSnapshotReader == diff --git a/source/dnode/vnode/src/meta/metaCommit.c b/source/dnode/vnode/src/meta/metaCommit.c index f61930b84c..f597c100d0 100644 --- a/source/dnode/vnode/src/meta/metaCommit.c +++ b/source/dnode/vnode/src/meta/metaCommit.c @@ -56,4 +56,7 @@ int metaPrepareAsyncCommit(SMeta *pMeta) { } // abort the meta txn -int metaAbort(SMeta *pMeta) { return tdbAbort(pMeta->pEnv, pMeta->txn); } +int metaAbort(SMeta *pMeta) { + if (!pMeta->txn) return 0; + return tdbAbort(pMeta->pEnv, pMeta->txn); +} diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index 867b481bcc..35677d6f07 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -203,7 +203,7 @@ _err: int metaClose(SMeta *pMeta) { if (pMeta) { - if (pMeta->pEnv) tdbAbort(pMeta->pEnv, pMeta->txn); + if (pMeta->pEnv) metaAbort(pMeta); if (pMeta->pCache) metaCacheClose(pMeta); if (pMeta->pIdx) metaCloseIdx(pMeta); if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb); diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 60a27bec10..7406f51d4b 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -1343,6 +1343,9 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { int32_t ret = 0; // get super table if (tdbTbGet(pMeta->pUidIdx, &pCtbEntry->ctbEntry.suid, sizeof(tb_uid_t), &pData, &nData) != 0) { + metaError("vgId:%d, failed to get stable suid for update. version:%" PRId64, TD_VID(pMeta->pVnode), + pCtbEntry->version); + terrno = TSDB_CODE_TDB_INVALID_TABLE_ID; ret = -1; goto end; } diff --git a/source/dnode/vnode/src/sma/smaSnapshot.c b/source/dnode/vnode/src/sma/smaSnapshot.c index 34f884f9f9..0a6fac0fe7 100644 --- a/source/dnode/vnode/src/sma/smaSnapshot.c +++ b/source/dnode/vnode/src/sma/smaSnapshot.c @@ -423,10 +423,10 @@ int32_t rsmaSnapWrite(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) // rsma1/rsma2 if (pHdr->type == SNAP_DATA_RSMA1) { pHdr->type = SNAP_DATA_TSDB; - code = tsdbSnapWrite(pWriter->pDataWriter[0], pData, nData); + code = tsdbSnapWrite(pWriter->pDataWriter[0], pHdr); } else if (pHdr->type == SNAP_DATA_RSMA2) { pHdr->type = SNAP_DATA_TSDB; - code = tsdbSnapWrite(pWriter->pDataWriter[1], pData, nData); + code = tsdbSnapWrite(pWriter->pDataWriter[1], pHdr); } else if (pHdr->type == SNAP_DATA_QTASK) { code = rsmaSnapWriteQTaskInfo(pWriter, pData, nData); } else { diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 1d5fae33eb..cca241a1cf 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -93,21 +93,21 @@ STQ* tqOpen(const char* path, SVnode* pVnode) { taosHashSetFreeFp(pTq->pCheckInfo, (FDelete)tDeleteSTqCheckInfo); if (tqMetaOpen(pTq) < 0) { - ASSERT(0); + return NULL; } pTq->pOffsetStore = tqOffsetOpen(pTq); if (pTq->pOffsetStore == NULL) { - ASSERT(0); + return NULL; } pTq->pStreamMeta = streamMetaOpen(path, pTq, (FTaskExpand*)tqExpandTask, pTq->pVnode->config.vgId); if (pTq->pStreamMeta == NULL) { - ASSERT(0); + return NULL; } if (streamLoadTasks(pTq->pStreamMeta) < 0) { - ASSERT(0); + return NULL; } return pTq; @@ -521,7 +521,12 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { tqOffsetResetToData(&fetchOffsetNew, 0, 0); } } else { - tqOffsetResetToLog(&fetchOffsetNew, walGetFirstVer(pTq->pVnode->pWal)); + pHandle->pRef = walRefFirstVer(pTq->pVnode->pWal, pHandle->pRef); + if (pHandle->pRef == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + tqOffsetResetToLog(&fetchOffsetNew, pHandle->pRef->refVer - 1); } } else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) { if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { @@ -719,6 +724,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) { SMqVDeleteReq* pReq = (SMqVDeleteReq*)msg; + tqDebug("vgId:%d, delete sub: %s", pTq->pVnode->config.vgId, pReq->subKey); + taosWLockLatch(&pTq->pushLock); int32_t code = taosHashRemove(pTq->pPushMgr, pReq->subKey, strlen(pReq->subKey)); if (code != 0) { diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 0fc5b617bb..fb2efda8e4 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -15,6 +15,34 @@ #include "tsdb.h" +static int32_t tsdbOpenBICache(STsdb *pTsdb) { + int32_t code = 0; + SLRUCache *pCache = taosLRUCacheInit(5 * 1024 * 1024, -1, .5); + if (pCache == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + + taosLRUCacheSetStrictCapacity(pCache, false); + + taosThreadMutexInit(&pTsdb->biMutex, NULL); + +_err: + pTsdb->biCache = pCache; + return code; +} + +static void tsdbCloseBICache(STsdb *pTsdb) { + SLRUCache *pCache = pTsdb->biCache; + if (pCache) { + taosLRUCacheEraseUnrefEntries(pCache); + + taosLRUCacheCleanup(pCache); + + taosThreadMutexDestroy(&pTsdb->biMutex); + } +} + int32_t tsdbOpenCache(STsdb *pTsdb) { int32_t code = 0; SLRUCache *pCache = NULL; @@ -26,6 +54,12 @@ int32_t tsdbOpenCache(STsdb *pTsdb) { goto _err; } + code = tsdbOpenBICache(pTsdb); + if (code != TSDB_CODE_SUCCESS) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + taosLRUCacheSetStrictCapacity(pCache, false); taosThreadMutexInit(&pTsdb->lruMutex, NULL); @@ -44,6 +78,8 @@ void tsdbCloseCache(STsdb *pTsdb) { taosThreadMutexDestroy(&pTsdb->lruMutex); } + + tsdbCloseBICache(pTsdb); } static void getTableCacheKey(tb_uid_t uid, int cacheType, char *key, int *len) { @@ -1475,3 +1511,84 @@ size_t tsdbCacheGetUsage(SVnode *pVnode) { return usage; } + +static void getBICacheKey(int32_t fid, int64_t commitID, char *key, int *len) { + struct { + int32_t fid; + int64_t commitID; + } biKey = {0}; + + biKey.fid = fid; + biKey.commitID = commitID; + + *len = sizeof(biKey); + memcpy(key, &biKey, *len); +} + +static int32_t tsdbCacheLoadBlockIdx(SDataFReader *pFileReader, SArray **aBlockIdx) { + SArray *pArray = taosArrayInit(8, sizeof(SBlockIdx)); + int32_t code = tsdbReadBlockIdx(pFileReader, pArray); + + if (code != TSDB_CODE_SUCCESS) { + taosArrayDestroy(pArray); + code = TSDB_CODE_OUT_OF_MEMORY; + return code; + } + + *aBlockIdx = pArray; + + return code; +} + +static void deleteBICache(const void *key, size_t keyLen, void *value) { + SArray *pArray = (SArray *)value; + + taosArrayDestroy(pArray); +} + +int32_t tsdbCacheGetBlockIdx(SLRUCache *pCache, SDataFReader *pFileReader, LRUHandle **handle) { + int32_t code = 0; + char key[128] = {0}; + int keyLen = 0; + + getBICacheKey(pFileReader->pSet->fid, pFileReader->pSet->pHeadF->commitID, key, &keyLen); + LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen); + if (!h) { + STsdb *pTsdb = pFileReader->pTsdb; + taosThreadMutexLock(&pTsdb->biMutex); + + h = taosLRUCacheLookup(pCache, key, keyLen); + if (!h) { + SArray *pArray = NULL; + code = tsdbCacheLoadBlockIdx(pFileReader, &pArray); + // if table's empty or error, return code of -1 + if (code != TSDB_CODE_SUCCESS || pArray == NULL) { + taosThreadMutexUnlock(&pTsdb->biMutex); + + *handle = NULL; + return 0; + } + + size_t charge = pArray->capacity * pArray->elemSize + sizeof(*pArray); + _taos_lru_deleter_t deleter = deleteBICache; + LRUStatus status = taosLRUCacheInsert(pCache, key, keyLen, pArray, charge, deleter, &h, TAOS_LRU_PRIORITY_LOW); + if (status != TAOS_LRU_STATUS_OK) { + code = -1; + } + } + + taosThreadMutexUnlock(&pTsdb->biMutex); + } + + *handle = h; + + return code; +} + +int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h) { + int32_t code = 0; + + taosLRUCacheRelease(pCache, h, false); + + return code; +} diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index af1a42d018..132b7c797c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -515,7 +515,7 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) { pIter->rInfo.row = tsdbRowFromBlockData(pBlockData, pIter->iRow); _exit: - return (terrno == TSDB_CODE_SUCCESS) && (pIter->pSttBlk != NULL); + return (terrno == TSDB_CODE_SUCCESS) && (pIter->pSttBlk != NULL) && (pBlockData != NULL); } SRowInfo *tLDataIterGet(SLDataIter *pIter) { return &pIter->rInfo; } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 85282a2340..53e5cd7a88 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -79,16 +79,19 @@ typedef struct SIOCostSummary { int64_t composedBlocks; double buildComposedBlockTime; double createScanInfoList; +// double getTbFromMemTime; +// double getTbFromIMemTime; + double initDelSkylineIterTime; } SIOCostSummary; typedef struct SBlockLoadSuppInfo { - SArray* pColAgg; - SColumnDataAgg tsColAgg; - int16_t* colId; - int16_t* slotId; - int32_t numOfCols; - char** buildBuf; // build string tmp buffer, todo remove it later after all string format being updated. - bool smaValid; // the sma on all queried columns are activated + SArray* pColAgg; + SColumnDataAgg tsColAgg; + int16_t* colId; + int16_t* slotId; + int32_t numOfCols; + char** buildBuf; // build string tmp buffer, todo remove it later after all string format being updated. + bool smaValid; // the sma on all queried columns are activated } SBlockLoadSuppInfo; typedef struct SLastBlockReader { @@ -168,11 +171,11 @@ struct STsdbReader { SBlockLoadSuppInfo suppInfo; STsdbReadSnap* pReadSnap; SIOCostSummary cost; - STSchema* pSchema; // the newest version schema - STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times - SDataFReader* pFileReader; // the file reader - SDelFReader* pDelFReader; // the del file reader - SArray* pDelIdx; // del file block index; + STSchema* pSchema; // the newest version schema + STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times + SDataFReader* pFileReader; // the file reader + SDelFReader* pDelFReader; // the del file reader + SArray* pDelIdx; // del file block index; SVersionRange verRange; SBlockInfoBuf blockInfoBuf; int32_t step; @@ -215,20 +218,24 @@ static int32_t doBuildDataBlock(STsdbReader* pReader); static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader); static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo); static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter); +static int32_t getInitialDelIndex(const SArray* pDelSkyline, int32_t order); + +static FORCE_INLINE STSchema* getLatestTableSchema(STsdbReader* pReader, uint64_t uid); static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); } -static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pCols, const int32_t* pSlotIdList, int32_t numOfCols) { +static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pCols, const int32_t* pSlotIdList, + int32_t numOfCols) { pSupInfo->smaValid = true; pSupInfo->numOfCols = numOfCols; - pSupInfo->colId = taosMemoryMalloc(numOfCols * (sizeof(int16_t)*2 + POINTER_BYTES)); + pSupInfo->colId = taosMemoryMalloc(numOfCols * (sizeof(int16_t) * 2 + POINTER_BYTES)); if (pSupInfo->colId == NULL) { taosMemoryFree(pSupInfo->colId); return TSDB_CODE_OUT_OF_MEMORY; } pSupInfo->slotId = (int16_t*)((char*)pSupInfo->colId + (sizeof(int16_t) * numOfCols)); - pSupInfo->buildBuf = (char**) ((char*)pSupInfo->slotId + (sizeof(int16_t) * numOfCols)); + pSupInfo->buildBuf = (char**)((char*)pSupInfo->slotId + (sizeof(int16_t) * numOfCols)); for (int32_t i = 0; i < numOfCols; ++i) { pSupInfo->colId[i] = pCols[i].colId; pSupInfo->slotId[i] = pSlotIdList[i]; @@ -246,7 +253,7 @@ static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pC static int32_t updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) { int32_t i = 0, j = 0; - while(i < pSchema->numOfCols && j < pSupInfo->numOfCols) { + while (i < pSchema->numOfCols && j < pSupInfo->numOfCols) { STColumn* pTCol = &pSchema->columns[i]; if (pTCol->colId == pSupInfo->colId[j]) { if (!IS_BSMA_ON(pTCol)) { @@ -311,7 +318,8 @@ static void* getPosInBlockInfoBuf(SBlockInfoBuf* pBuf, int32_t index) { } // NOTE: speedup the whole processing by preparing the buffer for STableBlockScanInfo in batch model -static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf* pBuf, const STableKeyInfo* idList, int32_t numOfTables) { +static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf* pBuf, const STableKeyInfo* idList, + int32_t numOfTables) { // allocate buffer in order to load data blocks from file // todo use simple hash instead, optimize the memory consumption SHashObj* pTableMap = @@ -397,9 +405,7 @@ static void destroyAllBlockScanInfo(SHashObj* pTableMap) { taosHashCleanup(pTableMap); } -static bool isEmptyQueryTimeWindow(STimeWindow* pWindow) { - return pWindow->skey > pWindow->ekey; -} +static bool isEmptyQueryTimeWindow(STimeWindow* pWindow) { return pWindow->skey > pWindow->ekey; } // Update the query time window according to the data time to live(TTL) information, in order to avoid to return // the expired data to client, even it is queried already. @@ -643,17 +649,21 @@ _end: } static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader, SArray* pIndexList) { - SArray* aBlockIdx = taosArrayInit(8, sizeof(SBlockIdx)); + // SArray* aBlockIdx = taosArrayInit(8, sizeof(SBlockIdx)); int64_t st = taosGetTimestampUs(); - int32_t code = tsdbReadBlockIdx(pFileReader, aBlockIdx); - if (code != TSDB_CODE_SUCCESS) { + // int32_t code = tsdbReadBlockIdx(pFileReader, aBlockIdx); + LRUHandle* handle = NULL; + int32_t code = tsdbCacheGetBlockIdx(pFileReader->pTsdb->biCache, pFileReader, &handle); + if (code != TSDB_CODE_SUCCESS || handle == NULL) { goto _end; } - size_t num = taosArrayGetSize(aBlockIdx); + SArray* aBlockIdx = (SArray*)taosLRUCacheValue(pFileReader->pTsdb->biCache, handle); + size_t num = taosArrayGetSize(aBlockIdx); if (num == 0) { - taosArrayDestroy(aBlockIdx); + tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); + // taosArrayDestroy(aBlockIdx); return TSDB_CODE_SUCCESS; } @@ -689,7 +699,8 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFReader* pFileReader, pReader->cost.headFileLoadTime += (et1 - st) / 1000.0; _end: - taosArrayDestroy(aBlockIdx); + // taosArrayDestroy(aBlockIdx); + tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); return code; } @@ -768,7 +779,6 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN numOfTables, pBlockNum->numOfBlocks, numOfQTable, pBlockNum->numOfLastFiles, sizeInDisk / 1000.0, el, pReader->idStr); - pReader->cost.numOfBlocks += total; pReader->cost.headFileLoadTime += el; @@ -902,7 +912,7 @@ static void copyPrimaryTsCol(const SBlockData* pBlockData, SFileBlockDumpInfo* p // a faster version of copy procedure. static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo, SColumnInfoData* pColData, - int32_t dumpedRows, bool asc) { + int32_t dumpedRows, bool asc) { uint8_t* p = NULL; if (asc) { p = pData->pData + tDataTypes[pData->type].bytes * pDumpInfo->rowIndex; @@ -911,22 +921,21 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo p = pData->pData + tDataTypes[pData->type].bytes * startIndex; } - int32_t step = asc? 1:-1; + int32_t step = asc ? 1 : -1; // make sure it is aligned to 8bit, the allocated memory address is aligned to 256bit -// ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0); + // ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0); // 1. copy data in a batch model memcpy(pColData->pData, p, dumpedRows * tDataTypes[pData->type].bytes); // 2. reverse the array list in case of descending order scan data block if (!asc) { - switch(pColData->info.type) { + switch (pColData->info.type) { case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_BIGINT: - case TSDB_DATA_TYPE_UBIGINT: - { + case TSDB_DATA_TYPE_UBIGINT: { int32_t mid = dumpedRows >> 1u; int64_t* pts = (int64_t*)pColData->pData; for (int32_t j = 0; j < mid; ++j) { @@ -940,7 +949,7 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_UTINYINT: { - int32_t mid = dumpedRows >> 1u; + int32_t mid = dumpedRows >> 1u; int8_t* pts = (int8_t*)pColData->pData; for (int32_t j = 0; j < mid; ++j) { int8_t t = pts[j]; @@ -991,7 +1000,7 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo } } -static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo) { +static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; SDataBlockIter* pBlockIter = &pStatus->blockIter; SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; @@ -1008,6 +1017,14 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn bool asc = ASCENDING_TRAVERSE(pReader->order); int32_t step = asc ? 1 : -1; + // no data exists, return directly. + if (pBlockData->nRow == 0 || pBlockData->aTSKEY == 0) { + tsdbWarn("%p no need to copy since no data in blockData, table uid:%" PRIu64 " has been dropped, %s", pReader, pBlockInfo->uid, + pReader->idStr); + pResBlock->info.rows = 0; + return 0; + } + if ((pDumpInfo->rowIndex == 0 && asc) || (pDumpInfo->rowIndex == pBlock->nRow - 1 && (!asc))) { if (asc && pReader->window.skey <= pBlock->minKey.ts) { // pDumpInfo->rowIndex = 0; @@ -1112,21 +1129,28 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn int32_t unDumpedRows = asc ? pBlock->nRow - pDumpInfo->rowIndex : pDumpInfo->rowIndex + 1; tsdbDebug("%p copy file block to sdatablock, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64 - ", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%.2f ms, %s", + ", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", uid:%" PRIu64 " elapsed time:%.2f ms, %s", pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, dumpedRows, - unDumpedRows, pBlock->minVer, pBlock->maxVer, elapsedTime, pReader->idStr); + unDumpedRows, pBlock->minVer, pBlock->maxVer, pBlockInfo->uid, elapsedTime, pReader->idStr); return TSDB_CODE_SUCCESS; } static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockIter, SBlockData* pBlockData, uint64_t uid) { + int32_t code = 0; int64_t st = taosGetTimestampUs(); tBlockDataReset(pBlockData); + STSchema* pSchema = getLatestTableSchema(pReader, uid); + if (pSchema == NULL) { + tsdbDebug("%p table uid:%"PRIu64" has been dropped, no data existed, %s", pReader, uid, pReader->idStr); + return code; + } + + SBlockLoadSuppInfo* pSup = &pReader->suppInfo; TABLEID tid = {.suid = pReader->suid, .uid = uid}; - int32_t code = - tBlockDataInit(pBlockData, &tid, pReader->pSchema, &pReader->suppInfo.colId[1], pReader->suppInfo.numOfCols - 1); + code = tBlockDataInit(pBlockData, &tid, pSchema, &pSup->colId[1], pSup->numOfCols - 1); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1551,8 +1575,7 @@ static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pBlock // log the reason why load the datablock for profile if (loadDataBlock) { - tsdbDebug("%p uid:%" PRIu64 - " need to load the datablock, overlapwithneighborblock:%d, hasDup:%d, partiallyRequired:%d, " + tsdbDebug("%p uid:%" PRIu64 " need to load the datablock, overlapneighbor:%d, hasDup:%d, partiallyRequired:%d, " "overlapWithKey:%d, greaterThanBuf:%d, overlapWithDel:%d, overlapWithlastBlock:%d, %s", pReader, pBlockInfo->uid, info.overlapWithNeighborBlock, info.hasDupTs, info.partiallyRequired, info.overlapWithKeyInBuf, info.moreThanCapcity, info.overlapWithDelInfo, info.overlapWithLastBlock, @@ -1650,6 +1673,19 @@ static bool tryCopyDistinctRowFromSttBlock(TSDBROW* fRow, SLastBlockReader* pLas return false; } +static FORCE_INLINE STSchema* getLatestTableSchema(STsdbReader* pReader, uint64_t uid) { + if (pReader->pSchema != NULL) { + return pReader->pSchema; + } + + pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, uid, -1, 1); + if (pReader->pSchema == NULL) { + tsdbError("failed to get table schema, uid:%" PRIu64 ", it may have been dropped, ver:-1, %s", uid, pReader->idStr); + } + + return pReader->pSchema; +} + static FORCE_INLINE STSchema* doGetSchemaForTSRow(int32_t sversion, STsdbReader* pReader, uint64_t uid) { // always set the newest schema version in pReader->pSchema if (pReader->pSchema == NULL) { @@ -1766,7 +1802,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* tRowMergerAdd(&merge, pRow, pSchema); } else { init = true; - int32_t code = tRowMergerInit(&merge, pRow, pSchema); + int32_t code = tRowMergerInit(&merge, pRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2177,6 +2213,7 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea } int32_t backward = (!ASCENDING_TRAVERSE(pReader->order)); + int64_t st = 0; STbData* d = NULL; if (pReader->pReadSnap->pMem != NULL) { @@ -2186,17 +2223,17 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea if (code == TSDB_CODE_SUCCESS) { pBlockScanInfo->iter.hasVal = (tsdbTbDataIterGet(pBlockScanInfo->iter.iter) != NULL); - tsdbDebug("%p uid:%" PRId64 ", check data in mem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64 + tsdbDebug("%p uid:%" PRIu64 ", check data in mem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64 "-%" PRId64 " %s", pReader, pBlockScanInfo->uid, startKey.ts, pReader->order, d->minKey, d->maxKey, pReader->idStr); } else { - tsdbError("%p uid:%" PRId64 ", failed to create iterator for imem, code:%s, %s", pReader, pBlockScanInfo->uid, + tsdbError("%p uid:%" PRIu64 ", failed to create iterator for imem, code:%s, %s", pReader, pBlockScanInfo->uid, tstrerror(code), pReader->idStr); return code; } } } else { - tsdbDebug("%p uid:%" PRId64 ", no data in mem, %s", pReader, pBlockScanInfo->uid, pReader->idStr); + tsdbDebug("%p uid:%" PRIu64 ", no data in mem, %s", pReader, pBlockScanInfo->uid, pReader->idStr); } STbData* di = NULL; @@ -2207,20 +2244,22 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea if (code == TSDB_CODE_SUCCESS) { pBlockScanInfo->iiter.hasVal = (tsdbTbDataIterGet(pBlockScanInfo->iiter.iter) != NULL); - tsdbDebug("%p uid:%" PRId64 ", check data in imem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64 + tsdbDebug("%p uid:%" PRIu64 ", check data in imem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64 "-%" PRId64 " %s", pReader, pBlockScanInfo->uid, startKey.ts, pReader->order, di->minKey, di->maxKey, pReader->idStr); } else { - tsdbError("%p uid:%" PRId64 ", failed to create iterator for mem, code:%s, %s", pReader, pBlockScanInfo->uid, + tsdbError("%p uid:%" PRIu64 ", failed to create iterator for mem, code:%s, %s", pReader, pBlockScanInfo->uid, tstrerror(code), pReader->idStr); return code; } } } else { - tsdbDebug("%p uid:%" PRId64 ", no data in imem, %s", pReader, pBlockScanInfo->uid, pReader->idStr); + tsdbDebug("%p uid:%" PRIu64 ", no data in imem, %s", pReader, pBlockScanInfo->uid, pReader->idStr); } + st = taosGetTimestampUs(); initDelSkylineIterator(pBlockScanInfo, pReader, d, di); + pReader->cost.initDelSkylineIterTime += (taosGetTimestampUs() - st) / 1000.0; pBlockScanInfo->iterInit = true; return TSDB_CODE_SUCCESS; @@ -2296,7 +2335,7 @@ static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) { return pLas bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* pDumpInfo) { if ((pBlockData->nRow > 0) && (pBlockData->nRow != pDumpInfo->totalRows)) { - return false; // this is an invalid result. + return false; // this is an invalid result. } return pBlockData->nRow > 0 && (!pDumpInfo->allDumped); } @@ -2447,10 +2486,10 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { TSDBKEY keyInBuf = getCurrentKeyInBuf(pBlockScanInfo, pReader); // it is a clean block, load it directly - if (isCleanFileDataBlock(pReader, pBlockInfo, pBlock, pBlockScanInfo, keyInBuf, pLastBlockReader) && + if (isCleanFileDataBlock(pReader, pBlockInfo, pBlock, pBlockScanInfo, keyInBuf, pLastBlockReader) && pBlock->nRow <= pReader->capacity) { if (asc || ((!asc) && (!hasDataInLastBlock(pLastBlockReader)))) { - copyBlockDataToSDataBlock(pReader, pBlockScanInfo); + copyBlockDataToSDataBlock(pReader); // record the last key value pBlockScanInfo->lastKey = asc ? pBlock->maxKey.ts : pBlock->minKey.ts; @@ -2526,6 +2565,14 @@ _end: void setComposedBlockFlag(STsdbReader* pReader, bool composed) { pReader->status.composedDataBlock = composed; } +int32_t getInitialDelIndex(const SArray* pDelSkyline, int32_t order) { + if (pDelSkyline == NULL) { + return 0; + } + + return ASCENDING_TRAVERSE(order) ? 0 : taosArrayGetSize(pDelSkyline) - 1; +} + int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, STbData* pMemTbData, STbData* piMemTbData) { if (pBlockScanInfo->delSkyline != NULL) { @@ -2543,7 +2590,6 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* if (pIdx != NULL) { code = tsdbReadDelData(pReader->pDelFReader, pIdx, pDelData); } - if (code != TSDB_CODE_SUCCESS) { goto _err; } @@ -2572,11 +2618,13 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* } taosArrayDestroy(pDelData); - pBlockScanInfo->iter.index = - ASCENDING_TRAVERSE(pReader->order) ? 0 : taosArrayGetSize(pBlockScanInfo->delSkyline) - 1; - pBlockScanInfo->iiter.index = pBlockScanInfo->iter.index; - pBlockScanInfo->fileDelIndex = pBlockScanInfo->iter.index; - pBlockScanInfo->lastBlockDelIndex = pBlockScanInfo->iter.index; + int32_t index = getInitialDelIndex(pBlockScanInfo->delSkyline, pReader->order); + + pBlockScanInfo->iter.index = index; + pBlockScanInfo->iiter.index = index; + pBlockScanInfo->fileDelIndex = index; + pBlockScanInfo->lastBlockDelIndex = index; + return code; _err: @@ -2585,21 +2633,39 @@ _err: } TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader) { - TSDBKEY key = {.ts = TSKEY_INITIAL_VAL}; + bool asc = ASCENDING_TRAVERSE(pReader->order); +// TSKEY initialVal = asc? TSKEY_MIN:TSKEY_MAX; + + TSDBKEY key = {.ts = TSKEY_INITIAL_VAL}, ikey = {.ts = TSKEY_INITIAL_VAL}; + + bool hasKey = false, hasIKey = false; TSDBROW* pRow = getValidMemRow(&pScanInfo->iter, pScanInfo->delSkyline, pReader); if (pRow != NULL) { + hasKey = true; key = TSDBROW_KEY(pRow); } - pRow = getValidMemRow(&pScanInfo->iiter, pScanInfo->delSkyline, pReader); - if (pRow != NULL) { - TSDBKEY k = TSDBROW_KEY(pRow); - if (key.ts > k.ts) { - key = k; - } + TSDBROW* pIRow = getValidMemRow(&pScanInfo->iiter, pScanInfo->delSkyline, pReader); + if (pIRow != NULL) { + hasIKey = true; + ikey = TSDBROW_KEY(pIRow); } - return key; + if (hasKey) { + if (hasIKey) { // has data in mem & imem + if (asc) { + return key.ts <= ikey.ts ? key : ikey; + } else { + return key.ts <= ikey.ts ? ikey: key; + } + } else { // no data in imem + return key; + } + } else { + // no data in mem & imem, return the initial value + // only imem has data, return ikey + return ikey; + } } static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) { @@ -2641,7 +2707,6 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) { taosArrayDestroy(pIndexList); if (pReader->pReadSnap != NULL) { - SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile; if (pReader->pDelFReader == NULL && pDelFile != NULL) { int32_t code = tsdbDelFReaderOpen(&pReader->pDelFReader, pDelFile, pReader->pTsdb); @@ -2676,7 +2741,7 @@ static int32_t uidComparFunc(const void* p1, const void* p2) { } } -static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus) { +static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus, int32_t order) { int32_t index = 0; int32_t total = taosHashGetSize(pStatus->pTableMap); @@ -2690,7 +2755,21 @@ static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SRea taosSort(pOrderCheckInfo->tableUidList, total, sizeof(uint64_t), uidComparFunc); } -static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus) { +// reset the last del file index +static void resetScanBlockLastBlockDelIndex(SReaderStatus* pStatus, int32_t order) { + void* p = taosHashIterate(pStatus->pTableMap, NULL); + while (p != NULL) { + STableBlockScanInfo* pScanInfo = *(STableBlockScanInfo**)p; + + // reset the last del file index + pScanInfo->lastBlockDelIndex = getInitialDelIndex(pScanInfo->delSkyline, order); + p = taosHashIterate(pStatus->pTableMap, p); + } +} + +static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, STsdbReader* pReader) { + SReaderStatus* pStatus = &pReader->status; + int32_t total = taosHashGetSize(pStatus->pTableMap); if (total == 0) { return TSDB_CODE_SUCCESS; @@ -2703,7 +2782,7 @@ static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderSt return TSDB_CODE_OUT_OF_MEMORY; } - extractOrderedTableUidList(pOrderCheckInfo, pStatus); + extractOrderedTableUidList(pOrderCheckInfo, pStatus, pReader->order); uint64_t uid = pOrderCheckInfo->tableUidList[0]; pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); } else { @@ -2720,7 +2799,7 @@ static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderSt } pOrderCheckInfo->tableUidList = p; - extractOrderedTableUidList(pOrderCheckInfo, pStatus); + extractOrderedTableUidList(pOrderCheckInfo, pStatus, pReader->order); uid = pOrderCheckInfo->tableUidList[0]; pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); @@ -2740,11 +2819,7 @@ static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus uint64_t uid = pOrderedCheckInfo->tableUidList[pOrderedCheckInfo->currentIndex]; pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); - if (pStatus->pTableIter == NULL) { - return false; - } - - return true; + return (pStatus->pTableIter != NULL); } static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { @@ -2752,7 +2827,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { SLastBlockReader* pLastBlockReader = pStatus->fileIter.pLastBlockReader; SUidOrderCheckInfo* pOrderedCheckInfo = &pStatus->uidCheckInfo; - int32_t code = initOrderCheckInfo(pOrderedCheckInfo, pStatus); + int32_t code = initOrderCheckInfo(pOrderedCheckInfo, pReader); if (code != TSDB_CODE_SUCCESS || (taosHashGetSize(pStatus->pTableMap) == 0)) { return code; } @@ -2817,59 +2892,21 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter); SLastBlockReader* pLastBlockReader = pReader->status.fileIter.pLastBlockReader; - if (pBlockInfo != NULL) { - pScanInfo = - *(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid)); - } else { - pScanInfo = *pReader->status.pTableIter; - } + ASSERT(pBlockInfo != NULL); + pScanInfo = *(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid)); if (pScanInfo == NULL) { tsdbError("failed to get table scan-info, %s", pReader->idStr); code = TSDB_CODE_INVALID_PARA; return code; } - if (pBlockInfo != NULL) { - pBlock = getCurrentBlock(pBlockIter); - } + pBlock = getCurrentBlock(pBlockIter); initLastBlockReader(pLastBlockReader, pScanInfo, pReader); TSDBKEY keyInBuf = getCurrentKeyInBuf(pScanInfo, pReader); - if (pBlockInfo == NULL) { // build data block from last data file - SBlockData* pBData = &pReader->status.fileBlockData; - tBlockDataReset(pBData); - - SSDataBlock* pResBlock = pReader->pResBlock; - tsdbDebug("load data in last block firstly, due to desc scan data, %s", pReader->idStr); - - int64_t st = taosGetTimestampUs(); - - while (1) { - bool hasBlockLData = hasDataInLastBlock(pLastBlockReader); - - // no data in last block and block, no need to proceed. - if (hasBlockLData == false) { - break; - } - - buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader); - if (pResBlock->info.rows >= pReader->capacity) { - break; - } - } - - double el = (taosGetTimestampUs() - st) / 1000.0; - updateComposedBlockInfo(pReader, el, pScanInfo); - - if (pResBlock->info.rows > 0) { - tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 - " rows:%d, elapsed time:%.2f ms %s", - pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, - pResBlock->info.rows, el, pReader->idStr); - } - } else if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) { + if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) { code = doLoadFileBlockData(pReader, pBlockIter, &pStatus->fileBlockData, pScanInfo->uid); if (code != TSDB_CODE_SUCCESS) { return code; @@ -2915,7 +2952,7 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { if (pResBlock->info.rows > 0) { tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 - " rows:%d, elapsed time:%.2f ms %s", + " rows:%d, elapsed time:%.2f ms %s", pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, pResBlock->info.rows, el, pReader->idStr); } @@ -2923,12 +2960,17 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { SDataBlockInfo* pInfo = &pReader->pResBlock->info; pInfo->rows = pBlock->nRow; pInfo->id.uid = pScanInfo->uid; + pInfo->dataLoad = 0; pInfo->window = (STimeWindow){.skey = pBlock->minKey.ts, .ekey = pBlock->maxKey.ts}; setComposedBlockFlag(pReader, false); setBlockAllDumped(&pStatus->fBlockDumpInfo, pBlock->maxKey.ts, pReader->order); // update the last key for the corresponding table pScanInfo->lastKey = ASCENDING_TRAVERSE(pReader->order) ? pInfo->window.ekey : pInfo->window.skey; + tsdbDebug("%p uid:%" PRIu64 " clean file block retrieved from file, global index:%d, " + "table index:%d, rows:%d, brange:%" PRId64 "-%" PRId64 ", %s", + pReader, pScanInfo->uid, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->nRow, pBlock->minKey.ts, + pBlock->maxKey.ts, pReader->idStr); } } @@ -3040,6 +3082,7 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) { // this file does not have data files, let's start check the last block file if exists if (pBlockIter->numOfBlocks == 0) { + resetScanBlockLastBlockDelIndex(&pReader->status, pReader->order); goto _begin; } } @@ -3071,6 +3114,7 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) { // data blocks in current file are exhausted, let's try the next file now tBlockDataReset(&pReader->status.fileBlockData); resetDataBlockIterator(pBlockIter, pReader->order); + resetScanBlockLastBlockDelIndex(&pReader->status, pReader->order); goto _begin; } else { code = initForFirstBlockInFile(pReader, pBlockIter); @@ -3082,6 +3126,7 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) { // this file does not have blocks, let's start check the last block file if (pBlockIter->numOfBlocks == 0) { + resetScanBlockLastBlockDelIndex(&pReader->status, pReader->order); goto _begin; } } @@ -3177,7 +3222,8 @@ bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32 return false; } else if (pKey->ts == last->ts) { TSDBKEY* prev = taosArrayGet(pDelList, num - 2); - return (prev->version >= pKey->version && prev->version <= pVerRange->maxVer && prev->version >= pVerRange->minVer); + return (prev->version >= pKey->version && prev->version <= pVerRange->maxVer && + prev->version >= pVerRange->minVer); } } else { TSDBKEY* pCurrent = taosArrayGet(pDelList, *index); @@ -3361,7 +3407,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn *state = CHECK_FILEBLOCK_QUIT; int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1; - bool loadNeighbor = true; + bool loadNeighbor = true; int32_t code = loadNeighborIfOverlap(pFBlock, pScanInfo, pReader, &loadNeighbor); if (loadNeighbor && (code == TSDB_CODE_SUCCESS)) { @@ -3613,7 +3659,7 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* SColVal colVal = {0}; int32_t i = 0, j = 0; - if (pSupInfo->colId[i]== PRIMARYKEY_TIMESTAMP_COL_ID) { + if (pSupInfo->colId[i] == PRIMARYKEY_TIMESTAMP_COL_ID) { SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, pSupInfo->slotId[i]); ((int64_t*)pColData->pData)[outputRowIndex] = pTSRow->ts; i += 1; @@ -3658,7 +3704,7 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S int32_t outputRowIndex = pResBlock->info.rows; SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; - if (pReader->suppInfo.colId[i]== PRIMARYKEY_TIMESTAMP_COL_ID) { + if (pReader->suppInfo.colId[i] == PRIMARYKEY_TIMESTAMP_COL_ID) { SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]); ((int64_t*)pColData->pData)[outputRowIndex] = pBlockData->aTSKEY[rowIndex]; i += 1; @@ -4000,22 +4046,24 @@ void tsdbReaderClose(STsdbReader* pReader) { taosMemoryFree(pLReader); } - tsdbDebug("%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64 - " SMA-time:%.2f ms, fileBlocks:%" PRId64 - ", fileBlocks-load-time:%.2f ms, " - "build in-memory-block-time:%.2f ms, lastBlocks:%" PRId64 - ", lastBlocks-time:%.2f ms, composed-blocks:%" PRId64 - ", composed-blocks-time:%.2fms, STableBlockScanInfo size:%.2f Kb, creatTime:%.2f ms, %s", - pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaDataLoad, pCost->smaLoadTime, - pCost->numOfBlocks, pCost->blockLoadTime, pCost->buildmemBlock, pCost->lastBlockLoad, - pCost->lastBlockLoadTime, pCost->composedBlocks, pCost->buildComposedBlockTime, - numOfTables * sizeof(STableBlockScanInfo) / 1000.0, pCost->createScanInfoList, pReader->idStr); + tsdbDebug( + "%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64 + " SMA-time:%.2f ms, fileBlocks:%" PRId64 + ", fileBlocks-load-time:%.2f ms, " + "build in-memory-block-time:%.2f ms, lastBlocks:%" PRId64 ", lastBlocks-time:%.2f ms, composed-blocks:%" PRId64 + ", composed-blocks-time:%.2fms, STableBlockScanInfo size:%.2f Kb, createTime:%.2f ms,initDelSkylineIterTime:%.2f ms, %s", + pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaDataLoad, pCost->smaLoadTime, pCost->numOfBlocks, + pCost->blockLoadTime, pCost->buildmemBlock, pCost->lastBlockLoad, pCost->lastBlockLoadTime, pCost->composedBlocks, + pCost->buildComposedBlockTime, numOfTables * sizeof(STableBlockScanInfo) / 1000.0, pCost->createScanInfoList, + pCost->initDelSkylineIterTime, pReader->idStr); taosMemoryFree(pReader->idStr); taosMemoryFree(pReader->pSchema); + if (pReader->pMemSchema != pReader->pSchema) { taosMemoryFree(pReader->pMemSchema); } + taosMemoryFreeClear(pReader); } @@ -4025,7 +4073,7 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) { blockDataCleanup(pBlock); SReaderStatus* pStatus = &pReader->status; - if (taosHashGetSize(pStatus->pTableMap) == 0){ + if (taosHashGetSize(pStatus->pTableMap) == 0) { return false; } @@ -4095,32 +4143,10 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { return false; } -static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) { - *rows = pReader->pResBlock->info.rows; - *uid = pReader->pResBlock->info.id.uid; - *pWindow = pReader->pResBlock->info.window; -} - -void tsdbRetrieveDataBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) { - if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) { - if (pReader->step == EXTERNAL_ROWS_MAIN) { - setBlockInfo(pReader, rows, uid, pWindow); - } else if (pReader->step == EXTERNAL_ROWS_PREV) { - setBlockInfo(pReader->innerReader[0], rows, uid, pWindow); - } else { - setBlockInfo(pReader->innerReader[1], rows, uid, pWindow); - } - } else { - setBlockInfo(pReader, rows, uid, pWindow); - } -} - - -static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_t numOfCols, - SColumnDataAgg* pTsAgg) { +static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_t numOfCols, SColumnDataAgg* pTsAgg) { // do fill all null column value SMA info int32_t i = 0, j = 0; - int32_t size = (int32_t) taosArrayGetSize(pSup->pColAgg); + int32_t size = (int32_t)taosArrayGetSize(pSup->pColAgg); taosArrayInsert(pSup->pColAgg, 0, pTsAgg); while (j < numOfCols && i < size) { @@ -4133,7 +4159,7 @@ static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_ } else if (pSup->colId[j] < pAgg->colId) { if (pSup->colId[j] != PRIMARYKEY_TIMESTAMP_COL_ID) { SColumnDataAgg nullColAgg = {.colId = pSup->colId[j], .numOfNull = numOfRows}; - taosArrayInsert(pSup->pColAgg, i ,&nullColAgg); + taosArrayInsert(pSup->pColAgg, i, &nullColAgg); } j += 1; } @@ -4252,7 +4278,7 @@ static SSDataBlock* doRetrieveDataBlock(STsdbReader* pReader) { return NULL; } - copyBlockDataToSDataBlock(pReader, pBlockScanInfo); + copyBlockDataToSDataBlock(pReader); return pReader->pResBlock; } @@ -4402,7 +4428,7 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) { STableBlockScanInfo* pBlockScanInfo = *(STableBlockScanInfo**)pStatus->pTableIter; STbData* d = NULL; - if (pReader->pTsdb->mem != NULL) { + if (pReader->pReadSnap->pMem != NULL) { d = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pMem, pReader->suid, pBlockScanInfo->uid); if (d != NULL) { rows += tsdbGetNRowsInTbData(d); @@ -4410,7 +4436,7 @@ int64_t tsdbGetNumOfRowsInMemTable(STsdbReader* pReader) { } STbData* di = NULL; - if (pReader->pTsdb->imem != NULL) { + if (pReader->pReadSnap->pIMem != NULL) { di = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pIMem, pReader->suid, pBlockScanInfo->uid); if (di != NULL) { rows += tsdbGetNRowsInTbData(di); diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 08d52554c6..e8181f922f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -15,274 +15,628 @@ #include "tsdb.h" -// STsdbSnapReader ======================================== -typedef enum { SNAP_DATA_FILE_ITER = 0, SNAP_STT_FILE_ITER } EFIterT; -typedef struct { - SRBTreeNode n; - SRowInfo rInfo; - EFIterT type; - union { - struct { - SArray* aBlockIdx; - int32_t iBlockIdx; - SBlockIdx* pBlockIdx; - SMapData mBlock; - int32_t iBlock; - }; // .data file - struct { - int32_t iStt; - SArray* aSttBlk; - int32_t iSttBlk; - }; // .stt file - }; - SBlockData bData; - int32_t iRow; -} SFDataIter; - -struct STsdbSnapReader { - STsdb* pTsdb; - int64_t sver; - int64_t ever; - STsdbFS fs; - int8_t type; - // for data file - int8_t dataDone; - int32_t fid; - SDataFReader* pDataFReader; - SFDataIter* pIter; - SRBTree rbt; - SFDataIter aFDataIter[TSDB_MAX_STT_TRIGGER + 1]; - SBlockData bData; - SSkmInfo skmTable; - // for del file - int8_t delDone; - SDelFReader* pDelFReader; - SArray* aDelIdx; // SArray - int32_t iDelIdx; - SArray* aDelData; // SArray - uint8_t* aBuf[5]; -}; - -extern int32_t tRowInfoCmprFn(const void* p1, const void* p2); extern int32_t tsdbReadDataBlockEx(SDataFReader* pReader, SDataBlk* pDataBlk, SBlockData* pBlockData); extern int32_t tsdbUpdateTableSchema(SMeta* pMeta, int64_t suid, int64_t uid, SSkmInfo* pSkmInfo); +extern int32_t tsdbWriteDataBlock(SDataFWriter* pWriter, SBlockData* pBlockData, SMapData* mDataBlk, int8_t cmprAlg); +extern int32_t tsdbWriteSttBlock(SDataFWriter* pWriter, SBlockData* pBlockData, SArray* aSttBlk, int8_t cmprAlg); -static int32_t tFDataIterCmprFn(const SRBTreeNode* pNode1, const SRBTreeNode* pNode2) { - SFDataIter* pIter1 = (SFDataIter*)(((uint8_t*)pNode1) - offsetof(SFDataIter, n)); - SFDataIter* pIter2 = (SFDataIter*)(((uint8_t*)pNode2) - offsetof(SFDataIter, n)); +// STsdbDataIter2 ======================================== +#define TSDB_MEM_TABLE_DATA_ITER 0 +#define TSDB_DATA_FILE_DATA_ITER 1 +#define TSDB_STT_FILE_DATA_ITER 2 +#define TSDB_TOMB_FILE_DATA_ITER 3 - return tRowInfoCmprFn(&pIter1->rInfo, &pIter2->rInfo); -} +typedef struct STsdbDataIter2 STsdbDataIter2; +typedef struct STsdbFilterInfo STsdbFilterInfo; -static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) { +typedef struct { + int64_t suid; + int64_t uid; + SDelData delData; +} SDelInfo; + +struct STsdbDataIter2 { + STsdbDataIter2* next; + SRBTreeNode rbtn; + + int32_t type; + SRowInfo rowInfo; + SDelInfo delInfo; + union { + // TSDB_MEM_TABLE_DATA_ITER + struct { + SMemTable* pMemTable; + } mIter; + + // TSDB_DATA_FILE_DATA_ITER + struct { + SDataFReader* pReader; + SArray* aBlockIdx; // SArray + SMapData mDataBlk; + SBlockData bData; + int32_t iBlockIdx; + int32_t iDataBlk; + int32_t iRow; + } dIter; + + // TSDB_STT_FILE_DATA_ITER + struct { + SDataFReader* pReader; + int32_t iStt; + SArray* aSttBlk; + SBlockData bData; + int32_t iSttBlk; + int32_t iRow; + } sIter; + // TSDB_TOMB_FILE_DATA_ITER + struct { + SDelFReader* pReader; + SArray* aDelIdx; + SArray* aDelData; + int32_t iDelIdx; + int32_t iDelData; + } tIter; + }; +}; + +#define TSDB_FILTER_FLAG_BY_VERSION 0x1 +struct STsdbFilterInfo { + int32_t flag; + int64_t sver; + int64_t ever; +}; + +#define TSDB_RBTN_TO_DATA_ITER(pNode) ((STsdbDataIter2*)(((char*)pNode) - offsetof(STsdbDataIter2, rbtn))) + +/* open */ +static int32_t tsdbOpenDataFileDataIter(SDataFReader* pReader, STsdbDataIter2** ppIter) { int32_t code = 0; int32_t lino = 0; - SDFileSet dFileSet = {.fid = pReader->fid}; - SDFileSet* pSet = taosArraySearch(pReader->fs.aDFileSet, &dFileSet, tDFileSetCmprFn, TD_GT); - if (pSet == NULL) return code; - - pReader->fid = pSet->fid; - code = tsdbDataFReaderOpen(&pReader->pDataFReader, pReader->pTsdb, pSet); - TSDB_CHECK_CODE(code, lino, _exit); - - pReader->pIter = NULL; - tRBTreeCreate(&pReader->rbt, tFDataIterCmprFn); - - // .data file - SFDataIter* pIter = &pReader->aFDataIter[0]; - pIter->type = SNAP_DATA_FILE_ITER; - - code = tsdbReadBlockIdx(pReader->pDataFReader, pIter->aBlockIdx); - TSDB_CHECK_CODE(code, lino, _exit); - - for (pIter->iBlockIdx = 0; pIter->iBlockIdx < taosArrayGetSize(pIter->aBlockIdx); pIter->iBlockIdx++) { - pIter->pBlockIdx = (SBlockIdx*)taosArrayGet(pIter->aBlockIdx, pIter->iBlockIdx); - - code = tsdbReadDataBlk(pReader->pDataFReader, pIter->pBlockIdx, &pIter->mBlock); + // create handle + STsdbDataIter2* pIter = (STsdbDataIter2*)taosMemoryCalloc(1, sizeof(*pIter)); + if (pIter == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; TSDB_CHECK_CODE(code, lino, _exit); - - for (pIter->iBlock = 0; pIter->iBlock < pIter->mBlock.nItem; pIter->iBlock++) { - SDataBlk dataBlk; - tMapDataGetItemByIdx(&pIter->mBlock, pIter->iBlock, &dataBlk, tGetDataBlk); - - if (dataBlk.minVer > pReader->ever || dataBlk.maxVer < pReader->sver) continue; - - code = tsdbReadDataBlockEx(pReader->pDataFReader, &dataBlk, &pIter->bData); - TSDB_CHECK_CODE(code, lino, _exit); - - ASSERT(pIter->pBlockIdx->suid == pIter->bData.suid); - ASSERT(pIter->pBlockIdx->uid == pIter->bData.uid); - - for (pIter->iRow = 0; pIter->iRow < pIter->bData.nRow; pIter->iRow++) { - int64_t rowVer = pIter->bData.aVersion[pIter->iRow]; - - if (rowVer >= pReader->sver && rowVer <= pReader->ever) { - pIter->rInfo.suid = pIter->pBlockIdx->suid; - pIter->rInfo.uid = pIter->pBlockIdx->uid; - pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow); - goto _add_iter_and_break; - } - } - } - - continue; - - _add_iter_and_break: - tRBTreePut(&pReader->rbt, (SRBTreeNode*)pIter); - break; } - // .stt file - pIter = &pReader->aFDataIter[1]; - for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) { - pIter->type = SNAP_STT_FILE_ITER; - pIter->iStt = iStt; - - code = tsdbReadSttBlk(pReader->pDataFReader, iStt, pIter->aSttBlk); + pIter->type = TSDB_DATA_FILE_DATA_ITER; + pIter->dIter.pReader = pReader; + if ((pIter->dIter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx))) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; TSDB_CHECK_CODE(code, lino, _exit); + } - for (pIter->iSttBlk = 0; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) { - SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk); + code = tBlockDataCreate(&pIter->dIter.bData); + TSDB_CHECK_CODE(code, lino, _exit); - if (pSttBlk->minVer > pReader->ever) continue; - if (pSttBlk->maxVer < pReader->sver) continue; + pIter->dIter.iBlockIdx = 0; + pIter->dIter.iDataBlk = 0; + pIter->dIter.iRow = 0; - code = tsdbReadSttBlockEx(pReader->pDataFReader, iStt, pSttBlk, &pIter->bData); - TSDB_CHECK_CODE(code, lino, _exit); + // read data + code = tsdbReadBlockIdx(pReader, pIter->dIter.aBlockIdx); + TSDB_CHECK_CODE(code, lino, _exit); - for (pIter->iRow = 0; pIter->iRow < pIter->bData.nRow; pIter->iRow++) { - int64_t rowVer = pIter->bData.aVersion[pIter->iRow]; + if (taosArrayGetSize(pIter->dIter.aBlockIdx) == 0) goto _clear; - if (rowVer >= pReader->sver && rowVer <= pReader->ever) { - pIter->rInfo.suid = pIter->bData.suid; - pIter->rInfo.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[pIter->iRow]; - pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow); - goto _add_iter; +_exit: + if (code) { + if (pIter) { + _clear: + tBlockDataDestroy(&pIter->dIter.bData, 1); + taosArrayDestroy(pIter->dIter.aBlockIdx); + taosMemoryFree(pIter); + pIter = NULL; + } + } + *ppIter = pIter; + return code; +} + +static int32_t tsdbOpenSttFileDataIter(SDataFReader* pReader, int32_t iStt, STsdbDataIter2** ppIter) { + int32_t code = 0; + int32_t lino = 0; + + // create handle + STsdbDataIter2* pIter = (STsdbDataIter2*)taosMemoryCalloc(1, sizeof(*pIter)); + if (pIter == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + pIter->type = TSDB_STT_FILE_DATA_ITER; + pIter->sIter.pReader = pReader; + pIter->sIter.iStt = iStt; + pIter->sIter.aSttBlk = taosArrayInit(0, sizeof(SSttBlk)); + if (pIter->sIter.aSttBlk == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + code = tBlockDataCreate(&pIter->sIter.bData); + TSDB_CHECK_CODE(code, lino, _exit); + + pIter->sIter.iSttBlk = 0; + pIter->sIter.iRow = 0; + + // read data + code = tsdbReadSttBlk(pReader, iStt, pIter->sIter.aSttBlk); + TSDB_CHECK_CODE(code, lino, _exit); + + if (taosArrayGetSize(pIter->sIter.aSttBlk) == 0) goto _clear; + +_exit: + if (code) { + if (pIter) { + _clear: + taosArrayDestroy(pIter->sIter.aSttBlk); + tBlockDataDestroy(&pIter->sIter.bData, 1); + taosMemoryFree(pIter); + pIter = NULL; + } + } + *ppIter = pIter; + return code; +} + +static int32_t tsdbOpenTombFileDataIter(SDelFReader* pReader, STsdbDataIter2** ppIter) { + int32_t code = 0; + int32_t lino = 0; + + STsdbDataIter2* pIter = (STsdbDataIter2*)taosMemoryCalloc(1, sizeof(*pIter)); + if (pIter == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + pIter->type = TSDB_TOMB_FILE_DATA_ITER; + + pIter->tIter.pReader = pReader; + if ((pIter->tIter.aDelIdx = taosArrayInit(0, sizeof(SDelIdx))) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if ((pIter->tIter.aDelData = taosArrayInit(0, sizeof(SDelData))) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + code = tsdbReadDelIdx(pReader, pIter->tIter.aDelIdx); + TSDB_CHECK_CODE(code, lino, _exit); + + if (taosArrayGetSize(pIter->tIter.aDelIdx) == 0) goto _clear; + + pIter->tIter.iDelIdx = 0; + pIter->tIter.iDelData = 0; + +_exit: + if (code) { + if (pIter) { + _clear: + taosArrayDestroy(pIter->tIter.aDelIdx); + taosArrayDestroy(pIter->tIter.aDelData); + taosMemoryFree(pIter); + pIter = NULL; + } + } + *ppIter = pIter; + return code; +} + +/* close */ +static void tsdbCloseDataFileDataIter(STsdbDataIter2* pIter) { + tBlockDataDestroy(&pIter->dIter.bData, 1); + tMapDataClear(&pIter->dIter.mDataBlk); + taosArrayDestroy(pIter->dIter.aBlockIdx); + taosMemoryFree(pIter); +} + +static void tsdbCloseSttFileDataIter(STsdbDataIter2* pIter) { + tBlockDataDestroy(&pIter->sIter.bData, 1); + taosArrayDestroy(pIter->sIter.aSttBlk); + taosMemoryFree(pIter); +} + +static void tsdbCloseTombFileDataIter(STsdbDataIter2* pIter) { + taosArrayDestroy(pIter->tIter.aDelData); + taosArrayDestroy(pIter->tIter.aDelIdx); + taosMemoryFree(pIter); +} + +static void tsdbCloseDataIter2(STsdbDataIter2* pIter) { + if (pIter->type == TSDB_MEM_TABLE_DATA_ITER) { + ASSERT(0); + } else if (pIter->type == TSDB_DATA_FILE_DATA_ITER) { + tsdbCloseDataFileDataIter(pIter); + } else if (pIter->type == TSDB_STT_FILE_DATA_ITER) { + tsdbCloseSttFileDataIter(pIter); + } else if (pIter->type == TSDB_TOMB_FILE_DATA_ITER) { + tsdbCloseTombFileDataIter(pIter); + } else { + ASSERT(0); + } +} + +/* cmpr */ +static int32_t tsdbDataIterCmprFn(const SRBTreeNode* pNode1, const SRBTreeNode* pNode2) { + STsdbDataIter2* pIter1 = TSDB_RBTN_TO_DATA_ITER(pNode1); + STsdbDataIter2* pIter2 = TSDB_RBTN_TO_DATA_ITER(pNode2); + return tRowInfoCmprFn(&pIter1->rowInfo, &pIter2->rowInfo); +} + +/* seek */ + +/* iter next */ +static int32_t tsdbDataFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) { + int32_t code = 0; + int32_t lino = 0; + + for (;;) { + while (pIter->dIter.iRow < pIter->dIter.bData.nRow) { + if (pFilterInfo) { + if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) { + if (pIter->dIter.bData.aVersion[pIter->dIter.iRow] < pFilterInfo->sver || + pIter->dIter.bData.aVersion[pIter->dIter.iRow] > pFilterInfo->ever) { + pIter->dIter.iRow++; + continue; + } + } + } + + pIter->rowInfo.suid = pIter->dIter.bData.suid; + pIter->rowInfo.uid = pIter->dIter.bData.uid; + pIter->rowInfo.row = tsdbRowFromBlockData(&pIter->dIter.bData, pIter->dIter.iRow); + pIter->dIter.iRow++; + goto _exit; + } + + for (;;) { + while (pIter->dIter.iDataBlk < pIter->dIter.mDataBlk.nItem) { + SDataBlk dataBlk; + tMapDataGetItemByIdx(&pIter->dIter.mDataBlk, pIter->dIter.iDataBlk, &dataBlk, tGetDataBlk); + + // filter + if (pFilterInfo) { + if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) { + if (pFilterInfo->sver > dataBlk.maxVer || pFilterInfo->ever < dataBlk.minVer) { + pIter->dIter.iDataBlk++; + continue; + } + } + } + + code = tsdbReadDataBlockEx(pIter->dIter.pReader, &dataBlk, &pIter->dIter.bData); + TSDB_CHECK_CODE(code, lino, _exit); + + pIter->dIter.iDataBlk++; + pIter->dIter.iRow = 0; + + break; + } + + if (pIter->dIter.iRow < pIter->dIter.bData.nRow) break; + + for (;;) { + if (pIter->dIter.iBlockIdx < taosArrayGetSize(pIter->dIter.aBlockIdx)) { + SBlockIdx* pBlockIdx = taosArrayGet(pIter->dIter.aBlockIdx, pIter->dIter.iBlockIdx); + + code = tsdbReadDataBlk(pIter->dIter.pReader, pBlockIdx, &pIter->dIter.mDataBlk); + TSDB_CHECK_CODE(code, lino, _exit); + + pIter->dIter.iBlockIdx++; + pIter->dIter.iDataBlk = 0; + + break; + } else { + pIter->rowInfo = (SRowInfo){0}; + goto _exit; } } } - - continue; - - _add_iter: - tRBTreePut(&pReader->rbt, (SRBTreeNode*)pIter); - pIter++; } _exit: if (code) { - tsdbError("vgId:%d, %s failed since %s", TD_VID(pReader->pTsdb->pVnode), __func__, tstrerror(code)); - } else { - tsdbInfo("vgId:%d, %s done, path:%s, fid:%d", TD_VID(pReader->pTsdb->pVnode), __func__, pReader->pTsdb->path, - pReader->fid); + tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); } return code; } -static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) { +static int32_t tsdbSttFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) { int32_t code = 0; + int32_t lino = 0; - if (pReader->pIter) { - SFDataIter* pIter = NULL; - while (true) { - _find_row: - pIter = pReader->pIter; - for (pIter->iRow++; pIter->iRow < pIter->bData.nRow; pIter->iRow++) { - int64_t rowVer = pIter->bData.aVersion[pIter->iRow]; - - if (rowVer >= pReader->sver && rowVer <= pReader->ever) { - pIter->rInfo.suid = pIter->bData.suid; - pIter->rInfo.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[pIter->iRow]; - pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow); - goto _out; - } - } - - if (pIter->type == SNAP_DATA_FILE_ITER) { - while (true) { - for (pIter->iBlock++; pIter->iBlock < pIter->mBlock.nItem; pIter->iBlock++) { - SDataBlk dataBlk; - tMapDataGetItemByIdx(&pIter->mBlock, pIter->iBlock, &dataBlk, tGetDataBlk); - - if (dataBlk.minVer > pReader->ever || dataBlk.maxVer < pReader->sver) continue; - - code = tsdbReadDataBlockEx(pReader->pDataFReader, &dataBlk, &pIter->bData); - if (code) goto _err; - - pIter->iRow = -1; - goto _find_row; + for (;;) { + while (pIter->sIter.iRow < pIter->sIter.bData.nRow) { + if (pFilterInfo) { + if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) { + if (pFilterInfo->sver > pIter->sIter.bData.aVersion[pIter->sIter.iRow] || + pFilterInfo->ever < pIter->sIter.bData.aVersion[pIter->sIter.iRow]) { + pIter->sIter.iRow++; + continue; } - - pIter->iBlockIdx++; - if (pIter->iBlockIdx >= taosArrayGetSize(pIter->aBlockIdx)) break; - - pIter->pBlockIdx = (SBlockIdx*)taosArrayGet(pIter->aBlockIdx, pIter->iBlockIdx); - code = tsdbReadDataBlk(pReader->pDataFReader, pIter->pBlockIdx, &pIter->mBlock); - if (code) goto _err; - pIter->iBlock = -1; } - - pReader->pIter = NULL; - break; - } else if (pIter->type == SNAP_STT_FILE_ITER) { - for (pIter->iSttBlk++; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) { - SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk); - - if (pSttBlk->minVer > pReader->ever || pSttBlk->maxVer < pReader->sver) continue; - - code = tsdbReadSttBlockEx(pReader->pDataFReader, pIter->iStt, pSttBlk, &pIter->bData); - if (code) goto _err; - - pIter->iRow = -1; - goto _find_row; - } - - pReader->pIter = NULL; - break; - } else { - ASSERT(0); } + + pIter->rowInfo.suid = pIter->sIter.bData.suid; + pIter->rowInfo.uid = pIter->sIter.bData.uid ? pIter->sIter.bData.uid : pIter->sIter.bData.aUid[pIter->sIter.iRow]; + pIter->rowInfo.row = tsdbRowFromBlockData(&pIter->sIter.bData, pIter->sIter.iRow); + pIter->sIter.iRow++; + goto _exit; } - _out: - pIter = (SFDataIter*)tRBTreeMin(&pReader->rbt); - if (pReader->pIter && pIter) { - int32_t c = tRowInfoCmprFn(&pReader->pIter->rInfo, &pIter->rInfo); - if (c > 0) { - tRBTreePut(&pReader->rbt, (SRBTreeNode*)pReader->pIter); - pReader->pIter = NULL; + for (;;) { + if (pIter->sIter.iSttBlk < taosArrayGetSize(pIter->sIter.aSttBlk)) { + SSttBlk* pSttBlk = taosArrayGet(pIter->sIter.aSttBlk, pIter->sIter.iSttBlk); + + if (pFilterInfo) { + if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) { + if (pFilterInfo->sver > pSttBlk->maxVer || pFilterInfo->ever < pSttBlk->minVer) { + pIter->sIter.iSttBlk++; + continue; + } + } + } + + code = tsdbReadSttBlockEx(pIter->sIter.pReader, pIter->sIter.iStt, pSttBlk, &pIter->sIter.bData); + TSDB_CHECK_CODE(code, lino, _exit); + + pIter->sIter.iRow = 0; + pIter->sIter.iSttBlk++; + break; } else { - ASSERT(c); + pIter->rowInfo = (SRowInfo){0}; + goto _exit; + } + } + } + +_exit: + if (code) { + tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } + return code; +} + +static int32_t tsdbTombFileDataIterNext(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) { + int32_t code = 0; + int32_t lino = 0; + + for (;;) { + while (pIter->tIter.iDelData < taosArrayGetSize(pIter->tIter.aDelData)) { + SDelData* pDelData = taosArrayGet(pIter->tIter.aDelData, pIter->tIter.iDelData); + + if (pFilterInfo) { + if (pFilterInfo->flag & TSDB_FILTER_FLAG_BY_VERSION) { + if (pFilterInfo->sver > pDelData->version || pFilterInfo->ever < pDelData->version) { + pIter->tIter.iDelData++; + continue; + } + } + } + + pIter->delInfo.delData = *pDelData; + pIter->tIter.iDelData++; + goto _exit; + } + + for (;;) { + if (pIter->tIter.iDelIdx < taosArrayGetSize(pIter->tIter.aDelIdx)) { + SDelIdx* pDelIdx = taosArrayGet(pIter->tIter.aDelIdx, pIter->tIter.iDelIdx); + + code = tsdbReadDelData(pIter->tIter.pReader, pDelIdx, pIter->tIter.aDelData); + TSDB_CHECK_CODE(code, lino, _exit); + + pIter->delInfo.suid = pDelIdx->suid; + pIter->delInfo.uid = pDelIdx->uid; + pIter->tIter.iDelData = 0; + pIter->tIter.iDelIdx++; + break; + } else { + pIter->delInfo = (SDelInfo){0}; + goto _exit; + } + } + } + +_exit: + if (code) { + tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } + return code; +} + +static int32_t tsdbDataIterNext2(STsdbDataIter2* pIter, STsdbFilterInfo* pFilterInfo) { + int32_t code = 0; + + if (pIter->type == TSDB_MEM_TABLE_DATA_ITER) { + ASSERT(0); + return code; + } else if (pIter->type == TSDB_DATA_FILE_DATA_ITER) { + return tsdbDataFileDataIterNext(pIter, pFilterInfo); + } else if (pIter->type == TSDB_STT_FILE_DATA_ITER) { + return tsdbSttFileDataIterNext(pIter, pFilterInfo); + } else if (pIter->type == TSDB_TOMB_FILE_DATA_ITER) { + return tsdbTombFileDataIterNext(pIter, pFilterInfo); + } else { + ASSERT(0); + return code; + } +} + +/* get */ + +// STsdbSnapReader ======================================== +struct STsdbSnapReader { + STsdb* pTsdb; + int64_t sver; + int64_t ever; + int8_t type; + uint8_t* aBuf[5]; + + STsdbFS fs; + TABLEID tbid; + SSkmInfo skmTable; + + // timeseries data + int8_t dataDone; + int32_t fid; + + SDataFReader* pDataFReader; + STsdbDataIter2* iterList; + STsdbDataIter2* pIter; + SRBTree rbt; + SBlockData bData; + + // tombstone data + int8_t delDone; + SDelFReader* pDelFReader; + STsdbDataIter2* pTIter; + SArray* aDelData; +}; + +static int32_t tsdbSnapReadFileDataStart(STsdbSnapReader* pReader) { + int32_t code = 0; + int32_t lino = 0; + + SDFileSet* pSet = taosArraySearch(pReader->fs.aDFileSet, &(SDFileSet){.fid = pReader->fid}, tDFileSetCmprFn, TD_GT); + if (pSet == NULL) { + pReader->fid = INT32_MAX; + goto _exit; + } + + pReader->fid = pSet->fid; + + tRBTreeCreate(&pReader->rbt, tsdbDataIterCmprFn); + + code = tsdbDataFReaderOpen(&pReader->pDataFReader, pReader->pTsdb, pSet); + TSDB_CHECK_CODE(code, lino, _exit); + + code = tsdbOpenDataFileDataIter(pReader->pDataFReader, &pReader->pIter); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pReader->pIter) { + // iter to next with filter info (sver, ever) + code = tsdbDataIterNext2(pReader->pIter, + &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, // flag + .sver = pReader->sver, + .ever = pReader->ever}); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pReader->pIter->rowInfo.suid || pReader->pIter->rowInfo.uid) { + // add to rbtree + tRBTreePut(&pReader->rbt, &pReader->pIter->rbtn); + + // add to iterList + pReader->pIter->next = pReader->iterList; + pReader->iterList = pReader->pIter; + } else { + tsdbCloseDataIter2(pReader->pIter); + } + } + + for (int32_t iStt = 0; iStt < pSet->nSttF; ++iStt) { + code = tsdbOpenSttFileDataIter(pReader->pDataFReader, iStt, &pReader->pIter); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pReader->pIter) { + // iter to valid row + code = tsdbDataIterNext2(pReader->pIter, + &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, // flag + .sver = pReader->sver, + .ever = pReader->ever}); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pReader->pIter->rowInfo.suid || pReader->pIter->rowInfo.uid) { + // add to rbtree + tRBTreePut(&pReader->rbt, &pReader->pIter->rbtn); + + // add to iterList + pReader->pIter->next = pReader->iterList; + pReader->iterList = pReader->pIter; + } else { + tsdbCloseDataIter2(pReader->pIter); + } + } + } + + pReader->pIter = NULL; + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbInfo("vgId:%d %s done, fid:%d", TD_VID(pReader->pTsdb->pVnode), __func__, pReader->fid); + } + return code; +} + +static void tsdbSnapReadFileDataEnd(STsdbSnapReader* pReader) { + while (pReader->iterList) { + STsdbDataIter2* pIter = pReader->iterList; + pReader->iterList = pIter->next; + tsdbCloseDataIter2(pIter); + } + + tsdbDataFReaderClose(&pReader->pDataFReader); +} + +static int32_t tsdbSnapReadNextRow(STsdbSnapReader* pReader, SRowInfo** ppRowInfo) { + int32_t code = 0; + int32_t lino = 0; + + if (pReader->pIter) { + code = tsdbDataIterNext2(pReader->pIter, &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, // flag + .sver = pReader->sver, + .ever = pReader->ever}); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pReader->pIter->rowInfo.suid == 0 && pReader->pIter->rowInfo.uid == 0) { + pReader->pIter = NULL; + } else { + SRBTreeNode* pNode = tRBTreeMin(&pReader->rbt); + if (pNode) { + int32_t c = tsdbDataIterCmprFn(&pReader->pIter->rbtn, pNode); + if (c > 0) { + tRBTreePut(&pReader->rbt, &pReader->pIter->rbtn); + pReader->pIter = NULL; + } else if (c == 0) { + ASSERT(0); + } } } } if (pReader->pIter == NULL) { - pReader->pIter = (SFDataIter*)tRBTreeMin(&pReader->rbt); - if (pReader->pIter) { - tRBTreeDrop(&pReader->rbt, (SRBTreeNode*)pReader->pIter); + SRBTreeNode* pNode = tRBTreeMin(&pReader->rbt); + if (pNode) { + tRBTreeDrop(&pReader->rbt, pNode); + pReader->pIter = TSDB_RBTN_TO_DATA_ITER(pNode); } } - return code; + if (ppRowInfo) { + if (pReader->pIter) { + *ppRowInfo = &pReader->pIter->rowInfo; + } else { + *ppRowInfo = NULL; + } + } -_err: +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } return code; } -static SRowInfo* tsdbSnapGetRow(STsdbSnapReader* pReader) { +static int32_t tsdbSnapReadGetRow(STsdbSnapReader* pReader, SRowInfo** ppRowInfo) { if (pReader->pIter) { - return &pReader->pIter->rInfo; - } else { - tsdbSnapNextRow(pReader); - - if (pReader->pIter) { - return &pReader->pIter->rInfo; - } else { - return NULL; - } + *ppRowInfo = &pReader->pIter->rowInfo; + return 0; } + + return tsdbSnapReadNextRow(pReader, ppRowInfo); } static int32_t tsdbSnapCmprData(STsdbSnapReader* pReader, uint8_t** ppData) { @@ -318,155 +672,213 @@ _exit: return code; } -static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) { +static int32_t tsdbSnapReadTimeSeriesData(STsdbSnapReader* pReader, uint8_t** ppData) { int32_t code = 0; int32_t lino = 0; STsdb* pTsdb = pReader->pTsdb; - while (true) { + tBlockDataReset(&pReader->bData); + + for (;;) { + // start a new file read if need if (pReader->pDataFReader == NULL) { - code = tsdbSnapReadOpenFile(pReader); + code = tsdbSnapReadFileDataStart(pReader); TSDB_CHECK_CODE(code, lino, _exit); } if (pReader->pDataFReader == NULL) break; - SRowInfo* pRowInfo = tsdbSnapGetRow(pReader); + SRowInfo* pRowInfo; + code = tsdbSnapReadGetRow(pReader, &pRowInfo); + TSDB_CHECK_CODE(code, lino, _exit); + if (pRowInfo == NULL) { - tsdbDataFReaderClose(&pReader->pDataFReader); + tsdbSnapReadFileDataEnd(pReader); continue; } - TABLEID id = {.suid = pRowInfo->suid, .uid = pRowInfo->uid}; - SBlockData* pBlockData = &pReader->bData; - - code = tsdbUpdateTableSchema(pTsdb->pVnode->pMeta, id.suid, id.uid, &pReader->skmTable); + code = tsdbUpdateTableSchema(pTsdb->pVnode->pMeta, pRowInfo->suid, pRowInfo->uid, &pReader->skmTable); TSDB_CHECK_CODE(code, lino, _exit); - code = tBlockDataInit(pBlockData, &id, pReader->skmTable.pTSchema, NULL, 0); + code = tBlockDataInit(&pReader->bData, (TABLEID*)pRowInfo, pReader->skmTable.pTSchema, NULL, 0); TSDB_CHECK_CODE(code, lino, _exit); - while (pRowInfo->suid == id.suid && pRowInfo->uid == id.uid) { - code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, NULL, pRowInfo->uid); - TSDB_CHECK_CODE(code, lino, _exit); + do { + if (!TABLE_SAME_SCHEMA(pReader->bData.suid, pReader->bData.uid, pRowInfo->suid, pRowInfo->uid)) break; - code = tsdbSnapNextRow(pReader); - TSDB_CHECK_CODE(code, lino, _exit); + if (pReader->bData.uid && pReader->bData.uid != pRowInfo->uid) { + code = tRealloc((uint8_t**)&pReader->bData.aUid, sizeof(int64_t) * (pReader->bData.nRow + 1)); + TSDB_CHECK_CODE(code, lino, _exit); - pRowInfo = tsdbSnapGetRow(pReader); - if (pRowInfo == NULL) { - tsdbDataFReaderClose(&pReader->pDataFReader); - break; + for (int32_t iRow = 0; iRow < pReader->bData.nRow; ++iRow) { + pReader->bData.aUid[iRow] = pReader->bData.uid; + } + pReader->bData.uid = 0; } - if (pBlockData->nRow >= 4096) break; - } + code = tBlockDataAppendRow(&pReader->bData, &pRowInfo->row, NULL, pRowInfo->uid); + TSDB_CHECK_CODE(code, lino, _exit); - code = tsdbSnapCmprData(pReader, ppData); - TSDB_CHECK_CODE(code, lino, _exit); + code = tsdbSnapReadNextRow(pReader, &pRowInfo); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pReader->bData.nRow >= 4096) break; + } while (pRowInfo); + + ASSERT(pReader->bData.nRow > 0); break; } + if (pReader->bData.nRow > 0) { + code = tsdbSnapCmprData(pReader, ppData); + TSDB_CHECK_CODE(code, lino, _exit); + } + _exit: if (code) { - tsdbError("vgId:%d, %s failed since %s, path:%s", TD_VID(pTsdb->pVnode), __func__, tstrerror(code), pTsdb->path); + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); } return code; } -static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) { +static int32_t tsdbSnapCmprTombData(STsdbSnapReader* pReader, uint8_t** ppData) { int32_t code = 0; int32_t lino = 0; - STsdb* pTsdb = pReader->pTsdb; - SDelFile* pDelFile = pReader->fs.pDelFile; - - if (pReader->pDelFReader == NULL) { - if (pDelFile == NULL) { - goto _exit; - } - - // open - code = tsdbDelFReaderOpen(&pReader->pDelFReader, pDelFile, pTsdb); - TSDB_CHECK_CODE(code, lino, _exit); - - // read index - code = tsdbReadDelIdx(pReader->pDelFReader, pReader->aDelIdx); - TSDB_CHECK_CODE(code, lino, _exit); - - pReader->iDelIdx = 0; + int64_t size = sizeof(TABLEID); + for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); ++iDelData) { + size += tPutDelData(NULL, taosArrayGet(pReader->aDelData, iDelData)); } - while (true) { - if (pReader->iDelIdx >= taosArrayGetSize(pReader->aDelIdx)) { - tsdbDelFReaderClose(&pReader->pDelFReader); - break; - } - - SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pReader->aDelIdx, pReader->iDelIdx); - - pReader->iDelIdx++; - - code = tsdbReadDelData(pReader->pDelFReader, pDelIdx, pReader->aDelData); + uint8_t* pData = (uint8_t*)taosMemoryMalloc(sizeof(SSnapDataHdr) + size); + if (pData == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; TSDB_CHECK_CODE(code, lino, _exit); + } - int32_t size = 0; - for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); iDelData++) { - SDelData* pDelData = (SDelData*)taosArrayGet(pReader->aDelData, iDelData); + SSnapDataHdr* pHdr = (SSnapDataHdr*)pData; + pHdr->type = SNAP_DATA_DEL; + pHdr->size = size; - if (pDelData->version >= pReader->sver && pDelData->version <= pReader->ever) { - size += tPutDelData(NULL, pDelData); - } - } - if (size == 0) continue; + TABLEID* pId = (TABLEID*)(pData + sizeof(SSnapDataHdr)); + *pId = pReader->tbid; - // org data - size = sizeof(TABLEID) + size; - *ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size); - if (*ppData == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - - SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData); - pHdr->type = SNAP_DATA_DEL; - pHdr->size = size; - - TABLEID* pId = (TABLEID*)(&pHdr[1]); - pId->suid = pDelIdx->suid; - pId->uid = pDelIdx->uid; - int32_t n = sizeof(SSnapDataHdr) + sizeof(TABLEID); - for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); iDelData++) { - SDelData* pDelData = (SDelData*)taosArrayGet(pReader->aDelData, iDelData); - - if (pDelData->version < pReader->sver) continue; - if (pDelData->version > pReader->ever) continue; - - n += tPutDelData((*ppData) + n, pDelData); - } - - tsdbInfo("vgId:%d, vnode snapshot tsdb read del data for %s, suid:%" PRId64 " uid:%" PRId64 " size:%d", - TD_VID(pTsdb->pVnode), pTsdb->path, pDelIdx->suid, pDelIdx->uid, size); - - break; + size = sizeof(SSnapDataHdr) + sizeof(TABLEID); + for (int32_t iDelData = 0; iDelData < taosArrayGetSize(pReader->aDelData); ++iDelData) { + size += tPutDelData(pData + size, taosArrayGet(pReader->aDelData, iDelData)); } _exit: if (code) { - tsdbError("vgId:%d, %s failed since %s, path:%s", TD_VID(pTsdb->pVnode), __func__, tstrerror(code), pTsdb->path); + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code)); + if (pData) { + taosMemoryFree(pData); + pData = NULL; + } + } + *ppData = pData; + return code; +} + +static void tsdbSnapReadGetTombData(STsdbSnapReader* pReader, SDelInfo** ppDelInfo) { + if (pReader->pTIter == NULL || (pReader->pTIter->delInfo.suid == 0 && pReader->pTIter->delInfo.uid == 0)) { + *ppDelInfo = NULL; + } else { + *ppDelInfo = &pReader->pTIter->delInfo; + } +} + +static int32_t tsdbSnapReadNextTombData(STsdbSnapReader* pReader, SDelInfo** ppDelInfo) { + int32_t code = 0; + int32_t lino = 0; + + code = tsdbDataIterNext2( + pReader->pTIter, + &(STsdbFilterInfo){.flag = TSDB_FILTER_FLAG_BY_VERSION, .sver = pReader->sver, .ever = pReader->ever}); + TSDB_CHECK_CODE(code, lino, _exit); + + if (ppDelInfo) { + tsdbSnapReadGetTombData(pReader, ppDelInfo); + } + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } + return code; +} + +static int32_t tsdbSnapReadTombData(STsdbSnapReader* pReader, uint8_t** ppData) { + int32_t code = 0; + int32_t lino = 0; + + STsdb* pTsdb = pReader->pTsdb; + + // open tombstone data iter if need + if (pReader->pDelFReader == NULL) { + if (pReader->fs.pDelFile == NULL) goto _exit; + + // open + code = tsdbDelFReaderOpen(&pReader->pDelFReader, pReader->fs.pDelFile, pTsdb); + TSDB_CHECK_CODE(code, lino, _exit); + + code = tsdbOpenTombFileDataIter(pReader->pDelFReader, &pReader->pTIter); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pReader->pTIter) { + code = tsdbSnapReadNextTombData(pReader, NULL); + TSDB_CHECK_CODE(code, lino, _exit); + } + } + + // loop to get tombstone data + SDelInfo* pDelInfo; + tsdbSnapReadGetTombData(pReader, &pDelInfo); + + if (pDelInfo == NULL) goto _exit; + + pReader->tbid = *(TABLEID*)pDelInfo; + + if (pReader->aDelData) { + taosArrayClear(pReader->aDelData); + } else if ((pReader->aDelData = taosArrayInit(16, sizeof(SDelData))) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + while (pDelInfo && pDelInfo->suid == pReader->tbid.suid && pDelInfo->uid == pReader->tbid.uid) { + if (taosArrayPush(pReader->aDelData, &pDelInfo->delData) < 0) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + code = tsdbSnapReadNextTombData(pReader, &pDelInfo); + TSDB_CHECK_CODE(code, lino, _exit); + } + + // encode tombstone data + if (taosArrayGetSize(pReader->aDelData) > 0) { + code = tsdbSnapCmprTombData(pReader, ppData); + TSDB_CHECK_CODE(code, lino, _exit); + } + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbDebug("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__); } return code; } int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type, STsdbSnapReader** ppReader) { - int32_t code = 0; - int32_t lino = 0; - STsdbSnapReader* pReader = NULL; + int32_t code = 0; + int32_t lino = 0; // alloc - pReader = (STsdbSnapReader*)taosMemoryCalloc(1, sizeof(*pReader)); + STsdbSnapReader* pReader = (STsdbSnapReader*)taosMemoryCalloc(1, sizeof(*pReader)); if (pReader == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; TSDB_CHECK_CODE(code, lino, _exit); @@ -476,118 +888,80 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type pReader->ever = ever; pReader->type = type; - code = taosThreadRwlockRdlock(&pTsdb->rwLock); - if (code) { - code = TAOS_SYSTEM_ERROR(code); - TSDB_CHECK_CODE(code, lino, _exit); - } - + taosThreadRwlockRdlock(&pTsdb->rwLock); code = tsdbFSRef(pTsdb, &pReader->fs); if (code) { taosThreadRwlockUnlock(&pTsdb->rwLock); TSDB_CHECK_CODE(code, lino, _exit); } + taosThreadRwlockUnlock(&pTsdb->rwLock); - code = taosThreadRwlockUnlock(&pTsdb->rwLock); - if (code) { - code = TAOS_SYSTEM_ERROR(code); - TSDB_CHECK_CODE(code, lino, _exit); - } - - // data + // init pReader->fid = INT32_MIN; - for (int32_t iIter = 0; iIter < sizeof(pReader->aFDataIter) / sizeof(pReader->aFDataIter[0]); iIter++) { - SFDataIter* pIter = &pReader->aFDataIter[iIter]; - - if (iIter == 0) { - pIter->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); - if (pIter->aBlockIdx == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - } else { - pIter->aSttBlk = taosArrayInit(0, sizeof(SSttBlk)); - if (pIter->aSttBlk == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - } - - code = tBlockDataCreate(&pIter->bData); - TSDB_CHECK_CODE(code, lino, _exit); - } code = tBlockDataCreate(&pReader->bData); TSDB_CHECK_CODE(code, lino, _exit); - // del - pReader->aDelIdx = taosArrayInit(0, sizeof(SDelIdx)); - if (pReader->aDelIdx == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - pReader->aDelData = taosArrayInit(0, sizeof(SDelData)); - if (pReader->aDelData == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - _exit: if (code) { - tsdbError("vgId:%d, %s failed at line %d since %s, TSDB path: %s", TD_VID(pTsdb->pVnode), __func__, lino, - tstrerror(code), pTsdb->path); - *ppReader = NULL; - + tsdbError("vgId:%d %s failed at line %d since %s, sver:%" PRId64 " ever:%" PRId64 " type:%d", TD_VID(pTsdb->pVnode), + __func__, lino, tstrerror(code), sver, ever, type); if (pReader) { - taosArrayDestroy(pReader->aDelData); - taosArrayDestroy(pReader->aDelIdx); tBlockDataDestroy(&pReader->bData, 1); - tsdbFSDestroy(&pReader->fs); + tsdbFSUnref(pTsdb, &pReader->fs); taosMemoryFree(pReader); + pReader = NULL; } } else { - *ppReader = pReader; - tsdbInfo("vgId:%d, vnode snapshot tsdb reader opened for %s", TD_VID(pTsdb->pVnode), pTsdb->path); + tsdbInfo("vgId:%d %s done, sver:%" PRId64 " ever:%" PRId64 " type:%d", TD_VID(pTsdb->pVnode), __func__, sver, ever, + type); } + *ppReader = pReader; return code; } int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) { - int32_t code = 0; + int32_t code = 0; + int32_t lino = 0; + STsdbSnapReader* pReader = *ppReader; + STsdb* pTsdb = pReader->pTsdb; - // data - if (pReader->pDataFReader) tsdbDataFReaderClose(&pReader->pDataFReader); - for (int32_t iIter = 0; iIter < sizeof(pReader->aFDataIter) / sizeof(pReader->aFDataIter[0]); iIter++) { - SFDataIter* pIter = &pReader->aFDataIter[iIter]; - - if (iIter == 0) { - taosArrayDestroy(pIter->aBlockIdx); - tMapDataClear(&pIter->mBlock); - } else { - taosArrayDestroy(pIter->aSttBlk); - } - - tBlockDataDestroy(&pIter->bData, 1); + // tombstone + if (pReader->pTIter) { + tsdbCloseDataIter2(pReader->pTIter); + pReader->pTIter = NULL; + } + if (pReader->pDelFReader) { + tsdbDelFReaderClose(&pReader->pDelFReader); } - - tBlockDataDestroy(&pReader->bData, 1); - tDestroyTSchema(pReader->skmTable.pTSchema); - - // del - if (pReader->pDelFReader) tsdbDelFReaderClose(&pReader->pDelFReader); - taosArrayDestroy(pReader->aDelIdx); taosArrayDestroy(pReader->aDelData); + // timeseries + while (pReader->iterList) { + STsdbDataIter2* pIter = pReader->iterList; + pReader->iterList = pIter->next; + tsdbCloseDataIter2(pIter); + } + if (pReader->pDataFReader) { + tsdbDataFReaderClose(&pReader->pDataFReader); + } + tBlockDataDestroy(&pReader->bData, 1); + + // other + tDestroyTSchema(pReader->skmTable.pTSchema); tsdbFSUnref(pReader->pTsdb, &pReader->fs); - - tsdbInfo("vgId:%d, vnode snapshot tsdb reader closed for %s", TD_VID(pReader->pTsdb->pVnode), pReader->pTsdb->path); - for (int32_t iBuf = 0; iBuf < sizeof(pReader->aBuf) / sizeof(pReader->aBuf[0]); iBuf++) { tFree(pReader->aBuf[iBuf]); } - taosMemoryFree(pReader); + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbDebug("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__); + } *ppReader = NULL; return code; } @@ -600,7 +974,7 @@ int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) { // read data file if (!pReader->dataDone) { - code = tsdbSnapReadData(pReader, ppData); + code = tsdbSnapReadTimeSeriesData(pReader, ppData); TSDB_CHECK_CODE(code, lino, _exit); if (*ppData) { goto _exit; @@ -611,7 +985,7 @@ int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) { // read del file if (!pReader->delDone) { - code = tsdbSnapReadDel(pReader, ppData); + code = tsdbSnapReadTombData(pReader, ppData); TSDB_CHECK_CODE(code, lino, _exit); if (*ppData) { goto _exit; @@ -622,22 +996,18 @@ int32_t tsdbSnapRead(STsdbSnapReader* pReader, uint8_t** ppData) { _exit: if (code) { - tsdbError("vgId:%d, %s failed since %s, path:%s", TD_VID(pReader->pTsdb->pVnode), __func__, tstrerror(code), - pReader->pTsdb->path); + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pReader->pTsdb->pVnode), __func__, lino, tstrerror(code)); } else { - tsdbDebug("vgId:%d, %s done, path:%s", TD_VID(pReader->pTsdb->pVnode), __func__, pReader->pTsdb->path); + tsdbDebug("vgId:%d %s done", TD_VID(pReader->pTsdb->pVnode), __func__); } return code; } // STsdbSnapWriter ======================================== struct STsdbSnapWriter { - STsdb* pTsdb; - int64_t sver; - int64_t ever; - STsdbFS fs; - - // config + STsdb* pTsdb; + int64_t sver; + int64_t ever; int32_t minutes; int8_t precision; int32_t minRow; @@ -646,641 +1016,816 @@ struct STsdbSnapWriter { int64_t commitID; uint8_t* aBuf[5]; - // for data file - SBlockData bData; - int32_t fid; - TABLEID id; - SSkmInfo skmTable; - struct { - SDataFReader* pReader; - SArray* aBlockIdx; - int32_t iBlockIdx; - SBlockIdx* pBlockIdx; - SMapData mDataBlk; - int32_t iDataBlk; - SBlockData bData; - int32_t iRow; - } dReader; - struct { - SDataFWriter* pWriter; - SArray* aBlockIdx; - SMapData mDataBlk; - SArray* aSttBlk; - SBlockData bData; - SBlockData sData; - } dWriter; + STsdbFS fs; + TABLEID tbid; - // for del file - SDelFReader* pDelFReader; + // time-series data + SBlockData inData; + + int32_t fid; + SSkmInfo skmTable; + + /* reader */ + SDataFReader* pDataFReader; + STsdbDataIter2* iterList; + STsdbDataIter2* pDIter; + STsdbDataIter2* pSIter; + SRBTree rbt; // SRBTree + + /* writer */ + SDataFWriter* pDataFWriter; + SArray* aBlockIdx; + SMapData mDataBlk; // SMapData + SArray* aSttBlk; // SArray + SBlockData bData; + SBlockData sData; + + // tombstone data + /* reader */ + SDelFReader* pDelFReader; + STsdbDataIter2* pTIter; + + /* writer */ SDelFWriter* pDelFWriter; - int32_t iDelIdx; - SArray* aDelIdxR; + SArray* aDelIdx; SArray* aDelData; - SArray* aDelIdxW; }; // SNAP_DATA_TSDB -extern int32_t tsdbWriteDataBlock(SDataFWriter* pWriter, SBlockData* pBlockData, SMapData* mDataBlk, int8_t cmprAlg); -extern int32_t tsdbWriteSttBlock(SDataFWriter* pWriter, SBlockData* pBlockData, SArray* aSttBlk, int8_t cmprAlg); - -static int32_t tsdbSnapNextTableData(STsdbSnapWriter* pWriter) { - int32_t code = 0; - - ASSERT(pWriter->dReader.iRow >= pWriter->dReader.bData.nRow); - - if (pWriter->dReader.iBlockIdx < taosArrayGetSize(pWriter->dReader.aBlockIdx)) { - pWriter->dReader.pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->dReader.aBlockIdx, pWriter->dReader.iBlockIdx); - - code = tsdbReadDataBlk(pWriter->dReader.pReader, pWriter->dReader.pBlockIdx, &pWriter->dReader.mDataBlk); - if (code) goto _exit; - - pWriter->dReader.iBlockIdx++; - } else { - pWriter->dReader.pBlockIdx = NULL; - tMapDataReset(&pWriter->dReader.mDataBlk); - } - pWriter->dReader.iDataBlk = 0; // point to the next one - tBlockDataReset(&pWriter->dReader.bData); - pWriter->dReader.iRow = 0; - -_exit: - return code; -} - -static int32_t tsdbSnapWriteCopyData(STsdbSnapWriter* pWriter, TABLEID* pId) { - int32_t code = 0; - - while (true) { - if (pWriter->dReader.pBlockIdx == NULL) break; - if (tTABLEIDCmprFn(pWriter->dReader.pBlockIdx, pId) >= 0) break; - - SBlockIdx blkIdx = *pWriter->dReader.pBlockIdx; - code = tsdbWriteDataBlk(pWriter->dWriter.pWriter, &pWriter->dReader.mDataBlk, &blkIdx); - if (code) goto _exit; - - if (taosArrayPush(pWriter->dWriter.aBlockIdx, &blkIdx) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } - - code = tsdbSnapNextTableData(pWriter); - if (code) goto _exit; - } - -_exit: - return code; -} - static int32_t tsdbSnapWriteTableDataStart(STsdbSnapWriter* pWriter, TABLEID* pId) { int32_t code = 0; + int32_t lino = 0; - code = tsdbSnapWriteCopyData(pWriter, pId); - if (code) goto _err; + if (pId) { + pWriter->tbid = *pId; + } else { + pWriter->tbid = (TABLEID){INT64_MAX, INT64_MAX}; + } - pWriter->id.suid = pId->suid; - pWriter->id.uid = pId->uid; + if (pWriter->pDIter) { + STsdbDataIter2* pIter = pWriter->pDIter; - code = tsdbUpdateTableSchema(pWriter->pTsdb->pVnode->pMeta, pId->suid, pId->uid, &pWriter->skmTable); - if (code) goto _err; + // assert last table data end + ASSERT(pIter->dIter.iRow >= pIter->dIter.bData.nRow); + ASSERT(pIter->dIter.iDataBlk >= pIter->dIter.mDataBlk.nItem); - tMapDataReset(&pWriter->dWriter.mDataBlk); - code = tBlockDataInit(&pWriter->dWriter.bData, pId, pWriter->skmTable.pTSchema, NULL, 0); - if (code) goto _err; + for (;;) { + if (pIter->dIter.iBlockIdx >= taosArrayGetSize(pIter->dIter.aBlockIdx)) { + pWriter->pDIter = NULL; + break; + } + SBlockIdx* pBlockIdx = (SBlockIdx*)taosArrayGet(pIter->dIter.aBlockIdx, pIter->dIter.iBlockIdx); + + int32_t c = tTABLEIDCmprFn(pBlockIdx, &pWriter->tbid); + if (c < 0) { + code = tsdbReadDataBlk(pIter->dIter.pReader, pBlockIdx, &pIter->dIter.mDataBlk); + TSDB_CHECK_CODE(code, lino, _exit); + + SBlockIdx* pNewBlockIdx = taosArrayReserve(pWriter->aBlockIdx, 1); + if (pNewBlockIdx == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + pNewBlockIdx->suid = pBlockIdx->suid; + pNewBlockIdx->uid = pBlockIdx->uid; + + code = tsdbWriteDataBlk(pWriter->pDataFWriter, &pIter->dIter.mDataBlk, pNewBlockIdx); + TSDB_CHECK_CODE(code, lino, _exit); + + pIter->dIter.iBlockIdx++; + } else if (c == 0) { + code = tsdbReadDataBlk(pIter->dIter.pReader, pBlockIdx, &pIter->dIter.mDataBlk); + TSDB_CHECK_CODE(code, lino, _exit); + + pIter->dIter.iDataBlk = 0; + pIter->dIter.iBlockIdx++; + + break; + } else { + pIter->dIter.iDataBlk = pIter->dIter.mDataBlk.nItem; + break; + } + } + } + + if (pId) { + code = tsdbUpdateTableSchema(pWriter->pTsdb->pVnode->pMeta, pId->suid, pId->uid, &pWriter->skmTable); + TSDB_CHECK_CODE(code, lino, _exit); + + tMapDataReset(&pWriter->mDataBlk); + + code = tBlockDataInit(&pWriter->bData, pId, pWriter->skmTable.pTSchema, NULL, 0); + TSDB_CHECK_CODE(code, lino, _exit); + } + + if (!TABLE_SAME_SCHEMA(pWriter->tbid.suid, pWriter->tbid.uid, pWriter->sData.suid, pWriter->sData.uid)) { + if ((pWriter->sData.nRow > 0)) { + code = tsdbWriteSttBlock(pWriter->pDataFWriter, &pWriter->sData, pWriter->aSttBlk, pWriter->cmprAlg); + TSDB_CHECK_CODE(code, lino, _exit); + } + + if (pId) { + TABLEID id = {.suid = pWriter->tbid.suid, .uid = pWriter->tbid.suid ? 0 : pWriter->tbid.uid}; + code = tBlockDataInit(&pWriter->sData, &id, pWriter->skmTable.pTSchema, NULL, 0); + TSDB_CHECK_CODE(code, lino, _exit); + } + } + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbTrace("vgId:%d %s done, suid:%" PRId64 " uid:%" PRId64, TD_VID(pWriter->pTsdb->pVnode), __func__, + pWriter->tbid.suid, pWriter->tbid.uid); + } return code; +} -_err: - tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code)); +static int32_t tsdbSnapWriteTableRowImpl(STsdbSnapWriter* pWriter, TSDBROW* pRow) { + int32_t code = 0; + int32_t lino = 0; + + code = tBlockDataAppendRow(&pWriter->bData, pRow, pWriter->skmTable.pTSchema, pWriter->tbid.uid); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pWriter->bData.nRow >= pWriter->maxRow) { + code = tsdbWriteDataBlock(pWriter->pDataFWriter, &pWriter->bData, &pWriter->mDataBlk, pWriter->cmprAlg); + TSDB_CHECK_CODE(code, lino, _exit); + } + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } + return code; +} + +static int32_t tsdbSnapWriteTableRow(STsdbSnapWriter* pWriter, TSDBROW* pRow) { + int32_t code = 0; + int32_t lino = 0; + + TSDBKEY inKey = pRow ? TSDBROW_KEY(pRow) : TSDBKEY_MAX; + + if (pWriter->pDIter == NULL || (pWriter->pDIter->dIter.iRow >= pWriter->pDIter->dIter.bData.nRow && + pWriter->pDIter->dIter.iDataBlk >= pWriter->pDIter->dIter.mDataBlk.nItem)) { + goto _write_row; + } else { + for (;;) { + while (pWriter->pDIter->dIter.iRow < pWriter->pDIter->dIter.bData.nRow) { + TSDBROW row = tsdbRowFromBlockData(&pWriter->pDIter->dIter.bData, pWriter->pDIter->dIter.iRow); + + int32_t c = tsdbKeyCmprFn(&inKey, &TSDBROW_KEY(&row)); + if (c < 0) { + goto _write_row; + } else if (c > 0) { + code = tsdbSnapWriteTableRowImpl(pWriter, &row); + TSDB_CHECK_CODE(code, lino, _exit); + + pWriter->pDIter->dIter.iRow++; + } else { + ASSERT(0); + } + } + + for (;;) { + if (pWriter->pDIter->dIter.iDataBlk >= pWriter->pDIter->dIter.mDataBlk.nItem) goto _write_row; + + // FIXME: Here can be slow, use array instead + SDataBlk dataBlk; + tMapDataGetItemByIdx(&pWriter->pDIter->dIter.mDataBlk, pWriter->pDIter->dIter.iDataBlk, &dataBlk, tGetDataBlk); + + int32_t c = tDataBlkCmprFn(&dataBlk, &(SDataBlk){.minKey = inKey, .maxKey = inKey}); + if (c > 0) { + goto _write_row; + } else if (c < 0) { + if (pWriter->bData.nRow > 0) { + code = tsdbWriteDataBlock(pWriter->pDataFWriter, &pWriter->bData, &pWriter->mDataBlk, pWriter->cmprAlg); + TSDB_CHECK_CODE(code, lino, _exit); + } + + tMapDataPutItem(&pWriter->mDataBlk, &dataBlk, tPutDataBlk); + pWriter->pDIter->dIter.iDataBlk++; + } else { + code = tsdbReadDataBlockEx(pWriter->pDataFReader, &dataBlk, &pWriter->pDIter->dIter.bData); + TSDB_CHECK_CODE(code, lino, _exit); + + pWriter->pDIter->dIter.iRow = 0; + pWriter->pDIter->dIter.iDataBlk++; + break; + } + } + } + } + +_write_row: + if (pRow) { + code = tsdbSnapWriteTableRowImpl(pWriter, pRow); + TSDB_CHECK_CODE(code, lino, _exit); + } + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } return code; } static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) { int32_t code = 0; + int32_t lino = 0; - if (pWriter->id.suid == 0 && pWriter->id.uid == 0) return code; + // write a NULL row to end current table data write + code = tsdbSnapWriteTableRow(pWriter, NULL); + TSDB_CHECK_CODE(code, lino, _exit); - int32_t c = 1; - if (pWriter->dReader.pBlockIdx) { - c = tTABLEIDCmprFn(pWriter->dReader.pBlockIdx, &pWriter->id); - ASSERT(c >= 0); - } + if (pWriter->bData.nRow > 0) { + if (pWriter->bData.nRow < pWriter->minRow) { + ASSERT(TABLE_SAME_SCHEMA(pWriter->sData.suid, pWriter->sData.uid, pWriter->tbid.suid, pWriter->tbid.uid)); + for (int32_t iRow = 0; iRow < pWriter->bData.nRow; iRow++) { + code = + tBlockDataAppendRow(&pWriter->sData, &tsdbRowFromBlockData(&pWriter->bData, iRow), NULL, pWriter->tbid.uid); + TSDB_CHECK_CODE(code, lino, _exit); - if (c == 0) { - SBlockData* pBData = &pWriter->dWriter.bData; - - for (; pWriter->dReader.iRow < pWriter->dReader.bData.nRow; pWriter->dReader.iRow++) { - TSDBROW row = tsdbRowFromBlockData(&pWriter->dReader.bData, pWriter->dReader.iRow); - - code = tBlockDataAppendRow(pBData, &row, NULL, pWriter->id.uid); - if (code) goto _err; - - if (pBData->nRow >= pWriter->maxRow) { - code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, pBData, &pWriter->dWriter.mDataBlk, pWriter->cmprAlg); - if (code) goto _err; + if (pWriter->sData.nRow >= pWriter->maxRow) { + code = tsdbWriteSttBlock(pWriter->pDataFWriter, &pWriter->sData, pWriter->aSttBlk, pWriter->cmprAlg); + TSDB_CHECK_CODE(code, lino, _exit); + } } + + tBlockDataClear(&pWriter->bData); + } else { + code = tsdbWriteDataBlock(pWriter->pDataFWriter, &pWriter->bData, &pWriter->mDataBlk, pWriter->cmprAlg); + TSDB_CHECK_CODE(code, lino, _exit); } - - code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, pBData, &pWriter->dWriter.mDataBlk, pWriter->cmprAlg); - if (code) goto _err; - - for (; pWriter->dReader.iDataBlk < pWriter->dReader.mDataBlk.nItem; pWriter->dReader.iDataBlk++) { - SDataBlk dataBlk; - tMapDataGetItemByIdx(&pWriter->dReader.mDataBlk, pWriter->dReader.iDataBlk, &dataBlk, tGetDataBlk); - - code = tMapDataPutItem(&pWriter->dWriter.mDataBlk, &dataBlk, tPutDataBlk); - if (code) goto _err; - } - - code = tsdbSnapNextTableData(pWriter); - if (code) goto _err; } - if (pWriter->dWriter.mDataBlk.nItem) { - SBlockIdx blockIdx = {.suid = pWriter->id.suid, .uid = pWriter->id.uid}; - code = tsdbWriteDataBlk(pWriter->dWriter.pWriter, &pWriter->dWriter.mDataBlk, &blockIdx); - - if (taosArrayPush(pWriter->dWriter.aBlockIdx, &blockIdx) == NULL) { + if (pWriter->mDataBlk.nItem) { + SBlockIdx* pBlockIdx = taosArrayReserve(pWriter->aBlockIdx, 1); + if (pBlockIdx == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + TSDB_CHECK_CODE(code, lino, _exit); } - } - pWriter->id.suid = 0; - pWriter->id.uid = 0; + pBlockIdx->suid = pWriter->tbid.suid; + pBlockIdx->uid = pWriter->tbid.uid; - return code; - -_err: - return code; -} - -static int32_t tsdbSnapWriteOpenFile(STsdbSnapWriter* pWriter, int32_t fid) { - int32_t code = 0; - STsdb* pTsdb = pWriter->pTsdb; - - ASSERT(pWriter->dWriter.pWriter == NULL); - - pWriter->fid = fid; - pWriter->id = (TABLEID){0}; - SDFileSet* pSet = taosArraySearch(pWriter->fs.aDFileSet, &(SDFileSet){.fid = fid}, tDFileSetCmprFn, TD_EQ); - - // Reader - if (pSet) { - code = tsdbDataFReaderOpen(&pWriter->dReader.pReader, pWriter->pTsdb, pSet); - if (code) goto _err; - - code = tsdbReadBlockIdx(pWriter->dReader.pReader, pWriter->dReader.aBlockIdx); - if (code) goto _err; - } else { - ASSERT(pWriter->dReader.pReader == NULL); - taosArrayClear(pWriter->dReader.aBlockIdx); - } - pWriter->dReader.iBlockIdx = 0; // point to the next one - code = tsdbSnapNextTableData(pWriter); - if (code) goto _err; - - // Writer - SHeadFile fHead = {.commitID = pWriter->commitID}; - SDataFile fData = {.commitID = pWriter->commitID}; - SSmaFile fSma = {.commitID = pWriter->commitID}; - SSttFile fStt = {.commitID = pWriter->commitID}; - SDFileSet wSet = {.fid = pWriter->fid, .pHeadF = &fHead, .pDataF = &fData, .pSmaF = &fSma}; - if (pSet) { - wSet.diskId = pSet->diskId; - fData = *pSet->pDataF; - fSma = *pSet->pSmaF; - for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) { - wSet.aSttF[iStt] = pSet->aSttF[iStt]; - } - wSet.nSttF = pSet->nSttF + 1; // TODO: fix pSet->nSttF == pTsdb->maxFile - } else { - SDiskID did = {0}; - tfsAllocDisk(pTsdb->pVnode->pTfs, 0, &did); - tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did); - wSet.diskId = did; - wSet.nSttF = 1; - } - wSet.aSttF[wSet.nSttF - 1] = &fStt; - - code = tsdbDataFWriterOpen(&pWriter->dWriter.pWriter, pWriter->pTsdb, &wSet); - if (code) goto _err; - taosArrayClear(pWriter->dWriter.aBlockIdx); - tMapDataReset(&pWriter->dWriter.mDataBlk); - taosArrayClear(pWriter->dWriter.aSttBlk); - tBlockDataReset(&pWriter->dWriter.bData); - tBlockDataReset(&pWriter->dWriter.sData); - - return code; - -_err: - return code; -} - -static int32_t tsdbSnapWriteCloseFile(STsdbSnapWriter* pWriter) { - int32_t code = 0; - - ASSERT(pWriter->dWriter.pWriter); - - code = tsdbSnapWriteTableDataEnd(pWriter); - if (code) goto _err; - - // copy remain table data - TABLEID id = {.suid = INT64_MAX, .uid = INT64_MAX}; - code = tsdbSnapWriteCopyData(pWriter, &id); - if (code) goto _err; - - code = - tsdbWriteSttBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.sData, pWriter->dWriter.aSttBlk, pWriter->cmprAlg); - if (code) goto _err; - - // Indices - code = tsdbWriteBlockIdx(pWriter->dWriter.pWriter, pWriter->dWriter.aBlockIdx); - if (code) goto _err; - - code = tsdbWriteSttBlk(pWriter->dWriter.pWriter, pWriter->dWriter.aSttBlk); - if (code) goto _err; - - code = tsdbUpdateDFileSetHeader(pWriter->dWriter.pWriter); - if (code) goto _err; - - code = tsdbFSUpsertFSet(&pWriter->fs, &pWriter->dWriter.pWriter->wSet); - if (code) goto _err; - - code = tsdbDataFWriterClose(&pWriter->dWriter.pWriter, 1); - if (code) goto _err; - - if (pWriter->dReader.pReader) { - code = tsdbDataFReaderClose(&pWriter->dReader.pReader); - if (code) goto _err; + code = tsdbWriteDataBlk(pWriter->pDataFWriter, &pWriter->mDataBlk, pBlockIdx); + TSDB_CHECK_CODE(code, lino, _exit); } _exit: - return code; - -_err: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } return code; } -static int32_t tsdbSnapWriteToDataFile(STsdbSnapWriter* pWriter, int32_t iRow, int8_t* done) { +static int32_t tsdbSnapWriteFileDataStart(STsdbSnapWriter* pWriter, int32_t fid) { int32_t code = 0; + int32_t lino = 0; - SBlockData* pBData = &pWriter->bData; - TABLEID id = {.suid = pBData->suid, .uid = pBData->uid ? pBData->uid : pBData->aUid[iRow]}; - TSDBROW row = tsdbRowFromBlockData(pBData, iRow); - TSDBKEY key = TSDBROW_KEY(&row); + ASSERT(pWriter->pDataFWriter == NULL && pWriter->fid < fid); - *done = 0; - while (pWriter->dReader.iRow < pWriter->dReader.bData.nRow || - pWriter->dReader.iDataBlk < pWriter->dReader.mDataBlk.nItem) { - // Merge row by row - for (; pWriter->dReader.iRow < pWriter->dReader.bData.nRow; pWriter->dReader.iRow++) { - TSDBROW trow = tsdbRowFromBlockData(&pWriter->dReader.bData, pWriter->dReader.iRow); - TSDBKEY tKey = TSDBROW_KEY(&trow); + STsdb* pTsdb = pWriter->pTsdb; - ASSERT(pWriter->dReader.bData.suid == id.suid && pWriter->dReader.bData.uid == id.uid); + pWriter->fid = fid; + pWriter->tbid = (TABLEID){0}; + SDFileSet* pSet = taosArraySearch(pWriter->fs.aDFileSet, &(SDFileSet){.fid = fid}, tDFileSetCmprFn, TD_EQ); - int32_t c = tsdbKeyCmprFn(&key, &tKey); - if (c < 0) { - code = tBlockDataAppendRow(&pWriter->dWriter.bData, &row, NULL, id.uid); - if (code) goto _err; - } else if (c > 0) { - code = tBlockDataAppendRow(&pWriter->dWriter.bData, &trow, NULL, id.uid); - if (code) goto _err; - } else { - ASSERT(0); - } + // open reader + pWriter->pDataFReader = NULL; + pWriter->iterList = NULL; + pWriter->pDIter = NULL; + pWriter->pSIter = NULL; + tRBTreeCreate(&pWriter->rbt, tsdbDataIterCmprFn); + if (pSet) { + code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet); + TSDB_CHECK_CODE(code, lino, _exit); - if (pWriter->dWriter.bData.nRow >= pWriter->maxRow) { - code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.bData, &pWriter->dWriter.mDataBlk, - pWriter->cmprAlg); - if (code) goto _err; - } + code = tsdbOpenDataFileDataIter(pWriter->pDataFReader, &pWriter->pDIter); + TSDB_CHECK_CODE(code, lino, _exit); + if (pWriter->pDIter) { + pWriter->pDIter->next = pWriter->iterList; + pWriter->iterList = pWriter->pDIter; + } - if (c < 0) { - *done = 1; - goto _exit; + for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) { + code = tsdbOpenSttFileDataIter(pWriter->pDataFReader, iStt, &pWriter->pSIter); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pWriter->pSIter) { + code = tsdbSttFileDataIterNext(pWriter->pSIter, NULL); + TSDB_CHECK_CODE(code, lino, _exit); + + // add to tree + tRBTreePut(&pWriter->rbt, &pWriter->pSIter->rbtn); + + // add to list + pWriter->pSIter->next = pWriter->iterList; + pWriter->iterList = pWriter->pSIter; } } - // Merge row by block - SDataBlk tDataBlk = {.minKey = key, .maxKey = key}; - for (; pWriter->dReader.iDataBlk < pWriter->dReader.mDataBlk.nItem; pWriter->dReader.iDataBlk++) { - SDataBlk dataBlk; - tMapDataGetItemByIdx(&pWriter->dReader.mDataBlk, pWriter->dReader.iDataBlk, &dataBlk, tGetDataBlk); + pWriter->pSIter = NULL; + } - int32_t c = tDataBlkCmprFn(&dataBlk, &tDataBlk); + // open writer + SDiskID diskId; + if (pSet) { + diskId = pSet->diskId; + } else { + tfsAllocDisk(pTsdb->pVnode->pTfs, 0 /*TODO*/, &diskId); + tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, diskId); + } + SDFileSet wSet = {.diskId = diskId, + .fid = fid, + .pHeadF = &(SHeadFile){.commitID = pWriter->commitID}, + .pDataF = (pSet) ? pSet->pDataF : &(SDataFile){.commitID = pWriter->commitID}, + .pSmaF = (pSet) ? pSet->pSmaF : &(SSmaFile){.commitID = pWriter->commitID}, + .nSttF = 1, + .aSttF = {&(SSttFile){.commitID = pWriter->commitID}}}; + code = tsdbDataFWriterOpen(&pWriter->pDataFWriter, pTsdb, &wSet); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pWriter->aBlockIdx) { + taosArrayClear(pWriter->aBlockIdx); + } else if ((pWriter->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx))) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + tMapDataReset(&pWriter->mDataBlk); + + if (pWriter->aSttBlk) { + taosArrayClear(pWriter->aSttBlk); + } else if ((pWriter->aSttBlk = taosArrayInit(0, sizeof(SSttBlk))) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + tBlockDataReset(&pWriter->bData); + tBlockDataReset(&pWriter->sData); + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s, fid:%d", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code), + fid); + } else { + tsdbDebug("vgId:%d %s done, fid:%d", TD_VID(pTsdb->pVnode), __func__, fid); + } + return code; +} + +static int32_t tsdbSnapWriteTableData(STsdbSnapWriter* pWriter, SRowInfo* pRowInfo) { + int32_t code = 0; + int32_t lino = 0; + + // switch to new table if need + if (pRowInfo == NULL || pRowInfo->uid != pWriter->tbid.uid) { + if (pWriter->tbid.uid) { + code = tsdbSnapWriteTableDataEnd(pWriter); + TSDB_CHECK_CODE(code, lino, _exit); + } + + code = tsdbSnapWriteTableDataStart(pWriter, (TABLEID*)pRowInfo); + TSDB_CHECK_CODE(code, lino, _exit); + } + + if (pRowInfo == NULL) goto _exit; + + code = tsdbSnapWriteTableRow(pWriter, &pRowInfo->row); + TSDB_CHECK_CODE(code, lino, _exit); + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } + return code; +} + +static int32_t tsdbSnapWriteNextRow(STsdbSnapWriter* pWriter, SRowInfo** ppRowInfo) { + int32_t code = 0; + int32_t lino = 0; + + if (pWriter->pSIter) { + code = tsdbDataIterNext2(pWriter->pSIter, NULL); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pWriter->pSIter->rowInfo.suid == 0 && pWriter->pSIter->rowInfo.uid == 0) { + pWriter->pSIter = NULL; + } else { + SRBTreeNode* pNode = tRBTreeMin(&pWriter->rbt); + if (pNode) { + int32_t c = tsdbDataIterCmprFn(&pWriter->pSIter->rbtn, pNode); + if (c > 0) { + tRBTreePut(&pWriter->rbt, &pWriter->pSIter->rbtn); + pWriter->pSIter = NULL; + } else if (c == 0) { + ASSERT(0); + } + } + } + } + + if (pWriter->pSIter == NULL) { + SRBTreeNode* pNode = tRBTreeMin(&pWriter->rbt); + if (pNode) { + tRBTreeDrop(&pWriter->rbt, pNode); + pWriter->pSIter = TSDB_RBTN_TO_DATA_ITER(pNode); + } + } + + if (ppRowInfo) { + if (pWriter->pSIter) { + *ppRowInfo = &pWriter->pSIter->rowInfo; + } else { + *ppRowInfo = NULL; + } + } + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } + return code; +} + +static int32_t tsdbSnapWriteGetRow(STsdbSnapWriter* pWriter, SRowInfo** ppRowInfo) { + int32_t code = 0; + int32_t lino = 0; + + if (pWriter->pSIter) { + *ppRowInfo = &pWriter->pSIter->rowInfo; + goto _exit; + } + + code = tsdbSnapWriteNextRow(pWriter, ppRowInfo); + TSDB_CHECK_CODE(code, lino, _exit); + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } + return code; +} + +static int32_t tsdbSnapWriteFileDataEnd(STsdbSnapWriter* pWriter) { + int32_t code = 0; + int32_t lino = 0; + + ASSERT(pWriter->pDataFWriter); + + // consume remain data and end with a NULL table row + SRowInfo* pRowInfo; + code = tsdbSnapWriteGetRow(pWriter, &pRowInfo); + TSDB_CHECK_CODE(code, lino, _exit); + for (;;) { + code = tsdbSnapWriteTableData(pWriter, pRowInfo); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pRowInfo == NULL) break; + + code = tsdbSnapWriteNextRow(pWriter, &pRowInfo); + TSDB_CHECK_CODE(code, lino, _exit); + } + + // do file-level updates + code = tsdbWriteSttBlk(pWriter->pDataFWriter, pWriter->aSttBlk); + TSDB_CHECK_CODE(code, lino, _exit); + + code = tsdbWriteBlockIdx(pWriter->pDataFWriter, pWriter->aBlockIdx); + TSDB_CHECK_CODE(code, lino, _exit); + + code = tsdbUpdateDFileSetHeader(pWriter->pDataFWriter); + TSDB_CHECK_CODE(code, lino, _exit); + + code = tsdbFSUpsertFSet(&pWriter->fs, &pWriter->pDataFWriter->wSet); + TSDB_CHECK_CODE(code, lino, _exit); + + code = tsdbDataFWriterClose(&pWriter->pDataFWriter, 1); + TSDB_CHECK_CODE(code, lino, _exit); + + if (pWriter->pDataFReader) { + code = tsdbDataFReaderClose(&pWriter->pDataFReader); + TSDB_CHECK_CODE(code, lino, _exit); + } + + // clear sources + while (pWriter->iterList) { + STsdbDataIter2* pIter = pWriter->iterList; + pWriter->iterList = pIter->next; + tsdbCloseDataIter2(pIter); + } + +_exit: + if (code) { + tsdbError("vgId:%d %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code)); + } else { + tsdbDebug("vgId:%d %s is done", TD_VID(pWriter->pTsdb->pVnode), __func__); + } + return code; +} + +static int32_t tsdbSnapWriteTimeSeriesData(STsdbSnapWriter* pWriter, SSnapDataHdr* pHdr) { + int32_t code = 0; + int32_t lino = 0; + + code = tDecmprBlockData(pHdr->data, pHdr->size, &pWriter->inData, pWriter->aBuf); + TSDB_CHECK_CODE(code, lino, _exit); + + ASSERT(pWriter->inData.nRow > 0); + + // switch to new data file if need + int32_t fid = tsdbKeyFid(pWriter->inData.aTSKEY[0], pWriter->minutes, pWriter->precision); + if (pWriter->fid != fid) { + if (pWriter->pDataFWriter) { + code = tsdbSnapWriteFileDataEnd(pWriter); + TSDB_CHECK_CODE(code, lino, _exit); + } + + code = tsdbSnapWriteFileDataStart(pWriter, fid); + TSDB_CHECK_CODE(code, lino, _exit); + } + + // loop write each row + SRowInfo* pRowInfo; + code = tsdbSnapWriteGetRow(pWriter, &pRowInfo); + TSDB_CHECK_CODE(code, lino, _exit); + for (int32_t iRow = 0; iRow < pWriter->inData.nRow; ++iRow) { + SRowInfo rInfo = {.suid = pWriter->inData.suid, + .uid = pWriter->inData.uid ? pWriter->inData.uid : pWriter->inData.aUid[iRow], + .row = tsdbRowFromBlockData(&pWriter->inData, iRow)}; + + for (;;) { + if (pRowInfo == NULL) { + code = tsdbSnapWriteTableData(pWriter, &rInfo); + TSDB_CHECK_CODE(code, lino, _exit); + break; + } else { + int32_t c = tRowInfoCmprFn(&rInfo, pRowInfo); + if (c < 0) { + code = tsdbSnapWriteTableData(pWriter, &rInfo); + TSDB_CHECK_CODE(code, lino, _exit); + break; + } else if (c > 0) { + code = tsdbSnapWriteTableData(pWriter, pRowInfo); + TSDB_CHECK_CODE(code, lino, _exit); + + code = tsdbSnapWriteNextRow(pWriter, &pRowInfo); + TSDB_CHECK_CODE(code, lino, _exit); + } else { + ASSERT(0); + } + } + } + } + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbDebug("vgId:%d %s done, suid:%" PRId64 " uid:%" PRId64 " nRow:%d", TD_VID(pWriter->pTsdb->pVnode), __func__, + pWriter->inData.suid, pWriter->inData.uid, pWriter->inData.nRow); + } + return code; +} + +// SNAP_DATA_DEL +static int32_t tsdbSnapWriteDelTableDataStart(STsdbSnapWriter* pWriter, TABLEID* pId) { + int32_t code = 0; + int32_t lino = 0; + + if (pId) { + pWriter->tbid = *pId; + } else { + pWriter->tbid = (TABLEID){.suid = INT64_MAX, .uid = INT64_MAX}; + } + + taosArrayClear(pWriter->aDelData); + + if (pWriter->pTIter) { + while (pWriter->pTIter->tIter.iDelIdx < taosArrayGetSize(pWriter->pTIter->tIter.aDelIdx)) { + SDelIdx* pDelIdx = taosArrayGet(pWriter->pTIter->tIter.aDelIdx, pWriter->pTIter->tIter.iDelIdx); + + int32_t c = tTABLEIDCmprFn(pDelIdx, &pWriter->tbid); if (c < 0) { - code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.bData, &pWriter->dWriter.mDataBlk, - pWriter->cmprAlg); - if (code) goto _err; + code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->pTIter->tIter.aDelData); + TSDB_CHECK_CODE(code, lino, _exit); - code = tMapDataPutItem(&pWriter->dWriter.mDataBlk, &dataBlk, tPutDataBlk); - if (code) goto _err; - } else if (c > 0) { - code = tBlockDataAppendRow(&pWriter->dWriter.bData, &row, NULL, id.uid); - if (code) goto _err; - - if (pWriter->dWriter.bData.nRow >= pWriter->maxRow) { - code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.bData, &pWriter->dWriter.mDataBlk, - pWriter->cmprAlg); - if (code) goto _err; + SDelIdx* pDelIdxNew = taosArrayReserve(pWriter->aDelIdx, 1); + if (pDelIdxNew == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); } - *done = 1; - goto _exit; - } else { - code = tsdbReadDataBlockEx(pWriter->dReader.pReader, &dataBlk, &pWriter->dReader.bData); - if (code) goto _err; - pWriter->dReader.iRow = 0; + pDelIdxNew->suid = pDelIdx->suid; + pDelIdxNew->uid = pDelIdx->uid; - pWriter->dReader.iDataBlk++; + code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->pTIter->tIter.aDelData, pDelIdxNew); + TSDB_CHECK_CODE(code, lino, _exit); + + pWriter->pTIter->tIter.iDelIdx++; + } else if (c == 0) { + code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData); + TSDB_CHECK_CODE(code, lino, _exit); + + pWriter->pTIter->tIter.iDelIdx++; + break; + } else { break; } } } _exit: - return code; - -_err: - tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code)); - return code; -} - -static int32_t tsdbSnapWriteToSttFile(STsdbSnapWriter* pWriter, int32_t iRow) { - int32_t code = 0; - - TABLEID id = {.suid = pWriter->bData.suid, - .uid = pWriter->bData.uid ? pWriter->bData.uid : pWriter->bData.aUid[iRow]}; - TSDBROW row = tsdbRowFromBlockData(&pWriter->bData, iRow); - SBlockData* pBData = &pWriter->dWriter.sData; - - if (pBData->suid || pBData->uid) { - if (!TABLE_SAME_SCHEMA(pBData->suid, pBData->uid, id.suid, id.uid)) { - code = tsdbWriteSttBlock(pWriter->dWriter.pWriter, pBData, pWriter->dWriter.aSttBlk, pWriter->cmprAlg); - if (code) goto _err; - - pBData->suid = 0; - pBData->uid = 0; - } - } - - if (pBData->suid == 0 && pBData->uid == 0) { - code = tsdbUpdateTableSchema(pWriter->pTsdb->pVnode->pMeta, pWriter->id.suid, pWriter->id.uid, &pWriter->skmTable); - if (code) goto _err; - - TABLEID tid = {.suid = pWriter->id.suid, .uid = pWriter->id.suid ? 0 : pWriter->id.uid}; - code = tBlockDataInit(pBData, &tid, pWriter->skmTable.pTSchema, NULL, 0); - if (code) goto _err; - } - - code = tBlockDataAppendRow(pBData, &row, NULL, id.uid); - if (code) goto _err; - - if (pBData->nRow >= pWriter->maxRow) { - code = tsdbWriteSttBlock(pWriter->dWriter.pWriter, pBData, pWriter->dWriter.aSttBlk, pWriter->cmprAlg); - if (code) goto _err; - } - -_exit: - return code; - -_err: - return code; -} - -static int32_t tsdbSnapWriteRowData(STsdbSnapWriter* pWriter, int32_t iRow) { - int32_t code = 0; - - SBlockData* pBlockData = &pWriter->bData; - TABLEID id = {.suid = pBlockData->suid, .uid = pBlockData->uid ? pBlockData->uid : pBlockData->aUid[iRow]}; - - // End last table data write if need - if (tTABLEIDCmprFn(&pWriter->id, &id) != 0) { - code = tsdbSnapWriteTableDataEnd(pWriter); - if (code) goto _err; - } - - // Start new table data write if need - if (pWriter->id.suid == 0 && pWriter->id.uid == 0) { - code = tsdbSnapWriteTableDataStart(pWriter, &id); - if (code) goto _err; - } - - // Merge with .data file data - int8_t done = 0; - if (pWriter->dReader.pBlockIdx && tTABLEIDCmprFn(pWriter->dReader.pBlockIdx, &id) == 0) { - code = tsdbSnapWriteToDataFile(pWriter, iRow, &done); - if (code) goto _err; - } - - // Append to the .stt data block (todo: check if need to set/reload sst block) - if (!done) { - code = tsdbSnapWriteToSttFile(pWriter, iRow); - if (code) goto _err; - } - -_exit: - return code; - -_err: - tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code)); - return code; -} - -static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { - int32_t code = 0; - STsdb* pTsdb = pWriter->pTsdb; - SBlockData* pBlockData = &pWriter->bData; - - // Decode data - SSnapDataHdr* pHdr = (SSnapDataHdr*)pData; - code = tDecmprBlockData(pHdr->data, pHdr->size, pBlockData, pWriter->aBuf); - if (code) goto _err; - - ASSERT(pBlockData->nRow > 0); - - // Loop to handle each row - for (int32_t iRow = 0; iRow < pBlockData->nRow; iRow++) { - TSKEY ts = pBlockData->aTSKEY[iRow]; - int32_t fid = tsdbKeyFid(ts, pWriter->minutes, pWriter->precision); - - if (pWriter->dWriter.pWriter == NULL || pWriter->fid != fid) { - if (pWriter->dWriter.pWriter) { - // ASSERT(fid > pWriter->fid); - - code = tsdbSnapWriteCloseFile(pWriter); - if (code) goto _err; - } - - code = tsdbSnapWriteOpenFile(pWriter, fid); - if (code) goto _err; - } - - code = tsdbSnapWriteRowData(pWriter, iRow); - if (code) goto _err; - } - - return code; - -_err: - tsdbError("vgId:%d, vnode snapshot tsdb write data for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, - tstrerror(code)); - return code; -} - -// SNAP_DATA_DEL -static int32_t tsdbSnapMoveWriteDelData(STsdbSnapWriter* pWriter, TABLEID* pId) { - int32_t code = 0; - - while (true) { - if (pWriter->iDelIdx >= taosArrayGetSize(pWriter->aDelIdxR)) break; - - SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx); - - if (tTABLEIDCmprFn(pDelIdx, pId) >= 0) break; - - code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData); - if (code) goto _exit; - - SDelIdx delIdx = *pDelIdx; - code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, &delIdx); - if (code) goto _exit; - - if (taosArrayPush(pWriter->aDelIdxW, &delIdx) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _exit; - } - - pWriter->iDelIdx++; - } - -_exit: - return code; -} - -static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { - int32_t code = 0; - STsdb* pTsdb = pWriter->pTsdb; - - // Open del file if not opened yet - if (pWriter->pDelFWriter == NULL) { - SDelFile* pDelFile = pWriter->fs.pDelFile; - - // reader - if (pDelFile) { - code = tsdbDelFReaderOpen(&pWriter->pDelFReader, pDelFile, pTsdb); - if (code) goto _err; - - code = tsdbReadDelIdx(pWriter->pDelFReader, pWriter->aDelIdxR); - if (code) goto _err; - } else { - taosArrayClear(pWriter->aDelIdxR); - } - pWriter->iDelIdx = 0; - - // writer - SDelFile delFile = {.commitID = pWriter->commitID}; - code = tsdbDelFWriterOpen(&pWriter->pDelFWriter, &delFile, pTsdb); - if (code) goto _err; - taosArrayClear(pWriter->aDelIdxW); - } - - SSnapDataHdr* pHdr = (SSnapDataHdr*)pData; - TABLEID id = *(TABLEID*)pHdr->data; - - ASSERT(pHdr->size + sizeof(SSnapDataHdr) == nData); - - // Move write data < id - code = tsdbSnapMoveWriteDelData(pWriter, &id); - if (code) goto _err; - - // Merge incoming data with current - if (pWriter->iDelIdx < taosArrayGetSize(pWriter->aDelIdxR) && - tTABLEIDCmprFn(taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx), &id) == 0) { - SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx); - - code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData); - if (code) goto _err; - - pWriter->iDelIdx++; + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); } else { - taosArrayClear(pWriter->aDelData); + tsdbTrace("vgId:%d %s done, suid:%" PRId64 " uid:%" PRId64, TD_VID(pWriter->pTsdb->pVnode), __func__, + pWriter->tbid.suid, pWriter->tbid.uid); + } + return code; +} + +static int32_t tsdbSnapWriteDelTableDataEnd(STsdbSnapWriter* pWriter) { + int32_t code = 0; + int32_t lino = 0; + + if (taosArrayGetSize(pWriter->aDelData) > 0) { + SDelIdx* pDelIdx = taosArrayReserve(pWriter->aDelIdx, 1); + if (pDelIdx == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + + pDelIdx->suid = pWriter->tbid.suid; + pDelIdx->uid = pWriter->tbid.uid; + + code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, pDelIdx); + TSDB_CHECK_CODE(code, lino, _exit); } - int64_t n = sizeof(SSnapDataHdr) + sizeof(TABLEID); - while (n < nData) { - SDelData delData; +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbTrace("vgId:%d %s done", TD_VID(pWriter->pTsdb->pVnode), __func__); + } + return code; +} +static int32_t tsdbSnapWriteDelTableData(STsdbSnapWriter* pWriter, TABLEID* pId, uint8_t* pData, int64_t size) { + int32_t code = 0; + int32_t lino = 0; + + if (pId == NULL || pId->uid != pWriter->tbid.uid) { + if (pWriter->tbid.uid) { + code = tsdbSnapWriteDelTableDataEnd(pWriter); + TSDB_CHECK_CODE(code, lino, _exit); + } + + code = tsdbSnapWriteDelTableDataStart(pWriter, pId); + TSDB_CHECK_CODE(code, lino, _exit); + } + + if (pId == NULL) goto _exit; + + int64_t n = 0; + while (n < size) { + SDelData delData; n += tGetDelData(pData + n, &delData); - if (taosArrayPush(pWriter->aDelData, &delData) == NULL) { + if (taosArrayPush(pWriter->aDelData, &delData) < 0) { code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + TSDB_CHECK_CODE(code, lino, _exit); } } + ASSERT(n == size); - SDelIdx delIdx = {.suid = id.suid, .uid = id.uid}; - code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, &delIdx); - if (code) goto _err; - - if (taosArrayPush(pWriter->aDelIdxW, &delIdx) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); } - - return code; - -_err: - tsdbError("vgId:%d, vnode snapshot tsdb write del for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, - tstrerror(code)); return code; } -static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) { +static int32_t tsdbSnapWriteDelDataStart(STsdbSnapWriter* pWriter) { int32_t code = 0; - STsdb* pTsdb = pWriter->pTsdb; + int32_t lino = 0; - if (pWriter->pDelFWriter == NULL) return code; + STsdb* pTsdb = pWriter->pTsdb; + SDelFile* pDelFile = pWriter->fs.pDelFile; - TABLEID id = {.suid = INT64_MAX, .uid = INT64_MAX}; - code = tsdbSnapMoveWriteDelData(pWriter, &id); - if (code) goto _err; + pWriter->tbid = (TABLEID){0}; - code = tsdbWriteDelIdx(pWriter->pDelFWriter, pWriter->aDelIdxW); - if (code) goto _err; + // reader + if (pDelFile) { + code = tsdbDelFReaderOpen(&pWriter->pDelFReader, pDelFile, pTsdb); + TSDB_CHECK_CODE(code, lino, _exit); + + code = tsdbOpenTombFileDataIter(pWriter->pDelFReader, &pWriter->pTIter); + TSDB_CHECK_CODE(code, lino, _exit); + } + + // writer + code = tsdbDelFWriterOpen(&pWriter->pDelFWriter, &(SDelFile){.commitID = pWriter->commitID}, pTsdb); + TSDB_CHECK_CODE(code, lino, _exit); + + if ((pWriter->aDelIdx = taosArrayInit(0, sizeof(SDelIdx))) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + if ((pWriter->aDelData = taosArrayInit(0, sizeof(SDelData))) == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TSDB_CHECK_CODE(code, lino, _exit); + } + +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbDebug("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__); + } + return code; +} + +static int32_t tsdbSnapWriteDelDataEnd(STsdbSnapWriter* pWriter) { + int32_t code = 0; + int32_t lino = 0; + + STsdb* pTsdb = pWriter->pTsdb; + + // end remaining table with NULL data + code = tsdbSnapWriteDelTableData(pWriter, NULL, NULL, 0); + TSDB_CHECK_CODE(code, lino, _exit); + + // update file-level info + code = tsdbWriteDelIdx(pWriter->pDelFWriter, pWriter->aDelIdx); + TSDB_CHECK_CODE(code, lino, _exit); code = tsdbUpdateDelFileHdr(pWriter->pDelFWriter); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); code = tsdbFSUpsertDelFile(&pWriter->fs, &pWriter->pDelFWriter->fDel); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); code = tsdbDelFWriterClose(&pWriter->pDelFWriter, 1); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); if (pWriter->pDelFReader) { code = tsdbDelFReaderClose(&pWriter->pDelFReader); - if (code) goto _err; + TSDB_CHECK_CODE(code, lino, _exit); } - tsdbInfo("vgId:%d, vnode snapshot tsdb write del for %s end", TD_VID(pTsdb->pVnode), pTsdb->path); - return code; + if (pWriter->pTIter) { + tsdbCloseDataIter2(pWriter->pTIter); + pWriter->pTIter = NULL; + } -_err: - tsdbError("vgId:%d, vnode snapshot tsdb write del end for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path, - tstrerror(code)); +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbInfo("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__); + } + return code; +} + +static int32_t tsdbSnapWriteDelData(STsdbSnapWriter* pWriter, SSnapDataHdr* pHdr) { + int32_t code = 0; + int32_t lino = 0; + + STsdb* pTsdb = pWriter->pTsdb; + + // start to write del data if need + if (pWriter->pDelFWriter == NULL) { + code = tsdbSnapWriteDelDataStart(pWriter); + TSDB_CHECK_CODE(code, lino, _exit); + } + + // do write del data + code = tsdbSnapWriteDelTableData(pWriter, (TABLEID*)pHdr->data, pHdr->data + sizeof(TABLEID), + pHdr->size - sizeof(TABLEID)); + TSDB_CHECK_CODE(code, lino, _exit); + +_exit: + if (code) { + tsdbError("vgId:%d %s failed since %s", TD_VID(pTsdb->pVnode), __func__, tstrerror(code)); + } else { + tsdbTrace("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__); + } return code; } // APIs int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter) { - int32_t code = 0; - int32_t lino = 0; - STsdbSnapWriter* pWriter = NULL; + int32_t code = 0; + int32_t lino = 0; // alloc - pWriter = (STsdbSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); + STsdbSnapWriter* pWriter = (STsdbSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); if (pWriter == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; TSDB_CHECK_CODE(code, lino, _exit); @@ -1288,11 +1833,6 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr pWriter->pTsdb = pTsdb; pWriter->sver = sver; pWriter->ever = ever; - - code = tsdbFSCopy(pTsdb, &pWriter->fs); - TSDB_CHECK_CODE(code, lino, _exit); - - // config pWriter->minutes = pTsdb->keepCfg.days; pWriter->precision = pTsdb->keepCfg.precision; pWriter->minRow = pTsdb->pVnode->config.tsdbCfg.minRows; @@ -1300,102 +1840,70 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr pWriter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression; pWriter->commitID = pTsdb->pVnode->state.commitID; + code = tsdbFSCopy(pTsdb, &pWriter->fs); + TSDB_CHECK_CODE(code, lino, _exit); + // SNAP_DATA_TSDB - code = tBlockDataCreate(&pWriter->bData); + code = tBlockDataCreate(&pWriter->inData); TSDB_CHECK_CODE(code, lino, _exit); pWriter->fid = INT32_MIN; - pWriter->id = (TABLEID){0}; - // Reader - pWriter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); - if (pWriter->dReader.aBlockIdx == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - code = tBlockDataCreate(&pWriter->dReader.bData); + + code = tBlockDataCreate(&pWriter->bData); TSDB_CHECK_CODE(code, lino, _exit); - // Writer - pWriter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); - if (pWriter->dWriter.aBlockIdx == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - pWriter->dWriter.aSttBlk = taosArrayInit(0, sizeof(SSttBlk)); - if (pWriter->dWriter.aSttBlk == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - code = tBlockDataCreate(&pWriter->dWriter.bData); - TSDB_CHECK_CODE(code, lino, _exit); - code = tBlockDataCreate(&pWriter->dWriter.sData); + code = tBlockDataCreate(&pWriter->sData); TSDB_CHECK_CODE(code, lino, _exit); // SNAP_DATA_DEL - pWriter->aDelIdxR = taosArrayInit(0, sizeof(SDelIdx)); - if (pWriter->aDelIdxR == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - pWriter->aDelData = taosArrayInit(0, sizeof(SDelData)); - if (pWriter->aDelData == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } - pWriter->aDelIdxW = taosArrayInit(0, sizeof(SDelIdx)); - if (pWriter->aDelIdxW == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - TSDB_CHECK_CODE(code, lino, _exit); - } _exit: if (code) { - tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); - *ppWriter = NULL; - + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); if (pWriter) { - if (pWriter->aDelIdxW) taosArrayDestroy(pWriter->aDelIdxW); - if (pWriter->aDelData) taosArrayDestroy(pWriter->aDelData); - if (pWriter->aDelIdxR) taosArrayDestroy(pWriter->aDelIdxR); - tBlockDataDestroy(&pWriter->dWriter.sData, 1); - tBlockDataDestroy(&pWriter->dWriter.bData, 1); - if (pWriter->dWriter.aSttBlk) taosArrayDestroy(pWriter->dWriter.aSttBlk); - if (pWriter->dWriter.aBlockIdx) taosArrayDestroy(pWriter->dWriter.aBlockIdx); - tBlockDataDestroy(&pWriter->dReader.bData, 1); - if (pWriter->dReader.aBlockIdx) taosArrayDestroy(pWriter->dReader.aBlockIdx); + tBlockDataDestroy(&pWriter->sData, 1); tBlockDataDestroy(&pWriter->bData, 1); + tBlockDataDestroy(&pWriter->inData, 1); tsdbFSDestroy(&pWriter->fs); - taosMemoryFree(pWriter); + pWriter = NULL; } } else { - tsdbInfo("vgId:%d, %s done", TD_VID(pTsdb->pVnode), __func__); - *ppWriter = pWriter; + tsdbInfo("vgId:%d %s done, sver:%" PRId64 " ever:%" PRId64, TD_VID(pTsdb->pVnode), __func__, sver, ever); } + *ppWriter = pWriter; return code; } int32_t tsdbSnapWriterPrepareClose(STsdbSnapWriter* pWriter) { int32_t code = 0; - if (pWriter->dWriter.pWriter) { - code = tsdbSnapWriteCloseFile(pWriter); - if (code) goto _exit; + int32_t lino = 0; + + if (pWriter->pDataFWriter) { + code = tsdbSnapWriteFileDataEnd(pWriter); + TSDB_CHECK_CODE(code, lino, _exit); } - code = tsdbSnapWriteDelEnd(pWriter); - if (code) goto _exit; + if (pWriter->pDelFWriter) { + code = tsdbSnapWriteDelDataEnd(pWriter); + TSDB_CHECK_CODE(code, lino, _exit); + } code = tsdbFSPrepareCommit(pWriter->pTsdb, &pWriter->fs); - if (code) goto _exit; + TSDB_CHECK_CODE(code, lino, _exit); _exit: if (code) { - tsdbError("vgId:%d, %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code)); + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbDebug("vgId:%d %s done", TD_VID(pWriter->pTsdb->pVnode), __func__); } return code; } int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) { - int32_t code = 0; + int32_t code = 0; + int32_t lino = 0; + STsdbSnapWriter* pWriter = *ppWriter; STsdb* pTsdb = pWriter->pTsdb; @@ -1408,7 +1916,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) { code = tsdbFSCommit(pWriter->pTsdb); if (code) { taosThreadRwlockUnlock(&pTsdb->rwLock); - goto _err; + TSDB_CHECK_CODE(code, lino, _exit); } // unlock @@ -1416,72 +1924,60 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) { } // SNAP_DATA_DEL - taosArrayDestroy(pWriter->aDelIdxW); taosArrayDestroy(pWriter->aDelData); - taosArrayDestroy(pWriter->aDelIdxR); + taosArrayDestroy(pWriter->aDelIdx); // SNAP_DATA_TSDB - - // Writer - tBlockDataDestroy(&pWriter->dWriter.sData, 1); - tBlockDataDestroy(&pWriter->dWriter.bData, 1); - taosArrayDestroy(pWriter->dWriter.aSttBlk); - tMapDataClear(&pWriter->dWriter.mDataBlk); - taosArrayDestroy(pWriter->dWriter.aBlockIdx); - - // Reader - tBlockDataDestroy(&pWriter->dReader.bData, 1); - tMapDataClear(&pWriter->dReader.mDataBlk); - taosArrayDestroy(pWriter->dReader.aBlockIdx); - + tBlockDataDestroy(&pWriter->sData, 1); tBlockDataDestroy(&pWriter->bData, 1); + taosArrayDestroy(pWriter->aSttBlk); + tMapDataClear(&pWriter->mDataBlk); + taosArrayDestroy(pWriter->aBlockIdx); tDestroyTSchema(pWriter->skmTable.pTSchema); + tBlockDataDestroy(&pWriter->inData, 1); for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t*); iBuf++) { tFree(pWriter->aBuf[iBuf]); } - tsdbInfo("vgId:%d, %s done", TD_VID(pWriter->pTsdb->pVnode), __func__); + tsdbFSDestroy(&pWriter->fs); taosMemoryFree(pWriter); *ppWriter = NULL; - return code; -_err: - tsdbError("vgId:%d, vnode snapshot tsdb writer close for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), - pWriter->pTsdb->path, tstrerror(code)); - taosMemoryFree(pWriter); - *ppWriter = NULL; +_exit: + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); + } else { + tsdbInfo("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__); + } return code; } -int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) { - int32_t code = 0; - SSnapDataHdr* pHdr = (SSnapDataHdr*)pData; +int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, SSnapDataHdr* pHdr) { + int32_t code = 0; + int32_t lino = 0; - // ts data if (pHdr->type == SNAP_DATA_TSDB) { - code = tsdbSnapWriteData(pWriter, pData, nData); - if (code) goto _err; - + code = tsdbSnapWriteTimeSeriesData(pWriter, pHdr); + TSDB_CHECK_CODE(code, lino, _exit); goto _exit; - } else { - if (pWriter->dWriter.pWriter) { - code = tsdbSnapWriteCloseFile(pWriter); - if (code) goto _err; - } + } else if (pWriter->pDataFWriter) { + code = tsdbSnapWriteFileDataEnd(pWriter); + TSDB_CHECK_CODE(code, lino, _exit); } - // del data if (pHdr->type == SNAP_DATA_DEL) { - code = tsdbSnapWriteDel(pWriter, pData, nData); - if (code) goto _err; + code = tsdbSnapWriteDelData(pWriter, pHdr); + TSDB_CHECK_CODE(code, lino, _exit); + goto _exit; } _exit: - tsdbDebug("vgId:%d, tsdb snapshot write for %s succeed", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path); - return code; - -_err: - tsdbError("vgId:%d, tsdb snapshot write for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path, - tstrerror(code)); + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s, type:%d index:%" PRId64 " size:%" PRId64, + TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code), pHdr->type, pHdr->index, pHdr->size); + } else { + tsdbDebug("vgId:%d %s done, type:%d index:%" PRId64 " size:%" PRId64, TD_VID(pWriter->pTsdb->pVnode), __func__, + pHdr->type, pHdr->index, pHdr->size); + } return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index ab10960970..a252c6deb6 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -684,7 +684,7 @@ int32_t tRowMergerInit2(SRowMerger *pMerger, STSchema *pResTSchema, TSDBROW *pRo tsdbRowGetColVal(pRow, pTSchema, jCol++, pColVal); if ((!COL_VAL_IS_NONE(pColVal)) && (!COL_VAL_IS_NULL(pColVal)) && IS_VAR_DATA_TYPE(pColVal->type)) { uint8_t *pVal = pColVal->value.pData; - + pColVal->value.pData = NULL; code = tRealloc(&pColVal->value.pData, pColVal->value.nData); if (code) goto _exit; @@ -757,7 +757,7 @@ int32_t tRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) { pTColVal->value.nData = pColVal->value.nData; if (pTColVal->value.nData) { - memcpy(pTColVal->value.pData, pColVal->value.pData, pTColVal->value.nData); + memcpy(pTColVal->value.pData, pColVal->value.pData, pTColVal->value.nData); } pTColVal->flag = 0; } else { @@ -776,7 +776,7 @@ int32_t tRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) { code = tRealloc(&tColVal->value.pData, pColVal->value.nData); if (code) return code; - tColVal->value.nData = pColVal->value.nData; + tColVal->value.nData = pColVal->value.nData; if (pColVal->value.nData) { memcpy(tColVal->value.pData, pColVal->value.pData, pColVal->value.nData); } @@ -825,7 +825,7 @@ int32_t tRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) { tsdbRowGetColVal(pRow, pTSchema, iCol, pColVal); if ((!COL_VAL_IS_NONE(pColVal)) && (!COL_VAL_IS_NULL(pColVal)) && IS_VAR_DATA_TYPE(pColVal->type)) { uint8_t *pVal = pColVal->value.pData; - + pColVal->value.pData = NULL; code = tRealloc(&pColVal->value.pData, pColVal->value.nData); if (code) goto _exit; @@ -834,7 +834,7 @@ int32_t tRowMergerInit(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) { memcpy(pColVal->value.pData, pVal, pColVal->value.nData); } } - + if (taosArrayPush(pMerger->pArray, pColVal) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; @@ -845,7 +845,7 @@ _exit: return code; } -void tRowMergerClear(SRowMerger *pMerger) { +void tRowMergerClear(SRowMerger *pMerger) { for (int32_t iCol = 1; iCol < pMerger->pTSchema->numOfCols; iCol++) { SColVal *pTColVal = taosArrayGet(pMerger->pArray, iCol); if (IS_VAR_DATA_TYPE(pTColVal->type)) { @@ -853,7 +853,7 @@ void tRowMergerClear(SRowMerger *pMerger) { } } - taosArrayDestroy(pMerger->pArray); + taosArrayDestroy(pMerger->pArray); } int32_t tRowMerge(SRowMerger *pMerger, TSDBROW *pRow) { @@ -876,7 +876,7 @@ int32_t tRowMerge(SRowMerger *pMerger, TSDBROW *pRow) { pTColVal->value.nData = pColVal->value.nData; if (pTColVal->value.nData) { - memcpy(pTColVal->value.pData, pColVal->value.pData, pTColVal->value.nData); + memcpy(pTColVal->value.pData, pColVal->value.pData, pTColVal->value.nData); } pTColVal->flag = 0; } else { @@ -898,7 +898,7 @@ int32_t tRowMerge(SRowMerger *pMerger, TSDBROW *pRow) { tColVal->value.nData = pColVal->value.nData; if (tColVal->value.nData) { - memcpy(tColVal->value.pData, pColVal->value.pData, tColVal->value.nData); + memcpy(tColVal->value.pData, pColVal->value.pData, tColVal->value.nData); } tColVal->flag = 0; } else { @@ -929,8 +929,9 @@ int32_t tRowMergerGetRow(SRowMerger *pMerger, STSRow **ppRow) { return code; } +/* // delete skyline ====================================================== -static int32_t tsdbMergeSkyline(SArray *aSkyline1, SArray *aSkyline2, SArray *aSkyline) { +static int32_t tsdbMergeSkyline2(SArray *aSkyline1, SArray *aSkyline2, SArray *aSkyline) { int32_t code = 0; int32_t i1 = 0; int32_t n1 = taosArrayGetSize(aSkyline1); @@ -996,7 +997,141 @@ static int32_t tsdbMergeSkyline(SArray *aSkyline1, SArray *aSkyline2, SArray *aS _exit: return code; } +*/ + +// delete skyline ====================================================== +static int32_t tsdbMergeSkyline(SArray *pSkyline1, SArray *pSkyline2, SArray *pSkyline) { + int32_t code = 0; + int32_t i1 = 0; + int32_t n1 = taosArrayGetSize(pSkyline1); + int32_t i2 = 0; + int32_t n2 = taosArrayGetSize(pSkyline2); + TSDBKEY *pKey1; + TSDBKEY *pKey2; + int64_t version1 = 0; + int64_t version2 = 0; + + ASSERT(n1 > 0 && n2 > 0); + + taosArrayClear(pSkyline); + TSDBKEY **pItem = TARRAY_GET_ELEM(pSkyline, 0); + + while (i1 < n1 && i2 < n2) { + pKey1 = (TSDBKEY *)taosArrayGetP(pSkyline1, i1); + pKey2 = (TSDBKEY *)taosArrayGetP(pSkyline2, i2); + + if (pKey1->ts < pKey2->ts) { + version1 = pKey1->version; + *pItem = pKey1; + i1++; + } else if (pKey1->ts > pKey2->ts) { + version2 = pKey2->version; + *pItem = pKey2; + i2++; + } else { + version1 = pKey1->version; + version2 = pKey2->version; + *pItem = pKey1; + i1++; + i2++; + } + + (*pItem)->version = TMAX(version1, version2); + pItem++; + } + + while (i1 < n1) { + pKey1 = (TSDBKEY *)taosArrayGetP(pSkyline1, i1); + *pItem = pKey1; + pItem++; + i1++; + } + + while (i2 < n2) { + pKey2 = (TSDBKEY *)taosArrayGetP(pSkyline2, i2); + *pItem = pKey2; + pItem++; + i2++; + } + + taosArraySetSize(pSkyline, TARRAY_ELEM_IDX(pSkyline, pItem)); + +_exit: + return code; +} + + +int32_t tsdbBuildDeleteSkylineImpl(SArray *aSkyline, int32_t sidx, int32_t eidx, SArray *pSkyline) { + int32_t code = 0; + SDelData *pDelData; + int32_t midx; + + taosArrayClear(pSkyline); + if (sidx == eidx) { + TSDBKEY *pItem1 = taosArrayGet(aSkyline, sidx * 2); + TSDBKEY *pItem2 = taosArrayGet(aSkyline, sidx * 2 + 1); + taosArrayPush(pSkyline, &pItem1); + taosArrayPush(pSkyline, &pItem2); + } else { + SArray *pSkyline1 = NULL; + SArray *pSkyline2 = NULL; + midx = (sidx + eidx) / 2; + + pSkyline1 = taosArrayInit((midx - sidx + 1) * 2, POINTER_BYTES); + pSkyline2 = taosArrayInit((eidx - midx) * 2, POINTER_BYTES); + if (pSkyline1 == NULL || pSkyline1 == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _clear; + } + + code = tsdbBuildDeleteSkylineImpl(aSkyline, sidx, midx, pSkyline1); + if (code) goto _clear; + + code = tsdbBuildDeleteSkylineImpl(aSkyline, midx + 1, eidx, pSkyline2); + if (code) goto _clear; + + code = tsdbMergeSkyline(pSkyline1, pSkyline2, pSkyline); + + _clear: + taosArrayDestroy(pSkyline1); + taosArrayDestroy(pSkyline2); + } + + return code; +} + + int32_t tsdbBuildDeleteSkyline(SArray *aDelData, int32_t sidx, int32_t eidx, SArray *aSkyline) { + SDelData *pDelData; + int32_t code = 0; + int32_t dataNum = eidx - sidx + 1; + SArray *aTmpSkyline = taosArrayInit(dataNum * 2, sizeof(TSDBKEY)); + SArray *pSkyline = taosArrayInit(dataNum * 2, POINTER_BYTES); + + for (int32_t i = sidx; i <= eidx; ++i) { + pDelData = (SDelData *)taosArrayGet(aDelData, i); + taosArrayPush(aTmpSkyline, &(TSDBKEY){.ts = pDelData->sKey, .version = pDelData->version}); + taosArrayPush(aTmpSkyline, &(TSDBKEY){.ts = pDelData->eKey, .version = 0}); + } + + code = tsdbBuildDeleteSkylineImpl(aTmpSkyline, sidx, eidx, pSkyline); + if (code) goto _clear; + + int32_t skylineNum = taosArrayGetSize(pSkyline); + for (int32_t i = 0; i < skylineNum; ++i) { + TSDBKEY *p = taosArrayGetP(pSkyline, i); + taosArrayPush(aSkyline, p); + } + +_clear: + taosArrayDestroy(aTmpSkyline); + taosArrayDestroy(pSkyline); + + return code; +} + +/* +int32_t tsdbBuildDeleteSkyline2(SArray *aDelData, int32_t sidx, int32_t eidx, SArray *aSkyline) { int32_t code = 0; SDelData *pDelData; int32_t midx; @@ -1033,6 +1168,7 @@ int32_t tsdbBuildDeleteSkyline(SArray *aDelData, int32_t sidx, int32_t eidx, SAr return code; } +*/ // SBlockData ====================================================== int32_t tBlockDataCreate(SBlockData *pBlockData) { diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index e75dc24329..4487261617 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -426,7 +426,13 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) { SVnode *pVnode = pWriter->pVnode; ASSERT(pHdr->size + sizeof(SSnapDataHdr) == nData); - ASSERT(pHdr->index == pWriter->index + 1); + + if (pHdr->index != pWriter->index + 1) { + vError("vgId:%d, unexpected vnode snapshot msg. index:%" PRId64 ", expected index:%" PRId64, TD_VID(pVnode), + pHdr->index, pWriter->index + 1); + return -1; + } + pWriter->index = pHdr->index; vDebug("vgId:%d, vnode snapshot write data, index:%" PRId64 " type:%d blockLen:%d", TD_VID(pVnode), pHdr->index, @@ -455,7 +461,7 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) { if (code) goto _err; } - code = tsdbSnapWrite(pWriter->pTsdbSnapWriter, pData, nData); + code = tsdbSnapWrite(pWriter->pTsdbSnapWriter, pHdr); if (code) goto _err; } break; case SNAP_DATA_TQ_HANDLE: { diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 4cf6c4e55c..5ee0e821b1 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -1185,7 +1185,7 @@ static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t version, void tDecodeSBatchDeleteReq(&decoder, &deleteReq); SMetaReader mr = {0}; - metaReaderInit(&mr, pVnode->pMeta, 0); + metaReaderInit(&mr, pVnode->pMeta, META_READER_NOLOCK); int32_t sz = taosArrayGetSize(deleteReq.deleteReqs); for (int32_t i = 0; i < sz; i++) { diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 4ae178d508..999a7965fb 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -474,6 +474,8 @@ typedef struct SStreamScanInfo { int32_t blockRecoverContiCnt; int32_t blockRecoverTotCnt; + int8_t igCheckUpdate; + int8_t igExpired; } SStreamScanInfo; typedef struct { diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index cdb5e845e3..3c4cafb753 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1658,12 +1658,18 @@ int32_t convertFillType(int32_t mode) { case FILL_MODE_NULL: type = TSDB_FILL_NULL; break; + case FILL_MODE_NULL_F: + type = TSDB_FILL_NULL_F; + break; case FILL_MODE_NEXT: type = TSDB_FILL_NEXT; break; case FILL_MODE_VALUE: type = TSDB_FILL_SET_VALUE; break; + case FILL_MODE_VALUE_F: + type = TSDB_FILL_SET_VALUE_F; + break; case FILL_MODE_LINEAR: type = TSDB_FILL_LINEAR; break; diff --git a/source/libs/executor/src/filloperator.c b/source/libs/executor/src/filloperator.c index 187c8f582a..41e4c990f8 100644 --- a/source/libs/executor/src/filloperator.c +++ b/source/libs/executor/src/filloperator.c @@ -140,7 +140,7 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) { while (1) { SSDataBlock* pBlock = pDownstream->fpSet.getNextFn(pDownstream); if (pBlock == NULL) { - if (pInfo->totalInputRows == 0) { + if (pInfo->totalInputRows == 0 && (pInfo->pFillInfo->type != TSDB_FILL_NULL_F && pInfo->pFillInfo->type != TSDB_FILL_SET_VALUE_F)) { setOperatorCompleted(pOperator); return NULL; } @@ -456,7 +456,8 @@ void* destroyStreamFillLinearInfo(SStreamFillLinearInfo* pFillLinear) { return NULL; } void* destroyStreamFillInfo(SStreamFillInfo* pFillInfo) { - if (pFillInfo->type == TSDB_FILL_SET_VALUE || pFillInfo->type == TSDB_FILL_NULL) { + if (pFillInfo->type == TSDB_FILL_SET_VALUE || pFillInfo->type == TSDB_FILL_SET_VALUE_F || + pFillInfo->type == TSDB_FILL_NULL || pFillInfo->type == TSDB_FILL_NULL_F) { taosMemoryFreeClear(pFillInfo->pResRow->pRowVal); taosMemoryFreeClear(pFillInfo->pResRow); } @@ -661,7 +662,9 @@ void setDeleteFillValueInfo(TSKEY start, TSKEY end, SStreamFillSupporter* pFillS pFillInfo->pos = FILL_POS_INVALID; switch (pFillInfo->type) { case TSDB_FILL_NULL: + case TSDB_FILL_NULL_F: case TSDB_FILL_SET_VALUE: + case TSDB_FILL_SET_VALUE_F: break; case TSDB_FILL_PREV: pFillInfo->pResRow = &pFillSup->prev; @@ -720,7 +723,9 @@ void setFillValueInfo(SSDataBlock* pBlock, TSKEY ts, int32_t rowId, SStreamFillS pFillInfo->pos = FILL_POS_INVALID; switch (pFillInfo->type) { case TSDB_FILL_NULL: - case TSDB_FILL_SET_VALUE: { + case TSDB_FILL_NULL_F: + case TSDB_FILL_SET_VALUE: + case TSDB_FILL_SET_VALUE_F: { if (pFillSup->prev.key == pFillInfo->preRowKey) { resetFillWindow(&pFillSup->prev); } @@ -1360,7 +1365,8 @@ SStreamFillInfo* initStreamFillInfo(SStreamFillSupporter* pFillSup, SSDataBlock* pFillInfo->pLinearInfo->winIndex = 0; pFillInfo->pResRow = NULL; - if (pFillSup->type == TSDB_FILL_SET_VALUE || pFillSup->type == TSDB_FILL_NULL) { + if (pFillSup->type == TSDB_FILL_SET_VALUE || pFillSup->type == TSDB_FILL_SET_VALUE_F + || pFillSup->type == TSDB_FILL_NULL || pFillSup->type == TSDB_FILL_NULL_F) { pFillInfo->pResRow = taosMemoryCalloc(1, sizeof(SResultRowData)); pFillInfo->pResRow->key = INT64_MIN; pFillInfo->pResRow->pRowVal = taosMemoryCalloc(1, pFillSup->rowSize); @@ -1405,7 +1411,7 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi goto _error; } - if (pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE) { + if (pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE || pInfo->pFillInfo->type == TSDB_FILL_SET_VALUE_F) { for (int32_t i = 0; i < pInfo->pFillSup->numOfAllCols; ++i) { SFillColInfo* pFillCol = pInfo->pFillSup->pAllColInfo + i; int32_t slotId = GET_DEST_SLOT_ID(pFillCol); @@ -1427,7 +1433,7 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi pCell->isNull = true; } } - } else if (pInfo->pFillInfo->type == TSDB_FILL_NULL) { + } else if (pInfo->pFillInfo->type == TSDB_FILL_NULL || pInfo->pFillInfo->type == TSDB_FILL_NULL_F) { for (int32_t i = 0; i < pInfo->pFillSup->numOfAllCols; ++i) { SFillColInfo* pFillCol = pInfo->pFillSup->pAllColInfo + i; int32_t slotId = GET_DEST_SLOT_ID(pFillCol); diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index bf4b9a2599..9d88126220 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -492,8 +492,8 @@ _error: static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) { SPartitionOperatorInfo* pInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + for (int32_t j = 0; j < pBlock->info.rows; ++j) { recordNewGroupKeys(pInfo->pGroupCols, pInfo->pGroupColVals, pBlock, j); int32_t len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals); @@ -690,8 +690,8 @@ static int compareDataGroupInfo(const void* group1, const void* group2) { static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) { SPartitionOperatorInfo* pInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SDataGroupInfo* pGroupInfo = (pInfo->groupIndex != -1) ? taosArrayGet(pInfo->sortedGroupArray, pInfo->groupIndex) : NULL; if (pInfo->groupIndex == -1 || pInfo->pageIndex >= taosArrayGetSize(pGroupInfo->pPageList)) { @@ -713,7 +713,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) { qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo)); T_LONG_JMP(pTaskInfo->env, terrno); } - + blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->rowCapacity); blockDataFromBuf1(pInfo->binfo.pRes, page, pInfo->rowCapacity); @@ -829,6 +829,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition SPartitionOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SPartitionOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + pTaskInfo->code = terrno; goto _error; } @@ -841,6 +843,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition SExprInfo* pExprInfo1 = createExprInfo(pPartNode->pExprs, NULL, &num); int32_t code = initExprSupp(&pInfo->scalarSup, pExprInfo1, num); if (code != TSDB_CODE_SUCCESS) { + terrno = code; + pTaskInfo->code = terrno; goto _error; } } @@ -848,6 +852,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); pInfo->pGroupSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK); if (pInfo->pGroupSet == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + pTaskInfo->code = terrno; goto _error; } @@ -866,6 +872,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition int32_t code = createDiskbasedBuf(&pInfo->pBuf, defaultPgsz, defaultBufsz, pTaskInfo->id.str, tsTempDir); if (code != TSDB_CODE_SUCCESS) { + terrno = code; + pTaskInfo->code = code; goto _error; } @@ -873,6 +881,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition pInfo->columnOffset = setupColumnOffset(pInfo->binfo.pRes, pInfo->rowCapacity); code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pInfo->pGroupCols); if (code != TSDB_CODE_SUCCESS) { + terrno = code; + pTaskInfo->code = code; goto _error; } @@ -885,10 +895,15 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition createOperatorFpSet(optrDummyOpenFn, hashPartition, NULL, destroyPartitionOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + pTaskInfo->code = code; + goto _error; + } + return pOperator; _error: - pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; if (pInfo != NULL) { destroyPartitionOperatorInfo(pInfo); } @@ -1094,7 +1109,7 @@ void initParDownStream(SOperatorInfo* downstream, SPartitionBySupporter* pParSup SStreamScanInfo* pScanInfo = downstream->info; pScanInfo->partitionSup = *pParSup; pScanInfo->pPartScalarSup = pExpr; - if (!pScanInfo->pUpdateInfo) { + if (!pScanInfo->igCheckUpdate && !pScanInfo->pUpdateInfo) { pScanInfo->pUpdateInfo = updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, 0); } } diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c index d641810cee..4a3a3f4de4 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -190,6 +190,7 @@ static int32_t setInfoForNewGroup(SSDataBlock* pBlock, SLimitInfo* pLimitInfo, S return PROJECT_RETRIEVE_DONE; } +// todo refactor static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SSDataBlock* pBlock, SOperatorInfo* pOperator) { // set current group id diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index d54f5bec5a..f90cc6699b 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -311,8 +311,8 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca pCost->totalRows += pBlock->info.rows; return TSDB_CODE_SUCCESS; } else if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) { - qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), - pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); + qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d, uid:%"PRIu64, GET_TASKID(pTaskInfo), + pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, pBlockInfo->id.uid); doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo, 1); pCost->skipBlocks += 1; return TSDB_CODE_SUCCESS; @@ -446,6 +446,16 @@ static STableCachedVal* createTableCacheVal(const SMetaReader* pMetaReader) { // const void *key, size_t keyLen, void *value static void freeCachedMetaItem(const void* key, size_t keyLen, void* value) { freeTableCachedVal(value); } + +static void doSetNullValue(SSDataBlock* pBlock, const SExprInfo* pExpr, int32_t numOfExpr) { + for (int32_t j = 0; j < numOfExpr; ++j) { + int32_t dstSlotId = pExpr[j].base.resSchema.slotId; + + SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, dstSlotId); + colDataAppendNNULL(pColInfoData, 0, pBlock->info.rows); + } +} + int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int32_t numOfExpr, SSDataBlock* pBlock, int32_t rows, const char* idStr, STableMetaCacheInfo* pCache) { // currently only the tbname pseudo column @@ -465,14 +475,22 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int SMetaReader mr = {0}; LRUHandle* h = NULL; + // todo refactor: extract method + // the handling of the null data should be packed in the extracted method + // 1. check if it is existed in meta cache if (pCache == NULL) { metaReaderInit(&mr, pHandle->meta, 0); code = metaGetTableEntryByUidCache(&mr, pBlock->info.id.uid); if (code != TSDB_CODE_SUCCESS) { + + // when encounter the TSDB_CODE_PAR_TABLE_NOT_EXIST error, we proceed. if (terrno == TSDB_CODE_PAR_TABLE_NOT_EXIST) { qWarn("failed to get table meta, table may have been dropped, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(terrno), idStr); + + // append null value before return to caller, since the caller will ignore this error code and proceed + doSetNullValue(pBlock, pExpr, numOfExpr); } else { qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(terrno), idStr); @@ -498,6 +516,8 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int if (terrno == TSDB_CODE_PAR_TABLE_NOT_EXIST) { qWarn("failed to get table meta, table may have been dropped, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(terrno), idStr); + // append null value before return to caller, since the caller will ignore this error code and proceed + doSetNullValue(pBlock, pExpr, numOfExpr); } else { qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(terrno), idStr); @@ -617,6 +637,10 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } + if (pOperator->status == OP_EXEC_DONE) { + break; + } + // process this data block based on the probabilities bool processThisBlock = processBlockWithProbability(&pTableScanInfo->sample); if (!processThisBlock) { @@ -628,9 +652,8 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { uint32_t status = 0; int32_t code = loadDataBlock(pOperator, &pTableScanInfo->base, pBlock, &status); - // int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pOperator->pTaskInfo->env, code); + T_LONG_JMP(pTaskInfo->env, code); } // current block is filter out according to filter condition, continue load the next block @@ -1412,7 +1435,12 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock dumyInfo.cur.pageId = -1; bool isClosed = false; STimeWindow win = {.skey = INT64_MIN, .ekey = INT64_MAX}; - if (tableInserted && isOverdue(tsCol[rowId], &pInfo->twAggSup)) { + bool overDue = isOverdue(tsCol[rowId], &pInfo->twAggSup); + if (pInfo->igExpired && overDue) { + continue; + } + + if (tableInserted && overDue) { win = getActiveTimeWindow(NULL, &dumyInfo, tsCol[rowId], &pInfo->interval, TSDB_ORDER_ASC); isClosed = isCloseWindow(&win, &pInfo->twAggSup); } @@ -1678,41 +1706,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { SStreamScanInfo* pInfo = pOperator->info; qDebug("stream scan called"); -#if 0 - SStreamState* pState = pTaskInfo->streamInfo.pState; - if (pState) { - printf(">>>>>>>> stream write backend\n"); - SWinKey key = { - .ts = 1, - .groupId = 2, - }; - char tmp[100] = "abcdefg1"; - if (streamStatePut(pState, &key, &tmp, strlen(tmp) + 1) < 0) { - ASSERT(0); - } - - key.ts = 2; - char tmp2[100] = "abcdefg2"; - if (streamStatePut(pState, &key, &tmp2, strlen(tmp2) + 1) < 0) { - ASSERT(0); - } - - key.groupId = 5; - key.ts = 1; - char tmp3[100] = "abcdefg3"; - if (streamStatePut(pState, &key, &tmp3, strlen(tmp3) + 1) < 0) { - ASSERT(0); - } - - char* val2 = NULL; - int32_t sz; - if (streamStateGet(pState, &key, (void**)&val2, &sz) < 0) { - ASSERT(0); - } - printf("stream read %s %d\n", val2, sz); - streamFreeVal(val2); - } -#endif if (pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__PREPARE1 || pTaskInfo->streamInfo.recoverStep == STREAM_RECOVER_STEP__PREPARE2) { @@ -2345,6 +2338,9 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pUpdateDataRes = createSpecialDataBlock(STREAM_CLEAR); pInfo->assignBlockUid = pTableScanNode->assignBlockUid; pInfo->partitionSup.needCalc = false; + pInfo->igCheckUpdate = pTableScanNode->igCheckUpdate; + pInfo->igExpired = pTableScanNode->igExpired; + pInfo->twAggSup.maxTs = INT64_MIN; setOperatorInfo(pOperator, "StreamScanOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, false, OP_NOT_OPENED, pInfo, pTaskInfo); @@ -2540,7 +2536,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) { } uint32_t status = 0; - loadDataBlock(pOperator, &pInfo->base, pBlock, &status); + code = loadDataBlock(pOperator, &pInfo->base, pBlock, &status); // code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); @@ -2714,10 +2710,13 @@ SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, SSDataBlock* } } - applyLimitOffset(&pInfo->limitInfo, pResBlock, pTaskInfo); + bool limitReached = applyLimitOffset(&pInfo->limitInfo, pResBlock, pTaskInfo); qDebug("%s get sorted row block, rows:%d, limit:%"PRId64, GET_TASKID(pTaskInfo), pResBlock->info.rows, - pInfo->limitInfo.numOfOutputRows); + pInfo->limitInfo.numOfOutputRows); + if (limitReached) { + resetLimitInfoForNextGroup(&pInfo->limitInfo); + } return (pResBlock->info.rows > 0) ? pResBlock : NULL; } diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index 2d921d43d3..778281f9b4 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -186,7 +186,7 @@ static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* } } } - } else if (pFillInfo->type == TSDB_FILL_NULL) { // fill with NULL + } else if (pFillInfo->type == TSDB_FILL_NULL || pFillInfo->type == TSDB_FILL_NULL_F) { // fill with NULL setNullRow(pBlock, pFillInfo, index); } else { // fill with user specified value for each column for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { @@ -349,7 +349,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t bool isNull = colDataIsNull_s(pSrc, pFillInfo->index); colDataAppend(pDst, index, src, isNull); saveColData(pFillInfo->prev.pRowVal, i, src, isNull); // todo: - } else if (pFillInfo->type == TSDB_FILL_NULL) { + } else if (pFillInfo->type == TSDB_FILL_NULL || pFillInfo->type == TSDB_FILL_NULL_F) { colDataAppendNULL(pDst, index); } else if (pFillInfo->type == TSDB_FILL_NEXT) { SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next.pRowVal : pFillInfo->prev.pRowVal; @@ -447,32 +447,6 @@ struct SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t taosResetFillInfo(pFillInfo, skey); - switch (fillType) { - case FILL_MODE_NONE: - pFillInfo->type = TSDB_FILL_NONE; - break; - case FILL_MODE_PREV: - pFillInfo->type = TSDB_FILL_PREV; - break; - case FILL_MODE_NULL: - pFillInfo->type = TSDB_FILL_NULL; - break; - case FILL_MODE_LINEAR: - pFillInfo->type = TSDB_FILL_LINEAR; - break; - case FILL_MODE_NEXT: - pFillInfo->type = TSDB_FILL_NEXT; - break; - case FILL_MODE_VALUE: - pFillInfo->type = TSDB_FILL_SET_VALUE; - break; - default: { - taosMemoryFree(pFillInfo); - terrno = TSDB_CODE_INVALID_PARA; - return NULL; - } - } - pFillInfo->type = fillType; pFillInfo->pFillCol = pCol; pFillInfo->numOfCols = numOfFillCols + numOfNotFillCols; @@ -572,15 +546,14 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) { } int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows) { - SColumnInfoData* pCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, pFillInfo->srcTsSlotId); - - int64_t* tsList = (int64_t*)pCol->pData; int32_t numOfRows = taosNumOfRemainRows(pFillInfo); TSKEY ekey1 = ekey; int64_t numOfRes = -1; if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set. + SColumnInfoData* pCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, pFillInfo->srcTsSlotId); + int64_t* tsList = (int64_t*)pCol->pData; TSKEY lastKey = tsList[pFillInfo->numOfRows - 1]; numOfRes = taosTimeCountInterval(lastKey, pFillInfo->currentKey, pFillInfo->interval.sliding, pFillInfo->interval.slidingUnit, pFillInfo->interval.precision); diff --git a/source/libs/executor/src/timesliceoperator.c b/source/libs/executor/src/timesliceoperator.c index 94c98f41c9..3bf597f3b3 100644 --- a/source/libs/executor/src/timesliceoperator.c +++ b/source/libs/executor/src/timesliceoperator.c @@ -181,12 +181,14 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; switch (pSliceInfo->fillType) { - case TSDB_FILL_NULL: { + case TSDB_FILL_NULL: + case TSDB_FILL_NULL_F: { colDataAppendNULL(pDst, rows); break; } - case TSDB_FILL_SET_VALUE: { + case TSDB_FILL_SET_VALUE: + case TSDB_FILL_SET_VALUE_F: { SVariant* pVar = &pSliceInfo->pFillColInfo[j].fillVal; if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) { @@ -433,6 +435,11 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { break; } + if (pSliceInfo->scalarSup.pExprInfo != NULL) { + SExprSupp* pExprSup = &pSliceInfo->scalarSup; + projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL); + } + int32_t code = initKeeperInfo(pSliceInfo, pBlock); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); @@ -531,6 +538,8 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); } + doFilter(pResBlock, pOperator->exprSupp.pFilterInfo, NULL); + // restore the value setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); if (pResBlock->info.rows == 0) { @@ -566,6 +575,11 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode } } + code = filterInitFromNode((SNode*)pInterpPhyNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + pInfo->tsCol = extractColumnFromColumnNode((SColumnNode*)pInterpPhyNode->pTimeSeries); pInfo->fillType = convertFillType(pInterpPhyNode->fillMode); initResultSizeInfo(&pOperator->resultInfo, 4096); @@ -622,6 +636,7 @@ void destroyTimeSliceOperatorInfo(void* param) { taosMemoryFree(pKey->end.val); } taosArrayDestroy(pInfo->pLinearInfo); + cleanupExprSupp(&pInfo->scalarSup); taosMemoryFree(pInfo->pFillColInfo); taosMemoryFreeClear(param); diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index d78e9c4edf..0dbed103c8 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1726,7 +1726,7 @@ void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSuppor SStreamScanInfo* pScanInfo = downstream->info; pScanInfo->windowSup.parentType = type; pScanInfo->windowSup.pIntervalAggSup = pSup; - if (!pScanInfo->pUpdateInfo) { + if (!pScanInfo->igCheckUpdate && !pScanInfo->pUpdateInfo) { pScanInfo->pUpdateInfo = updateInfoInitP(pInterval, pTwSup->waterMark); } pScanInfo->interval = *pInterval; @@ -2477,7 +2477,19 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p pInfo->delKey = key; } int32_t prevEndPos = (forwardRows - 1) * step + startPos; - ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0); + if (pSDataBlock->info.window.skey <= 0 || pSDataBlock->info.window.ekey <= 0) { + qError("table uid %" PRIu64 " data block timestamp range may not be calculated! minKey %" PRId64 + ",maxKey %" PRId64, + pSDataBlock->info.id.uid, pSDataBlock->info.window.skey, pSDataBlock->info.window.ekey); + blockDataUpdateTsWindow(pSDataBlock, 0); + + // timestamp of the data is incorrect + if (pSDataBlock->info.window.skey <= 0 || pSDataBlock->info.window.ekey <= 0) { + qError("table uid %" PRIu64 " data block timestamp is out of range! minKey %" PRId64 ",maxKey %" PRId64, + pSDataBlock->info.id.uid, pSDataBlock->info.window.skey, pSDataBlock->info.window.ekey); + } + } + if (IS_FINAL_OP(pInfo)) { startPos = getNextQualifiedFinalWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos); } else { @@ -2881,7 +2893,7 @@ void initDownStream(SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, uin } SStreamScanInfo* pScanInfo = downstream->info; pScanInfo->windowSup = (SWindowSupporter){.pStreamAggSup = pAggSup, .gap = pAggSup->gap, .parentType = type}; - if (!pScanInfo->pUpdateInfo) { + if (!pScanInfo->igCheckUpdate && !pScanInfo->pUpdateInfo) { pScanInfo->pUpdateInfo = updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, pTwSup->waterMark); } pScanInfo->twAggSup = *pTwSup; diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 661e9f97b7..90f20f40b8 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -190,8 +190,9 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { qError("Add to buf failed since %s", terrstr(terrno)); return terrno; } + int32_t code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, - "doAddToBuf", tsTempDir); + "sortExternalBuf", tsTempDir); dBufSetPrintInfo(pHandle->pBuf); if (code != TSDB_CODE_SUCCESS) { return code; @@ -635,6 +636,7 @@ int32_t getProperSortPageSize(size_t rowSize, uint32_t numOfCols) { static int32_t createInitialSources(SSortHandle* pHandle) { size_t sortBufSize = pHandle->numOfPages * pHandle->pageSize; + int32_t code = 0; if (pHandle->type == SORT_SINGLESOURCE_SORT) { SSortSource** pSource = taosArrayGet(pHandle->pOrderedSource, 0); @@ -663,8 +665,8 @@ static int32_t createInitialSources(SSortHandle* pHandle) { pHandle->beforeFp(pBlock, pHandle->param); } - int32_t code = blockDataMerge(pHandle->pDataBlock, pBlock); - if (code != 0) { + code = blockDataMerge(pHandle->pDataBlock, pBlock); + if (code != TSDB_CODE_SUCCESS) { if (source->param && !source->onlyRef) { taosMemoryFree(source->param); } @@ -689,6 +691,7 @@ static int32_t createInitialSources(SSortHandle* pHandle) { blockDataDestroy(source->src.pBlock); source->src.pBlock = NULL; } + taosMemoryFree(source); return code; } @@ -696,13 +699,17 @@ static int32_t createInitialSources(SSortHandle* pHandle) { int64_t el = taosGetTimestampUs() - p; pHandle->sortElapsed += el; - doAddToBuf(pHandle->pDataBlock, pHandle); + code = doAddToBuf(pHandle->pDataBlock, pHandle); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } if (source->param && !source->onlyRef) { taosMemoryFree(source->param); } + taosMemoryFree(source); if (pHandle->pDataBlock != NULL && pHandle->pDataBlock->info.rows > 0) { @@ -711,7 +718,7 @@ static int32_t createInitialSources(SSortHandle* pHandle) { // Perform the in-memory sort and then flush data in the buffer into disk. int64_t p = taosGetTimestampUs(); - int32_t code = blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo); + code = blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo); if (code != 0) { return code; } @@ -729,12 +736,12 @@ static int32_t createInitialSources(SSortHandle* pHandle) { pHandle->tupleHandle.pBlock = pHandle->pDataBlock; return 0; } else { - doAddToBuf(pHandle->pDataBlock, pHandle); + code = doAddToBuf(pHandle->pDataBlock, pHandle); } } } - return TSDB_CODE_SUCCESS; + return code; } int32_t tsortOpen(SSortHandle* pHandle) { diff --git a/source/libs/function/src/detail/tminmax.c b/source/libs/function/src/detail/tminmax.c index 847c738655..a511ca97f1 100644 --- a/source/libs/function/src/detail/tminmax.c +++ b/source/libs/function/src/detail/tminmax.c @@ -714,26 +714,18 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) pBuf->type = type; if (IS_NULL_TYPE(type)) { - numOfElems = 0; goto _over; } // data in current data block are qualified to the query if (pInput->colDataSMAIsSet) { numOfElems = pInput->numOfRows - pAgg->numOfNull; - if (numOfElems == 0) { goto _over; } - void* tval = NULL; int16_t index = 0; - - if (isMinFunc) { - tval = &pInput->pColumnDataAgg[0]->min; - } else { - tval = &pInput->pColumnDataAgg[0]->max; - } + void* tval = (isMinFunc) ? &pInput->pColumnDataAgg[0]->min : &pInput->pColumnDataAgg[0]->max; if (!pBuf->assign) { if (type == TSDB_DATA_TYPE_FLOAT) { @@ -824,8 +816,9 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc, int32_t* nElems) } } + numOfElems = 1; pBuf->assign = true; - return TSDB_CODE_SUCCESS; + goto _over; } int32_t start = pInput->startRowIndex; diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 6ab91a4483..e3127fcd7b 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -262,6 +262,13 @@ bool fmIsGroupKeyFunc(int32_t funcId) { return FUNCTION_TYPE_GROUP_KEY == funcMgtBuiltins[funcId].type; } +bool fmIsBlockDistFunc(int32_t funcId) { + if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { + return false; + } + return FUNCTION_TYPE_BLOCK_DIST == funcMgtBuiltins[funcId].type; +} + void fmFuncMgtDestroy() { void* m = gFunMgtService.pFuncNameHashTable; if (m != NULL && atomic_val_compare_exchange_ptr((void**)&gFunMgtService.pFuncNameHashTable, m, 0) == m) { diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 7b9c54ab2c..2b1819d5c0 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -380,6 +380,7 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { COPY_SCALAR_FIELD(watermark); COPY_SCALAR_FIELD(deleteMark); COPY_SCALAR_FIELD(igExpired); + COPY_SCALAR_FIELD(igCheckUpdate); CLONE_NODE_LIST_FIELD(pGroupTags); COPY_SCALAR_FIELD(groupSort); CLONE_NODE_LIST_FIELD(pTags); @@ -467,6 +468,7 @@ static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* p COPY_SCALAR_FIELD(watermark); COPY_SCALAR_FIELD(deleteMark); COPY_SCALAR_FIELD(igExpired); + COPY_SCALAR_FIELD(igCheckUpdate); COPY_SCALAR_FIELD(windowAlgo); COPY_SCALAR_FIELD(inputTsOrder); COPY_SCALAR_FIELD(outputTsOrder); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 1a4ba8e43e..c19f64bb3a 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1553,6 +1553,7 @@ static const char* jkTableScanPhysiPlanGroupSort = "GroupSort"; static const char* jkTableScanPhysiPlanTags = "Tags"; static const char* jkTableScanPhysiPlanSubtable = "Subtable"; static const char* jkTableScanPhysiPlanAssignBlockUid = "AssignBlockUid"; +static const char* jkTableScanPhysiPlanIgnoreUpdate = "IgnoreUpdate"; static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj; @@ -1618,6 +1619,9 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkTableScanPhysiPlanAssignBlockUid, pNode->assignBlockUid); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanIgnoreUpdate, pNode->igCheckUpdate); + } return code; } @@ -1686,6 +1690,9 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkTableScanPhysiPlanAssignBlockUid, &pNode->assignBlockUid); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetTinyIntValue(pJson, jkTableScanPhysiPlanIgnoreUpdate, &pNode->igCheckUpdate); + } return code; } diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index dfe2f6c8b9..274cac405d 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -2078,6 +2078,9 @@ static int32_t physiTableScanNodeInlineToMsg(const void* pObj, STlvEncoder* pEnc if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeValueBool(pEncoder, pNode->assignBlockUid); } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeValueI8(pEncoder, pNode->igCheckUpdate); + } return code; } @@ -2154,6 +2157,9 @@ static int32_t msgToPhysiTableScanNodeInline(STlvDecoder* pDecoder, void* pObj) if (TSDB_CODE_SUCCESS == code) { code = tlvDecodeValueBool(pDecoder, &pNode->assignBlockUid); } + if (TSDB_CODE_SUCCESS == code) { + code = tlvDecodeValueI8(pDecoder, &pNode->igCheckUpdate); + } return code; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index cd5ae7ad6e..e28486e0b6 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -1990,10 +1990,14 @@ char* nodesGetFillModeString(EFillMode mode) { return "none"; case FILL_MODE_VALUE: return "value"; + case FILL_MODE_VALUE_F: + return "value_f"; case FILL_MODE_PREV: return "prev"; case FILL_MODE_NULL: return "null"; + case FILL_MODE_NULL_F: + return "null_f"; case FILL_MODE_LINEAR: return "linear"; case FILL_MODE_NEXT: diff --git a/source/libs/parser/inc/parInsertUtil.h b/source/libs/parser/inc/parInsertUtil.h index 5cc72f8692..9dd4daec3b 100644 --- a/source/libs/parser/inc/parInsertUtil.h +++ b/source/libs/parser/inc/parInsertUtil.h @@ -22,11 +22,11 @@ struct SToken; #define IS_DATA_COL_ORDERED(spd) ((spd->orderStatus) == (int8_t)ORDER_STATUS_ORDERED) -#define NEXT_TOKEN(pSql, sToken) \ - do { \ - int32_t index = 0; \ - sToken = tStrGetToken(pSql, &index, false); \ - pSql += index; \ +#define NEXT_TOKEN(pSql, sToken) \ + do { \ + int32_t index = 0; \ + sToken = tStrGetToken(pSql, &index, false, NULL); \ + pSql += index; \ } while (0) #define CHECK_CODE(expr) \ diff --git a/source/libs/parser/inc/parToken.h b/source/libs/parser/inc/parToken.h index fb4b46aa35..d539e8b37b 100644 --- a/source/libs/parser/inc/parToken.h +++ b/source/libs/parser/inc/parToken.h @@ -55,7 +55,7 @@ uint32_t tGetToken(const char *z, uint32_t *tokenType); * @param isPrevOptr * @return */ -SToken tStrGetToken(const char *str, int32_t *i, bool isPrevOptr); +SToken tStrGetToken(const char *str, int32_t *i, bool isPrevOptr, bool *pIgnoreComma); /** * check if it is a keyword or not diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 7136a555cd..44a8f7e89f 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -544,6 +544,7 @@ stream_options(A) ::= stream_options(B) TRIGGER MAX_DELAY duration_literal(C). stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; } stream_options(A) ::= stream_options(B) IGNORE EXPIRED NK_INTEGER(C). { ((SStreamOptions*)B)->ignoreExpired = taosStr2Int8(C.z, NULL, 10); A = B; } stream_options(A) ::= stream_options(B) FILL_HISTORY NK_INTEGER(C). { ((SStreamOptions*)B)->fillHistory = taosStr2Int8(C.z, NULL, 10); A = B; } +stream_options(A) ::= stream_options(B) IGNORE UPDATE NK_INTEGER(C). { ((SStreamOptions*)B)->ignoreUpdate = taosStr2Int8(C.z, NULL, 10); A = B; } subtable_opt(A) ::= . { A = NULL; } subtable_opt(A) ::= SUBTABLE NK_LP expression(B) NK_RP. { A = releaseRawExprNode(pCxt, B); } @@ -978,12 +979,14 @@ sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. fill_opt(A) ::= . { A = NULL; } fill_opt(A) ::= FILL NK_LP fill_mode(B) NK_RP. { A = createFillNode(pCxt, B, NULL); } fill_opt(A) ::= FILL NK_LP VALUE NK_COMMA literal_list(B) NK_RP. { A = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, B)); } +fill_opt(A) ::= FILL NK_LP VALUE_F NK_COMMA literal_list(B) NK_RP. { A = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, B)); } %type fill_mode { EFillMode } %destructor fill_mode { } fill_mode(A) ::= NONE. { A = FILL_MODE_NONE; } fill_mode(A) ::= PREV. { A = FILL_MODE_PREV; } fill_mode(A) ::= NULL. { A = FILL_MODE_NULL; } +fill_mode(A) ::= NULL_F. { A = FILL_MODE_NULL_F; } fill_mode(A) ::= LINEAR. { A = FILL_MODE_LINEAR; } fill_mode(A) ::= NEXT. { A = FILL_MODE_NEXT; } @@ -1075,4 +1078,4 @@ null_ordering_opt(A) ::= NULLS LAST. %fallback ABORT AFTER ATTACH BEFORE BEGIN BITAND BITNOT BITOR BLOCKS CHANGE COMMA COMPACT CONCAT CONFLICT COPY DEFERRED DELIMITERS DETACH DIVIDE DOT EACH END FAIL FILE FOR GLOB ID IMMEDIATE IMPORT INITIALLY INSTEAD ISNULL KEY MODULES NK_BITNOT NK_SEMI NOTNULL OF PLUS PRIVILEGE RAISE REPLACE RESTRICT ROW SEMI STAR STATEMENT - STRICT STRING TIMES UPDATE VALUES VARIABLE VIEW WAL. + STRICT STRING TIMES VALUES VARIABLE VIEW WAL. diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index eaa72b1377..d1f861a5fc 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1763,6 +1763,7 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) { pOptions->triggerType = STREAM_TRIGGER_AT_ONCE; pOptions->fillHistory = STREAM_DEFAULT_FILL_HISTORY; pOptions->ignoreExpired = STREAM_DEFAULT_IGNORE_EXPIRED; + pOptions->ignoreUpdate = STREAM_DEFAULT_IGNORE_UPDATE; return (SNode*)pOptions; } diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 98c6aed829..abee9416fa 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -18,16 +18,23 @@ #include "tglobal.h" #include "ttime.h" -#define NEXT_TOKEN_WITH_PREV(pSql, token) \ - do { \ - int32_t index = 0; \ - token = tStrGetToken(pSql, &index, true); \ - pSql += index; \ +#define NEXT_TOKEN_WITH_PREV(pSql, token) \ + do { \ + int32_t index = 0; \ + token = tStrGetToken(pSql, &index, true, NULL); \ + pSql += index; \ } while (0) -#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \ - do { \ - token = tStrGetToken(pSql, &index, false); \ +#define NEXT_TOKEN_WITH_PREV_EXT(pSql, token, pIgnoreComma) \ + do { \ + int32_t index = 0; \ + token = tStrGetToken(pSql, &index, true, pIgnoreComma); \ + pSql += index; \ + } while (0) + +#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \ + do { \ + token = tStrGetToken(pSql, &index, false, NULL); \ } while (0) #define NEXT_VALID_TOKEN(pSql, token) \ @@ -302,12 +309,12 @@ static int parseTime(const char** end, SToken* pToken, int16_t timePrec, int64_t * e.g., now+12a, now-5h */ index = 0; - SToken token = tStrGetToken(pTokenEnd, &index, false); + SToken token = tStrGetToken(pTokenEnd, &index, false, NULL); pTokenEnd += index; if (token.type == TK_NK_MINUS || token.type == TK_NK_PLUS) { index = 0; - SToken valueToken = tStrGetToken(pTokenEnd, &index, false); + SToken valueToken = tStrGetToken(pTokenEnd, &index, false, NULL); pTokenEnd += index; if (valueToken.n < 2) { @@ -1240,30 +1247,35 @@ static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataB int32_t code = tdSRowResetBuf(pBuilder, row); // 1. set the parsed value from sql string for (int i = 0; i < pCols->numOfBound && TSDB_CODE_SUCCESS == code; ++i) { - NEXT_TOKEN_WITH_PREV(*pSql, *pToken); - SSchema* pSchema = &pSchemas[pCols->boundColumns[i]]; + const char* pOrigSql = *pSql; + bool ignoreComma = false; + NEXT_TOKEN_WITH_PREV_EXT(*pSql, *pToken, &ignoreComma); + if (ignoreComma) { + code = buildSyntaxErrMsg(&pCxt->msg, "invalid data or symbol", pOrigSql); + break; + } if (pToken->type == TK_NK_QUESTION) { isParseBindParam = true; if (NULL == pCxt->pComCxt->pStmtCb) { code = buildSyntaxErrMsg(&pCxt->msg, "? only used in stmt", pToken->z); + break; + } + } else { + if (TK_NK_RP == pToken->type) { + code = generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_INVALID_COLUMNS_NUM); + break; } - continue; - } - if (TSDB_CODE_SUCCESS == code && TK_NK_RP == pToken->type) { - code = generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_INVALID_COLUMNS_NUM); - } + if (isParseBindParam) { + code = buildInvalidOperationMsg(&pCxt->msg, "no mix usage for ? and values"); + break; + } - if (TSDB_CODE_SUCCESS == code && isParseBindParam) { - code = buildInvalidOperationMsg(&pCxt->msg, "no mix usage for ? and values"); - } - - if (TSDB_CODE_SUCCESS == code) { - param.schema = pSchema; + param.schema = &pSchemas[pCols->boundColumns[i]]; insGetSTSRowAppendInfo(pBuilder->rowType, pCols, i, ¶m.toffset, ¶m.colIdx); - code = parseValueToken(pCxt, pSql, pToken, pSchema, getTableInfo(pDataBuf->pTableMeta).precision, insMemRowAppend, - ¶m); + code = parseValueToken(pCxt, pSql, pToken, param.schema, getTableInfo(pDataBuf->pTableMeta).precision, + insMemRowAppend, ¶m); } if (TSDB_CODE_SUCCESS == code && i < pCols->numOfBound - 1) { @@ -1760,6 +1772,9 @@ static int32_t getTableSchemaFromMetaData(SInsertParseContext* pCxt, const SMeta if (TSDB_CODE_SUCCESS == code && !isStb && TSDB_SUPER_TABLE == pStmt->pTableMeta->tableType) { code = buildInvalidOperationMsg(&pCxt->msg, "insert data into super table is not supported"); } + if (TSDB_CODE_SUCCESS == code && isStb) { + code = storeTableMeta(pCxt, pStmt); + } if (TSDB_CODE_SUCCESS == code) { code = getTableVgroupFromMetaData(pMetaData->pTableHash, pStmt, isStb); } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index e62b2f0f5a..b248efee59 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -148,6 +148,7 @@ static SKeyword keywordTable[] = { {"NOT", TK_NOT}, {"NOW", TK_NOW}, {"NULL", TK_NULL}, + {"NULL_F", TK_NULL_F}, {"NULLS", TK_NULLS}, {"OFFSET", TK_OFFSET}, {"ON", TK_ON}, @@ -232,11 +233,13 @@ static SKeyword keywordTable[] = { {"TTL", TK_TTL}, {"UNION", TK_UNION}, {"UNSIGNED", TK_UNSIGNED}, + {"UPDATE", TK_UPDATE}, {"USE", TK_USE}, {"USER", TK_USER}, {"USERS", TK_USERS}, {"USING", TK_USING}, {"VALUE", TK_VALUE}, + {"VALUE_F", TK_VALUE_F}, {"VALUES", TK_VALUES}, {"VARCHAR", TK_VARCHAR}, {"VARIABLES", TK_VARIABLES}, @@ -620,7 +623,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) { return 0; } -SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) { +SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr, bool* pIgnoreComma) { SToken t0 = {0}; // here we reach the end of sql string, null-terminated string @@ -641,6 +644,10 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) { return t0; } + if (NULL != pIgnoreComma && t == ',') { + *pIgnoreComma = true; + } + t = str[++(*i)]; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 9991c2c6ae..2c99e50ff3 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1561,6 +1561,27 @@ static int32_t translateRepeatScanFunc(STranslateContext* pCxt, SFunctionNode* p return TSDB_CODE_SUCCESS; } +static int32_t translateBlockDistFunc(STranslateContext* pCtx, SFunctionNode* pFunc) { + if (!fmIsBlockDistFunc(pFunc->funcId)) { + return TSDB_CODE_SUCCESS; + } + if (!isSelectStmt(pCtx->pCurrStmt)) { + return generateSyntaxErrMsgExt(&pCtx->msgBuf, TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE, + "%s is only supported in single table query", pFunc->functionName); + } + SSelectStmt* pSelect = (SSelectStmt*)pCtx->pCurrStmt; + SNode* pTable = pSelect->pFromTable; + if (NULL != pTable && (QUERY_NODE_REAL_TABLE != nodeType(pTable) || + (TSDB_SUPER_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType && + TSDB_CHILD_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType && + TSDB_NORMAL_TABLE != ((SRealTableNode*)pTable)->pMeta->tableType))) { + return generateSyntaxErrMsgExt(&pCtx->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, + "%s is only supported on super table, child table or normal table", + pFunc->functionName); + } + return TSDB_CODE_SUCCESS; +} + static bool isStar(SNode* pNode) { return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' == ((SColumnNode*)pNode)->tableAlias[0]) && (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); @@ -1584,6 +1605,7 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu } if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias) { strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias); + strcpy(pFunc->node.aliasName, pFunc->node.userAlias); } return TSDB_CODE_SUCCESS; } @@ -1720,7 +1742,7 @@ static int32_t rewriteSystemInfoFunc(STranslateContext* pCxt, SNode** pNode) { return TSDB_CODE_PAR_INTERNAL_ERROR; } -static int32_t translateNoramlFunction(STranslateContext* pCxt, SFunctionNode* pFunc) { +static int32_t translateNormalFunction(STranslateContext* pCxt, SFunctionNode* pFunc) { int32_t code = translateAggFunc(pCxt, pFunc); if (TSDB_CODE_SUCCESS == code) { code = translateScanPseudoColumnFunc(pCxt, pFunc); @@ -1752,6 +1774,9 @@ static int32_t translateNoramlFunction(STranslateContext* pCxt, SFunctionNode* p if (TSDB_CODE_SUCCESS == code) { code = translateTimelineFunc(pCxt, pFunc); } + if (TSDB_CODE_SUCCESS == code) { + code = translateBlockDistFunc(pCxt, pFunc); + } if (TSDB_CODE_SUCCESS == code) { setFuncClassification(pCxt->pCurrStmt, pFunc); } @@ -1812,7 +1837,7 @@ static int32_t translateFunctionImpl(STranslateContext* pCxt, SFunctionNode** pF if (fmIsClientPseudoColumnFunc((*pFunc)->funcId)) { return rewriteClientPseudoColumnFunc(pCxt, (SNode**)pFunc); } - return translateNoramlFunction(pCxt, *pFunc); + return translateNormalFunction(pCxt, *pFunc); } static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode** pFunc) { @@ -2523,11 +2548,12 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) { int32_t len = 0; if (QUERY_NODE_COLUMN == nodeType(pExpr)) { SColumnNode* pCol = (SColumnNode*)pExpr; - len = snprintf(buf, sizeof(buf), "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName); - strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1)); if (tsKeepColumnName) { strcpy(pFunc->node.userAlias, pCol->colName); + strcpy(pFunc->node.aliasName, pCol->colName); } else { + len = snprintf(buf, sizeof(buf), "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName); + strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1)); len = snprintf(buf, sizeof(buf), "%s(%s)", pSrcFunc->functionName, pCol->colName); strncpy(pFunc->node.userAlias, buf, TMIN(len, sizeof(pFunc->node.userAlias) - 1)); } @@ -2794,7 +2820,7 @@ static int32_t convertFillValue(STranslateContext* pCxt, SDataType dt, SNodeList } static int32_t checkFillValues(STranslateContext* pCxt, SFillNode* pFill, SNodeList* pProjectionList) { - if (FILL_MODE_VALUE != pFill->mode) { + if (FILL_MODE_VALUE != pFill->mode && FILL_MODE_VALUE_F != pFill->mode) { return TSDB_CODE_SUCCESS; } @@ -2978,7 +3004,7 @@ static int32_t checkFill(STranslateContext* pCxt, SFillNode* pFill, SValueNode* intervalRange = pInterval->datum.i; } - if ((timeRange == 0) || (timeRange / intervalRange) >= MAX_INTERVAL_TIME_WINDOW) { + if ((timeRange / intervalRange) >= MAX_INTERVAL_TIME_WINDOW) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE); } @@ -5715,6 +5741,7 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt* pReq->watermark = (NULL != pStmt->pOptions->pWatermark ? ((SValueNode*)pStmt->pOptions->pWatermark)->datum.i : 0); pReq->fillHistory = pStmt->pOptions->fillHistory; pReq->igExpired = pStmt->pOptions->ignoreExpired; + pReq->igUpdate = pStmt->pOptions->ignoreUpdate; columnDefNodeToField(pStmt->pTags, &pReq->pTags); pReq->numOfTags = LIST_LENGTH(pStmt->pTags); } diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index cf338d63ff..47482db740 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -27,7 +27,7 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) { const char* pSql = pStr; int32_t index = 0; - SToken t = tStrGetToken((char*)pStr, &index, false); + SToken t = tStrGetToken((char*)pStr, &index, false, NULL); if (TK_INSERT != t.type && TK_IMPORT != t.type) { return false; } @@ -35,7 +35,7 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) { do { pStr += index; index = 0; - t = tStrGetToken((char*)pStr, &index, false); + t = tStrGetToken((char*)pStr, &index, false, NULL); if (TK_USING == t.type || TK_VALUES == t.type || TK_FILE == t.type) { return true; } else if (TK_SELECT == t.type) { diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index d3b9bf069b..9cd3a3c65c 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 459 +#define YYNOCODE 461 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOperatorType yy20; - SNode* yy74; - ENullOrder yy109; - SToken yy317; - EOrder yy326; - bool yy335; - int8_t yy449; - int64_t yy531; - EJoinType yy630; - SAlterOption yy767; - EFillMode yy828; - int32_t yy856; - SNodeList* yy874; - SDataType yy898; + EOrder yy32; + SToken yy77; + int32_t yy248; + int8_t yy287; + ENullOrder yy385; + EJoinType yy560; + SNode* yy600; + SNodeList* yy601; + SAlterOption yy661; + EOperatorType yy666; + int64_t yy717; + EFillMode yy798; + bool yy841; + SDataType yy888; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 711 -#define YYNRULE 541 -#define YYNTOKEN 322 -#define YY_MAX_SHIFT 710 -#define YY_MIN_SHIFTREDUCE 1054 -#define YY_MAX_SHIFTREDUCE 1594 -#define YY_ERROR_ACTION 1595 -#define YY_ACCEPT_ACTION 1596 -#define YY_NO_ACTION 1597 -#define YY_MIN_REDUCE 1598 -#define YY_MAX_REDUCE 2138 +#define YYNSTATE 715 +#define YYNRULE 544 +#define YYNTOKEN 324 +#define YY_MAX_SHIFT 714 +#define YY_MIN_SHIFTREDUCE 1061 +#define YY_MAX_SHIFTREDUCE 1604 +#define YY_ERROR_ACTION 1605 +#define YY_ACCEPT_ACTION 1606 +#define YY_NO_ACTION 1607 +#define YY_MIN_REDUCE 1608 +#define YY_MAX_REDUCE 2151 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,742 +216,744 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2723) +#define YY_ACTTAB_COUNT (2733) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 459, 353, 460, 1634, 566, 600, 578, 2114, 2109, 155, - /* 10 */ 1940, 2109, 43, 41, 1525, 39, 38, 37, 1753, 123, - /* 20 */ 361, 1936, 1375, 565, 173, 599, 498, 2113, 2110, 567, - /* 30 */ 1954, 2110, 2112, 1455, 1400, 1373, 1751, 131, 468, 406, - /* 40 */ 460, 1634, 36, 35, 1940, 586, 42, 40, 39, 38, - /* 50 */ 37, 1932, 1938, 344, 541, 1936, 167, 578, 1450, 465, - /* 60 */ 585, 1972, 610, 16, 366, 461, 1804, 1797, 1799, 581, - /* 70 */ 1381, 599, 1401, 330, 1922, 158, 616, 333, 1851, 319, - /* 80 */ 1705, 1972, 1802, 43, 41, 1932, 1938, 356, 131, 560, - /* 90 */ 477, 361, 475, 1375, 1860, 12, 610, 326, 172, 2049, - /* 100 */ 2050, 1953, 129, 2054, 1455, 1988, 1373, 2113, 100, 1955, - /* 110 */ 620, 1957, 1958, 615, 600, 610, 1106, 707, 1105, 654, - /* 120 */ 170, 458, 2041, 599, 463, 1640, 355, 2037, 123, 1450, - /* 130 */ 559, 210, 1457, 1458, 16, 503, 33, 275, 1484, 566, - /* 140 */ 175, 1381, 157, 2109, 1610, 1751, 46, 1107, 2067, 255, - /* 150 */ 2049, 577, 578, 124, 576, 1621, 1954, 2109, 565, 173, - /* 160 */ 600, 1431, 1440, 2110, 567, 578, 12, 42, 40, 39, - /* 170 */ 38, 37, 565, 173, 52, 1309, 1310, 2110, 567, 97, - /* 180 */ 1376, 586, 1374, 131, 1256, 1257, 467, 1972, 707, 463, - /* 190 */ 1640, 1751, 1402, 132, 1485, 614, 131, 561, 46, 1922, - /* 200 */ 1922, 1743, 616, 1457, 1458, 1379, 1380, 62, 1430, 1433, - /* 210 */ 1434, 1435, 1436, 1437, 1438, 1439, 612, 608, 1448, 1449, - /* 220 */ 1451, 1452, 1453, 1454, 1456, 1459, 2, 1953, 595, 58, - /* 230 */ 1860, 1988, 1431, 1440, 311, 1955, 620, 1957, 1958, 615, - /* 240 */ 613, 610, 601, 2006, 174, 2049, 2050, 1400, 129, 2054, - /* 250 */ 338, 1376, 2056, 1374, 1798, 1799, 580, 171, 2049, 2050, - /* 260 */ 556, 129, 2054, 1620, 58, 32, 359, 1479, 1480, 1481, - /* 270 */ 1482, 1483, 1487, 1488, 1489, 1490, 1379, 1380, 2053, 1430, - /* 280 */ 1433, 1434, 1435, 1436, 1437, 1438, 1439, 612, 608, 1448, - /* 290 */ 1449, 1451, 1452, 1453, 1454, 1456, 1459, 2, 58, 9, - /* 300 */ 43, 41, 1667, 47, 1551, 1596, 1847, 1922, 361, 1529, - /* 310 */ 1375, 339, 1729, 337, 336, 1400, 500, 181, 1954, 1619, - /* 320 */ 502, 1455, 58, 1373, 1213, 642, 641, 640, 1217, 639, - /* 330 */ 1219, 1220, 638, 1222, 635, 257, 1228, 632, 1230, 1231, - /* 340 */ 629, 626, 501, 562, 557, 258, 1450, 176, 399, 1972, - /* 350 */ 398, 16, 553, 1549, 1550, 1552, 1553, 617, 1381, 1106, - /* 360 */ 1173, 1105, 1922, 1922, 616, 569, 395, 513, 512, 511, - /* 370 */ 376, 43, 41, 1460, 477, 128, 507, 400, 176, 361, - /* 380 */ 506, 1375, 58, 12, 85, 505, 510, 397, 393, 1953, - /* 390 */ 1107, 504, 1455, 1988, 1373, 1175, 100, 1955, 620, 1957, - /* 400 */ 1958, 615, 1954, 610, 80, 707, 134, 1618, 141, 2012, - /* 410 */ 2041, 600, 546, 176, 355, 2037, 2109, 1450, 127, 546, - /* 420 */ 1457, 1458, 169, 2109, 1401, 178, 226, 1746, 573, 1381, - /* 430 */ 1617, 2115, 173, 1972, 1599, 1791, 2110, 567, 2115, 173, - /* 440 */ 1375, 617, 1751, 2110, 567, 167, 1922, 176, 616, 1431, - /* 450 */ 1440, 1922, 176, 1373, 44, 113, 1432, 587, 112, 111, - /* 460 */ 110, 109, 108, 107, 106, 105, 104, 1852, 1376, 352, - /* 470 */ 1374, 176, 1864, 1953, 1922, 227, 707, 1988, 1781, 1804, - /* 480 */ 160, 1955, 620, 1957, 1958, 615, 354, 610, 1381, 1352, - /* 490 */ 1353, 1457, 1458, 1379, 1380, 1802, 1430, 1433, 1434, 1435, - /* 500 */ 1436, 1437, 1438, 1439, 612, 608, 1448, 1449, 1451, 1452, - /* 510 */ 1453, 1454, 1456, 1459, 2, 509, 508, 678, 676, 113, - /* 520 */ 1431, 1440, 112, 111, 110, 109, 108, 107, 106, 105, - /* 530 */ 104, 176, 568, 2130, 364, 707, 513, 512, 511, 1376, - /* 540 */ 367, 1374, 155, 1804, 128, 507, 1465, 1909, 155, 506, - /* 550 */ 365, 1753, 1400, 1403, 505, 510, 1728, 1753, 1954, 1802, - /* 560 */ 504, 266, 267, 1400, 1379, 1380, 265, 1430, 1433, 1434, - /* 570 */ 1435, 1436, 1437, 1438, 1439, 612, 608, 1448, 1449, 1451, - /* 580 */ 1452, 1453, 1454, 1456, 1459, 2, 43, 41, 1598, 1972, - /* 590 */ 1616, 600, 185, 527, 361, 383, 1375, 581, 1376, 1727, - /* 600 */ 1374, 1615, 1922, 1399, 616, 404, 525, 1455, 523, 1373, - /* 610 */ 1742, 600, 122, 121, 120, 119, 118, 117, 116, 115, - /* 620 */ 114, 1936, 1751, 1379, 1380, 405, 11, 10, 77, 1953, - /* 630 */ 1614, 76, 1450, 1988, 1922, 1613, 100, 1955, 620, 1957, - /* 640 */ 1958, 615, 1751, 610, 1381, 1922, 91, 80, 170, 574, - /* 650 */ 2041, 1932, 1938, 133, 355, 2037, 2012, 43, 41, 600, - /* 660 */ 518, 654, 610, 652, 2114, 361, 1954, 1375, 1744, 44, - /* 670 */ 1747, 442, 1612, 414, 1922, 528, 2068, 587, 1455, 1922, - /* 680 */ 1373, 1402, 146, 145, 649, 648, 647, 143, 29, 224, - /* 690 */ 1751, 707, 1865, 1432, 36, 35, 182, 1972, 42, 40, - /* 700 */ 39, 38, 37, 1450, 521, 617, 1457, 1458, 1609, 515, - /* 710 */ 1922, 1608, 616, 2056, 223, 1381, 1922, 1607, 2114, 36, - /* 720 */ 35, 1498, 2109, 42, 40, 39, 38, 37, 1522, 189, - /* 730 */ 188, 1403, 1641, 1486, 2056, 1431, 1440, 1953, 2113, 2052, - /* 740 */ 12, 1988, 2110, 2111, 101, 1955, 620, 1957, 1958, 615, - /* 750 */ 64, 610, 1922, 63, 1376, 1922, 1374, 1584, 2041, 31, - /* 760 */ 2051, 1922, 707, 2038, 1606, 36, 35, 1605, 225, 42, - /* 770 */ 40, 39, 38, 37, 9, 1604, 1087, 1457, 1458, 1379, - /* 780 */ 1380, 702, 1430, 1433, 1434, 1435, 1436, 1437, 1438, 1439, - /* 790 */ 612, 608, 1448, 1449, 1451, 1452, 1453, 1454, 1456, 1459, - /* 800 */ 2, 318, 1384, 1398, 30, 1603, 1431, 1440, 1922, 710, - /* 810 */ 436, 1922, 155, 449, 1491, 1089, 448, 1092, 1093, 1922, - /* 820 */ 602, 1754, 2013, 282, 257, 1376, 1664, 1374, 82, 321, - /* 830 */ 1847, 420, 531, 450, 529, 9, 422, 7, 166, 1834, - /* 840 */ 604, 183, 2013, 6, 700, 696, 692, 688, 280, 1922, - /* 850 */ 1379, 1380, 1726, 1430, 1433, 1434, 1435, 1436, 1437, 1438, - /* 860 */ 1439, 612, 608, 1448, 1449, 1451, 1452, 1453, 1454, 1456, - /* 870 */ 1459, 2, 1804, 1403, 235, 36, 35, 334, 1400, 42, - /* 880 */ 40, 39, 38, 37, 98, 1847, 607, 273, 1803, 410, - /* 890 */ 645, 684, 683, 682, 681, 371, 187, 680, 679, 135, - /* 900 */ 674, 673, 672, 671, 670, 669, 668, 148, 664, 663, - /* 910 */ 662, 370, 369, 659, 658, 657, 656, 655, 646, 446, - /* 920 */ 596, 1795, 441, 440, 439, 438, 435, 434, 433, 432, - /* 930 */ 431, 427, 426, 425, 424, 335, 417, 416, 415, 1381, - /* 940 */ 412, 411, 332, 156, 1092, 1093, 36, 35, 295, 1387, - /* 950 */ 42, 40, 39, 38, 37, 1602, 1601, 260, 1954, 652, - /* 960 */ 666, 650, 293, 66, 1795, 289, 65, 651, 1781, 1521, - /* 970 */ 1795, 667, 1740, 1721, 1346, 48, 229, 3, 146, 145, - /* 980 */ 649, 648, 647, 143, 193, 455, 453, 36, 35, 1972, - /* 990 */ 423, 42, 40, 39, 38, 37, 502, 617, 1943, 1922, - /* 1000 */ 1922, 600, 1922, 652, 616, 1736, 36, 35, 2061, 1518, - /* 1010 */ 42, 40, 39, 38, 37, 428, 234, 233, 501, 1432, - /* 1020 */ 58, 600, 146, 145, 649, 648, 647, 143, 1476, 1953, - /* 1030 */ 154, 600, 1751, 1988, 1561, 429, 100, 1955, 620, 1957, - /* 1040 */ 1958, 615, 25, 610, 144, 476, 1945, 1518, 2129, 137, - /* 1050 */ 2041, 125, 1751, 407, 355, 2037, 83, 1738, 67, 99, - /* 1060 */ 600, 1954, 1751, 36, 35, 2075, 408, 42, 40, 39, - /* 1070 */ 38, 37, 36, 35, 1748, 1734, 42, 40, 39, 38, - /* 1080 */ 37, 600, 216, 218, 570, 214, 217, 600, 1654, 1383, - /* 1090 */ 220, 1751, 1972, 219, 1647, 139, 51, 74, 73, 403, - /* 1100 */ 617, 542, 180, 600, 60, 1922, 1954, 616, 75, 1645, - /* 1110 */ 514, 222, 1751, 1941, 221, 239, 516, 582, 1751, 45, - /* 1120 */ 317, 1593, 1594, 391, 1936, 389, 385, 381, 378, 375, - /* 1130 */ 263, 519, 1953, 600, 1751, 600, 1988, 1972, 1611, 100, - /* 1140 */ 1955, 620, 1957, 1958, 615, 617, 610, 270, 140, 597, - /* 1150 */ 1922, 2129, 616, 2041, 1932, 1938, 1548, 355, 2037, 1706, - /* 1160 */ 1541, 600, 600, 230, 1751, 610, 1751, 241, 2103, 176, - /* 1170 */ 142, 1322, 611, 50, 144, 598, 276, 1953, 545, 1954, - /* 1180 */ 60, 1988, 268, 252, 100, 1955, 620, 1957, 1958, 615, - /* 1190 */ 660, 610, 1751, 1751, 358, 357, 2129, 600, 2041, 45, - /* 1200 */ 592, 45, 355, 2037, 1389, 11, 10, 661, 644, 96, - /* 1210 */ 1972, 368, 1154, 2060, 2081, 1455, 624, 1382, 617, 93, - /* 1220 */ 211, 584, 272, 1922, 374, 616, 1206, 1591, 1751, 1152, - /* 1230 */ 209, 554, 1492, 246, 1954, 162, 1386, 142, 1973, 372, - /* 1240 */ 1450, 494, 490, 486, 482, 208, 144, 1856, 1635, 126, - /* 1250 */ 1953, 1441, 1381, 288, 1988, 1792, 142, 100, 1955, 620, - /* 1260 */ 1957, 1958, 615, 546, 610, 1972, 546, 2109, 1234, 2016, - /* 1270 */ 2109, 2041, 1135, 617, 579, 355, 2037, 2071, 1922, 251, - /* 1280 */ 616, 81, 2115, 173, 206, 2115, 173, 2110, 567, 1238, - /* 1290 */ 2110, 567, 254, 1, 373, 4, 382, 331, 1245, 606, - /* 1300 */ 377, 1243, 1339, 571, 283, 1953, 186, 1136, 147, 1988, - /* 1310 */ 409, 1403, 100, 1955, 620, 1957, 1958, 615, 1857, 610, - /* 1320 */ 413, 1590, 444, 418, 2014, 1398, 2041, 430, 1849, 437, - /* 1330 */ 355, 2037, 443, 451, 452, 445, 546, 190, 454, 456, - /* 1340 */ 2109, 1404, 457, 466, 1406, 470, 1954, 534, 469, 1405, - /* 1350 */ 196, 205, 199, 198, 204, 2115, 173, 473, 471, 1407, - /* 1360 */ 2110, 567, 1390, 472, 1385, 201, 474, 203, 78, 79, - /* 1370 */ 478, 1109, 207, 197, 495, 496, 1954, 1972, 499, 497, - /* 1380 */ 103, 1741, 1899, 213, 320, 617, 1898, 1393, 1395, 546, - /* 1390 */ 1922, 1737, 616, 2109, 533, 284, 535, 215, 149, 608, - /* 1400 */ 1448, 1449, 1451, 1452, 1453, 1454, 150, 1972, 2115, 173, - /* 1410 */ 228, 536, 1739, 2110, 567, 617, 540, 1953, 1735, 151, - /* 1420 */ 1922, 1988, 616, 152, 100, 1955, 620, 1957, 1958, 615, - /* 1430 */ 231, 610, 1954, 543, 550, 537, 603, 2072, 2041, 590, - /* 1440 */ 2082, 555, 355, 2037, 5, 552, 345, 1953, 2087, 558, - /* 1450 */ 237, 1988, 1954, 240, 101, 1955, 620, 1957, 1958, 615, - /* 1460 */ 2063, 610, 2086, 1972, 564, 548, 551, 549, 2041, 572, - /* 1470 */ 250, 617, 2040, 2037, 247, 245, 1922, 346, 616, 575, - /* 1480 */ 130, 248, 1518, 1972, 249, 163, 1402, 2057, 349, 583, - /* 1490 */ 259, 617, 1408, 1861, 285, 593, 1922, 588, 616, 286, - /* 1500 */ 589, 1870, 1869, 1953, 1868, 2108, 351, 1988, 88, 1752, - /* 1510 */ 101, 1955, 620, 1957, 1958, 615, 287, 610, 90, 594, - /* 1520 */ 1954, 253, 57, 618, 2041, 2022, 2132, 1988, 605, 2037, - /* 1530 */ 101, 1955, 620, 1957, 1958, 615, 1954, 610, 92, 622, - /* 1540 */ 279, 703, 1796, 1722, 2041, 704, 290, 706, 325, 2037, - /* 1550 */ 49, 1972, 314, 322, 323, 294, 1916, 1915, 71, 617, - /* 1560 */ 72, 292, 1914, 1913, 1922, 1910, 616, 1972, 379, 299, - /* 1570 */ 1367, 313, 303, 380, 1368, 617, 179, 1908, 384, 386, - /* 1580 */ 1922, 387, 616, 388, 1907, 390, 1906, 392, 1905, 394, - /* 1590 */ 1904, 1953, 1342, 396, 1341, 1988, 1881, 1954, 159, 1955, - /* 1600 */ 620, 1957, 1958, 615, 1880, 610, 401, 1953, 402, 1879, - /* 1610 */ 1878, 1988, 1842, 1300, 159, 1955, 620, 1957, 1958, 615, - /* 1620 */ 1841, 610, 1839, 136, 1838, 1837, 1840, 1836, 1972, 184, - /* 1630 */ 419, 1830, 421, 1829, 1828, 1827, 617, 1835, 1833, 547, - /* 1640 */ 2078, 1922, 1954, 616, 1832, 1831, 1826, 1825, 1824, 1823, - /* 1650 */ 1822, 1821, 1820, 1819, 1818, 1817, 2079, 1816, 1815, 138, - /* 1660 */ 1814, 1813, 1812, 1811, 1810, 1302, 1809, 1808, 1953, 1807, - /* 1670 */ 1806, 447, 1988, 1972, 1181, 305, 1955, 620, 1957, 1958, - /* 1680 */ 615, 617, 610, 1805, 1669, 1668, 1922, 1666, 616, 1630, - /* 1690 */ 191, 1095, 1094, 1629, 192, 1894, 1888, 1877, 194, 202, - /* 1700 */ 1876, 1859, 1730, 1954, 69, 1128, 1942, 1665, 1663, 1661, - /* 1710 */ 1659, 70, 168, 1953, 479, 195, 1657, 1988, 462, 563, - /* 1720 */ 160, 1955, 620, 1957, 1958, 615, 1954, 610, 464, 200, - /* 1730 */ 480, 481, 1644, 483, 1972, 1643, 484, 1626, 485, 350, - /* 1740 */ 487, 491, 617, 489, 1732, 1249, 59, 1922, 1731, 616, - /* 1750 */ 1250, 488, 493, 1172, 1171, 1170, 1169, 1972, 675, 492, - /* 1760 */ 1166, 677, 1164, 1165, 1163, 614, 1655, 340, 1648, 341, - /* 1770 */ 1922, 1646, 616, 2131, 1953, 212, 517, 342, 1988, 1625, - /* 1780 */ 1624, 312, 1955, 620, 1957, 1958, 615, 1954, 610, 520, - /* 1790 */ 1623, 522, 524, 102, 526, 1357, 1356, 1953, 530, 1893, - /* 1800 */ 1348, 1988, 1887, 53, 311, 1955, 620, 1957, 1958, 615, - /* 1810 */ 1875, 610, 1873, 2007, 538, 1874, 2114, 1954, 1972, 17, - /* 1820 */ 1359, 14, 56, 360, 244, 24, 617, 1563, 26, 236, - /* 1830 */ 243, 1922, 238, 616, 1547, 1540, 161, 242, 1943, 28, - /* 1840 */ 1954, 27, 18, 539, 84, 61, 1583, 1584, 1972, 19, - /* 1850 */ 15, 232, 1578, 362, 343, 1577, 617, 347, 1953, 153, - /* 1860 */ 1582, 1922, 1988, 616, 1581, 312, 1955, 620, 1957, 1958, - /* 1870 */ 615, 1972, 610, 348, 256, 55, 1872, 1515, 1514, 617, - /* 1880 */ 164, 544, 1871, 261, 1922, 1954, 616, 1858, 1953, 20, - /* 1890 */ 87, 264, 1988, 262, 1545, 312, 1955, 620, 1957, 1958, - /* 1900 */ 615, 1954, 610, 269, 86, 93, 89, 274, 21, 10, - /* 1910 */ 1391, 532, 1445, 1991, 609, 1988, 1972, 271, 307, 1955, - /* 1920 */ 620, 1957, 1958, 615, 617, 610, 1443, 34, 591, 1922, - /* 1930 */ 1442, 616, 1972, 165, 13, 22, 54, 177, 1423, 1415, - /* 1940 */ 617, 23, 625, 621, 1235, 1922, 623, 616, 363, 1467, - /* 1950 */ 1232, 628, 627, 630, 1954, 1229, 1953, 1477, 631, 633, - /* 1960 */ 1988, 1223, 634, 296, 1955, 620, 1957, 1958, 615, 1221, - /* 1970 */ 610, 619, 1953, 636, 637, 1212, 1988, 1227, 643, 297, - /* 1980 */ 1955, 620, 1957, 1958, 615, 1972, 610, 8, 1226, 1225, - /* 1990 */ 1466, 1224, 94, 617, 277, 95, 1244, 1240, 1922, 1954, - /* 2000 */ 616, 68, 1160, 1126, 653, 1159, 1158, 1157, 1156, 1155, - /* 2010 */ 1179, 1153, 1151, 1150, 1149, 665, 1147, 1146, 1145, 1144, - /* 2020 */ 1143, 1142, 1141, 1174, 278, 1953, 1176, 1138, 1137, 1988, - /* 2030 */ 1972, 1134, 298, 1955, 620, 1957, 1958, 615, 617, 610, - /* 2040 */ 1133, 1132, 1131, 1922, 1662, 616, 685, 686, 687, 1660, - /* 2050 */ 689, 690, 1954, 691, 1658, 693, 694, 695, 1656, 697, - /* 2060 */ 698, 699, 1642, 701, 1084, 1622, 709, 281, 1954, 705, - /* 2070 */ 1953, 1597, 1377, 291, 1988, 1597, 708, 304, 1955, 620, - /* 2080 */ 1957, 1958, 615, 1972, 610, 1597, 1597, 1597, 1597, 1597, - /* 2090 */ 1597, 617, 1597, 1597, 1597, 1597, 1922, 1597, 616, 1972, - /* 2100 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 617, 1597, 1597, - /* 2110 */ 1597, 1597, 1922, 1954, 616, 1597, 1597, 1597, 1597, 1597, - /* 2120 */ 1597, 1597, 1597, 1953, 1597, 1597, 1597, 1988, 1597, 1597, - /* 2130 */ 308, 1955, 620, 1957, 1958, 615, 1597, 610, 1597, 1953, - /* 2140 */ 1597, 1597, 1597, 1988, 1972, 1597, 300, 1955, 620, 1957, - /* 2150 */ 1958, 615, 617, 610, 1597, 1597, 1597, 1922, 1597, 616, - /* 2160 */ 1597, 1597, 1597, 1597, 1597, 1597, 1954, 1597, 1597, 1597, - /* 2170 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, - /* 2180 */ 1597, 1597, 1954, 1597, 1953, 1597, 1597, 1597, 1988, 1597, - /* 2190 */ 1597, 309, 1955, 620, 1957, 1958, 615, 1972, 610, 1597, - /* 2200 */ 1597, 1597, 1597, 1597, 1597, 617, 1597, 1597, 1597, 1597, - /* 2210 */ 1922, 1597, 616, 1972, 1597, 1597, 1597, 1597, 1597, 1597, - /* 2220 */ 1597, 617, 1597, 1597, 1597, 1597, 1922, 1954, 616, 1597, - /* 2230 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1953, 1597, 1597, - /* 2240 */ 1597, 1988, 1597, 1597, 301, 1955, 620, 1957, 1958, 615, - /* 2250 */ 1954, 610, 1597, 1953, 1597, 1597, 1597, 1988, 1972, 1597, - /* 2260 */ 310, 1955, 620, 1957, 1958, 615, 617, 610, 1597, 1597, - /* 2270 */ 1597, 1922, 1597, 616, 1597, 1597, 1597, 1597, 1597, 1597, - /* 2280 */ 1954, 1972, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 617, - /* 2290 */ 1597, 1597, 1597, 1597, 1922, 1597, 616, 1597, 1953, 1597, - /* 2300 */ 1597, 1597, 1988, 1597, 1597, 302, 1955, 620, 1957, 1958, - /* 2310 */ 615, 1972, 610, 1597, 1597, 1597, 1597, 1597, 1597, 617, - /* 2320 */ 1597, 1953, 1597, 1597, 1922, 1988, 616, 1597, 315, 1955, - /* 2330 */ 620, 1957, 1958, 615, 1597, 610, 1597, 1597, 1597, 1597, - /* 2340 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, - /* 2350 */ 1597, 1953, 1597, 1597, 1597, 1988, 1954, 1597, 316, 1955, - /* 2360 */ 620, 1957, 1958, 615, 1597, 610, 1597, 1597, 1597, 1597, - /* 2370 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1954, 1597, - /* 2380 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1972, 1597, 1597, - /* 2390 */ 1597, 1597, 1597, 1597, 1597, 617, 1597, 1597, 1597, 1597, - /* 2400 */ 1922, 1597, 616, 1597, 1597, 1597, 1597, 1597, 1597, 1972, - /* 2410 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 617, 1597, 1597, - /* 2420 */ 1597, 1597, 1922, 1597, 616, 1597, 1597, 1953, 1597, 1597, - /* 2430 */ 1597, 1988, 1597, 1954, 1966, 1955, 620, 1957, 1958, 615, - /* 2440 */ 1597, 610, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1953, - /* 2450 */ 1597, 1597, 1597, 1988, 1597, 1597, 1965, 1955, 620, 1957, - /* 2460 */ 1958, 615, 1597, 610, 1972, 1597, 1597, 1597, 1597, 1597, - /* 2470 */ 1597, 1597, 617, 1597, 1597, 1597, 1597, 1922, 1954, 616, - /* 2480 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, - /* 2490 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, - /* 2500 */ 1597, 1597, 1597, 1597, 1953, 1597, 1597, 1597, 1988, 1972, - /* 2510 */ 1597, 1964, 1955, 620, 1957, 1958, 615, 617, 610, 1597, - /* 2520 */ 1597, 1597, 1922, 1954, 616, 1597, 1597, 1597, 1597, 1597, - /* 2530 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1954, - /* 2540 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1953, - /* 2550 */ 1597, 1597, 1597, 1988, 1972, 1597, 327, 1955, 620, 1957, - /* 2560 */ 1958, 615, 617, 610, 1597, 1597, 1597, 1922, 1597, 616, - /* 2570 */ 1972, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 617, 1597, - /* 2580 */ 1597, 1597, 1597, 1922, 1954, 616, 1597, 1597, 1597, 1597, - /* 2590 */ 1597, 1597, 1597, 1597, 1953, 1597, 1597, 1597, 1988, 1597, - /* 2600 */ 1597, 328, 1955, 620, 1957, 1958, 615, 1954, 610, 1597, - /* 2610 */ 1953, 1597, 1597, 1597, 1988, 1972, 1597, 324, 1955, 620, - /* 2620 */ 1957, 1958, 615, 617, 610, 1597, 1597, 1597, 1922, 1597, - /* 2630 */ 616, 1597, 1597, 1597, 1597, 1597, 1597, 1954, 1972, 1597, - /* 2640 */ 1597, 1597, 1597, 1597, 1597, 1597, 617, 1597, 1597, 1597, - /* 2650 */ 1597, 1922, 1597, 616, 1597, 1953, 1597, 1597, 1597, 1988, - /* 2660 */ 1597, 1597, 329, 1955, 620, 1957, 1958, 615, 1972, 610, - /* 2670 */ 1597, 1597, 1597, 1597, 1597, 1597, 617, 1597, 618, 1597, - /* 2680 */ 1597, 1922, 1988, 616, 1597, 307, 1955, 620, 1957, 1958, - /* 2690 */ 615, 1597, 610, 1597, 1597, 1597, 1597, 1597, 1597, 1597, - /* 2700 */ 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1597, 1953, 1597, - /* 2710 */ 1597, 1597, 1988, 1597, 1597, 306, 1955, 620, 1957, 1958, - /* 2720 */ 615, 1597, 610, + /* 0 */ 462, 369, 463, 1644, 1807, 1809, 403, 1965, 1752, 33, + /* 10 */ 276, 170, 43, 41, 1533, 1631, 1750, 570, 168, 1947, + /* 20 */ 364, 2122, 1383, 1951, 1801, 42, 40, 39, 38, 37, + /* 30 */ 1965, 604, 1606, 1463, 1947, 1381, 569, 174, 1983, 334, + /* 40 */ 1861, 2123, 571, 1808, 1809, 52, 621, 590, 549, 1943, + /* 50 */ 1949, 1933, 2122, 620, 11, 10, 1408, 588, 1458, 1933, + /* 60 */ 614, 1983, 1761, 16, 1943, 1949, 346, 2128, 174, 585, + /* 70 */ 1389, 1409, 2123, 571, 1933, 614, 620, 461, 1964, 603, + /* 80 */ 466, 1650, 1999, 43, 41, 161, 1966, 624, 1968, 1969, + /* 90 */ 619, 364, 614, 1383, 478, 12, 1870, 379, 603, 549, + /* 100 */ 604, 1964, 159, 2122, 1463, 1999, 1381, 1715, 101, 1966, + /* 110 */ 624, 1968, 1969, 619, 124, 614, 259, 711, 2128, 174, + /* 120 */ 171, 501, 2052, 2123, 571, 228, 358, 2048, 1791, 1458, + /* 130 */ 603, 1761, 1465, 1466, 16, 97, 604, 572, 2143, 549, + /* 140 */ 176, 1389, 582, 2122, 471, 94, 463, 1644, 2078, 1506, + /* 150 */ 124, 157, 1180, 59, 46, 86, 296, 506, 2128, 174, + /* 160 */ 591, 1439, 1448, 2123, 571, 470, 12, 1761, 466, 1650, + /* 170 */ 294, 67, 355, 132, 66, 1874, 2067, 516, 515, 514, + /* 180 */ 1384, 1677, 1382, 1263, 1264, 129, 510, 1182, 711, 1952, + /* 190 */ 509, 356, 194, 458, 456, 508, 513, 1316, 1317, 156, + /* 200 */ 1947, 507, 2064, 1465, 1466, 46, 1387, 1388, 1763, 1438, + /* 210 */ 1441, 1442, 1443, 1444, 1445, 1446, 1447, 616, 612, 1456, + /* 220 */ 1457, 1459, 1460, 1461, 1462, 1464, 1467, 2, 59, 604, + /* 230 */ 1943, 1949, 1439, 1448, 256, 2060, 581, 589, 125, 580, + /* 240 */ 1410, 614, 2122, 179, 468, 1408, 516, 515, 514, 168, + /* 250 */ 464, 1384, 226, 1382, 129, 510, 50, 569, 174, 509, + /* 260 */ 1761, 548, 2123, 571, 508, 513, 480, 100, 36, 35, + /* 270 */ 507, 1862, 42, 40, 39, 38, 37, 1387, 1388, 377, + /* 280 */ 1438, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 616, 612, + /* 290 */ 1456, 1457, 1459, 1460, 1461, 1462, 1464, 1467, 2, 521, + /* 300 */ 9, 43, 41, 177, 177, 75, 74, 406, 92, 364, + /* 310 */ 181, 1383, 83, 322, 531, 1983, 344, 98, 532, 1965, + /* 320 */ 59, 549, 1463, 564, 1381, 2122, 1814, 145, 225, 318, + /* 330 */ 1754, 133, 394, 357, 392, 388, 384, 381, 378, 1753, + /* 340 */ 2128, 174, 1812, 524, 1951, 2123, 571, 1458, 518, 367, + /* 350 */ 1983, 63, 16, 224, 370, 1947, 1571, 156, 621, 1389, + /* 360 */ 2127, 658, 156, 1933, 563, 620, 1763, 39, 38, 37, + /* 370 */ 590, 1763, 43, 41, 1468, 565, 59, 1410, 177, 51, + /* 380 */ 364, 1965, 1383, 258, 12, 1943, 1949, 347, 59, 65, + /* 390 */ 1964, 81, 64, 1463, 1999, 1381, 614, 101, 1966, 624, + /* 400 */ 1968, 1969, 619, 9, 614, 128, 711, 135, 1494, 142, + /* 410 */ 2023, 2052, 1983, 1739, 1756, 358, 2048, 599, 1458, 1870, + /* 420 */ 621, 1465, 1466, 267, 268, 1933, 1094, 620, 266, 1737, + /* 430 */ 1389, 1220, 646, 645, 644, 1224, 643, 1226, 1227, 642, + /* 440 */ 1229, 639, 59, 1235, 636, 1237, 1238, 633, 630, 649, + /* 450 */ 1439, 1448, 1964, 1594, 1409, 44, 1999, 1608, 186, 102, + /* 460 */ 1966, 624, 1968, 1969, 619, 1096, 614, 1099, 1100, 1384, + /* 470 */ 177, 1382, 402, 2052, 401, 480, 1408, 711, 2049, 409, + /* 480 */ 30, 123, 122, 121, 120, 119, 118, 117, 116, 115, + /* 490 */ 1499, 658, 1465, 1466, 78, 1387, 1388, 77, 1438, 1441, + /* 500 */ 1442, 1443, 1444, 1445, 1446, 1447, 616, 612, 1456, 1457, + /* 510 */ 1459, 1460, 1461, 1462, 1464, 1467, 2, 512, 511, 320, + /* 520 */ 258, 1439, 1448, 1609, 114, 604, 177, 113, 112, 111, + /* 530 */ 110, 109, 108, 107, 106, 105, 81, 1407, 177, 407, + /* 540 */ 1384, 158, 1382, 1620, 114, 1389, 1630, 113, 112, 111, + /* 550 */ 110, 109, 108, 107, 106, 105, 1761, 36, 35, 1757, + /* 560 */ 1965, 42, 40, 39, 38, 37, 1387, 1388, 47, 1438, + /* 570 */ 1441, 1442, 1443, 1444, 1445, 1446, 1447, 616, 612, 1456, + /* 580 */ 1457, 1459, 1460, 1461, 1462, 1464, 1467, 2, 43, 41, + /* 590 */ 1933, 1983, 177, 25, 410, 445, 364, 591, 1383, 585, + /* 600 */ 339, 1113, 670, 1112, 1933, 560, 620, 411, 9, 1463, + /* 610 */ 7, 1381, 1875, 1814, 1814, 606, 211, 2024, 36, 35, + /* 620 */ 368, 331, 42, 40, 39, 38, 37, 6, 1629, 1812, + /* 630 */ 1812, 1964, 1114, 1951, 1458, 1999, 530, 582, 101, 1966, + /* 640 */ 624, 1968, 1969, 619, 1947, 614, 1389, 1560, 604, 528, + /* 650 */ 171, 526, 2052, 190, 189, 582, 358, 2048, 2067, 43, + /* 660 */ 41, 340, 408, 338, 337, 1746, 503, 364, 132, 1383, + /* 670 */ 505, 44, 1933, 327, 1943, 1949, 359, 1748, 2079, 1761, + /* 680 */ 1463, 398, 1381, 1411, 2063, 614, 132, 570, 1537, 566, + /* 690 */ 561, 2122, 504, 711, 1408, 557, 556, 1558, 1559, 1561, + /* 700 */ 1562, 1563, 544, 400, 396, 1458, 569, 174, 1465, 1466, + /* 710 */ 1628, 2123, 571, 227, 1492, 2127, 1627, 1389, 177, 2122, + /* 720 */ 36, 35, 604, 1744, 42, 40, 39, 38, 37, 173, + /* 730 */ 2060, 2061, 1411, 130, 2065, 2126, 417, 1439, 1448, 2123, + /* 740 */ 2125, 2127, 12, 2067, 1473, 2122, 584, 172, 2060, 2061, + /* 750 */ 1408, 130, 2065, 1761, 1933, 231, 1384, 608, 1382, 2024, + /* 760 */ 1933, 2126, 505, 1626, 711, 2123, 2124, 36, 35, 2062, + /* 770 */ 1493, 42, 40, 39, 38, 37, 1359, 1360, 134, 1465, + /* 780 */ 1466, 2023, 1387, 1388, 504, 1438, 1441, 1442, 1443, 1444, + /* 790 */ 1445, 1446, 1447, 616, 612, 1456, 1457, 1459, 1460, 1461, + /* 800 */ 1462, 1464, 1467, 2, 319, 2126, 1406, 1933, 1439, 1448, + /* 810 */ 1113, 615, 1112, 439, 682, 680, 452, 36, 35, 451, + /* 820 */ 1857, 42, 40, 39, 38, 37, 183, 1384, 1674, 1382, + /* 830 */ 650, 182, 1526, 1805, 423, 1440, 453, 1625, 1530, 425, + /* 840 */ 1624, 1114, 32, 362, 1487, 1488, 1489, 1490, 1491, 1495, + /* 850 */ 1496, 1497, 1498, 1387, 1388, 1549, 1438, 1441, 1442, 1443, + /* 860 */ 1444, 1445, 1446, 1447, 616, 612, 1456, 1457, 1459, 1460, + /* 870 */ 1461, 1462, 1464, 1467, 2, 236, 29, 1623, 648, 1622, + /* 880 */ 335, 1933, 36, 35, 1933, 1621, 42, 40, 39, 38, + /* 890 */ 37, 1440, 413, 688, 687, 686, 685, 374, 1619, 684, + /* 900 */ 683, 136, 678, 677, 676, 675, 674, 673, 672, 149, + /* 910 */ 668, 667, 666, 373, 372, 663, 662, 661, 660, 659, + /* 920 */ 1618, 1933, 449, 1933, 1965, 444, 443, 442, 441, 438, + /* 930 */ 437, 436, 435, 434, 430, 429, 428, 427, 336, 420, + /* 940 */ 419, 418, 1933, 415, 414, 333, 1617, 1965, 1616, 1857, + /* 950 */ 1857, 290, 361, 360, 1791, 1983, 1615, 604, 604, 1411, + /* 960 */ 184, 188, 1397, 621, 1933, 604, 604, 1614, 1933, 1738, + /* 970 */ 620, 431, 432, 1463, 156, 1390, 1408, 582, 1983, 371, + /* 980 */ 479, 1601, 671, 1764, 1731, 1814, 621, 2092, 1761, 1761, + /* 990 */ 1933, 1933, 1933, 620, 376, 1964, 1761, 1761, 1458, 1999, + /* 1000 */ 1933, 1813, 101, 1966, 624, 1968, 1969, 619, 132, 614, + /* 1010 */ 1389, 1933, 1099, 1100, 2142, 1613, 2052, 1716, 1964, 1612, + /* 1020 */ 358, 2048, 1999, 1844, 1611, 101, 1966, 624, 1968, 1969, + /* 1030 */ 619, 2086, 614, 1965, 574, 31, 549, 2142, 253, 2052, + /* 1040 */ 2122, 36, 35, 358, 2048, 42, 40, 39, 38, 37, + /* 1050 */ 654, 2072, 1526, 1805, 2116, 2128, 174, 610, 1920, 1933, + /* 1060 */ 2123, 571, 655, 1933, 1983, 1805, 573, 212, 1933, 175, + /* 1070 */ 2060, 2061, 621, 130, 2065, 210, 656, 1933, 1600, 620, + /* 1080 */ 1529, 1664, 163, 1657, 48, 138, 3, 126, 497, 493, + /* 1090 */ 489, 485, 209, 68, 558, 147, 146, 653, 652, 651, + /* 1100 */ 144, 577, 235, 517, 1964, 519, 386, 534, 1999, 533, + /* 1110 */ 1965, 101, 1966, 624, 1968, 1969, 619, 1440, 614, 604, + /* 1120 */ 1398, 217, 1393, 2142, 215, 2052, 1603, 1604, 82, 358, + /* 1130 */ 2048, 207, 1392, 1758, 1965, 664, 219, 234, 1383, 218, + /* 1140 */ 2071, 1983, 61, 76, 61, 240, 1401, 1403, 656, 621, + /* 1150 */ 1761, 1381, 604, 1655, 1933, 1391, 620, 1161, 612, 1456, + /* 1160 */ 1457, 1459, 1460, 1461, 1462, 1983, 140, 147, 146, 653, + /* 1170 */ 652, 651, 144, 621, 426, 522, 84, 611, 1933, 1965, + /* 1180 */ 620, 1964, 247, 1761, 221, 1999, 1389, 220, 101, 1966, + /* 1190 */ 624, 1968, 1969, 619, 1557, 614, 1556, 242, 206, 200, + /* 1200 */ 2027, 205, 2052, 45, 476, 1964, 358, 2048, 1984, 1999, + /* 1210 */ 1983, 1736, 101, 1966, 624, 1968, 1969, 619, 621, 614, + /* 1220 */ 198, 11, 10, 1933, 2025, 620, 2052, 375, 1866, 264, + /* 1230 */ 358, 2048, 604, 711, 1965, 36, 35, 604, 1645, 42, + /* 1240 */ 40, 39, 38, 37, 2082, 141, 545, 143, 145, 61, + /* 1250 */ 1964, 586, 604, 604, 1999, 1329, 575, 101, 1966, 624, + /* 1260 */ 1968, 1969, 619, 1761, 614, 1983, 271, 601, 1761, 607, + /* 1270 */ 1802, 2052, 604, 621, 223, 358, 2048, 222, 1933, 1395, + /* 1280 */ 620, 269, 537, 1761, 1761, 255, 602, 36, 35, 583, + /* 1290 */ 1965, 42, 40, 39, 38, 37, 1384, 596, 1382, 273, + /* 1300 */ 1213, 1500, 1394, 1761, 45, 1964, 1954, 45, 628, 1999, + /* 1310 */ 143, 145, 102, 1966, 624, 1968, 1969, 619, 656, 614, + /* 1320 */ 1484, 1983, 1387, 1388, 549, 578, 2052, 1651, 2122, 621, + /* 1330 */ 2051, 2048, 127, 604, 1933, 1965, 620, 147, 146, 653, + /* 1340 */ 652, 651, 144, 2128, 174, 665, 143, 277, 2123, 571, + /* 1350 */ 1142, 252, 1, 4, 1956, 380, 1449, 385, 1965, 289, + /* 1360 */ 1241, 1964, 1245, 1252, 1761, 1999, 1983, 1159, 102, 1966, + /* 1370 */ 624, 1968, 1969, 619, 621, 614, 706, 332, 1346, 1933, + /* 1380 */ 284, 620, 2052, 187, 1250, 1143, 609, 2048, 412, 1983, + /* 1390 */ 155, 1411, 1867, 416, 447, 421, 1406, 618, 148, 433, + /* 1400 */ 1859, 454, 1933, 440, 620, 446, 622, 191, 448, 455, + /* 1410 */ 1999, 457, 459, 102, 1966, 624, 1968, 1969, 619, 1412, + /* 1420 */ 614, 460, 469, 1414, 473, 472, 1413, 2052, 197, 1964, + /* 1430 */ 199, 326, 2048, 1999, 1415, 474, 312, 1966, 624, 1968, + /* 1440 */ 1969, 619, 617, 614, 605, 2017, 1965, 477, 202, 475, + /* 1450 */ 204, 79, 481, 80, 208, 500, 1116, 1909, 538, 498, + /* 1460 */ 502, 499, 1965, 1751, 536, 321, 214, 104, 285, 539, + /* 1470 */ 559, 2083, 229, 1747, 1908, 2093, 216, 1983, 540, 232, + /* 1480 */ 546, 2098, 150, 151, 594, 621, 1749, 1745, 152, 153, + /* 1490 */ 1933, 2097, 620, 1983, 5, 568, 2074, 246, 554, 552, + /* 1500 */ 543, 621, 249, 164, 551, 553, 1933, 248, 620, 555, + /* 1510 */ 348, 349, 562, 250, 579, 2145, 576, 1964, 1965, 1526, + /* 1520 */ 131, 1999, 2121, 238, 160, 1966, 624, 1968, 1969, 619, + /* 1530 */ 241, 614, 1410, 1964, 587, 254, 260, 1999, 352, 1416, + /* 1540 */ 160, 1966, 624, 1968, 1969, 619, 1965, 614, 251, 1983, + /* 1550 */ 2068, 1871, 286, 592, 593, 1880, 287, 621, 1879, 1878, + /* 1560 */ 354, 597, 1933, 598, 620, 550, 2089, 89, 288, 91, + /* 1570 */ 58, 2033, 1762, 93, 626, 291, 707, 1983, 1806, 1732, + /* 1580 */ 708, 280, 2090, 710, 49, 621, 315, 295, 300, 1964, + /* 1590 */ 1933, 314, 620, 1999, 1927, 323, 306, 1966, 624, 1968, + /* 1600 */ 1969, 619, 324, 614, 304, 293, 1926, 72, 1965, 1925, + /* 1610 */ 1924, 73, 1921, 382, 1375, 383, 1376, 1964, 180, 387, + /* 1620 */ 714, 1999, 1919, 389, 161, 1966, 624, 1968, 1969, 619, + /* 1630 */ 390, 614, 391, 1918, 283, 393, 1917, 395, 1916, 1983, + /* 1640 */ 567, 397, 1915, 399, 353, 1349, 1348, 621, 1891, 167, + /* 1650 */ 1890, 405, 1933, 404, 620, 704, 700, 696, 692, 281, + /* 1660 */ 1889, 1888, 1307, 1965, 185, 137, 1848, 1847, 1850, 1846, + /* 1670 */ 1845, 1843, 1842, 1841, 422, 1840, 424, 2144, 1852, 1964, + /* 1680 */ 1851, 1849, 1839, 1999, 1838, 1837, 313, 1966, 624, 1968, + /* 1690 */ 1969, 619, 1836, 614, 1983, 99, 1835, 1834, 274, 1833, + /* 1700 */ 1832, 1831, 618, 1830, 1829, 1828, 1827, 1933, 1826, 620, + /* 1710 */ 1825, 1824, 1823, 1822, 1821, 1820, 139, 1309, 1819, 1818, + /* 1720 */ 1817, 450, 1816, 1815, 1188, 1965, 70, 169, 195, 1639, + /* 1730 */ 1102, 600, 1679, 1678, 1964, 192, 1676, 193, 1999, 1640, + /* 1740 */ 1953, 312, 1966, 624, 1968, 1969, 619, 1904, 614, 465, + /* 1750 */ 2018, 1101, 1898, 1887, 467, 1965, 1983, 196, 203, 1886, + /* 1760 */ 71, 363, 1869, 201, 621, 1740, 1675, 1673, 261, 1933, + /* 1770 */ 482, 620, 1671, 1135, 1669, 483, 486, 484, 487, 488, + /* 1780 */ 490, 492, 491, 1667, 494, 1353, 1983, 230, 1654, 496, + /* 1790 */ 1653, 365, 495, 1636, 621, 1742, 1964, 1256, 60, 1933, + /* 1800 */ 1999, 620, 1741, 313, 1966, 624, 1968, 1969, 619, 1171, + /* 1810 */ 614, 1257, 1179, 1965, 1178, 1177, 1176, 679, 1665, 1173, + /* 1820 */ 1172, 1170, 681, 341, 1658, 342, 1964, 213, 1656, 1965, + /* 1830 */ 1999, 343, 520, 313, 1966, 624, 1968, 1969, 619, 523, + /* 1840 */ 614, 1635, 525, 1634, 1983, 527, 1633, 529, 1364, 103, + /* 1850 */ 1365, 1363, 621, 1367, 1903, 24, 1355, 1933, 1897, 620, + /* 1860 */ 1983, 53, 541, 1885, 1883, 2127, 17, 14, 621, 18, + /* 1870 */ 56, 154, 62, 1933, 1965, 620, 57, 244, 245, 28, + /* 1880 */ 15, 1954, 19, 1588, 535, 1573, 26, 237, 1999, 162, + /* 1890 */ 1965, 308, 1966, 624, 1968, 1969, 619, 547, 614, 257, + /* 1900 */ 1964, 239, 1555, 243, 1999, 1983, 542, 297, 1966, 624, + /* 1910 */ 1968, 1969, 619, 621, 614, 27, 233, 345, 1933, 1548, + /* 1920 */ 620, 1983, 85, 1587, 350, 1592, 55, 1591, 351, 621, + /* 1930 */ 165, 1884, 1593, 1594, 1933, 1523, 620, 1882, 1522, 1881, + /* 1940 */ 20, 262, 1868, 263, 265, 1964, 1553, 88, 270, 1999, + /* 1950 */ 87, 90, 298, 1966, 624, 1968, 1969, 619, 275, 614, + /* 1960 */ 21, 1964, 595, 272, 94, 1999, 10, 1965, 299, 1966, + /* 1970 */ 624, 1968, 1969, 619, 54, 614, 1475, 1399, 1431, 2002, + /* 1980 */ 166, 1453, 613, 178, 625, 8, 1474, 627, 366, 631, + /* 1990 */ 34, 1965, 1451, 1450, 13, 22, 634, 1423, 1983, 23, + /* 2000 */ 637, 1242, 629, 1485, 640, 1239, 621, 632, 623, 1236, + /* 2010 */ 635, 1933, 638, 620, 1230, 1228, 641, 1234, 1219, 95, + /* 2020 */ 278, 1233, 1983, 96, 1251, 1232, 1247, 647, 1167, 1231, + /* 2030 */ 621, 1133, 1166, 69, 657, 1933, 1165, 620, 1964, 669, + /* 2040 */ 1164, 1163, 1999, 1162, 1160, 305, 1966, 624, 1968, 1969, + /* 2050 */ 619, 1158, 614, 1965, 1157, 1156, 1186, 279, 1154, 1153, + /* 2060 */ 1152, 1151, 1964, 1150, 1149, 1148, 1999, 1181, 1183, 309, + /* 2070 */ 1966, 624, 1968, 1969, 619, 1145, 614, 1144, 1141, 1140, + /* 2080 */ 1139, 1138, 1672, 1965, 1983, 689, 690, 691, 1670, 694, + /* 2090 */ 693, 695, 621, 1668, 697, 698, 699, 1933, 1666, 620, + /* 2100 */ 701, 702, 703, 1652, 705, 1091, 1632, 282, 709, 1607, + /* 2110 */ 1607, 1385, 292, 712, 1983, 713, 1607, 1607, 1607, 1607, + /* 2120 */ 1607, 1607, 621, 1607, 1964, 1607, 1607, 1933, 1999, 620, + /* 2130 */ 1607, 301, 1966, 624, 1968, 1969, 619, 1607, 614, 1607, + /* 2140 */ 1607, 1965, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2150 */ 1607, 1607, 1607, 1607, 1964, 1607, 1607, 1965, 1999, 1607, + /* 2160 */ 1607, 310, 1966, 624, 1968, 1969, 619, 1607, 614, 1607, + /* 2170 */ 1607, 1607, 1983, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2180 */ 621, 1607, 1607, 1607, 1607, 1933, 1607, 620, 1983, 1607, + /* 2190 */ 1607, 1607, 1607, 1607, 1607, 1607, 621, 1607, 1607, 1607, + /* 2200 */ 1607, 1933, 1965, 620, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2210 */ 1607, 1607, 1964, 1607, 1607, 1607, 1999, 1607, 1965, 302, + /* 2220 */ 1966, 624, 1968, 1969, 619, 1607, 614, 1607, 1964, 1607, + /* 2230 */ 1607, 1607, 1999, 1983, 1607, 311, 1966, 624, 1968, 1969, + /* 2240 */ 619, 621, 614, 1607, 1607, 1607, 1933, 1607, 620, 1983, + /* 2250 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 621, 1607, 1607, + /* 2260 */ 1607, 1607, 1933, 1607, 620, 1607, 1607, 1607, 1607, 1607, + /* 2270 */ 1607, 1607, 1607, 1964, 1607, 1607, 1607, 1999, 1607, 1607, + /* 2280 */ 303, 1966, 624, 1968, 1969, 619, 1607, 614, 1607, 1964, + /* 2290 */ 1607, 1607, 1607, 1999, 1607, 1965, 316, 1966, 624, 1968, + /* 2300 */ 1969, 619, 1607, 614, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2310 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1965, + /* 2320 */ 1607, 1607, 1607, 1607, 1607, 1607, 1983, 1607, 1607, 1607, + /* 2330 */ 1607, 1607, 1607, 1607, 621, 1607, 1607, 1607, 1607, 1933, + /* 2340 */ 1607, 620, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2350 */ 1983, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 621, 1607, + /* 2360 */ 1607, 1607, 1607, 1933, 1607, 620, 1964, 1607, 1607, 1607, + /* 2370 */ 1999, 1607, 1607, 317, 1966, 624, 1968, 1969, 619, 1607, + /* 2380 */ 614, 1965, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2390 */ 1964, 1607, 1607, 1607, 1999, 1607, 1607, 1977, 1966, 624, + /* 2400 */ 1968, 1969, 619, 1607, 614, 1607, 1607, 1607, 1607, 1607, + /* 2410 */ 1607, 1965, 1983, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2420 */ 621, 1607, 1607, 1607, 1607, 1933, 1607, 620, 1607, 1607, + /* 2430 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2440 */ 1607, 1607, 1983, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2450 */ 621, 1607, 1964, 1607, 1607, 1933, 1999, 620, 1607, 1976, + /* 2460 */ 1966, 624, 1968, 1969, 619, 1607, 614, 1607, 1607, 1965, + /* 2470 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2480 */ 1607, 1607, 1964, 1607, 1607, 1965, 1999, 1607, 1607, 1975, + /* 2490 */ 1966, 624, 1968, 1969, 619, 1607, 614, 1607, 1607, 1607, + /* 2500 */ 1983, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 621, 1607, + /* 2510 */ 1607, 1607, 1607, 1933, 1607, 620, 1983, 1607, 1607, 1607, + /* 2520 */ 1607, 1607, 1607, 1607, 621, 1607, 1607, 1607, 1607, 1933, + /* 2530 */ 1965, 620, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2540 */ 1964, 1607, 1607, 1607, 1999, 1607, 1965, 328, 1966, 624, + /* 2550 */ 1968, 1969, 619, 1607, 614, 1607, 1964, 1607, 1607, 1607, + /* 2560 */ 1999, 1983, 1607, 329, 1966, 624, 1968, 1969, 619, 621, + /* 2570 */ 614, 1607, 1607, 1607, 1933, 1607, 620, 1983, 1607, 1607, + /* 2580 */ 1607, 1607, 1607, 1607, 1607, 621, 1607, 1607, 1607, 1607, + /* 2590 */ 1933, 1607, 620, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2600 */ 1607, 1964, 1607, 1607, 1607, 1999, 1607, 1607, 325, 1966, + /* 2610 */ 624, 1968, 1969, 619, 1607, 614, 1607, 1964, 1607, 1607, + /* 2620 */ 1607, 1999, 1607, 1965, 330, 1966, 624, 1968, 1969, 619, + /* 2630 */ 1607, 614, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, + /* 2640 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1965, 1607, 1607, + /* 2650 */ 1607, 1607, 1607, 1607, 1983, 1607, 1607, 1607, 1607, 1607, + /* 2660 */ 1607, 1607, 621, 1607, 1607, 1607, 1607, 1933, 1607, 620, + /* 2670 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1983, 1607, + /* 2680 */ 1607, 1607, 1607, 1607, 1607, 1607, 621, 1607, 1607, 1607, + /* 2690 */ 1607, 1933, 1607, 620, 622, 1607, 1607, 1607, 1999, 1607, + /* 2700 */ 1607, 308, 1966, 624, 1968, 1969, 619, 1607, 614, 1607, + /* 2710 */ 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1607, 1964, 1607, + /* 2720 */ 1607, 1607, 1999, 1607, 1607, 307, 1966, 624, 1968, 1969, + /* 2730 */ 619, 1607, 614, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 329, 348, 331, 332, 429, 333, 333, 429, 433, 356, - /* 10 */ 358, 433, 12, 13, 14, 14, 15, 16, 365, 347, - /* 20 */ 20, 369, 22, 448, 449, 20, 354, 449, 453, 454, - /* 30 */ 325, 453, 454, 33, 20, 35, 364, 364, 329, 333, - /* 40 */ 331, 332, 8, 9, 358, 333, 12, 13, 14, 15, - /* 50 */ 16, 399, 400, 401, 391, 369, 356, 333, 58, 14, - /* 60 */ 20, 356, 410, 63, 367, 20, 356, 370, 371, 364, - /* 70 */ 70, 20, 20, 363, 369, 340, 371, 377, 378, 373, - /* 80 */ 345, 356, 372, 12, 13, 399, 400, 401, 364, 364, - /* 90 */ 62, 20, 380, 22, 382, 95, 410, 63, 425, 426, - /* 100 */ 427, 396, 429, 430, 33, 400, 35, 3, 403, 404, - /* 110 */ 405, 406, 407, 408, 333, 410, 20, 117, 22, 62, - /* 120 */ 415, 330, 417, 20, 333, 334, 421, 422, 347, 58, - /* 130 */ 405, 35, 132, 133, 63, 354, 418, 419, 104, 429, - /* 140 */ 435, 70, 324, 433, 326, 364, 95, 51, 443, 425, - /* 150 */ 426, 427, 333, 429, 430, 325, 325, 433, 448, 449, - /* 160 */ 333, 161, 162, 453, 454, 333, 95, 12, 13, 14, - /* 170 */ 15, 16, 448, 449, 347, 161, 162, 453, 454, 337, - /* 180 */ 180, 333, 182, 364, 132, 133, 330, 356, 117, 333, - /* 190 */ 334, 364, 20, 351, 160, 364, 364, 20, 95, 369, - /* 200 */ 369, 359, 371, 132, 133, 205, 206, 4, 208, 209, + /* 0 */ 331, 369, 333, 334, 372, 373, 389, 327, 360, 420, + /* 10 */ 421, 357, 12, 13, 14, 327, 359, 431, 358, 371, + /* 20 */ 20, 435, 22, 360, 370, 12, 13, 14, 15, 16, + /* 30 */ 327, 335, 324, 33, 371, 35, 450, 451, 358, 379, + /* 40 */ 380, 455, 456, 372, 373, 349, 366, 335, 431, 401, + /* 50 */ 402, 371, 435, 373, 1, 2, 20, 389, 58, 371, + /* 60 */ 412, 358, 366, 63, 401, 402, 403, 450, 451, 366, + /* 70 */ 70, 20, 455, 456, 371, 412, 373, 332, 398, 20, + /* 80 */ 335, 336, 402, 12, 13, 405, 406, 407, 408, 409, + /* 90 */ 410, 20, 412, 22, 382, 95, 384, 389, 20, 431, + /* 100 */ 335, 398, 342, 435, 33, 402, 35, 347, 405, 406, + /* 110 */ 407, 408, 409, 410, 349, 412, 58, 117, 450, 451, + /* 120 */ 417, 356, 419, 455, 456, 351, 423, 424, 354, 58, + /* 130 */ 20, 366, 132, 133, 63, 95, 335, 457, 458, 431, + /* 140 */ 437, 70, 335, 435, 331, 105, 333, 334, 445, 96, + /* 150 */ 349, 18, 35, 95, 95, 97, 23, 356, 450, 451, + /* 160 */ 373, 161, 162, 455, 456, 332, 95, 366, 335, 336, + /* 170 */ 37, 38, 385, 366, 41, 388, 404, 65, 66, 67, + /* 180 */ 180, 0, 182, 132, 133, 73, 74, 70, 117, 360, + /* 190 */ 78, 350, 59, 60, 61, 83, 84, 161, 162, 358, + /* 200 */ 371, 89, 430, 132, 133, 95, 206, 207, 367, 209, /* 210 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 220 */ 220, 221, 222, 223, 224, 225, 226, 396, 380, 95, - /* 230 */ 382, 400, 161, 162, 403, 404, 405, 406, 407, 408, - /* 240 */ 409, 410, 411, 412, 425, 426, 427, 20, 429, 430, - /* 250 */ 37, 180, 402, 182, 370, 371, 424, 425, 426, 427, - /* 260 */ 166, 429, 430, 325, 95, 231, 232, 233, 234, 235, - /* 270 */ 236, 237, 238, 239, 240, 241, 205, 206, 428, 208, + /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 95, 335, + /* 230 */ 401, 402, 161, 162, 427, 428, 429, 20, 431, 432, + /* 240 */ 20, 412, 435, 349, 14, 20, 65, 66, 67, 358, + /* 250 */ 20, 180, 127, 182, 73, 74, 163, 450, 451, 78, + /* 260 */ 366, 168, 455, 456, 83, 84, 62, 134, 8, 9, + /* 270 */ 89, 380, 12, 13, 14, 15, 16, 206, 207, 389, /* 280 */ 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, - /* 290 */ 219, 220, 221, 222, 223, 224, 225, 226, 95, 228, - /* 300 */ 12, 13, 0, 95, 205, 322, 364, 369, 20, 14, - /* 310 */ 22, 98, 0, 100, 101, 20, 103, 375, 325, 325, - /* 320 */ 107, 33, 95, 35, 108, 109, 110, 111, 112, 113, - /* 330 */ 114, 115, 116, 117, 118, 163, 120, 121, 122, 123, - /* 340 */ 124, 125, 129, 249, 250, 58, 58, 244, 179, 356, - /* 350 */ 181, 63, 253, 254, 255, 256, 257, 364, 70, 20, - /* 360 */ 35, 22, 369, 369, 371, 261, 175, 65, 66, 67, - /* 370 */ 387, 12, 13, 14, 62, 73, 74, 387, 244, 20, - /* 380 */ 78, 22, 95, 95, 97, 83, 84, 196, 197, 396, - /* 390 */ 51, 89, 33, 400, 35, 70, 403, 404, 405, 406, - /* 400 */ 407, 408, 325, 410, 339, 117, 413, 325, 415, 416, - /* 410 */ 417, 333, 429, 244, 421, 422, 433, 58, 353, 429, - /* 420 */ 132, 133, 355, 433, 20, 347, 126, 362, 44, 70, - /* 430 */ 325, 448, 449, 356, 0, 368, 453, 454, 448, 449, - /* 440 */ 22, 364, 364, 453, 454, 356, 369, 244, 371, 161, - /* 450 */ 162, 369, 244, 35, 95, 21, 161, 371, 24, 25, - /* 460 */ 26, 27, 28, 29, 30, 31, 32, 378, 180, 383, - /* 470 */ 182, 244, 386, 396, 369, 349, 117, 400, 352, 356, - /* 480 */ 403, 404, 405, 406, 407, 408, 363, 410, 70, 189, - /* 490 */ 190, 132, 133, 205, 206, 372, 208, 209, 210, 211, - /* 500 */ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, - /* 510 */ 222, 223, 224, 225, 226, 342, 343, 342, 343, 21, - /* 520 */ 161, 162, 24, 25, 26, 27, 28, 29, 30, 31, - /* 530 */ 32, 244, 455, 456, 348, 117, 65, 66, 67, 180, - /* 540 */ 348, 182, 356, 356, 73, 74, 14, 0, 356, 78, - /* 550 */ 363, 365, 20, 20, 83, 84, 0, 365, 325, 372, - /* 560 */ 89, 126, 127, 20, 205, 206, 131, 208, 209, 210, - /* 570 */ 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, - /* 580 */ 221, 222, 223, 224, 225, 226, 12, 13, 0, 356, - /* 590 */ 325, 333, 58, 21, 20, 48, 22, 364, 180, 0, - /* 600 */ 182, 325, 369, 20, 371, 347, 34, 33, 36, 35, - /* 610 */ 358, 333, 24, 25, 26, 27, 28, 29, 30, 31, - /* 620 */ 32, 369, 364, 205, 206, 347, 1, 2, 94, 396, - /* 630 */ 325, 97, 58, 400, 369, 325, 403, 404, 405, 406, - /* 640 */ 407, 408, 364, 410, 70, 369, 337, 339, 415, 265, - /* 650 */ 417, 399, 400, 413, 421, 422, 416, 12, 13, 333, - /* 660 */ 4, 62, 410, 107, 3, 20, 325, 22, 359, 95, - /* 670 */ 362, 79, 325, 347, 369, 19, 443, 371, 33, 369, - /* 680 */ 35, 20, 126, 127, 128, 129, 130, 131, 2, 33, - /* 690 */ 364, 117, 386, 161, 8, 9, 163, 356, 12, 13, - /* 700 */ 14, 15, 16, 58, 48, 364, 132, 133, 325, 53, - /* 710 */ 369, 325, 371, 402, 58, 70, 369, 325, 429, 8, - /* 720 */ 9, 96, 433, 12, 13, 14, 15, 16, 4, 137, - /* 730 */ 138, 20, 0, 160, 402, 161, 162, 396, 449, 428, - /* 740 */ 95, 400, 453, 454, 403, 404, 405, 406, 407, 408, - /* 750 */ 94, 410, 369, 97, 180, 369, 182, 96, 417, 2, - /* 760 */ 428, 369, 117, 422, 325, 8, 9, 325, 127, 12, - /* 770 */ 13, 14, 15, 16, 228, 325, 4, 132, 133, 205, - /* 780 */ 206, 49, 208, 209, 210, 211, 212, 213, 214, 215, - /* 790 */ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, - /* 800 */ 226, 18, 35, 20, 231, 325, 161, 162, 369, 19, - /* 810 */ 27, 369, 356, 30, 241, 43, 33, 45, 46, 369, - /* 820 */ 414, 365, 416, 33, 163, 180, 0, 182, 187, 188, - /* 830 */ 364, 48, 191, 50, 193, 228, 53, 230, 48, 0, - /* 840 */ 414, 375, 416, 39, 54, 55, 56, 57, 58, 369, - /* 850 */ 205, 206, 0, 208, 209, 210, 211, 212, 213, 214, - /* 860 */ 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, - /* 870 */ 225, 226, 356, 20, 163, 8, 9, 94, 20, 12, - /* 880 */ 13, 14, 15, 16, 94, 364, 63, 97, 372, 106, - /* 890 */ 106, 65, 66, 67, 68, 69, 375, 71, 72, 73, - /* 900 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - /* 910 */ 84, 85, 86, 87, 88, 89, 90, 91, 366, 136, - /* 920 */ 130, 369, 139, 140, 141, 142, 143, 144, 145, 146, - /* 930 */ 147, 148, 149, 150, 151, 152, 153, 154, 155, 70, - /* 940 */ 157, 158, 159, 18, 45, 46, 8, 9, 23, 182, - /* 950 */ 12, 13, 14, 15, 16, 325, 325, 167, 325, 107, - /* 960 */ 70, 366, 37, 38, 369, 349, 41, 366, 352, 245, - /* 970 */ 369, 344, 357, 346, 184, 42, 186, 44, 126, 127, - /* 980 */ 128, 129, 130, 131, 59, 60, 61, 8, 9, 356, - /* 990 */ 151, 12, 13, 14, 15, 16, 107, 364, 47, 369, - /* 1000 */ 369, 333, 369, 107, 371, 357, 8, 9, 242, 243, - /* 1010 */ 12, 13, 14, 15, 16, 347, 163, 58, 129, 161, - /* 1020 */ 95, 333, 126, 127, 128, 129, 130, 131, 205, 396, - /* 1030 */ 163, 333, 364, 400, 96, 347, 403, 404, 405, 406, - /* 1040 */ 407, 408, 44, 410, 44, 347, 95, 243, 415, 42, - /* 1050 */ 417, 44, 364, 22, 421, 422, 97, 357, 106, 134, - /* 1060 */ 333, 325, 364, 8, 9, 432, 35, 12, 13, 14, - /* 1070 */ 15, 16, 8, 9, 347, 357, 12, 13, 14, 15, - /* 1080 */ 16, 333, 99, 99, 44, 102, 102, 333, 0, 35, - /* 1090 */ 99, 364, 356, 102, 0, 347, 96, 172, 173, 174, - /* 1100 */ 364, 347, 177, 333, 44, 369, 325, 371, 156, 0, - /* 1110 */ 22, 99, 364, 358, 102, 44, 22, 347, 364, 44, - /* 1120 */ 195, 132, 133, 198, 369, 200, 201, 202, 203, 204, - /* 1130 */ 44, 22, 396, 333, 364, 333, 400, 356, 326, 403, - /* 1140 */ 404, 405, 406, 407, 408, 364, 410, 347, 44, 347, - /* 1150 */ 369, 415, 371, 417, 399, 400, 96, 421, 422, 345, - /* 1160 */ 96, 333, 333, 357, 364, 410, 364, 96, 432, 244, - /* 1170 */ 44, 96, 357, 163, 44, 347, 347, 396, 168, 325, - /* 1180 */ 44, 400, 96, 457, 403, 404, 405, 406, 407, 408, - /* 1190 */ 13, 410, 364, 364, 12, 13, 415, 333, 417, 44, - /* 1200 */ 96, 44, 421, 422, 22, 1, 2, 13, 357, 95, - /* 1210 */ 356, 347, 35, 432, 379, 33, 44, 35, 364, 105, - /* 1220 */ 33, 387, 96, 369, 387, 371, 96, 172, 364, 35, - /* 1230 */ 335, 446, 96, 440, 325, 48, 182, 44, 356, 335, - /* 1240 */ 58, 54, 55, 56, 57, 58, 44, 379, 332, 44, - /* 1250 */ 396, 96, 70, 96, 400, 368, 44, 403, 404, 405, - /* 1260 */ 406, 407, 408, 429, 410, 356, 429, 433, 96, 415, - /* 1270 */ 433, 417, 35, 364, 431, 421, 422, 379, 369, 423, - /* 1280 */ 371, 94, 448, 449, 97, 448, 449, 453, 454, 96, - /* 1290 */ 453, 454, 450, 434, 387, 246, 48, 397, 96, 117, - /* 1300 */ 398, 96, 178, 263, 389, 396, 42, 70, 96, 400, - /* 1310 */ 376, 20, 403, 404, 405, 406, 407, 408, 379, 410, - /* 1320 */ 376, 266, 160, 374, 415, 20, 417, 333, 333, 376, - /* 1330 */ 421, 422, 374, 93, 341, 374, 429, 333, 333, 333, - /* 1340 */ 433, 20, 327, 327, 20, 371, 325, 387, 393, 20, - /* 1350 */ 339, 164, 165, 339, 167, 448, 449, 170, 334, 20, - /* 1360 */ 453, 454, 180, 388, 182, 339, 334, 339, 339, 339, - /* 1370 */ 333, 52, 339, 186, 336, 336, 325, 356, 356, 327, - /* 1380 */ 333, 356, 369, 356, 327, 364, 369, 205, 206, 429, - /* 1390 */ 369, 356, 371, 433, 194, 393, 395, 356, 356, 217, - /* 1400 */ 218, 219, 220, 221, 222, 223, 356, 356, 448, 449, - /* 1410 */ 337, 185, 356, 453, 454, 364, 371, 396, 356, 356, - /* 1420 */ 369, 400, 371, 356, 403, 404, 405, 406, 407, 408, - /* 1430 */ 337, 410, 325, 333, 369, 392, 415, 379, 417, 251, - /* 1440 */ 379, 252, 421, 422, 258, 369, 369, 396, 439, 369, - /* 1450 */ 384, 400, 325, 384, 403, 404, 405, 406, 407, 408, - /* 1460 */ 442, 410, 439, 356, 171, 247, 260, 259, 417, 262, - /* 1470 */ 398, 364, 421, 422, 438, 441, 369, 267, 371, 264, - /* 1480 */ 364, 437, 243, 356, 436, 439, 20, 402, 334, 333, - /* 1490 */ 337, 364, 20, 382, 384, 165, 369, 369, 371, 384, - /* 1500 */ 369, 369, 369, 396, 369, 452, 369, 400, 337, 364, - /* 1510 */ 403, 404, 405, 406, 407, 408, 352, 410, 337, 381, - /* 1520 */ 325, 451, 95, 396, 417, 420, 458, 400, 421, 422, - /* 1530 */ 403, 404, 405, 406, 407, 408, 325, 410, 95, 360, - /* 1540 */ 337, 36, 369, 346, 417, 328, 333, 327, 421, 422, - /* 1550 */ 390, 356, 394, 385, 385, 323, 0, 0, 187, 364, - /* 1560 */ 42, 338, 0, 0, 369, 0, 371, 356, 35, 350, - /* 1570 */ 35, 350, 350, 199, 35, 364, 35, 0, 199, 35, - /* 1580 */ 369, 35, 371, 199, 0, 199, 0, 35, 0, 22, - /* 1590 */ 0, 396, 182, 35, 180, 400, 0, 325, 403, 404, - /* 1600 */ 405, 406, 407, 408, 0, 410, 176, 396, 175, 0, - /* 1610 */ 0, 400, 0, 47, 403, 404, 405, 406, 407, 408, - /* 1620 */ 0, 410, 0, 42, 0, 0, 0, 0, 356, 151, - /* 1630 */ 35, 0, 151, 0, 0, 0, 364, 0, 0, 444, - /* 1640 */ 445, 369, 325, 371, 0, 0, 0, 0, 0, 0, - /* 1650 */ 0, 0, 0, 0, 0, 0, 445, 0, 0, 42, - /* 1660 */ 0, 0, 0, 0, 0, 22, 0, 0, 396, 0, - /* 1670 */ 0, 135, 400, 356, 35, 403, 404, 405, 406, 407, - /* 1680 */ 408, 364, 410, 0, 0, 0, 369, 0, 371, 0, - /* 1690 */ 58, 14, 14, 0, 58, 0, 0, 0, 42, 171, - /* 1700 */ 0, 0, 0, 325, 39, 64, 47, 0, 0, 0, - /* 1710 */ 0, 39, 44, 396, 35, 40, 0, 400, 47, 447, - /* 1720 */ 403, 404, 405, 406, 407, 408, 325, 410, 47, 39, - /* 1730 */ 48, 39, 0, 35, 356, 0, 48, 0, 39, 361, - /* 1740 */ 35, 35, 364, 39, 0, 22, 104, 369, 0, 371, - /* 1750 */ 35, 48, 39, 35, 35, 35, 35, 356, 44, 48, - /* 1760 */ 35, 44, 22, 35, 35, 364, 0, 22, 0, 22, - /* 1770 */ 369, 0, 371, 456, 396, 102, 50, 22, 400, 0, - /* 1780 */ 0, 403, 404, 405, 406, 407, 408, 325, 410, 35, - /* 1790 */ 0, 35, 35, 20, 22, 35, 35, 396, 192, 0, - /* 1800 */ 35, 400, 0, 163, 403, 404, 405, 406, 407, 408, - /* 1810 */ 0, 410, 0, 412, 22, 0, 3, 325, 356, 44, - /* 1820 */ 96, 248, 44, 361, 47, 95, 364, 96, 95, 95, - /* 1830 */ 44, 369, 96, 371, 96, 96, 95, 95, 47, 44, - /* 1840 */ 325, 95, 248, 163, 95, 3, 96, 96, 356, 44, - /* 1850 */ 248, 165, 35, 361, 163, 35, 364, 35, 396, 183, - /* 1860 */ 35, 369, 400, 371, 35, 403, 404, 405, 406, 407, - /* 1870 */ 408, 356, 410, 35, 47, 44, 0, 96, 96, 364, - /* 1880 */ 47, 169, 0, 47, 369, 325, 371, 0, 396, 95, - /* 1890 */ 39, 95, 400, 96, 96, 403, 404, 405, 406, 407, - /* 1900 */ 408, 325, 410, 95, 95, 105, 95, 47, 44, 2, - /* 1910 */ 22, 396, 96, 95, 95, 400, 356, 164, 403, 404, - /* 1920 */ 405, 406, 407, 408, 364, 410, 96, 95, 166, 369, - /* 1930 */ 96, 371, 356, 47, 95, 95, 242, 47, 22, 96, - /* 1940 */ 364, 95, 95, 106, 96, 369, 35, 371, 35, 227, - /* 1950 */ 96, 95, 35, 35, 325, 96, 396, 205, 95, 35, - /* 1960 */ 400, 96, 95, 403, 404, 405, 406, 407, 408, 96, - /* 1970 */ 410, 207, 396, 35, 95, 22, 400, 119, 107, 403, - /* 1980 */ 404, 405, 406, 407, 408, 356, 410, 229, 119, 119, - /* 1990 */ 227, 119, 95, 364, 44, 95, 35, 22, 369, 325, - /* 2000 */ 371, 95, 35, 64, 63, 35, 35, 35, 35, 35, - /* 2010 */ 70, 35, 35, 35, 35, 92, 35, 35, 35, 22, - /* 2020 */ 35, 35, 35, 35, 44, 396, 70, 35, 35, 400, - /* 2030 */ 356, 35, 403, 404, 405, 406, 407, 408, 364, 410, - /* 2040 */ 35, 22, 35, 369, 0, 371, 35, 48, 39, 0, - /* 2050 */ 35, 48, 325, 39, 0, 35, 48, 39, 0, 35, - /* 2060 */ 48, 39, 0, 35, 35, 0, 20, 22, 325, 21, - /* 2070 */ 396, 459, 22, 22, 400, 459, 21, 403, 404, 405, - /* 2080 */ 406, 407, 408, 356, 410, 459, 459, 459, 459, 459, - /* 2090 */ 459, 364, 459, 459, 459, 459, 369, 459, 371, 356, - /* 2100 */ 459, 459, 459, 459, 459, 459, 459, 364, 459, 459, - /* 2110 */ 459, 459, 369, 325, 371, 459, 459, 459, 459, 459, - /* 2120 */ 459, 459, 459, 396, 459, 459, 459, 400, 459, 459, - /* 2130 */ 403, 404, 405, 406, 407, 408, 459, 410, 459, 396, - /* 2140 */ 459, 459, 459, 400, 356, 459, 403, 404, 405, 406, - /* 2150 */ 407, 408, 364, 410, 459, 459, 459, 369, 459, 371, - /* 2160 */ 459, 459, 459, 459, 459, 459, 325, 459, 459, 459, - /* 2170 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, - /* 2180 */ 459, 459, 325, 459, 396, 459, 459, 459, 400, 459, - /* 2190 */ 459, 403, 404, 405, 406, 407, 408, 356, 410, 459, - /* 2200 */ 459, 459, 459, 459, 459, 364, 459, 459, 459, 459, - /* 2210 */ 369, 459, 371, 356, 459, 459, 459, 459, 459, 459, - /* 2220 */ 459, 364, 459, 459, 459, 459, 369, 325, 371, 459, - /* 2230 */ 459, 459, 459, 459, 459, 459, 459, 396, 459, 459, - /* 2240 */ 459, 400, 459, 459, 403, 404, 405, 406, 407, 408, - /* 2250 */ 325, 410, 459, 396, 459, 459, 459, 400, 356, 459, - /* 2260 */ 403, 404, 405, 406, 407, 408, 364, 410, 459, 459, - /* 2270 */ 459, 369, 459, 371, 459, 459, 459, 459, 459, 459, - /* 2280 */ 325, 356, 459, 459, 459, 459, 459, 459, 459, 364, - /* 2290 */ 459, 459, 459, 459, 369, 459, 371, 459, 396, 459, - /* 2300 */ 459, 459, 400, 459, 459, 403, 404, 405, 406, 407, - /* 2310 */ 408, 356, 410, 459, 459, 459, 459, 459, 459, 364, - /* 2320 */ 459, 396, 459, 459, 369, 400, 371, 459, 403, 404, - /* 2330 */ 405, 406, 407, 408, 459, 410, 459, 459, 459, 459, - /* 2340 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, - /* 2350 */ 459, 396, 459, 459, 459, 400, 325, 459, 403, 404, - /* 2360 */ 405, 406, 407, 408, 459, 410, 459, 459, 459, 459, - /* 2370 */ 459, 459, 459, 459, 459, 459, 459, 459, 325, 459, - /* 2380 */ 459, 459, 459, 459, 459, 459, 459, 356, 459, 459, - /* 2390 */ 459, 459, 459, 459, 459, 364, 459, 459, 459, 459, - /* 2400 */ 369, 459, 371, 459, 459, 459, 459, 459, 459, 356, - /* 2410 */ 459, 459, 459, 459, 459, 459, 459, 364, 459, 459, - /* 2420 */ 459, 459, 369, 459, 371, 459, 459, 396, 459, 459, - /* 2430 */ 459, 400, 459, 325, 403, 404, 405, 406, 407, 408, - /* 2440 */ 459, 410, 459, 459, 459, 459, 459, 459, 459, 396, - /* 2450 */ 459, 459, 459, 400, 459, 459, 403, 404, 405, 406, - /* 2460 */ 407, 408, 459, 410, 356, 459, 459, 459, 459, 459, - /* 2470 */ 459, 459, 364, 459, 459, 459, 459, 369, 325, 371, - /* 2480 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, - /* 2490 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, - /* 2500 */ 459, 459, 459, 459, 396, 459, 459, 459, 400, 356, - /* 2510 */ 459, 403, 404, 405, 406, 407, 408, 364, 410, 459, - /* 2520 */ 459, 459, 369, 325, 371, 459, 459, 459, 459, 459, - /* 2530 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 325, - /* 2540 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 396, - /* 2550 */ 459, 459, 459, 400, 356, 459, 403, 404, 405, 406, - /* 2560 */ 407, 408, 364, 410, 459, 459, 459, 369, 459, 371, - /* 2570 */ 356, 459, 459, 459, 459, 459, 459, 459, 364, 459, - /* 2580 */ 459, 459, 459, 369, 325, 371, 459, 459, 459, 459, - /* 2590 */ 459, 459, 459, 459, 396, 459, 459, 459, 400, 459, - /* 2600 */ 459, 403, 404, 405, 406, 407, 408, 325, 410, 459, - /* 2610 */ 396, 459, 459, 459, 400, 356, 459, 403, 404, 405, - /* 2620 */ 406, 407, 408, 364, 410, 459, 459, 459, 369, 459, - /* 2630 */ 371, 459, 459, 459, 459, 459, 459, 325, 356, 459, - /* 2640 */ 459, 459, 459, 459, 459, 459, 364, 459, 459, 459, - /* 2650 */ 459, 369, 459, 371, 459, 396, 459, 459, 459, 400, - /* 2660 */ 459, 459, 403, 404, 405, 406, 407, 408, 356, 410, - /* 2670 */ 459, 459, 459, 459, 459, 459, 364, 459, 396, 459, - /* 2680 */ 459, 369, 400, 371, 459, 403, 404, 405, 406, 407, - /* 2690 */ 408, 459, 410, 459, 459, 459, 459, 459, 459, 459, - /* 2700 */ 459, 459, 459, 459, 459, 459, 459, 459, 396, 459, - /* 2710 */ 459, 459, 400, 459, 459, 403, 404, 405, 406, 407, - /* 2720 */ 408, 459, 410, + /* 290 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 4, + /* 300 */ 229, 12, 13, 245, 245, 172, 173, 174, 339, 20, + /* 310 */ 177, 22, 187, 188, 19, 358, 191, 339, 193, 327, + /* 320 */ 95, 431, 33, 366, 35, 435, 358, 44, 33, 196, + /* 330 */ 361, 353, 199, 365, 201, 202, 203, 204, 205, 361, + /* 340 */ 450, 451, 374, 48, 360, 455, 456, 58, 53, 350, + /* 350 */ 358, 4, 63, 58, 350, 371, 96, 358, 366, 70, + /* 360 */ 3, 62, 358, 371, 407, 373, 367, 14, 15, 16, + /* 370 */ 335, 367, 12, 13, 14, 20, 95, 20, 245, 96, + /* 380 */ 20, 327, 22, 163, 95, 401, 402, 403, 95, 94, + /* 390 */ 398, 341, 97, 33, 402, 35, 412, 405, 406, 407, + /* 400 */ 408, 409, 410, 229, 412, 355, 117, 415, 160, 417, + /* 410 */ 418, 419, 358, 0, 364, 423, 424, 382, 58, 384, + /* 420 */ 366, 132, 133, 126, 127, 371, 4, 373, 131, 0, + /* 430 */ 70, 108, 109, 110, 111, 112, 113, 114, 115, 116, + /* 440 */ 117, 118, 95, 120, 121, 122, 123, 124, 125, 106, + /* 450 */ 161, 162, 398, 96, 20, 95, 402, 0, 58, 405, + /* 460 */ 406, 407, 408, 409, 410, 43, 412, 45, 46, 180, + /* 470 */ 245, 182, 179, 419, 181, 62, 20, 117, 424, 335, + /* 480 */ 232, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 490 */ 242, 62, 132, 133, 94, 206, 207, 97, 209, 210, + /* 500 */ 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, + /* 510 */ 221, 222, 223, 224, 225, 226, 227, 344, 345, 375, + /* 520 */ 163, 161, 162, 0, 21, 335, 245, 24, 25, 26, + /* 530 */ 27, 28, 29, 30, 31, 32, 341, 20, 245, 349, + /* 540 */ 180, 326, 182, 328, 21, 70, 327, 24, 25, 26, + /* 550 */ 27, 28, 29, 30, 31, 32, 366, 8, 9, 364, + /* 560 */ 327, 12, 13, 14, 15, 16, 206, 207, 95, 209, + /* 570 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, + /* 580 */ 220, 221, 222, 223, 224, 225, 226, 227, 12, 13, + /* 590 */ 371, 358, 245, 44, 22, 79, 20, 373, 22, 366, + /* 600 */ 37, 20, 70, 22, 371, 166, 373, 35, 229, 33, + /* 610 */ 231, 35, 388, 358, 358, 416, 35, 418, 8, 9, + /* 620 */ 365, 365, 12, 13, 14, 15, 16, 39, 327, 374, + /* 630 */ 374, 398, 51, 360, 58, 402, 21, 335, 405, 406, + /* 640 */ 407, 408, 409, 410, 371, 412, 70, 206, 335, 34, + /* 650 */ 417, 36, 419, 137, 138, 335, 423, 424, 404, 12, + /* 660 */ 13, 98, 349, 100, 101, 359, 103, 20, 366, 22, + /* 670 */ 107, 95, 371, 63, 401, 402, 403, 359, 445, 366, + /* 680 */ 33, 175, 35, 20, 430, 412, 366, 431, 14, 250, + /* 690 */ 251, 435, 129, 117, 20, 254, 255, 256, 257, 258, + /* 700 */ 259, 260, 393, 197, 198, 58, 450, 451, 132, 133, + /* 710 */ 327, 455, 456, 126, 104, 431, 327, 70, 245, 435, + /* 720 */ 8, 9, 335, 359, 12, 13, 14, 15, 16, 427, + /* 730 */ 428, 429, 20, 431, 432, 451, 349, 161, 162, 455, + /* 740 */ 456, 431, 95, 404, 14, 435, 426, 427, 428, 429, + /* 750 */ 20, 431, 432, 366, 371, 359, 180, 416, 182, 418, + /* 760 */ 371, 451, 107, 327, 117, 455, 456, 8, 9, 430, + /* 770 */ 160, 12, 13, 14, 15, 16, 189, 190, 415, 132, + /* 780 */ 133, 418, 206, 207, 129, 209, 210, 211, 212, 213, + /* 790 */ 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, + /* 800 */ 224, 225, 226, 227, 18, 3, 20, 371, 161, 162, + /* 810 */ 20, 359, 22, 27, 344, 345, 30, 8, 9, 33, + /* 820 */ 366, 12, 13, 14, 15, 16, 163, 180, 0, 182, + /* 830 */ 368, 377, 244, 371, 48, 161, 50, 327, 4, 53, + /* 840 */ 327, 51, 232, 233, 234, 235, 236, 237, 238, 239, + /* 850 */ 240, 241, 242, 206, 207, 96, 209, 210, 211, 212, + /* 860 */ 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, + /* 870 */ 223, 224, 225, 226, 227, 163, 2, 327, 359, 327, + /* 880 */ 94, 371, 8, 9, 371, 328, 12, 13, 14, 15, + /* 890 */ 16, 161, 106, 65, 66, 67, 68, 69, 327, 71, + /* 900 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + /* 910 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + /* 920 */ 327, 371, 136, 371, 327, 139, 140, 141, 142, 143, + /* 930 */ 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, + /* 940 */ 154, 155, 371, 157, 158, 159, 327, 327, 327, 366, + /* 950 */ 366, 351, 12, 13, 354, 358, 327, 335, 335, 20, + /* 960 */ 377, 377, 22, 366, 371, 335, 335, 327, 371, 0, + /* 970 */ 373, 349, 349, 33, 358, 35, 20, 335, 358, 349, + /* 980 */ 349, 172, 346, 367, 348, 358, 366, 381, 366, 366, + /* 990 */ 371, 371, 371, 373, 389, 398, 366, 366, 58, 402, + /* 1000 */ 371, 374, 405, 406, 407, 408, 409, 410, 366, 412, + /* 1010 */ 70, 371, 45, 46, 417, 327, 419, 347, 398, 327, + /* 1020 */ 423, 424, 402, 0, 327, 405, 406, 407, 408, 409, + /* 1030 */ 410, 434, 412, 327, 44, 2, 431, 417, 459, 419, + /* 1040 */ 435, 8, 9, 423, 424, 12, 13, 14, 15, 16, + /* 1050 */ 368, 243, 244, 371, 434, 450, 451, 117, 0, 371, + /* 1060 */ 455, 456, 368, 371, 358, 371, 264, 33, 371, 427, + /* 1070 */ 428, 429, 366, 431, 432, 337, 107, 371, 269, 373, + /* 1080 */ 246, 0, 48, 0, 42, 42, 44, 44, 54, 55, + /* 1090 */ 56, 57, 58, 106, 448, 126, 127, 128, 129, 130, + /* 1100 */ 131, 44, 163, 22, 398, 22, 48, 192, 402, 194, + /* 1110 */ 327, 405, 406, 407, 408, 409, 410, 161, 412, 335, + /* 1120 */ 180, 99, 182, 417, 102, 419, 132, 133, 94, 423, + /* 1130 */ 424, 97, 35, 349, 327, 13, 99, 58, 22, 102, + /* 1140 */ 434, 358, 44, 156, 44, 44, 206, 207, 107, 366, + /* 1150 */ 366, 35, 335, 0, 371, 35, 373, 35, 218, 219, + /* 1160 */ 220, 221, 222, 223, 224, 358, 349, 126, 127, 128, + /* 1170 */ 129, 130, 131, 366, 151, 22, 97, 63, 371, 327, + /* 1180 */ 373, 398, 442, 366, 99, 402, 70, 102, 405, 406, + /* 1190 */ 407, 408, 409, 410, 96, 412, 96, 96, 164, 165, + /* 1200 */ 417, 167, 419, 44, 170, 398, 423, 424, 358, 402, + /* 1210 */ 358, 0, 405, 406, 407, 408, 409, 410, 366, 412, + /* 1220 */ 186, 1, 2, 371, 417, 373, 419, 337, 381, 44, + /* 1230 */ 423, 424, 335, 117, 327, 8, 9, 335, 334, 12, + /* 1240 */ 13, 14, 15, 16, 381, 44, 349, 44, 44, 44, + /* 1250 */ 398, 349, 335, 335, 402, 96, 266, 405, 406, 407, + /* 1260 */ 408, 409, 410, 366, 412, 358, 349, 349, 366, 417, + /* 1270 */ 370, 419, 335, 366, 99, 423, 424, 102, 371, 182, + /* 1280 */ 373, 96, 389, 366, 366, 452, 349, 8, 9, 433, + /* 1290 */ 327, 12, 13, 14, 15, 16, 180, 96, 182, 96, + /* 1300 */ 96, 96, 182, 366, 44, 398, 47, 44, 44, 402, + /* 1310 */ 44, 44, 405, 406, 407, 408, 409, 410, 107, 412, + /* 1320 */ 206, 358, 206, 207, 431, 268, 419, 0, 435, 366, + /* 1330 */ 423, 424, 44, 335, 371, 327, 373, 126, 127, 128, + /* 1340 */ 129, 130, 131, 450, 451, 13, 44, 349, 455, 456, + /* 1350 */ 35, 425, 436, 247, 95, 400, 96, 48, 327, 96, + /* 1360 */ 96, 398, 96, 96, 366, 402, 358, 35, 405, 406, + /* 1370 */ 407, 408, 409, 410, 366, 412, 49, 399, 178, 371, + /* 1380 */ 391, 373, 419, 42, 96, 70, 423, 424, 378, 358, + /* 1390 */ 163, 20, 381, 378, 160, 376, 20, 366, 96, 335, + /* 1400 */ 335, 93, 371, 378, 373, 376, 398, 335, 376, 343, + /* 1410 */ 402, 335, 335, 405, 406, 407, 408, 409, 410, 20, + /* 1420 */ 412, 329, 329, 20, 373, 395, 20, 419, 341, 398, + /* 1430 */ 341, 423, 424, 402, 20, 336, 405, 406, 407, 408, + /* 1440 */ 409, 410, 411, 412, 413, 414, 327, 336, 341, 390, + /* 1450 */ 341, 341, 335, 341, 341, 329, 52, 371, 397, 338, + /* 1460 */ 358, 338, 327, 358, 195, 329, 358, 335, 395, 185, + /* 1470 */ 253, 381, 339, 358, 371, 381, 358, 358, 394, 339, + /* 1480 */ 335, 441, 358, 358, 252, 366, 358, 358, 358, 358, + /* 1490 */ 371, 441, 373, 358, 261, 171, 444, 443, 263, 262, + /* 1500 */ 373, 366, 439, 441, 248, 371, 371, 440, 373, 371, + /* 1510 */ 371, 270, 371, 438, 267, 460, 265, 398, 327, 244, + /* 1520 */ 366, 402, 454, 386, 405, 406, 407, 408, 409, 410, + /* 1530 */ 386, 412, 20, 398, 335, 453, 339, 402, 336, 20, + /* 1540 */ 405, 406, 407, 408, 409, 410, 327, 412, 400, 358, + /* 1550 */ 404, 384, 386, 371, 371, 371, 386, 366, 371, 371, + /* 1560 */ 371, 165, 371, 383, 373, 446, 447, 339, 354, 339, + /* 1570 */ 95, 422, 366, 95, 362, 335, 36, 358, 371, 348, + /* 1580 */ 330, 339, 447, 329, 392, 366, 396, 325, 352, 398, + /* 1590 */ 371, 352, 373, 402, 0, 387, 405, 406, 407, 408, + /* 1600 */ 409, 410, 387, 412, 352, 340, 0, 187, 327, 0, + /* 1610 */ 0, 42, 0, 35, 35, 200, 35, 398, 35, 200, + /* 1620 */ 19, 402, 0, 35, 405, 406, 407, 408, 409, 410, + /* 1630 */ 35, 412, 200, 0, 33, 200, 0, 35, 0, 358, + /* 1640 */ 449, 22, 0, 35, 363, 182, 180, 366, 0, 48, + /* 1650 */ 0, 175, 371, 176, 373, 54, 55, 56, 57, 58, + /* 1660 */ 0, 0, 47, 327, 151, 42, 0, 0, 0, 0, + /* 1670 */ 0, 0, 0, 0, 35, 0, 151, 458, 0, 398, + /* 1680 */ 0, 0, 0, 402, 0, 0, 405, 406, 407, 408, + /* 1690 */ 409, 410, 0, 412, 358, 94, 0, 0, 97, 0, + /* 1700 */ 0, 0, 366, 0, 0, 0, 0, 371, 0, 373, + /* 1710 */ 0, 0, 0, 0, 0, 0, 42, 22, 0, 0, + /* 1720 */ 0, 135, 0, 0, 35, 327, 39, 44, 42, 0, + /* 1730 */ 14, 130, 0, 0, 398, 58, 0, 58, 402, 0, + /* 1740 */ 47, 405, 406, 407, 408, 409, 410, 0, 412, 47, + /* 1750 */ 414, 14, 0, 0, 47, 327, 358, 40, 171, 0, + /* 1760 */ 39, 363, 0, 39, 366, 0, 0, 0, 167, 371, + /* 1770 */ 35, 373, 0, 64, 0, 48, 35, 39, 48, 39, + /* 1780 */ 35, 39, 48, 0, 35, 184, 358, 186, 0, 39, + /* 1790 */ 0, 363, 48, 0, 366, 0, 398, 22, 104, 371, + /* 1800 */ 402, 373, 0, 405, 406, 407, 408, 409, 410, 22, + /* 1810 */ 412, 35, 35, 327, 35, 35, 35, 44, 0, 35, + /* 1820 */ 35, 35, 44, 22, 0, 22, 398, 102, 0, 327, + /* 1830 */ 402, 22, 50, 405, 406, 407, 408, 409, 410, 35, + /* 1840 */ 412, 0, 35, 0, 358, 35, 0, 22, 35, 20, + /* 1850 */ 35, 35, 366, 96, 0, 95, 35, 371, 0, 373, + /* 1860 */ 358, 163, 22, 0, 0, 3, 44, 249, 366, 249, + /* 1870 */ 44, 183, 3, 371, 327, 373, 44, 44, 47, 44, + /* 1880 */ 249, 47, 44, 35, 398, 96, 95, 95, 402, 95, + /* 1890 */ 327, 405, 406, 407, 408, 409, 410, 169, 412, 47, + /* 1900 */ 398, 96, 96, 95, 402, 358, 163, 405, 406, 407, + /* 1910 */ 408, 409, 410, 366, 412, 95, 165, 163, 371, 96, + /* 1920 */ 373, 358, 95, 35, 35, 35, 44, 35, 35, 366, + /* 1930 */ 47, 0, 96, 96, 371, 96, 373, 0, 96, 0, + /* 1940 */ 95, 47, 0, 96, 95, 398, 96, 39, 95, 402, + /* 1950 */ 95, 95, 405, 406, 407, 408, 409, 410, 47, 412, + /* 1960 */ 44, 398, 166, 164, 105, 402, 2, 327, 405, 406, + /* 1970 */ 407, 408, 409, 410, 243, 412, 228, 22, 22, 95, + /* 1980 */ 47, 96, 95, 47, 106, 230, 228, 35, 35, 35, + /* 1990 */ 95, 327, 96, 96, 95, 95, 35, 96, 358, 95, + /* 2000 */ 35, 96, 95, 206, 35, 96, 366, 95, 208, 96, + /* 2010 */ 95, 371, 95, 373, 96, 96, 95, 119, 22, 95, + /* 2020 */ 44, 119, 358, 95, 35, 119, 22, 107, 35, 119, + /* 2030 */ 366, 64, 35, 95, 63, 371, 35, 373, 398, 92, + /* 2040 */ 35, 35, 402, 35, 35, 405, 406, 407, 408, 409, + /* 2050 */ 410, 35, 412, 327, 35, 35, 70, 44, 35, 35, + /* 2060 */ 35, 22, 398, 35, 35, 35, 402, 35, 70, 405, + /* 2070 */ 406, 407, 408, 409, 410, 35, 412, 35, 35, 35, + /* 2080 */ 22, 35, 0, 327, 358, 35, 48, 39, 0, 48, + /* 2090 */ 35, 39, 366, 0, 35, 48, 39, 371, 0, 373, + /* 2100 */ 35, 48, 39, 0, 35, 35, 0, 22, 21, 461, + /* 2110 */ 461, 22, 22, 21, 358, 20, 461, 461, 461, 461, + /* 2120 */ 461, 461, 366, 461, 398, 461, 461, 371, 402, 373, + /* 2130 */ 461, 405, 406, 407, 408, 409, 410, 461, 412, 461, + /* 2140 */ 461, 327, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2150 */ 461, 461, 461, 461, 398, 461, 461, 327, 402, 461, + /* 2160 */ 461, 405, 406, 407, 408, 409, 410, 461, 412, 461, + /* 2170 */ 461, 461, 358, 461, 461, 461, 461, 461, 461, 461, + /* 2180 */ 366, 461, 461, 461, 461, 371, 461, 373, 358, 461, + /* 2190 */ 461, 461, 461, 461, 461, 461, 366, 461, 461, 461, + /* 2200 */ 461, 371, 327, 373, 461, 461, 461, 461, 461, 461, + /* 2210 */ 461, 461, 398, 461, 461, 461, 402, 461, 327, 405, + /* 2220 */ 406, 407, 408, 409, 410, 461, 412, 461, 398, 461, + /* 2230 */ 461, 461, 402, 358, 461, 405, 406, 407, 408, 409, + /* 2240 */ 410, 366, 412, 461, 461, 461, 371, 461, 373, 358, + /* 2250 */ 461, 461, 461, 461, 461, 461, 461, 366, 461, 461, + /* 2260 */ 461, 461, 371, 461, 373, 461, 461, 461, 461, 461, + /* 2270 */ 461, 461, 461, 398, 461, 461, 461, 402, 461, 461, + /* 2280 */ 405, 406, 407, 408, 409, 410, 461, 412, 461, 398, + /* 2290 */ 461, 461, 461, 402, 461, 327, 405, 406, 407, 408, + /* 2300 */ 409, 410, 461, 412, 461, 461, 461, 461, 461, 461, + /* 2310 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 327, + /* 2320 */ 461, 461, 461, 461, 461, 461, 358, 461, 461, 461, + /* 2330 */ 461, 461, 461, 461, 366, 461, 461, 461, 461, 371, + /* 2340 */ 461, 373, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2350 */ 358, 461, 461, 461, 461, 461, 461, 461, 366, 461, + /* 2360 */ 461, 461, 461, 371, 461, 373, 398, 461, 461, 461, + /* 2370 */ 402, 461, 461, 405, 406, 407, 408, 409, 410, 461, + /* 2380 */ 412, 327, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2390 */ 398, 461, 461, 461, 402, 461, 461, 405, 406, 407, + /* 2400 */ 408, 409, 410, 461, 412, 461, 461, 461, 461, 461, + /* 2410 */ 461, 327, 358, 461, 461, 461, 461, 461, 461, 461, + /* 2420 */ 366, 461, 461, 461, 461, 371, 461, 373, 461, 461, + /* 2430 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2440 */ 461, 461, 358, 461, 461, 461, 461, 461, 461, 461, + /* 2450 */ 366, 461, 398, 461, 461, 371, 402, 373, 461, 405, + /* 2460 */ 406, 407, 408, 409, 410, 461, 412, 461, 461, 327, + /* 2470 */ 461, 461, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2480 */ 461, 461, 398, 461, 461, 327, 402, 461, 461, 405, + /* 2490 */ 406, 407, 408, 409, 410, 461, 412, 461, 461, 461, + /* 2500 */ 358, 461, 461, 461, 461, 461, 461, 461, 366, 461, + /* 2510 */ 461, 461, 461, 371, 461, 373, 358, 461, 461, 461, + /* 2520 */ 461, 461, 461, 461, 366, 461, 461, 461, 461, 371, + /* 2530 */ 327, 373, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2540 */ 398, 461, 461, 461, 402, 461, 327, 405, 406, 407, + /* 2550 */ 408, 409, 410, 461, 412, 461, 398, 461, 461, 461, + /* 2560 */ 402, 358, 461, 405, 406, 407, 408, 409, 410, 366, + /* 2570 */ 412, 461, 461, 461, 371, 461, 373, 358, 461, 461, + /* 2580 */ 461, 461, 461, 461, 461, 366, 461, 461, 461, 461, + /* 2590 */ 371, 461, 373, 461, 461, 461, 461, 461, 461, 461, + /* 2600 */ 461, 398, 461, 461, 461, 402, 461, 461, 405, 406, + /* 2610 */ 407, 408, 409, 410, 461, 412, 461, 398, 461, 461, + /* 2620 */ 461, 402, 461, 327, 405, 406, 407, 408, 409, 410, + /* 2630 */ 461, 412, 461, 461, 461, 461, 461, 461, 461, 461, + /* 2640 */ 461, 461, 461, 461, 461, 461, 461, 327, 461, 461, + /* 2650 */ 461, 461, 461, 461, 358, 461, 461, 461, 461, 461, + /* 2660 */ 461, 461, 366, 461, 461, 461, 461, 371, 461, 373, + /* 2670 */ 461, 461, 461, 461, 461, 461, 461, 461, 358, 461, + /* 2680 */ 461, 461, 461, 461, 461, 461, 366, 461, 461, 461, + /* 2690 */ 461, 371, 461, 373, 398, 461, 461, 461, 402, 461, + /* 2700 */ 461, 405, 406, 407, 408, 409, 410, 461, 412, 461, + /* 2710 */ 461, 461, 461, 461, 461, 461, 461, 461, 398, 461, + /* 2720 */ 461, 461, 402, 461, 461, 405, 406, 407, 408, 409, + /* 2730 */ 410, 461, 412, }; -#define YY_SHIFT_COUNT (710) +#define YY_SHIFT_COUNT (714) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2065) +#define YY_SHIFT_MAX (2106) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 925, 0, 71, 0, 288, 288, 288, 288, 288, 288, - /* 10 */ 288, 288, 288, 359, 574, 574, 645, 574, 574, 574, - /* 20 */ 574, 574, 574, 574, 574, 574, 574, 574, 574, 574, - /* 30 */ 574, 574, 574, 574, 574, 574, 574, 574, 574, 574, - /* 40 */ 574, 574, 574, 574, 574, 574, 103, 227, 51, 169, - /* 50 */ 287, 134, 208, 134, 51, 51, 1182, 1182, 134, 1182, - /* 60 */ 1182, 203, 134, 5, 5, 772, 772, 14, 52, 45, - /* 70 */ 45, 5, 5, 5, 5, 5, 5, 5, 40, 5, - /* 80 */ 5, 28, 5, 5, 177, 5, 404, 5, 40, 543, - /* 90 */ 5, 5, 543, 5, 543, 543, 543, 5, 57, 783, - /* 100 */ 34, 34, 498, 471, 418, 418, 418, 418, 418, 418, - /* 110 */ 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, - /* 120 */ 418, 418, 418, 213, 661, 14, 52, 312, 325, 172, - /* 130 */ 172, 172, 599, 607, 607, 325, 583, 583, 583, 784, - /* 140 */ 404, 546, 543, 869, 543, 869, 869, 784, 890, 216, - /* 150 */ 216, 216, 216, 216, 216, 216, 790, 434, 302, 711, - /* 160 */ 1055, 99, 96, 94, 295, 532, 339, 533, 899, 889, - /* 170 */ 853, 766, 804, 104, 766, 933, 724, 858, 1049, 1248, - /* 180 */ 1124, 1264, 1291, 1264, 1162, 1305, 1305, 1264, 1162, 1162, - /* 190 */ 1240, 1305, 1305, 1305, 1321, 1321, 1324, 28, 404, 28, - /* 200 */ 1329, 1339, 28, 1329, 28, 28, 28, 1305, 28, 1319, - /* 210 */ 1319, 1321, 543, 543, 543, 543, 543, 543, 543, 543, - /* 220 */ 543, 543, 543, 1305, 1321, 869, 869, 1200, 1324, 57, - /* 230 */ 1226, 404, 57, 1305, 1291, 1291, 869, 1189, 1188, 869, - /* 240 */ 1189, 1188, 869, 869, 543, 1186, 1293, 1189, 1206, 1208, - /* 250 */ 1218, 1049, 1210, 1215, 1207, 1239, 583, 1466, 1305, 1329, - /* 260 */ 57, 1472, 1188, 869, 869, 869, 869, 869, 1188, 869, - /* 270 */ 1330, 57, 784, 57, 583, 1427, 1443, 869, 890, 1305, - /* 280 */ 57, 1505, 1321, 2723, 2723, 2723, 2723, 2723, 2723, 2723, - /* 290 */ 2723, 2723, 826, 1187, 588, 656, 938, 998, 1064, 556, - /* 300 */ 686, 757, 867, 852, 979, 979, 979, 979, 979, 979, - /* 310 */ 979, 979, 979, 896, 641, 155, 155, 191, 534, 592, - /* 320 */ 572, 300, 435, 435, 1, 625, 573, 1, 1, 1, - /* 330 */ 1000, 547, 1031, 1007, 952, 839, 983, 984, 991, 1012, - /* 340 */ 1088, 1094, 1109, 959, 1060, 1071, 989, 1040, 384, 1010, - /* 350 */ 1075, 1086, 1104, 1126, 1130, 1204, 1136, 767, 1054, 823, - /* 360 */ 1155, 951, 1157, 1172, 1193, 1202, 1205, 1212, 1114, 1177, - /* 370 */ 1194, 1237, 732, 1556, 1557, 1371, 1562, 1563, 1518, 1565, - /* 380 */ 1533, 1374, 1535, 1539, 1541, 1379, 1577, 1544, 1546, 1384, - /* 390 */ 1584, 1386, 1586, 1552, 1588, 1567, 1590, 1558, 1410, 1414, - /* 400 */ 1596, 1604, 1430, 1433, 1609, 1610, 1566, 1612, 1620, 1622, - /* 410 */ 1581, 1624, 1625, 1626, 1627, 1637, 1638, 1644, 1645, 1478, - /* 420 */ 1595, 1631, 1481, 1633, 1634, 1635, 1646, 1647, 1648, 1649, - /* 430 */ 1650, 1651, 1652, 1653, 1654, 1655, 1657, 1658, 1617, 1660, - /* 440 */ 1661, 1662, 1663, 1664, 1643, 1666, 1667, 1669, 1536, 1670, - /* 450 */ 1683, 1639, 1684, 1632, 1685, 1636, 1687, 1689, 1656, 1665, - /* 460 */ 1668, 1659, 1677, 1671, 1678, 1681, 1693, 1675, 1672, 1695, - /* 470 */ 1696, 1697, 1690, 1528, 1700, 1701, 1702, 1641, 1707, 1708, - /* 480 */ 1679, 1682, 1692, 1709, 1698, 1688, 1699, 1710, 1705, 1703, - /* 490 */ 1704, 1716, 1706, 1711, 1713, 1732, 1735, 1737, 1744, 1642, - /* 500 */ 1673, 1715, 1723, 1748, 1718, 1719, 1720, 1721, 1714, 1717, - /* 510 */ 1725, 1728, 1740, 1729, 1766, 1745, 1768, 1747, 1726, 1771, - /* 520 */ 1755, 1754, 1779, 1756, 1780, 1757, 1790, 1772, 1773, 1760, - /* 530 */ 1761, 1606, 1724, 1730, 1799, 1640, 1765, 1802, 1676, 1792, - /* 540 */ 1680, 1686, 1810, 1812, 1691, 1712, 1813, 1775, 1573, 1733, - /* 550 */ 1731, 1734, 1736, 1778, 1738, 1741, 1742, 1746, 1739, 1786, - /* 560 */ 1777, 1791, 1749, 1795, 1594, 1750, 1751, 1842, 1805, 1602, - /* 570 */ 1817, 1820, 1822, 1825, 1829, 1838, 1781, 1782, 1827, 1694, - /* 580 */ 1831, 1833, 1815, 1876, 1882, 1659, 1836, 1794, 1797, 1798, - /* 590 */ 1796, 1808, 1762, 1809, 1887, 1851, 1753, 1811, 1800, 1659, - /* 600 */ 1860, 1864, 1722, 1758, 1763, 1907, 1888, 1752, 1818, 1816, - /* 610 */ 1819, 1830, 1832, 1834, 1886, 1839, 1840, 1890, 1843, 1916, - /* 620 */ 1764, 1846, 1837, 1848, 1911, 1913, 1847, 1854, 1917, 1856, - /* 630 */ 1859, 1918, 1863, 1865, 1924, 1867, 1873, 1938, 1879, 1858, - /* 640 */ 1869, 1870, 1872, 1953, 1871, 1897, 1950, 1900, 1961, 1906, - /* 650 */ 1950, 1950, 1975, 1939, 1941, 1967, 1970, 1971, 1972, 1973, - /* 660 */ 1974, 1976, 1977, 1978, 1979, 1940, 1923, 1980, 1981, 1982, - /* 670 */ 1983, 1997, 1985, 1986, 1987, 1956, 1714, 1988, 1717, 1992, - /* 680 */ 1993, 1996, 2005, 2019, 2007, 2044, 2011, 1999, 2009, 2049, - /* 690 */ 2015, 2003, 2014, 2054, 2020, 2008, 2018, 2058, 2024, 2012, - /* 700 */ 2022, 2062, 2028, 2029, 2065, 2045, 2048, 2050, 2051, 2055, - /* 710 */ 2046, + /* 0 */ 133, 0, 71, 0, 289, 289, 289, 289, 289, 289, + /* 10 */ 289, 289, 289, 360, 576, 576, 647, 576, 576, 576, + /* 20 */ 576, 576, 576, 576, 576, 576, 576, 576, 576, 576, + /* 30 */ 576, 576, 576, 576, 576, 576, 576, 576, 576, 576, + /* 40 */ 576, 576, 576, 576, 576, 576, 59, 225, 110, 293, + /* 50 */ 58, 281, 473, 281, 110, 110, 940, 940, 940, 281, + /* 60 */ 940, 940, 347, 281, 78, 78, 422, 422, 36, 51, + /* 70 */ 230, 230, 78, 78, 78, 78, 78, 78, 78, 217, + /* 80 */ 78, 78, 204, 78, 78, 355, 78, 434, 78, 217, + /* 90 */ 456, 78, 78, 456, 78, 456, 456, 456, 78, 299, + /* 100 */ 786, 610, 610, 503, 112, 1116, 1116, 1116, 1116, 1116, + /* 110 */ 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, + /* 120 */ 1116, 1116, 1116, 1116, 563, 357, 36, 51, 413, 117, + /* 130 */ 220, 220, 220, 429, 379, 379, 117, 517, 517, 517, + /* 140 */ 343, 434, 174, 456, 475, 456, 475, 475, 343, 532, + /* 150 */ 323, 323, 323, 323, 323, 323, 323, 1601, 523, 181, + /* 160 */ 712, 809, 441, 581, 439, 674, 730, 790, 663, 967, + /* 170 */ 655, 939, 808, 588, 802, 808, 1042, 834, 956, 1106, + /* 180 */ 1309, 1200, 1341, 1371, 1341, 1234, 1376, 1376, 1341, 1234, + /* 190 */ 1234, 1308, 1376, 1376, 1376, 1399, 1399, 1403, 204, 434, + /* 200 */ 204, 1406, 1414, 204, 1406, 204, 204, 204, 1376, 204, + /* 210 */ 1404, 1404, 1399, 456, 456, 456, 456, 456, 456, 456, + /* 220 */ 456, 456, 456, 456, 1376, 1399, 475, 475, 1269, 1403, + /* 230 */ 299, 1284, 434, 299, 1376, 1371, 1371, 475, 1217, 1232, + /* 240 */ 475, 1217, 1232, 475, 475, 456, 1233, 1324, 1217, 1235, + /* 250 */ 1237, 1256, 1106, 1241, 1247, 1251, 1275, 517, 1512, 1376, + /* 260 */ 1406, 299, 1519, 1232, 475, 475, 475, 475, 475, 1232, + /* 270 */ 475, 1396, 299, 343, 299, 517, 1475, 1478, 475, 532, + /* 280 */ 1376, 299, 1540, 1399, 2733, 2733, 2733, 2733, 2733, 2733, + /* 290 */ 2733, 2733, 2733, 828, 1034, 457, 295, 260, 549, 759, + /* 300 */ 969, 874, 1033, 1227, 1211, 1279, 1279, 1279, 1279, 1279, + /* 310 */ 1279, 1279, 1279, 1279, 1041, 125, 13, 13, 506, 400, + /* 320 */ 516, 615, 587, 297, 297, 353, 53, 248, 353, 353, + /* 330 */ 353, 283, 1058, 572, 1043, 987, 1023, 1022, 1037, 1085, + /* 340 */ 1175, 1081, 1083, 1153, 915, 1079, 1098, 1100, 1101, 994, + /* 350 */ 990, 1057, 93, 1159, 1185, 1201, 1203, 1204, 1220, 1205, + /* 360 */ 1097, 1120, 1114, 1260, 1259, 1263, 1264, 1266, 1267, 1288, + /* 370 */ 1302, 40, 1122, 1332, 1315, 1327, 1594, 1606, 1420, 1609, + /* 380 */ 1610, 1569, 1612, 1578, 1415, 1579, 1581, 1583, 1419, 1622, + /* 390 */ 1588, 1595, 1432, 1633, 1435, 1636, 1602, 1638, 1619, 1642, + /* 400 */ 1608, 1463, 1466, 1648, 1650, 1477, 1476, 1660, 1661, 1615, + /* 410 */ 1678, 1680, 1681, 1623, 1666, 1667, 1668, 1669, 1670, 1671, + /* 420 */ 1672, 1673, 1513, 1639, 1675, 1525, 1682, 1684, 1685, 1692, + /* 430 */ 1696, 1697, 1699, 1700, 1701, 1703, 1704, 1705, 1706, 1708, + /* 440 */ 1710, 1674, 1711, 1712, 1713, 1714, 1715, 1695, 1718, 1719, + /* 450 */ 1720, 1586, 1722, 1723, 1689, 1732, 1677, 1733, 1679, 1736, + /* 460 */ 1739, 1686, 1687, 1683, 1693, 1716, 1702, 1737, 1707, 1729, + /* 470 */ 1717, 1721, 1747, 1752, 1753, 1724, 1587, 1759, 1762, 1765, + /* 480 */ 1709, 1766, 1767, 1735, 1727, 1738, 1772, 1741, 1730, 1740, + /* 490 */ 1774, 1745, 1734, 1742, 1783, 1749, 1744, 1750, 1788, 1790, + /* 500 */ 1793, 1795, 1694, 1725, 1776, 1775, 1802, 1777, 1779, 1780, + /* 510 */ 1781, 1773, 1778, 1784, 1785, 1787, 1786, 1818, 1801, 1824, + /* 520 */ 1803, 1782, 1828, 1809, 1804, 1841, 1807, 1843, 1810, 1846, + /* 530 */ 1825, 1829, 1813, 1815, 1816, 1757, 1760, 1854, 1698, 1821, + /* 540 */ 1858, 1688, 1840, 1743, 1751, 1863, 1864, 1754, 1728, 1862, + /* 550 */ 1822, 1618, 1791, 1789, 1792, 1805, 1826, 1832, 1806, 1794, + /* 560 */ 1808, 1820, 1823, 1833, 1831, 1834, 1827, 1835, 1620, 1836, + /* 570 */ 1837, 1869, 1838, 1631, 1848, 1888, 1889, 1890, 1892, 1893, + /* 580 */ 1839, 1842, 1852, 1731, 1882, 1883, 1931, 1937, 1939, 1693, + /* 590 */ 1894, 1845, 1847, 1850, 1849, 1853, 1796, 1855, 1942, 1908, + /* 600 */ 1799, 1856, 1859, 1693, 1911, 1916, 1748, 1755, 1758, 1964, + /* 610 */ 1955, 1797, 1884, 1885, 1887, 1896, 1895, 1897, 1933, 1899, + /* 620 */ 1900, 1936, 1901, 1956, 1800, 1904, 1878, 1905, 1952, 1953, + /* 630 */ 1907, 1909, 1954, 1912, 1913, 1961, 1915, 1918, 1965, 1917, + /* 640 */ 1919, 1969, 1921, 1898, 1902, 1906, 1910, 1996, 1920, 1924, + /* 650 */ 1976, 1928, 1989, 1938, 1976, 1976, 2004, 1967, 1971, 1993, + /* 660 */ 1997, 2001, 2005, 2006, 2008, 2009, 2016, 2019, 2020, 1986, + /* 670 */ 1947, 2013, 2023, 2024, 2025, 2039, 2028, 2029, 2030, 1998, + /* 680 */ 1773, 2032, 1778, 2040, 2042, 2043, 2044, 2058, 2046, 2082, + /* 690 */ 2050, 2038, 2048, 2088, 2055, 2041, 2052, 2093, 2059, 2047, + /* 700 */ 2057, 2098, 2065, 2053, 2063, 2103, 2069, 2070, 2106, 2085, + /* 710 */ 2087, 2089, 2090, 2092, 2095, }; -#define YY_REDUCE_COUNT (291) -#define YY_REDUCE_MIN (-425) -#define YY_REDUCE_MAX (2312) +#define YY_REDUCE_COUNT (292) +#define YY_REDUCE_MIN (-414) +#define YY_REDUCE_MAX (2320) static const short yy_reduce_ofst[] = { - /* 0 */ -17, -295, -7, 233, 633, 736, 781, 854, 909, 1021, - /* 10 */ 1051, 1107, 1127, -169, 1195, 77, 341, 1211, 1272, 1317, - /* 20 */ 1378, 1401, 1462, 1492, 1515, 1560, 1576, 1629, 1674, 1727, - /* 30 */ 1743, 1788, 1841, 1857, 1902, 1925, 1955, 2031, 2053, 2108, - /* 40 */ 2153, 2198, 2214, 2259, 2282, 2312, -276, -290, -168, -10, - /* 50 */ 834, 837, 907, 960, -327, -181, -348, -314, -425, 252, - /* 60 */ 755, -422, 289, -328, -219, -329, -291, -300, -303, -209, - /* 70 */ -144, -173, 78, 258, 278, 326, 668, 688, -288, 698, - /* 80 */ 727, 65, 748, 754, -275, 770, 86, 800, -152, -347, - /* 90 */ 802, 828, 123, 829, 186, 187, 192, 864, -158, -294, - /* 100 */ -282, -282, -182, -265, -170, -62, -6, 82, 105, 265, - /* 110 */ 276, 305, 310, 347, 383, 386, 392, 439, 442, 450, - /* 120 */ 480, 630, 631, 67, -150, 89, -116, 308, 173, -150, - /* 130 */ 311, 332, 309, 406, 426, 175, -58, 466, 521, 126, - /* 140 */ 306, 240, 456, 552, 516, 595, 601, 616, 627, 615, - /* 150 */ 648, 700, 718, 806, 815, 851, -337, 812, 814, 835, - /* 160 */ 726, 785, 895, 793, 882, 882, 904, 868, 916, 887, - /* 170 */ 898, 843, 843, 842, 843, 856, 859, 882, 902, 900, - /* 180 */ 915, 934, 939, 944, 949, 994, 995, 953, 958, 961, - /* 190 */ 993, 1004, 1005, 1006, 1015, 1016, 955, 1011, 974, 1014, - /* 200 */ 1024, 975, 1026, 1032, 1028, 1029, 1030, 1037, 1033, 1038, - /* 210 */ 1039, 1052, 1022, 1025, 1027, 1035, 1041, 1042, 1050, 1056, - /* 220 */ 1062, 1063, 1067, 1047, 1057, 1013, 1017, 1001, 1002, 1073, - /* 230 */ 1043, 1045, 1093, 1100, 1058, 1061, 1065, 1009, 1066, 1076, - /* 240 */ 1023, 1069, 1077, 1080, 882, 1018, 1034, 1046, 1036, 1044, - /* 250 */ 1048, 1072, 1068, 1053, 1070, 843, 1116, 1085, 1156, 1154, - /* 260 */ 1153, 1111, 1110, 1128, 1131, 1132, 1133, 1135, 1115, 1137, - /* 270 */ 1138, 1171, 1164, 1181, 1145, 1105, 1179, 1173, 1197, 1213, - /* 280 */ 1203, 1217, 1220, 1160, 1158, 1168, 1169, 1219, 1221, 1222, - /* 290 */ 1223, 1232, + /* 0 */ -292, -297, -8, 233, 597, 620, 706, 783, 807, 852, + /* 10 */ 907, 963, 1008, 1031, 1119, -320, 54, 1135, 1191, 1219, + /* 20 */ 1281, 1336, 1398, 1428, 1486, 1502, 1547, 1563, 1640, 1664, + /* 30 */ 1726, 1756, 1814, 1830, 1875, 1891, 1968, 1992, 2054, 2084, + /* 40 */ 2142, 2158, 2203, 2219, 2296, 2320, -193, 256, 320, -383, + /* 50 */ -332, -110, 605, 893, 302, 642, -337, -16, 273, -414, + /* 60 */ -352, -171, 284, 310, -235, -199, -331, -187, -340, -368, + /* 70 */ -255, -167, -304, -106, 190, 313, 387, 622, 623, -288, + /* 80 */ 631, 784, 50, 817, 897, -43, 902, -213, 917, 35, + /* 90 */ -159, 918, 937, -32, 998, -1, 255, 4, 630, -22, + /* 100 */ 144, -411, -411, 215, -240, -312, 219, 301, 383, 389, + /* 110 */ 436, 510, 513, 550, 552, 571, 593, 619, 621, 629, + /* 120 */ 640, 688, 692, 697, -346, -228, -109, -329, 195, 173, + /* 130 */ -228, 254, 339, -31, 199, 341, 470, 454, 583, 584, + /* 140 */ -226, 224, 363, 616, 462, 627, 682, 694, 600, 636, + /* 150 */ -343, 306, 318, 364, 396, 452, 519, 309, 557, 670, + /* 160 */ 606, 579, 646, 738, 740, 850, 850, 890, 847, 904, + /* 170 */ 900, 863, 856, 856, 833, 856, 926, 916, 850, 955, + /* 180 */ 978, 989, 1010, 1011, 1015, 1019, 1064, 1065, 1025, 1029, + /* 190 */ 1032, 1066, 1072, 1076, 1077, 1092, 1093, 1030, 1087, 1051, + /* 200 */ 1089, 1099, 1059, 1107, 1111, 1109, 1110, 1112, 1117, 1113, + /* 210 */ 1121, 1123, 1126, 1102, 1105, 1108, 1115, 1118, 1124, 1125, + /* 220 */ 1128, 1129, 1130, 1131, 1132, 1136, 1086, 1103, 1061, 1073, + /* 230 */ 1133, 1084, 1127, 1140, 1145, 1090, 1094, 1134, 1040, 1137, + /* 240 */ 1138, 1050, 1144, 1139, 1141, 850, 1052, 1054, 1062, 1067, + /* 250 */ 1063, 1075, 1148, 1055, 1068, 1082, 856, 1154, 1146, 1199, + /* 260 */ 1202, 1197, 1167, 1166, 1182, 1183, 1184, 1187, 1188, 1170, + /* 270 */ 1189, 1180, 1228, 1214, 1230, 1206, 1149, 1212, 1207, 1231, + /* 280 */ 1240, 1242, 1250, 1254, 1192, 1190, 1208, 1215, 1236, 1239, + /* 290 */ 1252, 1265, 1262, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 10 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 20 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 30 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 40 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 50 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 60 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1850, 1595, 1595, - /* 70 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 80 */ 1595, 1673, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 90 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1671, 1843, - /* 100 */ 2043, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 110 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 120 */ 1595, 1595, 1595, 1595, 2055, 1595, 1595, 1673, 1595, 2055, - /* 130 */ 2055, 2055, 1671, 2015, 2015, 1595, 1595, 1595, 1595, 1780, - /* 140 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1780, 1595, 1595, - /* 150 */ 1595, 1595, 1595, 1595, 1595, 1595, 1889, 1595, 1595, 2080, - /* 160 */ 2133, 1595, 1595, 2083, 1595, 1595, 1595, 1855, 1595, 1733, - /* 170 */ 2070, 2047, 2061, 2117, 2048, 2045, 2064, 1595, 2074, 1595, - /* 180 */ 1882, 1848, 1595, 1848, 1845, 1595, 1595, 1848, 1845, 1845, - /* 190 */ 1724, 1595, 1595, 1595, 1595, 1595, 1595, 1673, 1595, 1673, - /* 200 */ 1595, 1595, 1673, 1595, 1673, 1673, 1673, 1595, 1673, 1652, - /* 210 */ 1652, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 220 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1902, 1595, 1671, - /* 230 */ 1891, 1595, 1671, 1595, 1595, 1595, 1595, 2090, 2088, 1595, - /* 240 */ 2090, 2088, 1595, 1595, 1595, 2102, 2098, 2090, 2106, 2104, - /* 250 */ 2076, 2074, 2136, 2123, 2119, 2061, 1595, 1595, 1595, 1595, - /* 260 */ 1671, 1595, 2088, 1595, 1595, 1595, 1595, 1595, 2088, 1595, - /* 270 */ 1595, 1671, 1595, 1671, 1595, 1595, 1749, 1595, 1595, 1595, - /* 280 */ 1671, 1627, 1595, 1884, 1895, 1867, 1867, 1783, 1783, 1783, - /* 290 */ 1674, 1600, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 300 */ 1595, 1595, 1595, 1595, 2101, 2100, 1971, 1595, 2019, 2018, - /* 310 */ 2017, 2008, 1970, 1745, 1595, 1969, 1968, 1595, 1595, 1595, - /* 320 */ 1595, 1595, 1863, 1862, 1962, 1595, 1595, 1963, 1961, 1960, - /* 330 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 340 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 2120, 2124, 1595, - /* 350 */ 1595, 1595, 1595, 1595, 1595, 2044, 1595, 1595, 1595, 1595, - /* 360 */ 1595, 1944, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 370 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 380 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 390 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 400 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 410 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 420 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 430 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 440 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 450 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 460 */ 1632, 1949, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 470 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 480 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 490 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 500 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1712, 1711, - /* 510 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 520 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 530 */ 1595, 1595, 1953, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 540 */ 1595, 1595, 1595, 1595, 1595, 1595, 2116, 2077, 1595, 1595, - /* 550 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 560 */ 1595, 1944, 1595, 2099, 1595, 1595, 2114, 1595, 2118, 1595, - /* 570 */ 1595, 1595, 1595, 1595, 1595, 1595, 2054, 2050, 1595, 1595, - /* 580 */ 2046, 1595, 1595, 1595, 1595, 1952, 1595, 1595, 1595, 1595, - /* 590 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1943, - /* 600 */ 1595, 2005, 1595, 1595, 1595, 2039, 1595, 1595, 1990, 1595, - /* 610 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1953, 1595, - /* 620 */ 1956, 1595, 1595, 1595, 1595, 1595, 1777, 1595, 1595, 1595, - /* 630 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1762, - /* 640 */ 1760, 1759, 1758, 1595, 1755, 1595, 1790, 1595, 1595, 1595, - /* 650 */ 1786, 1785, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 660 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1692, 1595, 1595, - /* 670 */ 1595, 1595, 1595, 1595, 1595, 1595, 1684, 1595, 1683, 1595, - /* 680 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 690 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 700 */ 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, 1595, - /* 710 */ 1595, + /* 0 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 10 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 20 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 30 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 40 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 50 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 60 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1860, 1605, + /* 70 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 80 */ 1605, 1605, 1683, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 90 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1681, + /* 100 */ 1853, 2054, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 110 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 120 */ 1605, 1605, 1605, 1605, 1605, 2066, 1605, 1605, 1683, 1605, + /* 130 */ 2066, 2066, 2066, 1681, 2026, 2026, 1605, 1605, 1605, 1605, + /* 140 */ 1790, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1790, 1605, + /* 150 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1899, 1605, 1605, + /* 160 */ 2091, 2146, 1605, 1605, 2094, 1605, 1605, 1605, 1865, 1605, + /* 170 */ 1743, 2081, 2058, 2072, 2130, 2059, 2056, 2075, 1605, 2085, + /* 180 */ 1605, 1892, 1858, 1605, 1858, 1855, 1605, 1605, 1858, 1855, + /* 190 */ 1855, 1734, 1605, 1605, 1605, 1605, 1605, 1605, 1683, 1605, + /* 200 */ 1683, 1605, 1605, 1683, 1605, 1683, 1683, 1683, 1605, 1683, + /* 210 */ 1662, 1662, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 220 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1913, 1605, + /* 230 */ 1681, 1901, 1605, 1681, 1605, 1605, 1605, 1605, 2101, 2099, + /* 240 */ 1605, 2101, 2099, 1605, 1605, 1605, 2115, 2111, 2101, 2119, + /* 250 */ 2117, 2087, 2085, 2149, 2136, 2132, 2072, 1605, 1605, 1605, + /* 260 */ 1605, 1681, 1605, 2099, 1605, 1605, 1605, 1605, 1605, 2099, + /* 270 */ 1605, 1605, 1681, 1605, 1681, 1605, 1605, 1759, 1605, 1605, + /* 280 */ 1605, 1681, 1637, 1605, 1894, 1905, 1877, 1877, 1793, 1793, + /* 290 */ 1793, 1684, 1610, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 300 */ 1605, 1605, 1605, 1605, 1605, 2114, 2113, 1982, 1605, 2030, + /* 310 */ 2029, 2028, 2019, 1981, 1755, 1605, 1980, 1979, 1605, 1605, + /* 320 */ 1605, 1605, 1605, 1873, 1872, 1973, 1605, 1605, 1974, 1972, + /* 330 */ 1971, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 340 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 350 */ 2133, 2137, 1605, 1605, 1605, 1605, 1605, 1605, 2055, 1605, + /* 360 */ 1605, 1605, 1605, 1605, 1955, 1605, 1605, 1605, 1605, 1605, + /* 370 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 380 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 390 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 400 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 410 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 420 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 430 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 440 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 450 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 460 */ 1605, 1605, 1605, 1642, 1960, 1605, 1605, 1605, 1605, 1605, + /* 470 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 480 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 490 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 500 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 510 */ 1605, 1722, 1721, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 520 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 530 */ 1605, 1605, 1605, 1605, 1605, 1964, 1605, 1605, 1605, 1605, + /* 540 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 2129, + /* 550 */ 2088, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 560 */ 1605, 1605, 1605, 1605, 1605, 1955, 1605, 2112, 1605, 1605, + /* 570 */ 2127, 1605, 2131, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 580 */ 2065, 2061, 1605, 1605, 2057, 1605, 1605, 1605, 1605, 1963, + /* 590 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 600 */ 1605, 1605, 1605, 1954, 1605, 2016, 1605, 1605, 1605, 2050, + /* 610 */ 1605, 1605, 2001, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 620 */ 1605, 1605, 1964, 1605, 1967, 1605, 1605, 1605, 1605, 1605, + /* 630 */ 1787, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 640 */ 1605, 1605, 1605, 1772, 1770, 1769, 1768, 1605, 1765, 1605, + /* 650 */ 1800, 1605, 1605, 1605, 1796, 1795, 1605, 1605, 1605, 1605, + /* 660 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 670 */ 1605, 1702, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 680 */ 1694, 1605, 1693, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 690 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 700 */ 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, 1605, + /* 710 */ 1605, 1605, 1605, 1605, 1605, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1165,6 +1167,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* IGNORE => nothing */ 0, /* EXPIRED => nothing */ 0, /* FILL_HISTORY => nothing */ + 0, /* UPDATE => nothing */ 0, /* SUBTABLE => nothing */ 0, /* KILL => nothing */ 0, /* CONNECTION => nothing */ @@ -1198,7 +1201,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* COUNT => nothing */ 0, /* LAST_ROW => nothing */ 0, /* CASE => nothing */ - 268, /* END => ABORT */ + 271, /* END => ABORT */ 0, /* WHEN => nothing */ 0, /* THEN => nothing */ 0, /* ELSE => nothing */ @@ -1225,8 +1228,10 @@ static const YYCODETYPE yyFallback[] = { 0, /* SLIDING => nothing */ 0, /* FILL => nothing */ 0, /* VALUE => nothing */ + 0, /* VALUE_F => nothing */ 0, /* NONE => nothing */ 0, /* PREV => nothing */ + 0, /* NULL_F => nothing */ 0, /* LINEAR => nothing */ 0, /* NEXT => nothing */ 0, /* HAVING => nothing */ @@ -1240,59 +1245,58 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 268, /* AFTER => ABORT */ - 268, /* ATTACH => ABORT */ - 268, /* BEFORE => ABORT */ - 268, /* BEGIN => ABORT */ - 268, /* BITAND => ABORT */ - 268, /* BITNOT => ABORT */ - 268, /* BITOR => ABORT */ - 268, /* BLOCKS => ABORT */ - 268, /* CHANGE => ABORT */ - 268, /* COMMA => ABORT */ - 268, /* COMPACT => ABORT */ - 268, /* CONCAT => ABORT */ - 268, /* CONFLICT => ABORT */ - 268, /* COPY => ABORT */ - 268, /* DEFERRED => ABORT */ - 268, /* DELIMITERS => ABORT */ - 268, /* DETACH => ABORT */ - 268, /* DIVIDE => ABORT */ - 268, /* DOT => ABORT */ - 268, /* EACH => ABORT */ - 268, /* FAIL => ABORT */ - 268, /* FILE => ABORT */ - 268, /* FOR => ABORT */ - 268, /* GLOB => ABORT */ - 268, /* ID => ABORT */ - 268, /* IMMEDIATE => ABORT */ - 268, /* IMPORT => ABORT */ - 268, /* INITIALLY => ABORT */ - 268, /* INSTEAD => ABORT */ - 268, /* ISNULL => ABORT */ - 268, /* KEY => ABORT */ - 268, /* MODULES => ABORT */ - 268, /* NK_BITNOT => ABORT */ - 268, /* NK_SEMI => ABORT */ - 268, /* NOTNULL => ABORT */ - 268, /* OF => ABORT */ - 268, /* PLUS => ABORT */ - 268, /* PRIVILEGE => ABORT */ - 268, /* RAISE => ABORT */ - 268, /* REPLACE => ABORT */ - 268, /* RESTRICT => ABORT */ - 268, /* ROW => ABORT */ - 268, /* SEMI => ABORT */ - 268, /* STAR => ABORT */ - 268, /* STATEMENT => ABORT */ - 268, /* STRICT => ABORT */ - 268, /* STRING => ABORT */ - 268, /* TIMES => ABORT */ - 268, /* UPDATE => ABORT */ - 268, /* VALUES => ABORT */ - 268, /* VARIABLE => ABORT */ - 268, /* VIEW => ABORT */ - 268, /* WAL => ABORT */ + 271, /* AFTER => ABORT */ + 271, /* ATTACH => ABORT */ + 271, /* BEFORE => ABORT */ + 271, /* BEGIN => ABORT */ + 271, /* BITAND => ABORT */ + 271, /* BITNOT => ABORT */ + 271, /* BITOR => ABORT */ + 271, /* BLOCKS => ABORT */ + 271, /* CHANGE => ABORT */ + 271, /* COMMA => ABORT */ + 271, /* COMPACT => ABORT */ + 271, /* CONCAT => ABORT */ + 271, /* CONFLICT => ABORT */ + 271, /* COPY => ABORT */ + 271, /* DEFERRED => ABORT */ + 271, /* DELIMITERS => ABORT */ + 271, /* DETACH => ABORT */ + 271, /* DIVIDE => ABORT */ + 271, /* DOT => ABORT */ + 271, /* EACH => ABORT */ + 271, /* FAIL => ABORT */ + 271, /* FILE => ABORT */ + 271, /* FOR => ABORT */ + 271, /* GLOB => ABORT */ + 271, /* ID => ABORT */ + 271, /* IMMEDIATE => ABORT */ + 271, /* IMPORT => ABORT */ + 271, /* INITIALLY => ABORT */ + 271, /* INSTEAD => ABORT */ + 271, /* ISNULL => ABORT */ + 271, /* KEY => ABORT */ + 271, /* MODULES => ABORT */ + 271, /* NK_BITNOT => ABORT */ + 271, /* NK_SEMI => ABORT */ + 271, /* NOTNULL => ABORT */ + 271, /* OF => ABORT */ + 271, /* PLUS => ABORT */ + 271, /* PRIVILEGE => ABORT */ + 271, /* RAISE => ABORT */ + 271, /* REPLACE => ABORT */ + 271, /* RESTRICT => ABORT */ + 271, /* ROW => ABORT */ + 271, /* SEMI => ABORT */ + 271, /* STAR => ABORT */ + 271, /* STATEMENT => ABORT */ + 271, /* STRICT => ABORT */ + 271, /* STRING => ABORT */ + 271, /* TIMES => ABORT */ + 271, /* VALUES => ABORT */ + 271, /* VARIABLE => ABORT */ + 271, /* VIEW => ABORT */ + 271, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1574,271 +1578,273 @@ static const char *const yyTokenName[] = { /* 191 */ "IGNORE", /* 192 */ "EXPIRED", /* 193 */ "FILL_HISTORY", - /* 194 */ "SUBTABLE", - /* 195 */ "KILL", - /* 196 */ "CONNECTION", - /* 197 */ "TRANSACTION", - /* 198 */ "BALANCE", - /* 199 */ "VGROUP", - /* 200 */ "MERGE", - /* 201 */ "REDISTRIBUTE", - /* 202 */ "SPLIT", - /* 203 */ "DELETE", - /* 204 */ "INSERT", - /* 205 */ "NULL", - /* 206 */ "NK_QUESTION", - /* 207 */ "NK_ARROW", - /* 208 */ "ROWTS", - /* 209 */ "QSTART", - /* 210 */ "QEND", - /* 211 */ "QDURATION", - /* 212 */ "WSTART", - /* 213 */ "WEND", - /* 214 */ "WDURATION", - /* 215 */ "IROWTS", - /* 216 */ "CAST", - /* 217 */ "NOW", - /* 218 */ "TODAY", - /* 219 */ "TIMEZONE", - /* 220 */ "CLIENT_VERSION", - /* 221 */ "SERVER_VERSION", - /* 222 */ "SERVER_STATUS", - /* 223 */ "CURRENT_USER", - /* 224 */ "COUNT", - /* 225 */ "LAST_ROW", - /* 226 */ "CASE", - /* 227 */ "END", - /* 228 */ "WHEN", - /* 229 */ "THEN", - /* 230 */ "ELSE", - /* 231 */ "BETWEEN", - /* 232 */ "IS", - /* 233 */ "NK_LT", - /* 234 */ "NK_GT", - /* 235 */ "NK_LE", - /* 236 */ "NK_GE", - /* 237 */ "NK_NE", - /* 238 */ "MATCH", - /* 239 */ "NMATCH", - /* 240 */ "CONTAINS", - /* 241 */ "IN", - /* 242 */ "JOIN", - /* 243 */ "INNER", - /* 244 */ "SELECT", - /* 245 */ "DISTINCT", - /* 246 */ "WHERE", - /* 247 */ "PARTITION", - /* 248 */ "BY", - /* 249 */ "SESSION", - /* 250 */ "STATE_WINDOW", - /* 251 */ "SLIDING", - /* 252 */ "FILL", - /* 253 */ "VALUE", - /* 254 */ "NONE", - /* 255 */ "PREV", - /* 256 */ "LINEAR", - /* 257 */ "NEXT", - /* 258 */ "HAVING", - /* 259 */ "RANGE", - /* 260 */ "EVERY", - /* 261 */ "ORDER", - /* 262 */ "SLIMIT", - /* 263 */ "SOFFSET", - /* 264 */ "LIMIT", - /* 265 */ "OFFSET", - /* 266 */ "ASC", - /* 267 */ "NULLS", - /* 268 */ "ABORT", - /* 269 */ "AFTER", - /* 270 */ "ATTACH", - /* 271 */ "BEFORE", - /* 272 */ "BEGIN", - /* 273 */ "BITAND", - /* 274 */ "BITNOT", - /* 275 */ "BITOR", - /* 276 */ "BLOCKS", - /* 277 */ "CHANGE", - /* 278 */ "COMMA", - /* 279 */ "COMPACT", - /* 280 */ "CONCAT", - /* 281 */ "CONFLICT", - /* 282 */ "COPY", - /* 283 */ "DEFERRED", - /* 284 */ "DELIMITERS", - /* 285 */ "DETACH", - /* 286 */ "DIVIDE", - /* 287 */ "DOT", - /* 288 */ "EACH", - /* 289 */ "FAIL", - /* 290 */ "FILE", - /* 291 */ "FOR", - /* 292 */ "GLOB", - /* 293 */ "ID", - /* 294 */ "IMMEDIATE", - /* 295 */ "IMPORT", - /* 296 */ "INITIALLY", - /* 297 */ "INSTEAD", - /* 298 */ "ISNULL", - /* 299 */ "KEY", - /* 300 */ "MODULES", - /* 301 */ "NK_BITNOT", - /* 302 */ "NK_SEMI", - /* 303 */ "NOTNULL", - /* 304 */ "OF", - /* 305 */ "PLUS", - /* 306 */ "PRIVILEGE", - /* 307 */ "RAISE", - /* 308 */ "REPLACE", - /* 309 */ "RESTRICT", - /* 310 */ "ROW", - /* 311 */ "SEMI", - /* 312 */ "STAR", - /* 313 */ "STATEMENT", - /* 314 */ "STRICT", - /* 315 */ "STRING", - /* 316 */ "TIMES", - /* 317 */ "UPDATE", - /* 318 */ "VALUES", - /* 319 */ "VARIABLE", - /* 320 */ "VIEW", - /* 321 */ "WAL", - /* 322 */ "cmd", - /* 323 */ "account_options", - /* 324 */ "alter_account_options", - /* 325 */ "literal", - /* 326 */ "alter_account_option", - /* 327 */ "user_name", - /* 328 */ "sysinfo_opt", - /* 329 */ "privileges", - /* 330 */ "priv_level", - /* 331 */ "priv_type_list", - /* 332 */ "priv_type", - /* 333 */ "db_name", - /* 334 */ "topic_name", - /* 335 */ "dnode_endpoint", - /* 336 */ "force_opt", - /* 337 */ "not_exists_opt", - /* 338 */ "db_options", - /* 339 */ "exists_opt", - /* 340 */ "alter_db_options", - /* 341 */ "speed_opt", - /* 342 */ "integer_list", - /* 343 */ "variable_list", - /* 344 */ "retention_list", - /* 345 */ "alter_db_option", - /* 346 */ "retention", - /* 347 */ "full_table_name", - /* 348 */ "column_def_list", - /* 349 */ "tags_def_opt", - /* 350 */ "table_options", - /* 351 */ "multi_create_clause", - /* 352 */ "tags_def", - /* 353 */ "multi_drop_clause", - /* 354 */ "alter_table_clause", - /* 355 */ "alter_table_options", - /* 356 */ "column_name", - /* 357 */ "type_name", - /* 358 */ "signed_literal", - /* 359 */ "create_subtable_clause", - /* 360 */ "specific_cols_opt", - /* 361 */ "expression_list", - /* 362 */ "drop_table_clause", - /* 363 */ "col_name_list", - /* 364 */ "table_name", - /* 365 */ "column_def", - /* 366 */ "duration_list", - /* 367 */ "rollup_func_list", - /* 368 */ "alter_table_option", - /* 369 */ "duration_literal", - /* 370 */ "rollup_func_name", - /* 371 */ "function_name", - /* 372 */ "col_name", - /* 373 */ "db_name_cond_opt", - /* 374 */ "like_pattern_opt", - /* 375 */ "table_name_cond", - /* 376 */ "from_db_opt", - /* 377 */ "tag_list_opt", - /* 378 */ "tag_item", - /* 379 */ "column_alias", - /* 380 */ "full_index_name", - /* 381 */ "index_options", - /* 382 */ "index_name", - /* 383 */ "func_list", - /* 384 */ "sliding_opt", - /* 385 */ "sma_stream_opt", - /* 386 */ "func", - /* 387 */ "query_or_subquery", - /* 388 */ "cgroup_name", - /* 389 */ "analyze_opt", - /* 390 */ "explain_options", - /* 391 */ "agg_func_opt", - /* 392 */ "bufsize_opt", - /* 393 */ "stream_name", - /* 394 */ "stream_options", - /* 395 */ "subtable_opt", - /* 396 */ "expression", - /* 397 */ "dnode_list", - /* 398 */ "where_clause_opt", - /* 399 */ "signed", - /* 400 */ "literal_func", - /* 401 */ "literal_list", - /* 402 */ "table_alias", - /* 403 */ "expr_or_subquery", - /* 404 */ "pseudo_column", - /* 405 */ "column_reference", - /* 406 */ "function_expression", - /* 407 */ "case_when_expression", - /* 408 */ "star_func", - /* 409 */ "star_func_para_list", - /* 410 */ "noarg_func", - /* 411 */ "other_para_list", - /* 412 */ "star_func_para", - /* 413 */ "when_then_list", - /* 414 */ "case_when_else_opt", - /* 415 */ "common_expression", - /* 416 */ "when_then_expr", - /* 417 */ "predicate", - /* 418 */ "compare_op", - /* 419 */ "in_op", - /* 420 */ "in_predicate_value", - /* 421 */ "boolean_value_expression", - /* 422 */ "boolean_primary", - /* 423 */ "from_clause_opt", - /* 424 */ "table_reference_list", - /* 425 */ "table_reference", - /* 426 */ "table_primary", - /* 427 */ "joined_table", - /* 428 */ "alias_opt", - /* 429 */ "subquery", - /* 430 */ "parenthesized_joined_table", - /* 431 */ "join_type", - /* 432 */ "search_condition", - /* 433 */ "query_specification", - /* 434 */ "set_quantifier_opt", - /* 435 */ "select_list", - /* 436 */ "partition_by_clause_opt", - /* 437 */ "range_opt", - /* 438 */ "every_opt", - /* 439 */ "fill_opt", - /* 440 */ "twindow_clause_opt", - /* 441 */ "group_by_clause_opt", - /* 442 */ "having_clause_opt", - /* 443 */ "select_item", - /* 444 */ "partition_list", - /* 445 */ "partition_item", - /* 446 */ "fill_mode", - /* 447 */ "group_by_list", - /* 448 */ "query_expression", - /* 449 */ "query_simple", - /* 450 */ "order_by_clause_opt", - /* 451 */ "slimit_clause_opt", - /* 452 */ "limit_clause_opt", - /* 453 */ "union_query_expression", - /* 454 */ "query_simple_or_subquery", - /* 455 */ "sort_specification_list", - /* 456 */ "sort_specification", - /* 457 */ "ordering_specification_opt", - /* 458 */ "null_ordering_opt", + /* 194 */ "UPDATE", + /* 195 */ "SUBTABLE", + /* 196 */ "KILL", + /* 197 */ "CONNECTION", + /* 198 */ "TRANSACTION", + /* 199 */ "BALANCE", + /* 200 */ "VGROUP", + /* 201 */ "MERGE", + /* 202 */ "REDISTRIBUTE", + /* 203 */ "SPLIT", + /* 204 */ "DELETE", + /* 205 */ "INSERT", + /* 206 */ "NULL", + /* 207 */ "NK_QUESTION", + /* 208 */ "NK_ARROW", + /* 209 */ "ROWTS", + /* 210 */ "QSTART", + /* 211 */ "QEND", + /* 212 */ "QDURATION", + /* 213 */ "WSTART", + /* 214 */ "WEND", + /* 215 */ "WDURATION", + /* 216 */ "IROWTS", + /* 217 */ "CAST", + /* 218 */ "NOW", + /* 219 */ "TODAY", + /* 220 */ "TIMEZONE", + /* 221 */ "CLIENT_VERSION", + /* 222 */ "SERVER_VERSION", + /* 223 */ "SERVER_STATUS", + /* 224 */ "CURRENT_USER", + /* 225 */ "COUNT", + /* 226 */ "LAST_ROW", + /* 227 */ "CASE", + /* 228 */ "END", + /* 229 */ "WHEN", + /* 230 */ "THEN", + /* 231 */ "ELSE", + /* 232 */ "BETWEEN", + /* 233 */ "IS", + /* 234 */ "NK_LT", + /* 235 */ "NK_GT", + /* 236 */ "NK_LE", + /* 237 */ "NK_GE", + /* 238 */ "NK_NE", + /* 239 */ "MATCH", + /* 240 */ "NMATCH", + /* 241 */ "CONTAINS", + /* 242 */ "IN", + /* 243 */ "JOIN", + /* 244 */ "INNER", + /* 245 */ "SELECT", + /* 246 */ "DISTINCT", + /* 247 */ "WHERE", + /* 248 */ "PARTITION", + /* 249 */ "BY", + /* 250 */ "SESSION", + /* 251 */ "STATE_WINDOW", + /* 252 */ "SLIDING", + /* 253 */ "FILL", + /* 254 */ "VALUE", + /* 255 */ "VALUE_F", + /* 256 */ "NONE", + /* 257 */ "PREV", + /* 258 */ "NULL_F", + /* 259 */ "LINEAR", + /* 260 */ "NEXT", + /* 261 */ "HAVING", + /* 262 */ "RANGE", + /* 263 */ "EVERY", + /* 264 */ "ORDER", + /* 265 */ "SLIMIT", + /* 266 */ "SOFFSET", + /* 267 */ "LIMIT", + /* 268 */ "OFFSET", + /* 269 */ "ASC", + /* 270 */ "NULLS", + /* 271 */ "ABORT", + /* 272 */ "AFTER", + /* 273 */ "ATTACH", + /* 274 */ "BEFORE", + /* 275 */ "BEGIN", + /* 276 */ "BITAND", + /* 277 */ "BITNOT", + /* 278 */ "BITOR", + /* 279 */ "BLOCKS", + /* 280 */ "CHANGE", + /* 281 */ "COMMA", + /* 282 */ "COMPACT", + /* 283 */ "CONCAT", + /* 284 */ "CONFLICT", + /* 285 */ "COPY", + /* 286 */ "DEFERRED", + /* 287 */ "DELIMITERS", + /* 288 */ "DETACH", + /* 289 */ "DIVIDE", + /* 290 */ "DOT", + /* 291 */ "EACH", + /* 292 */ "FAIL", + /* 293 */ "FILE", + /* 294 */ "FOR", + /* 295 */ "GLOB", + /* 296 */ "ID", + /* 297 */ "IMMEDIATE", + /* 298 */ "IMPORT", + /* 299 */ "INITIALLY", + /* 300 */ "INSTEAD", + /* 301 */ "ISNULL", + /* 302 */ "KEY", + /* 303 */ "MODULES", + /* 304 */ "NK_BITNOT", + /* 305 */ "NK_SEMI", + /* 306 */ "NOTNULL", + /* 307 */ "OF", + /* 308 */ "PLUS", + /* 309 */ "PRIVILEGE", + /* 310 */ "RAISE", + /* 311 */ "REPLACE", + /* 312 */ "RESTRICT", + /* 313 */ "ROW", + /* 314 */ "SEMI", + /* 315 */ "STAR", + /* 316 */ "STATEMENT", + /* 317 */ "STRICT", + /* 318 */ "STRING", + /* 319 */ "TIMES", + /* 320 */ "VALUES", + /* 321 */ "VARIABLE", + /* 322 */ "VIEW", + /* 323 */ "WAL", + /* 324 */ "cmd", + /* 325 */ "account_options", + /* 326 */ "alter_account_options", + /* 327 */ "literal", + /* 328 */ "alter_account_option", + /* 329 */ "user_name", + /* 330 */ "sysinfo_opt", + /* 331 */ "privileges", + /* 332 */ "priv_level", + /* 333 */ "priv_type_list", + /* 334 */ "priv_type", + /* 335 */ "db_name", + /* 336 */ "topic_name", + /* 337 */ "dnode_endpoint", + /* 338 */ "force_opt", + /* 339 */ "not_exists_opt", + /* 340 */ "db_options", + /* 341 */ "exists_opt", + /* 342 */ "alter_db_options", + /* 343 */ "speed_opt", + /* 344 */ "integer_list", + /* 345 */ "variable_list", + /* 346 */ "retention_list", + /* 347 */ "alter_db_option", + /* 348 */ "retention", + /* 349 */ "full_table_name", + /* 350 */ "column_def_list", + /* 351 */ "tags_def_opt", + /* 352 */ "table_options", + /* 353 */ "multi_create_clause", + /* 354 */ "tags_def", + /* 355 */ "multi_drop_clause", + /* 356 */ "alter_table_clause", + /* 357 */ "alter_table_options", + /* 358 */ "column_name", + /* 359 */ "type_name", + /* 360 */ "signed_literal", + /* 361 */ "create_subtable_clause", + /* 362 */ "specific_cols_opt", + /* 363 */ "expression_list", + /* 364 */ "drop_table_clause", + /* 365 */ "col_name_list", + /* 366 */ "table_name", + /* 367 */ "column_def", + /* 368 */ "duration_list", + /* 369 */ "rollup_func_list", + /* 370 */ "alter_table_option", + /* 371 */ "duration_literal", + /* 372 */ "rollup_func_name", + /* 373 */ "function_name", + /* 374 */ "col_name", + /* 375 */ "db_name_cond_opt", + /* 376 */ "like_pattern_opt", + /* 377 */ "table_name_cond", + /* 378 */ "from_db_opt", + /* 379 */ "tag_list_opt", + /* 380 */ "tag_item", + /* 381 */ "column_alias", + /* 382 */ "full_index_name", + /* 383 */ "index_options", + /* 384 */ "index_name", + /* 385 */ "func_list", + /* 386 */ "sliding_opt", + /* 387 */ "sma_stream_opt", + /* 388 */ "func", + /* 389 */ "query_or_subquery", + /* 390 */ "cgroup_name", + /* 391 */ "analyze_opt", + /* 392 */ "explain_options", + /* 393 */ "agg_func_opt", + /* 394 */ "bufsize_opt", + /* 395 */ "stream_name", + /* 396 */ "stream_options", + /* 397 */ "subtable_opt", + /* 398 */ "expression", + /* 399 */ "dnode_list", + /* 400 */ "where_clause_opt", + /* 401 */ "signed", + /* 402 */ "literal_func", + /* 403 */ "literal_list", + /* 404 */ "table_alias", + /* 405 */ "expr_or_subquery", + /* 406 */ "pseudo_column", + /* 407 */ "column_reference", + /* 408 */ "function_expression", + /* 409 */ "case_when_expression", + /* 410 */ "star_func", + /* 411 */ "star_func_para_list", + /* 412 */ "noarg_func", + /* 413 */ "other_para_list", + /* 414 */ "star_func_para", + /* 415 */ "when_then_list", + /* 416 */ "case_when_else_opt", + /* 417 */ "common_expression", + /* 418 */ "when_then_expr", + /* 419 */ "predicate", + /* 420 */ "compare_op", + /* 421 */ "in_op", + /* 422 */ "in_predicate_value", + /* 423 */ "boolean_value_expression", + /* 424 */ "boolean_primary", + /* 425 */ "from_clause_opt", + /* 426 */ "table_reference_list", + /* 427 */ "table_reference", + /* 428 */ "table_primary", + /* 429 */ "joined_table", + /* 430 */ "alias_opt", + /* 431 */ "subquery", + /* 432 */ "parenthesized_joined_table", + /* 433 */ "join_type", + /* 434 */ "search_condition", + /* 435 */ "query_specification", + /* 436 */ "set_quantifier_opt", + /* 437 */ "select_list", + /* 438 */ "partition_by_clause_opt", + /* 439 */ "range_opt", + /* 440 */ "every_opt", + /* 441 */ "fill_opt", + /* 442 */ "twindow_clause_opt", + /* 443 */ "group_by_clause_opt", + /* 444 */ "having_clause_opt", + /* 445 */ "select_item", + /* 446 */ "partition_list", + /* 447 */ "partition_item", + /* 448 */ "fill_mode", + /* 449 */ "group_by_list", + /* 450 */ "query_expression", + /* 451 */ "query_simple", + /* 452 */ "order_by_clause_opt", + /* 453 */ "slimit_clause_opt", + /* 454 */ "limit_clause_opt", + /* 455 */ "union_query_expression", + /* 456 */ "query_simple_or_subquery", + /* 457 */ "sort_specification_list", + /* 458 */ "sort_specification", + /* 459 */ "ordering_specification_opt", + /* 460 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2150,243 +2156,246 @@ static const char *const yyRuleName[] = { /* 301 */ "stream_options ::= stream_options WATERMARK duration_literal", /* 302 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", /* 303 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 304 */ "subtable_opt ::=", - /* 305 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 306 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 307 */ "cmd ::= KILL QUERY NK_STRING", - /* 308 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 309 */ "cmd ::= BALANCE VGROUP", - /* 310 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 311 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 312 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 313 */ "dnode_list ::= DNODE NK_INTEGER", - /* 314 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 315 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 316 */ "cmd ::= query_or_subquery", - /* 317 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 318 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", - /* 319 */ "literal ::= NK_INTEGER", - /* 320 */ "literal ::= NK_FLOAT", - /* 321 */ "literal ::= NK_STRING", - /* 322 */ "literal ::= NK_BOOL", - /* 323 */ "literal ::= TIMESTAMP NK_STRING", - /* 324 */ "literal ::= duration_literal", - /* 325 */ "literal ::= NULL", - /* 326 */ "literal ::= NK_QUESTION", - /* 327 */ "duration_literal ::= NK_VARIABLE", - /* 328 */ "signed ::= NK_INTEGER", - /* 329 */ "signed ::= NK_PLUS NK_INTEGER", - /* 330 */ "signed ::= NK_MINUS NK_INTEGER", - /* 331 */ "signed ::= NK_FLOAT", - /* 332 */ "signed ::= NK_PLUS NK_FLOAT", - /* 333 */ "signed ::= NK_MINUS NK_FLOAT", - /* 334 */ "signed_literal ::= signed", - /* 335 */ "signed_literal ::= NK_STRING", - /* 336 */ "signed_literal ::= NK_BOOL", - /* 337 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 338 */ "signed_literal ::= duration_literal", - /* 339 */ "signed_literal ::= NULL", - /* 340 */ "signed_literal ::= literal_func", - /* 341 */ "signed_literal ::= NK_QUESTION", - /* 342 */ "literal_list ::= signed_literal", - /* 343 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 344 */ "db_name ::= NK_ID", - /* 345 */ "table_name ::= NK_ID", - /* 346 */ "column_name ::= NK_ID", - /* 347 */ "function_name ::= NK_ID", - /* 348 */ "table_alias ::= NK_ID", - /* 349 */ "column_alias ::= NK_ID", - /* 350 */ "user_name ::= NK_ID", - /* 351 */ "topic_name ::= NK_ID", - /* 352 */ "stream_name ::= NK_ID", - /* 353 */ "cgroup_name ::= NK_ID", - /* 354 */ "index_name ::= NK_ID", - /* 355 */ "expr_or_subquery ::= expression", - /* 356 */ "expression ::= literal", - /* 357 */ "expression ::= pseudo_column", - /* 358 */ "expression ::= column_reference", - /* 359 */ "expression ::= function_expression", - /* 360 */ "expression ::= case_when_expression", - /* 361 */ "expression ::= NK_LP expression NK_RP", - /* 362 */ "expression ::= NK_PLUS expr_or_subquery", - /* 363 */ "expression ::= NK_MINUS expr_or_subquery", - /* 364 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 365 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 366 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 367 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 368 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 369 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 370 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 371 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 372 */ "expression_list ::= expr_or_subquery", - /* 373 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 374 */ "column_reference ::= column_name", - /* 375 */ "column_reference ::= table_name NK_DOT column_name", - /* 376 */ "pseudo_column ::= ROWTS", - /* 377 */ "pseudo_column ::= TBNAME", - /* 378 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 379 */ "pseudo_column ::= QSTART", - /* 380 */ "pseudo_column ::= QEND", - /* 381 */ "pseudo_column ::= QDURATION", - /* 382 */ "pseudo_column ::= WSTART", - /* 383 */ "pseudo_column ::= WEND", - /* 384 */ "pseudo_column ::= WDURATION", - /* 385 */ "pseudo_column ::= IROWTS", - /* 386 */ "pseudo_column ::= QTAGS", - /* 387 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 388 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 389 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 390 */ "function_expression ::= literal_func", - /* 391 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 392 */ "literal_func ::= NOW", - /* 393 */ "noarg_func ::= NOW", - /* 394 */ "noarg_func ::= TODAY", - /* 395 */ "noarg_func ::= TIMEZONE", - /* 396 */ "noarg_func ::= DATABASE", - /* 397 */ "noarg_func ::= CLIENT_VERSION", - /* 398 */ "noarg_func ::= SERVER_VERSION", - /* 399 */ "noarg_func ::= SERVER_STATUS", - /* 400 */ "noarg_func ::= CURRENT_USER", - /* 401 */ "noarg_func ::= USER", - /* 402 */ "star_func ::= COUNT", - /* 403 */ "star_func ::= FIRST", - /* 404 */ "star_func ::= LAST", - /* 405 */ "star_func ::= LAST_ROW", - /* 406 */ "star_func_para_list ::= NK_STAR", - /* 407 */ "star_func_para_list ::= other_para_list", - /* 408 */ "other_para_list ::= star_func_para", - /* 409 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 410 */ "star_func_para ::= expr_or_subquery", - /* 411 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 412 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 413 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 414 */ "when_then_list ::= when_then_expr", - /* 415 */ "when_then_list ::= when_then_list when_then_expr", - /* 416 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 417 */ "case_when_else_opt ::=", - /* 418 */ "case_when_else_opt ::= ELSE common_expression", - /* 419 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 420 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 421 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 422 */ "predicate ::= expr_or_subquery IS NULL", - /* 423 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 424 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 425 */ "compare_op ::= NK_LT", - /* 426 */ "compare_op ::= NK_GT", - /* 427 */ "compare_op ::= NK_LE", - /* 428 */ "compare_op ::= NK_GE", - /* 429 */ "compare_op ::= NK_NE", - /* 430 */ "compare_op ::= NK_EQ", - /* 431 */ "compare_op ::= LIKE", - /* 432 */ "compare_op ::= NOT LIKE", - /* 433 */ "compare_op ::= MATCH", - /* 434 */ "compare_op ::= NMATCH", - /* 435 */ "compare_op ::= CONTAINS", - /* 436 */ "in_op ::= IN", - /* 437 */ "in_op ::= NOT IN", - /* 438 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 439 */ "boolean_value_expression ::= boolean_primary", - /* 440 */ "boolean_value_expression ::= NOT boolean_primary", - /* 441 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 442 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 443 */ "boolean_primary ::= predicate", - /* 444 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 445 */ "common_expression ::= expr_or_subquery", - /* 446 */ "common_expression ::= boolean_value_expression", - /* 447 */ "from_clause_opt ::=", - /* 448 */ "from_clause_opt ::= FROM table_reference_list", - /* 449 */ "table_reference_list ::= table_reference", - /* 450 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 451 */ "table_reference ::= table_primary", - /* 452 */ "table_reference ::= joined_table", - /* 453 */ "table_primary ::= table_name alias_opt", - /* 454 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 455 */ "table_primary ::= subquery alias_opt", - /* 456 */ "table_primary ::= parenthesized_joined_table", - /* 457 */ "alias_opt ::=", - /* 458 */ "alias_opt ::= table_alias", - /* 459 */ "alias_opt ::= AS table_alias", - /* 460 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 461 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 462 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 463 */ "join_type ::=", - /* 464 */ "join_type ::= INNER", - /* 465 */ "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", - /* 466 */ "set_quantifier_opt ::=", - /* 467 */ "set_quantifier_opt ::= DISTINCT", - /* 468 */ "set_quantifier_opt ::= ALL", - /* 469 */ "select_list ::= select_item", - /* 470 */ "select_list ::= select_list NK_COMMA select_item", - /* 471 */ "select_item ::= NK_STAR", - /* 472 */ "select_item ::= common_expression", - /* 473 */ "select_item ::= common_expression column_alias", - /* 474 */ "select_item ::= common_expression AS column_alias", - /* 475 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 476 */ "where_clause_opt ::=", - /* 477 */ "where_clause_opt ::= WHERE search_condition", - /* 478 */ "partition_by_clause_opt ::=", - /* 479 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 480 */ "partition_list ::= partition_item", - /* 481 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 482 */ "partition_item ::= expr_or_subquery", - /* 483 */ "partition_item ::= expr_or_subquery column_alias", - /* 484 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 485 */ "twindow_clause_opt ::=", - /* 486 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 487 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 488 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 489 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 490 */ "sliding_opt ::=", - /* 491 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 492 */ "fill_opt ::=", - /* 493 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 494 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 495 */ "fill_mode ::= NONE", - /* 496 */ "fill_mode ::= PREV", - /* 497 */ "fill_mode ::= NULL", - /* 498 */ "fill_mode ::= LINEAR", - /* 499 */ "fill_mode ::= NEXT", - /* 500 */ "group_by_clause_opt ::=", - /* 501 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 502 */ "group_by_list ::= expr_or_subquery", - /* 503 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 504 */ "having_clause_opt ::=", - /* 505 */ "having_clause_opt ::= HAVING search_condition", - /* 506 */ "range_opt ::=", - /* 507 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 508 */ "every_opt ::=", - /* 509 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 510 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 511 */ "query_simple ::= query_specification", - /* 512 */ "query_simple ::= union_query_expression", - /* 513 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 514 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 515 */ "query_simple_or_subquery ::= query_simple", - /* 516 */ "query_simple_or_subquery ::= subquery", - /* 517 */ "query_or_subquery ::= query_expression", - /* 518 */ "query_or_subquery ::= subquery", - /* 519 */ "order_by_clause_opt ::=", - /* 520 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 521 */ "slimit_clause_opt ::=", - /* 522 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 523 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 524 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 525 */ "limit_clause_opt ::=", - /* 526 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 527 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 528 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 529 */ "subquery ::= NK_LP query_expression NK_RP", - /* 530 */ "subquery ::= NK_LP subquery NK_RP", - /* 531 */ "search_condition ::= common_expression", - /* 532 */ "sort_specification_list ::= sort_specification", - /* 533 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 534 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 535 */ "ordering_specification_opt ::=", - /* 536 */ "ordering_specification_opt ::= ASC", - /* 537 */ "ordering_specification_opt ::= DESC", - /* 538 */ "null_ordering_opt ::=", - /* 539 */ "null_ordering_opt ::= NULLS FIRST", - /* 540 */ "null_ordering_opt ::= NULLS LAST", + /* 304 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 305 */ "subtable_opt ::=", + /* 306 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 307 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 308 */ "cmd ::= KILL QUERY NK_STRING", + /* 309 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 310 */ "cmd ::= BALANCE VGROUP", + /* 311 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 312 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 313 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 314 */ "dnode_list ::= DNODE NK_INTEGER", + /* 315 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 316 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 317 */ "cmd ::= query_or_subquery", + /* 318 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 319 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", + /* 320 */ "literal ::= NK_INTEGER", + /* 321 */ "literal ::= NK_FLOAT", + /* 322 */ "literal ::= NK_STRING", + /* 323 */ "literal ::= NK_BOOL", + /* 324 */ "literal ::= TIMESTAMP NK_STRING", + /* 325 */ "literal ::= duration_literal", + /* 326 */ "literal ::= NULL", + /* 327 */ "literal ::= NK_QUESTION", + /* 328 */ "duration_literal ::= NK_VARIABLE", + /* 329 */ "signed ::= NK_INTEGER", + /* 330 */ "signed ::= NK_PLUS NK_INTEGER", + /* 331 */ "signed ::= NK_MINUS NK_INTEGER", + /* 332 */ "signed ::= NK_FLOAT", + /* 333 */ "signed ::= NK_PLUS NK_FLOAT", + /* 334 */ "signed ::= NK_MINUS NK_FLOAT", + /* 335 */ "signed_literal ::= signed", + /* 336 */ "signed_literal ::= NK_STRING", + /* 337 */ "signed_literal ::= NK_BOOL", + /* 338 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 339 */ "signed_literal ::= duration_literal", + /* 340 */ "signed_literal ::= NULL", + /* 341 */ "signed_literal ::= literal_func", + /* 342 */ "signed_literal ::= NK_QUESTION", + /* 343 */ "literal_list ::= signed_literal", + /* 344 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 345 */ "db_name ::= NK_ID", + /* 346 */ "table_name ::= NK_ID", + /* 347 */ "column_name ::= NK_ID", + /* 348 */ "function_name ::= NK_ID", + /* 349 */ "table_alias ::= NK_ID", + /* 350 */ "column_alias ::= NK_ID", + /* 351 */ "user_name ::= NK_ID", + /* 352 */ "topic_name ::= NK_ID", + /* 353 */ "stream_name ::= NK_ID", + /* 354 */ "cgroup_name ::= NK_ID", + /* 355 */ "index_name ::= NK_ID", + /* 356 */ "expr_or_subquery ::= expression", + /* 357 */ "expression ::= literal", + /* 358 */ "expression ::= pseudo_column", + /* 359 */ "expression ::= column_reference", + /* 360 */ "expression ::= function_expression", + /* 361 */ "expression ::= case_when_expression", + /* 362 */ "expression ::= NK_LP expression NK_RP", + /* 363 */ "expression ::= NK_PLUS expr_or_subquery", + /* 364 */ "expression ::= NK_MINUS expr_or_subquery", + /* 365 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 366 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 367 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 368 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 369 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 370 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 371 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 372 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 373 */ "expression_list ::= expr_or_subquery", + /* 374 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 375 */ "column_reference ::= column_name", + /* 376 */ "column_reference ::= table_name NK_DOT column_name", + /* 377 */ "pseudo_column ::= ROWTS", + /* 378 */ "pseudo_column ::= TBNAME", + /* 379 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 380 */ "pseudo_column ::= QSTART", + /* 381 */ "pseudo_column ::= QEND", + /* 382 */ "pseudo_column ::= QDURATION", + /* 383 */ "pseudo_column ::= WSTART", + /* 384 */ "pseudo_column ::= WEND", + /* 385 */ "pseudo_column ::= WDURATION", + /* 386 */ "pseudo_column ::= IROWTS", + /* 387 */ "pseudo_column ::= QTAGS", + /* 388 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 389 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 390 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 391 */ "function_expression ::= literal_func", + /* 392 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 393 */ "literal_func ::= NOW", + /* 394 */ "noarg_func ::= NOW", + /* 395 */ "noarg_func ::= TODAY", + /* 396 */ "noarg_func ::= TIMEZONE", + /* 397 */ "noarg_func ::= DATABASE", + /* 398 */ "noarg_func ::= CLIENT_VERSION", + /* 399 */ "noarg_func ::= SERVER_VERSION", + /* 400 */ "noarg_func ::= SERVER_STATUS", + /* 401 */ "noarg_func ::= CURRENT_USER", + /* 402 */ "noarg_func ::= USER", + /* 403 */ "star_func ::= COUNT", + /* 404 */ "star_func ::= FIRST", + /* 405 */ "star_func ::= LAST", + /* 406 */ "star_func ::= LAST_ROW", + /* 407 */ "star_func_para_list ::= NK_STAR", + /* 408 */ "star_func_para_list ::= other_para_list", + /* 409 */ "other_para_list ::= star_func_para", + /* 410 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 411 */ "star_func_para ::= expr_or_subquery", + /* 412 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 413 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 414 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 415 */ "when_then_list ::= when_then_expr", + /* 416 */ "when_then_list ::= when_then_list when_then_expr", + /* 417 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 418 */ "case_when_else_opt ::=", + /* 419 */ "case_when_else_opt ::= ELSE common_expression", + /* 420 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 421 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 422 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 423 */ "predicate ::= expr_or_subquery IS NULL", + /* 424 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 425 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 426 */ "compare_op ::= NK_LT", + /* 427 */ "compare_op ::= NK_GT", + /* 428 */ "compare_op ::= NK_LE", + /* 429 */ "compare_op ::= NK_GE", + /* 430 */ "compare_op ::= NK_NE", + /* 431 */ "compare_op ::= NK_EQ", + /* 432 */ "compare_op ::= LIKE", + /* 433 */ "compare_op ::= NOT LIKE", + /* 434 */ "compare_op ::= MATCH", + /* 435 */ "compare_op ::= NMATCH", + /* 436 */ "compare_op ::= CONTAINS", + /* 437 */ "in_op ::= IN", + /* 438 */ "in_op ::= NOT IN", + /* 439 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 440 */ "boolean_value_expression ::= boolean_primary", + /* 441 */ "boolean_value_expression ::= NOT boolean_primary", + /* 442 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 443 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 444 */ "boolean_primary ::= predicate", + /* 445 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 446 */ "common_expression ::= expr_or_subquery", + /* 447 */ "common_expression ::= boolean_value_expression", + /* 448 */ "from_clause_opt ::=", + /* 449 */ "from_clause_opt ::= FROM table_reference_list", + /* 450 */ "table_reference_list ::= table_reference", + /* 451 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 452 */ "table_reference ::= table_primary", + /* 453 */ "table_reference ::= joined_table", + /* 454 */ "table_primary ::= table_name alias_opt", + /* 455 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 456 */ "table_primary ::= subquery alias_opt", + /* 457 */ "table_primary ::= parenthesized_joined_table", + /* 458 */ "alias_opt ::=", + /* 459 */ "alias_opt ::= table_alias", + /* 460 */ "alias_opt ::= AS table_alias", + /* 461 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 462 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 463 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 464 */ "join_type ::=", + /* 465 */ "join_type ::= INNER", + /* 466 */ "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", + /* 467 */ "set_quantifier_opt ::=", + /* 468 */ "set_quantifier_opt ::= DISTINCT", + /* 469 */ "set_quantifier_opt ::= ALL", + /* 470 */ "select_list ::= select_item", + /* 471 */ "select_list ::= select_list NK_COMMA select_item", + /* 472 */ "select_item ::= NK_STAR", + /* 473 */ "select_item ::= common_expression", + /* 474 */ "select_item ::= common_expression column_alias", + /* 475 */ "select_item ::= common_expression AS column_alias", + /* 476 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 477 */ "where_clause_opt ::=", + /* 478 */ "where_clause_opt ::= WHERE search_condition", + /* 479 */ "partition_by_clause_opt ::=", + /* 480 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 481 */ "partition_list ::= partition_item", + /* 482 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 483 */ "partition_item ::= expr_or_subquery", + /* 484 */ "partition_item ::= expr_or_subquery column_alias", + /* 485 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 486 */ "twindow_clause_opt ::=", + /* 487 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 488 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 489 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 490 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 491 */ "sliding_opt ::=", + /* 492 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 493 */ "fill_opt ::=", + /* 494 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 495 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 496 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP", + /* 497 */ "fill_mode ::= NONE", + /* 498 */ "fill_mode ::= PREV", + /* 499 */ "fill_mode ::= NULL", + /* 500 */ "fill_mode ::= NULL_F", + /* 501 */ "fill_mode ::= LINEAR", + /* 502 */ "fill_mode ::= NEXT", + /* 503 */ "group_by_clause_opt ::=", + /* 504 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 505 */ "group_by_list ::= expr_or_subquery", + /* 506 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 507 */ "having_clause_opt ::=", + /* 508 */ "having_clause_opt ::= HAVING search_condition", + /* 509 */ "range_opt ::=", + /* 510 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 511 */ "every_opt ::=", + /* 512 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 513 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 514 */ "query_simple ::= query_specification", + /* 515 */ "query_simple ::= union_query_expression", + /* 516 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 517 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 518 */ "query_simple_or_subquery ::= query_simple", + /* 519 */ "query_simple_or_subquery ::= subquery", + /* 520 */ "query_or_subquery ::= query_expression", + /* 521 */ "query_or_subquery ::= subquery", + /* 522 */ "order_by_clause_opt ::=", + /* 523 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 524 */ "slimit_clause_opt ::=", + /* 525 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 526 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 527 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 528 */ "limit_clause_opt ::=", + /* 529 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 530 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 531 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 532 */ "subquery ::= NK_LP query_expression NK_RP", + /* 533 */ "subquery ::= NK_LP subquery NK_RP", + /* 534 */ "search_condition ::= common_expression", + /* 535 */ "sort_specification_list ::= sort_specification", + /* 536 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 537 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 538 */ "ordering_specification_opt ::=", + /* 539 */ "ordering_specification_opt ::= ASC", + /* 540 */ "ordering_specification_opt ::= DESC", + /* 541 */ "null_ordering_opt ::=", + /* 542 */ "null_ordering_opt ::= NULLS FIRST", + /* 543 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2513,195 +2522,195 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 322: /* cmd */ - case 325: /* literal */ - case 338: /* db_options */ - case 340: /* alter_db_options */ - case 346: /* retention */ - case 347: /* full_table_name */ - case 350: /* table_options */ - case 354: /* alter_table_clause */ - case 355: /* alter_table_options */ - case 358: /* signed_literal */ - case 359: /* create_subtable_clause */ - case 362: /* drop_table_clause */ - case 365: /* column_def */ - case 369: /* duration_literal */ - case 370: /* rollup_func_name */ - case 372: /* col_name */ - case 373: /* db_name_cond_opt */ - case 374: /* like_pattern_opt */ - case 375: /* table_name_cond */ - case 376: /* from_db_opt */ - case 378: /* tag_item */ - case 380: /* full_index_name */ - case 381: /* index_options */ - case 384: /* sliding_opt */ - case 385: /* sma_stream_opt */ - case 386: /* func */ - case 387: /* query_or_subquery */ - case 390: /* explain_options */ - case 394: /* stream_options */ - case 395: /* subtable_opt */ - case 396: /* expression */ - case 398: /* where_clause_opt */ - case 399: /* signed */ - case 400: /* literal_func */ - case 403: /* expr_or_subquery */ - case 404: /* pseudo_column */ - case 405: /* column_reference */ - case 406: /* function_expression */ - case 407: /* case_when_expression */ - case 412: /* star_func_para */ - case 414: /* case_when_else_opt */ - case 415: /* common_expression */ - case 416: /* when_then_expr */ - case 417: /* predicate */ - case 420: /* in_predicate_value */ - case 421: /* boolean_value_expression */ - case 422: /* boolean_primary */ - case 423: /* from_clause_opt */ - case 424: /* table_reference_list */ - case 425: /* table_reference */ - case 426: /* table_primary */ - case 427: /* joined_table */ - case 429: /* subquery */ - case 430: /* parenthesized_joined_table */ - case 432: /* search_condition */ - case 433: /* query_specification */ - case 437: /* range_opt */ - case 438: /* every_opt */ - case 439: /* fill_opt */ - case 440: /* twindow_clause_opt */ - case 442: /* having_clause_opt */ - case 443: /* select_item */ - case 445: /* partition_item */ - case 448: /* query_expression */ - case 449: /* query_simple */ - case 451: /* slimit_clause_opt */ - case 452: /* limit_clause_opt */ - case 453: /* union_query_expression */ - case 454: /* query_simple_or_subquery */ - case 456: /* sort_specification */ + case 324: /* cmd */ + case 327: /* literal */ + case 340: /* db_options */ + case 342: /* alter_db_options */ + case 348: /* retention */ + case 349: /* full_table_name */ + case 352: /* table_options */ + case 356: /* alter_table_clause */ + case 357: /* alter_table_options */ + case 360: /* signed_literal */ + case 361: /* create_subtable_clause */ + case 364: /* drop_table_clause */ + case 367: /* column_def */ + case 371: /* duration_literal */ + case 372: /* rollup_func_name */ + case 374: /* col_name */ + case 375: /* db_name_cond_opt */ + case 376: /* like_pattern_opt */ + case 377: /* table_name_cond */ + case 378: /* from_db_opt */ + case 380: /* tag_item */ + case 382: /* full_index_name */ + case 383: /* index_options */ + case 386: /* sliding_opt */ + case 387: /* sma_stream_opt */ + case 388: /* func */ + case 389: /* query_or_subquery */ + case 392: /* explain_options */ + case 396: /* stream_options */ + case 397: /* subtable_opt */ + case 398: /* expression */ + case 400: /* where_clause_opt */ + case 401: /* signed */ + case 402: /* literal_func */ + case 405: /* expr_or_subquery */ + case 406: /* pseudo_column */ + case 407: /* column_reference */ + case 408: /* function_expression */ + case 409: /* case_when_expression */ + case 414: /* star_func_para */ + case 416: /* case_when_else_opt */ + case 417: /* common_expression */ + case 418: /* when_then_expr */ + case 419: /* predicate */ + case 422: /* in_predicate_value */ + case 423: /* boolean_value_expression */ + case 424: /* boolean_primary */ + case 425: /* from_clause_opt */ + case 426: /* table_reference_list */ + case 427: /* table_reference */ + case 428: /* table_primary */ + case 429: /* joined_table */ + case 431: /* subquery */ + case 432: /* parenthesized_joined_table */ + case 434: /* search_condition */ + case 435: /* query_specification */ + case 439: /* range_opt */ + case 440: /* every_opt */ + case 441: /* fill_opt */ + case 442: /* twindow_clause_opt */ + case 444: /* having_clause_opt */ + case 445: /* select_item */ + case 447: /* partition_item */ + case 450: /* query_expression */ + case 451: /* query_simple */ + case 453: /* slimit_clause_opt */ + case 454: /* limit_clause_opt */ + case 455: /* union_query_expression */ + case 456: /* query_simple_or_subquery */ + case 458: /* sort_specification */ { - nodesDestroyNode((yypminor->yy74)); + nodesDestroyNode((yypminor->yy600)); } break; - case 323: /* account_options */ - case 324: /* alter_account_options */ - case 326: /* alter_account_option */ - case 341: /* speed_opt */ - case 392: /* bufsize_opt */ + case 325: /* account_options */ + case 326: /* alter_account_options */ + case 328: /* alter_account_option */ + case 343: /* speed_opt */ + case 394: /* bufsize_opt */ { } break; - case 327: /* user_name */ - case 330: /* priv_level */ - case 333: /* db_name */ - case 334: /* topic_name */ - case 335: /* dnode_endpoint */ - case 356: /* column_name */ - case 364: /* table_name */ - case 371: /* function_name */ - case 379: /* column_alias */ - case 382: /* index_name */ - case 388: /* cgroup_name */ - case 393: /* stream_name */ - case 402: /* table_alias */ - case 408: /* star_func */ - case 410: /* noarg_func */ - case 428: /* alias_opt */ + case 329: /* user_name */ + case 332: /* priv_level */ + case 335: /* db_name */ + case 336: /* topic_name */ + case 337: /* dnode_endpoint */ + case 358: /* column_name */ + case 366: /* table_name */ + case 373: /* function_name */ + case 381: /* column_alias */ + case 384: /* index_name */ + case 390: /* cgroup_name */ + case 395: /* stream_name */ + case 404: /* table_alias */ + case 410: /* star_func */ + case 412: /* noarg_func */ + case 430: /* alias_opt */ { } break; - case 328: /* sysinfo_opt */ + case 330: /* sysinfo_opt */ { } break; - case 329: /* privileges */ - case 331: /* priv_type_list */ - case 332: /* priv_type */ + case 331: /* privileges */ + case 333: /* priv_type_list */ + case 334: /* priv_type */ { } break; - case 336: /* force_opt */ - case 337: /* not_exists_opt */ - case 339: /* exists_opt */ - case 389: /* analyze_opt */ - case 391: /* agg_func_opt */ - case 434: /* set_quantifier_opt */ + case 338: /* force_opt */ + case 339: /* not_exists_opt */ + case 341: /* exists_opt */ + case 391: /* analyze_opt */ + case 393: /* agg_func_opt */ + case 436: /* set_quantifier_opt */ { } break; - case 342: /* integer_list */ - case 343: /* variable_list */ - case 344: /* retention_list */ - case 348: /* column_def_list */ - case 349: /* tags_def_opt */ - case 351: /* multi_create_clause */ - case 352: /* tags_def */ - case 353: /* multi_drop_clause */ - case 360: /* specific_cols_opt */ - case 361: /* expression_list */ - case 363: /* col_name_list */ - case 366: /* duration_list */ - case 367: /* rollup_func_list */ - case 377: /* tag_list_opt */ - case 383: /* func_list */ - case 397: /* dnode_list */ - case 401: /* literal_list */ - case 409: /* star_func_para_list */ - case 411: /* other_para_list */ - case 413: /* when_then_list */ - case 435: /* select_list */ - case 436: /* partition_by_clause_opt */ - case 441: /* group_by_clause_opt */ - case 444: /* partition_list */ - case 447: /* group_by_list */ - case 450: /* order_by_clause_opt */ - case 455: /* sort_specification_list */ + case 344: /* integer_list */ + case 345: /* variable_list */ + case 346: /* retention_list */ + case 350: /* column_def_list */ + case 351: /* tags_def_opt */ + case 353: /* multi_create_clause */ + case 354: /* tags_def */ + case 355: /* multi_drop_clause */ + case 362: /* specific_cols_opt */ + case 363: /* expression_list */ + case 365: /* col_name_list */ + case 368: /* duration_list */ + case 369: /* rollup_func_list */ + case 379: /* tag_list_opt */ + case 385: /* func_list */ + case 399: /* dnode_list */ + case 403: /* literal_list */ + case 411: /* star_func_para_list */ + case 413: /* other_para_list */ + case 415: /* when_then_list */ + case 437: /* select_list */ + case 438: /* partition_by_clause_opt */ + case 443: /* group_by_clause_opt */ + case 446: /* partition_list */ + case 449: /* group_by_list */ + case 452: /* order_by_clause_opt */ + case 457: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy874)); + nodesDestroyList((yypminor->yy601)); } break; - case 345: /* alter_db_option */ - case 368: /* alter_table_option */ + case 347: /* alter_db_option */ + case 370: /* alter_table_option */ { } break; - case 357: /* type_name */ + case 359: /* type_name */ { } break; - case 418: /* compare_op */ - case 419: /* in_op */ + case 420: /* compare_op */ + case 421: /* in_op */ { } break; - case 431: /* join_type */ + case 433: /* join_type */ { } break; - case 446: /* fill_mode */ + case 448: /* fill_mode */ { } break; - case 457: /* ordering_specification_opt */ + case 459: /* ordering_specification_opt */ { } break; - case 458: /* null_ordering_opt */ + case 460: /* null_ordering_opt */ { } @@ -3000,547 +3009,550 @@ 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[] = { - { 322, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 322, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 323, 0 }, /* (2) account_options ::= */ - { 323, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 323, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 323, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 323, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 323, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 323, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 323, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 323, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 323, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 324, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 324, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 326, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 326, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 326, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 326, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 326, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 326, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 326, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 326, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 326, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 326, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 322, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 322, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 322, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 322, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 322, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 328, 0 }, /* (29) sysinfo_opt ::= */ - { 328, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 322, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 322, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 329, -1 }, /* (33) privileges ::= ALL */ - { 329, -1 }, /* (34) privileges ::= priv_type_list */ - { 329, -1 }, /* (35) privileges ::= SUBSCRIBE */ - { 331, -1 }, /* (36) priv_type_list ::= priv_type */ - { 331, -3 }, /* (37) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 332, -1 }, /* (38) priv_type ::= READ */ - { 332, -1 }, /* (39) priv_type ::= WRITE */ - { 330, -3 }, /* (40) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 330, -3 }, /* (41) priv_level ::= db_name NK_DOT NK_STAR */ - { 330, -1 }, /* (42) priv_level ::= topic_name */ - { 322, -3 }, /* (43) cmd ::= CREATE DNODE dnode_endpoint */ - { 322, -5 }, /* (44) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 322, -4 }, /* (45) cmd ::= DROP DNODE NK_INTEGER force_opt */ - { 322, -4 }, /* (46) cmd ::= DROP DNODE dnode_endpoint force_opt */ - { 322, -4 }, /* (47) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 322, -5 }, /* (48) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 322, -4 }, /* (49) cmd ::= ALTER ALL DNODES NK_STRING */ - { 322, -5 }, /* (50) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 335, -1 }, /* (51) dnode_endpoint ::= NK_STRING */ - { 335, -1 }, /* (52) dnode_endpoint ::= NK_ID */ - { 335, -1 }, /* (53) dnode_endpoint ::= NK_IPTOKEN */ - { 336, 0 }, /* (54) force_opt ::= */ - { 336, -1 }, /* (55) force_opt ::= FORCE */ - { 322, -3 }, /* (56) cmd ::= ALTER LOCAL NK_STRING */ - { 322, -4 }, /* (57) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 322, -5 }, /* (58) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 322, -5 }, /* (59) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 322, -5 }, /* (60) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 322, -5 }, /* (61) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 322, -5 }, /* (62) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 322, -5 }, /* (63) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 322, -5 }, /* (64) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 322, -5 }, /* (65) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 322, -5 }, /* (66) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 322, -4 }, /* (67) cmd ::= DROP DATABASE exists_opt db_name */ - { 322, -2 }, /* (68) cmd ::= USE db_name */ - { 322, -4 }, /* (69) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 322, -3 }, /* (70) cmd ::= FLUSH DATABASE db_name */ - { 322, -4 }, /* (71) cmd ::= TRIM DATABASE db_name speed_opt */ - { 337, -3 }, /* (72) not_exists_opt ::= IF NOT EXISTS */ - { 337, 0 }, /* (73) not_exists_opt ::= */ - { 339, -2 }, /* (74) exists_opt ::= IF EXISTS */ - { 339, 0 }, /* (75) exists_opt ::= */ - { 338, 0 }, /* (76) db_options ::= */ - { 338, -3 }, /* (77) db_options ::= db_options BUFFER NK_INTEGER */ - { 338, -3 }, /* (78) db_options ::= db_options CACHEMODEL NK_STRING */ - { 338, -3 }, /* (79) db_options ::= db_options CACHESIZE NK_INTEGER */ - { 338, -3 }, /* (80) db_options ::= db_options COMP NK_INTEGER */ - { 338, -3 }, /* (81) db_options ::= db_options DURATION NK_INTEGER */ - { 338, -3 }, /* (82) db_options ::= db_options DURATION NK_VARIABLE */ - { 338, -3 }, /* (83) db_options ::= db_options MAXROWS NK_INTEGER */ - { 338, -3 }, /* (84) db_options ::= db_options MINROWS NK_INTEGER */ - { 338, -3 }, /* (85) db_options ::= db_options KEEP integer_list */ - { 338, -3 }, /* (86) db_options ::= db_options KEEP variable_list */ - { 338, -3 }, /* (87) db_options ::= db_options PAGES NK_INTEGER */ - { 338, -3 }, /* (88) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 338, -3 }, /* (89) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - { 338, -3 }, /* (90) db_options ::= db_options PRECISION NK_STRING */ - { 338, -3 }, /* (91) db_options ::= db_options REPLICA NK_INTEGER */ - { 338, -3 }, /* (92) db_options ::= db_options VGROUPS NK_INTEGER */ - { 338, -3 }, /* (93) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 338, -3 }, /* (94) db_options ::= db_options RETENTIONS retention_list */ - { 338, -3 }, /* (95) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 338, -3 }, /* (96) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - { 338, -3 }, /* (97) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - { 338, -3 }, /* (98) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - { 338, -4 }, /* (99) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - { 338, -3 }, /* (100) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - { 338, -4 }, /* (101) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - { 338, -3 }, /* (102) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - { 338, -3 }, /* (103) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - { 338, -3 }, /* (104) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - { 338, -3 }, /* (105) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ - { 338, -3 }, /* (106) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ - { 340, -1 }, /* (107) alter_db_options ::= alter_db_option */ - { 340, -2 }, /* (108) alter_db_options ::= alter_db_options alter_db_option */ - { 345, -2 }, /* (109) alter_db_option ::= BUFFER NK_INTEGER */ - { 345, -2 }, /* (110) alter_db_option ::= CACHEMODEL NK_STRING */ - { 345, -2 }, /* (111) alter_db_option ::= CACHESIZE NK_INTEGER */ - { 345, -2 }, /* (112) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - { 345, -2 }, /* (113) alter_db_option ::= KEEP integer_list */ - { 345, -2 }, /* (114) alter_db_option ::= KEEP variable_list */ - { 345, -2 }, /* (115) alter_db_option ::= PAGES NK_INTEGER */ - { 345, -2 }, /* (116) alter_db_option ::= REPLICA NK_INTEGER */ - { 345, -2 }, /* (117) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - { 345, -2 }, /* (118) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - { 342, -1 }, /* (119) integer_list ::= NK_INTEGER */ - { 342, -3 }, /* (120) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 343, -1 }, /* (121) variable_list ::= NK_VARIABLE */ - { 343, -3 }, /* (122) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 344, -1 }, /* (123) retention_list ::= retention */ - { 344, -3 }, /* (124) retention_list ::= retention_list NK_COMMA retention */ - { 346, -3 }, /* (125) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 341, 0 }, /* (126) speed_opt ::= */ - { 341, -2 }, /* (127) speed_opt ::= MAX_SPEED NK_INTEGER */ - { 322, -9 }, /* (128) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 322, -3 }, /* (129) cmd ::= CREATE TABLE multi_create_clause */ - { 322, -9 }, /* (130) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 322, -3 }, /* (131) cmd ::= DROP TABLE multi_drop_clause */ - { 322, -4 }, /* (132) cmd ::= DROP STABLE exists_opt full_table_name */ - { 322, -3 }, /* (133) cmd ::= ALTER TABLE alter_table_clause */ - { 322, -3 }, /* (134) cmd ::= ALTER STABLE alter_table_clause */ - { 354, -2 }, /* (135) alter_table_clause ::= full_table_name alter_table_options */ - { 354, -5 }, /* (136) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 354, -4 }, /* (137) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 354, -5 }, /* (138) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 354, -5 }, /* (139) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 354, -5 }, /* (140) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 354, -4 }, /* (141) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 354, -5 }, /* (142) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 354, -5 }, /* (143) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 354, -6 }, /* (144) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 351, -1 }, /* (145) multi_create_clause ::= create_subtable_clause */ - { 351, -2 }, /* (146) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 359, -10 }, /* (147) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ - { 353, -1 }, /* (148) multi_drop_clause ::= drop_table_clause */ - { 353, -2 }, /* (149) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 362, -2 }, /* (150) drop_table_clause ::= exists_opt full_table_name */ - { 360, 0 }, /* (151) specific_cols_opt ::= */ - { 360, -3 }, /* (152) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - { 347, -1 }, /* (153) full_table_name ::= table_name */ - { 347, -3 }, /* (154) full_table_name ::= db_name NK_DOT table_name */ - { 348, -1 }, /* (155) column_def_list ::= column_def */ - { 348, -3 }, /* (156) column_def_list ::= column_def_list NK_COMMA column_def */ - { 365, -2 }, /* (157) column_def ::= column_name type_name */ - { 365, -4 }, /* (158) column_def ::= column_name type_name COMMENT NK_STRING */ - { 357, -1 }, /* (159) type_name ::= BOOL */ - { 357, -1 }, /* (160) type_name ::= TINYINT */ - { 357, -1 }, /* (161) type_name ::= SMALLINT */ - { 357, -1 }, /* (162) type_name ::= INT */ - { 357, -1 }, /* (163) type_name ::= INTEGER */ - { 357, -1 }, /* (164) type_name ::= BIGINT */ - { 357, -1 }, /* (165) type_name ::= FLOAT */ - { 357, -1 }, /* (166) type_name ::= DOUBLE */ - { 357, -4 }, /* (167) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 357, -1 }, /* (168) type_name ::= TIMESTAMP */ - { 357, -4 }, /* (169) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 357, -2 }, /* (170) type_name ::= TINYINT UNSIGNED */ - { 357, -2 }, /* (171) type_name ::= SMALLINT UNSIGNED */ - { 357, -2 }, /* (172) type_name ::= INT UNSIGNED */ - { 357, -2 }, /* (173) type_name ::= BIGINT UNSIGNED */ - { 357, -1 }, /* (174) type_name ::= JSON */ - { 357, -4 }, /* (175) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 357, -1 }, /* (176) type_name ::= MEDIUMBLOB */ - { 357, -1 }, /* (177) type_name ::= BLOB */ - { 357, -4 }, /* (178) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 357, -1 }, /* (179) type_name ::= DECIMAL */ - { 357, -4 }, /* (180) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 357, -6 }, /* (181) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 349, 0 }, /* (182) tags_def_opt ::= */ - { 349, -1 }, /* (183) tags_def_opt ::= tags_def */ - { 352, -4 }, /* (184) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 350, 0 }, /* (185) table_options ::= */ - { 350, -3 }, /* (186) table_options ::= table_options COMMENT NK_STRING */ - { 350, -3 }, /* (187) table_options ::= table_options MAX_DELAY duration_list */ - { 350, -3 }, /* (188) table_options ::= table_options WATERMARK duration_list */ - { 350, -5 }, /* (189) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 350, -3 }, /* (190) table_options ::= table_options TTL NK_INTEGER */ - { 350, -5 }, /* (191) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 350, -3 }, /* (192) table_options ::= table_options DELETE_MARK duration_list */ - { 355, -1 }, /* (193) alter_table_options ::= alter_table_option */ - { 355, -2 }, /* (194) alter_table_options ::= alter_table_options alter_table_option */ - { 368, -2 }, /* (195) alter_table_option ::= COMMENT NK_STRING */ - { 368, -2 }, /* (196) alter_table_option ::= TTL NK_INTEGER */ - { 366, -1 }, /* (197) duration_list ::= duration_literal */ - { 366, -3 }, /* (198) duration_list ::= duration_list NK_COMMA duration_literal */ - { 367, -1 }, /* (199) rollup_func_list ::= rollup_func_name */ - { 367, -3 }, /* (200) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 370, -1 }, /* (201) rollup_func_name ::= function_name */ - { 370, -1 }, /* (202) rollup_func_name ::= FIRST */ - { 370, -1 }, /* (203) rollup_func_name ::= LAST */ - { 363, -1 }, /* (204) col_name_list ::= col_name */ - { 363, -3 }, /* (205) col_name_list ::= col_name_list NK_COMMA col_name */ - { 372, -1 }, /* (206) col_name ::= column_name */ - { 322, -2 }, /* (207) cmd ::= SHOW DNODES */ - { 322, -2 }, /* (208) cmd ::= SHOW USERS */ - { 322, -3 }, /* (209) cmd ::= SHOW USER PRIVILEGES */ - { 322, -2 }, /* (210) cmd ::= SHOW DATABASES */ - { 322, -4 }, /* (211) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 322, -4 }, /* (212) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 322, -3 }, /* (213) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 322, -2 }, /* (214) cmd ::= SHOW MNODES */ - { 322, -2 }, /* (215) cmd ::= SHOW QNODES */ - { 322, -2 }, /* (216) cmd ::= SHOW FUNCTIONS */ - { 322, -5 }, /* (217) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 322, -2 }, /* (218) cmd ::= SHOW STREAMS */ - { 322, -2 }, /* (219) cmd ::= SHOW ACCOUNTS */ - { 322, -2 }, /* (220) cmd ::= SHOW APPS */ - { 322, -2 }, /* (221) cmd ::= SHOW CONNECTIONS */ - { 322, -2 }, /* (222) cmd ::= SHOW LICENCES */ - { 322, -2 }, /* (223) cmd ::= SHOW GRANTS */ - { 322, -4 }, /* (224) cmd ::= SHOW CREATE DATABASE db_name */ - { 322, -4 }, /* (225) cmd ::= SHOW CREATE TABLE full_table_name */ - { 322, -4 }, /* (226) cmd ::= SHOW CREATE STABLE full_table_name */ - { 322, -2 }, /* (227) cmd ::= SHOW QUERIES */ - { 322, -2 }, /* (228) cmd ::= SHOW SCORES */ - { 322, -2 }, /* (229) cmd ::= SHOW TOPICS */ - { 322, -2 }, /* (230) cmd ::= SHOW VARIABLES */ - { 322, -3 }, /* (231) cmd ::= SHOW CLUSTER VARIABLES */ - { 322, -3 }, /* (232) cmd ::= SHOW LOCAL VARIABLES */ - { 322, -5 }, /* (233) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - { 322, -2 }, /* (234) cmd ::= SHOW BNODES */ - { 322, -2 }, /* (235) cmd ::= SHOW SNODES */ - { 322, -2 }, /* (236) cmd ::= SHOW CLUSTER */ - { 322, -2 }, /* (237) cmd ::= SHOW TRANSACTIONS */ - { 322, -4 }, /* (238) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 322, -2 }, /* (239) cmd ::= SHOW CONSUMERS */ - { 322, -2 }, /* (240) cmd ::= SHOW SUBSCRIPTIONS */ - { 322, -5 }, /* (241) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - { 322, -7 }, /* (242) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - { 322, -3 }, /* (243) cmd ::= SHOW VNODES NK_INTEGER */ - { 322, -3 }, /* (244) cmd ::= SHOW VNODES NK_STRING */ - { 373, 0 }, /* (245) db_name_cond_opt ::= */ - { 373, -2 }, /* (246) db_name_cond_opt ::= db_name NK_DOT */ - { 374, 0 }, /* (247) like_pattern_opt ::= */ - { 374, -2 }, /* (248) like_pattern_opt ::= LIKE NK_STRING */ - { 375, -1 }, /* (249) table_name_cond ::= table_name */ - { 376, 0 }, /* (250) from_db_opt ::= */ - { 376, -2 }, /* (251) from_db_opt ::= FROM db_name */ - { 377, 0 }, /* (252) tag_list_opt ::= */ - { 377, -1 }, /* (253) tag_list_opt ::= tag_item */ - { 377, -3 }, /* (254) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - { 378, -1 }, /* (255) tag_item ::= TBNAME */ - { 378, -1 }, /* (256) tag_item ::= QTAGS */ - { 378, -1 }, /* (257) tag_item ::= column_name */ - { 378, -2 }, /* (258) tag_item ::= column_name column_alias */ - { 378, -3 }, /* (259) tag_item ::= column_name AS column_alias */ - { 322, -8 }, /* (260) cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ - { 322, -4 }, /* (261) cmd ::= DROP INDEX exists_opt full_index_name */ - { 380, -1 }, /* (262) full_index_name ::= index_name */ - { 380, -3 }, /* (263) full_index_name ::= db_name NK_DOT index_name */ - { 381, -10 }, /* (264) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 381, -12 }, /* (265) 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 */ - { 383, -1 }, /* (266) func_list ::= func */ - { 383, -3 }, /* (267) func_list ::= func_list NK_COMMA func */ - { 386, -4 }, /* (268) func ::= function_name NK_LP expression_list NK_RP */ - { 385, 0 }, /* (269) sma_stream_opt ::= */ - { 385, -3 }, /* (270) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - { 385, -3 }, /* (271) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - { 385, -3 }, /* (272) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - { 322, -6 }, /* (273) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - { 322, -7 }, /* (274) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 322, -9 }, /* (275) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 322, -7 }, /* (276) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 322, -9 }, /* (277) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 322, -4 }, /* (278) cmd ::= DROP TOPIC exists_opt topic_name */ - { 322, -7 }, /* (279) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 322, -2 }, /* (280) cmd ::= DESC full_table_name */ - { 322, -2 }, /* (281) cmd ::= DESCRIBE full_table_name */ - { 322, -3 }, /* (282) cmd ::= RESET QUERY CACHE */ - { 322, -4 }, /* (283) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - { 389, 0 }, /* (284) analyze_opt ::= */ - { 389, -1 }, /* (285) analyze_opt ::= ANALYZE */ - { 390, 0 }, /* (286) explain_options ::= */ - { 390, -3 }, /* (287) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 390, -3 }, /* (288) explain_options ::= explain_options RATIO NK_FLOAT */ - { 322, -10 }, /* (289) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 322, -4 }, /* (290) cmd ::= DROP FUNCTION exists_opt function_name */ - { 391, 0 }, /* (291) agg_func_opt ::= */ - { 391, -1 }, /* (292) agg_func_opt ::= AGGREGATE */ - { 392, 0 }, /* (293) bufsize_opt ::= */ - { 392, -2 }, /* (294) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 322, -11 }, /* (295) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ - { 322, -4 }, /* (296) cmd ::= DROP STREAM exists_opt stream_name */ - { 394, 0 }, /* (297) stream_options ::= */ - { 394, -3 }, /* (298) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 394, -3 }, /* (299) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 394, -4 }, /* (300) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 394, -3 }, /* (301) stream_options ::= stream_options WATERMARK duration_literal */ - { 394, -4 }, /* (302) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - { 394, -3 }, /* (303) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - { 395, 0 }, /* (304) subtable_opt ::= */ - { 395, -4 }, /* (305) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - { 322, -3 }, /* (306) cmd ::= KILL CONNECTION NK_INTEGER */ - { 322, -3 }, /* (307) cmd ::= KILL QUERY NK_STRING */ - { 322, -3 }, /* (308) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 322, -2 }, /* (309) cmd ::= BALANCE VGROUP */ - { 322, -4 }, /* (310) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 322, -4 }, /* (311) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 322, -3 }, /* (312) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 397, -2 }, /* (313) dnode_list ::= DNODE NK_INTEGER */ - { 397, -3 }, /* (314) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 322, -4 }, /* (315) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 322, -1 }, /* (316) cmd ::= query_or_subquery */ - { 322, -7 }, /* (317) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - { 322, -4 }, /* (318) cmd ::= INSERT INTO full_table_name query_or_subquery */ - { 325, -1 }, /* (319) literal ::= NK_INTEGER */ - { 325, -1 }, /* (320) literal ::= NK_FLOAT */ - { 325, -1 }, /* (321) literal ::= NK_STRING */ - { 325, -1 }, /* (322) literal ::= NK_BOOL */ - { 325, -2 }, /* (323) literal ::= TIMESTAMP NK_STRING */ - { 325, -1 }, /* (324) literal ::= duration_literal */ - { 325, -1 }, /* (325) literal ::= NULL */ - { 325, -1 }, /* (326) literal ::= NK_QUESTION */ - { 369, -1 }, /* (327) duration_literal ::= NK_VARIABLE */ - { 399, -1 }, /* (328) signed ::= NK_INTEGER */ - { 399, -2 }, /* (329) signed ::= NK_PLUS NK_INTEGER */ - { 399, -2 }, /* (330) signed ::= NK_MINUS NK_INTEGER */ - { 399, -1 }, /* (331) signed ::= NK_FLOAT */ - { 399, -2 }, /* (332) signed ::= NK_PLUS NK_FLOAT */ - { 399, -2 }, /* (333) signed ::= NK_MINUS NK_FLOAT */ - { 358, -1 }, /* (334) signed_literal ::= signed */ - { 358, -1 }, /* (335) signed_literal ::= NK_STRING */ - { 358, -1 }, /* (336) signed_literal ::= NK_BOOL */ - { 358, -2 }, /* (337) signed_literal ::= TIMESTAMP NK_STRING */ - { 358, -1 }, /* (338) signed_literal ::= duration_literal */ - { 358, -1 }, /* (339) signed_literal ::= NULL */ - { 358, -1 }, /* (340) signed_literal ::= literal_func */ - { 358, -1 }, /* (341) signed_literal ::= NK_QUESTION */ - { 401, -1 }, /* (342) literal_list ::= signed_literal */ - { 401, -3 }, /* (343) literal_list ::= literal_list NK_COMMA signed_literal */ - { 333, -1 }, /* (344) db_name ::= NK_ID */ - { 364, -1 }, /* (345) table_name ::= NK_ID */ - { 356, -1 }, /* (346) column_name ::= NK_ID */ - { 371, -1 }, /* (347) function_name ::= NK_ID */ - { 402, -1 }, /* (348) table_alias ::= NK_ID */ - { 379, -1 }, /* (349) column_alias ::= NK_ID */ - { 327, -1 }, /* (350) user_name ::= NK_ID */ - { 334, -1 }, /* (351) topic_name ::= NK_ID */ - { 393, -1 }, /* (352) stream_name ::= NK_ID */ - { 388, -1 }, /* (353) cgroup_name ::= NK_ID */ - { 382, -1 }, /* (354) index_name ::= NK_ID */ - { 403, -1 }, /* (355) expr_or_subquery ::= expression */ - { 396, -1 }, /* (356) expression ::= literal */ - { 396, -1 }, /* (357) expression ::= pseudo_column */ - { 396, -1 }, /* (358) expression ::= column_reference */ - { 396, -1 }, /* (359) expression ::= function_expression */ - { 396, -1 }, /* (360) expression ::= case_when_expression */ - { 396, -3 }, /* (361) expression ::= NK_LP expression NK_RP */ - { 396, -2 }, /* (362) expression ::= NK_PLUS expr_or_subquery */ - { 396, -2 }, /* (363) expression ::= NK_MINUS expr_or_subquery */ - { 396, -3 }, /* (364) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - { 396, -3 }, /* (365) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - { 396, -3 }, /* (366) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - { 396, -3 }, /* (367) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - { 396, -3 }, /* (368) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - { 396, -3 }, /* (369) expression ::= column_reference NK_ARROW NK_STRING */ - { 396, -3 }, /* (370) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - { 396, -3 }, /* (371) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - { 361, -1 }, /* (372) expression_list ::= expr_or_subquery */ - { 361, -3 }, /* (373) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - { 405, -1 }, /* (374) column_reference ::= column_name */ - { 405, -3 }, /* (375) column_reference ::= table_name NK_DOT column_name */ - { 404, -1 }, /* (376) pseudo_column ::= ROWTS */ - { 404, -1 }, /* (377) pseudo_column ::= TBNAME */ - { 404, -3 }, /* (378) pseudo_column ::= table_name NK_DOT TBNAME */ - { 404, -1 }, /* (379) pseudo_column ::= QSTART */ - { 404, -1 }, /* (380) pseudo_column ::= QEND */ - { 404, -1 }, /* (381) pseudo_column ::= QDURATION */ - { 404, -1 }, /* (382) pseudo_column ::= WSTART */ - { 404, -1 }, /* (383) pseudo_column ::= WEND */ - { 404, -1 }, /* (384) pseudo_column ::= WDURATION */ - { 404, -1 }, /* (385) pseudo_column ::= IROWTS */ - { 404, -1 }, /* (386) pseudo_column ::= QTAGS */ - { 406, -4 }, /* (387) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 406, -4 }, /* (388) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 406, -6 }, /* (389) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - { 406, -1 }, /* (390) function_expression ::= literal_func */ - { 400, -3 }, /* (391) literal_func ::= noarg_func NK_LP NK_RP */ - { 400, -1 }, /* (392) literal_func ::= NOW */ - { 410, -1 }, /* (393) noarg_func ::= NOW */ - { 410, -1 }, /* (394) noarg_func ::= TODAY */ - { 410, -1 }, /* (395) noarg_func ::= TIMEZONE */ - { 410, -1 }, /* (396) noarg_func ::= DATABASE */ - { 410, -1 }, /* (397) noarg_func ::= CLIENT_VERSION */ - { 410, -1 }, /* (398) noarg_func ::= SERVER_VERSION */ - { 410, -1 }, /* (399) noarg_func ::= SERVER_STATUS */ - { 410, -1 }, /* (400) noarg_func ::= CURRENT_USER */ - { 410, -1 }, /* (401) noarg_func ::= USER */ - { 408, -1 }, /* (402) star_func ::= COUNT */ - { 408, -1 }, /* (403) star_func ::= FIRST */ - { 408, -1 }, /* (404) star_func ::= LAST */ - { 408, -1 }, /* (405) star_func ::= LAST_ROW */ - { 409, -1 }, /* (406) star_func_para_list ::= NK_STAR */ - { 409, -1 }, /* (407) star_func_para_list ::= other_para_list */ - { 411, -1 }, /* (408) other_para_list ::= star_func_para */ - { 411, -3 }, /* (409) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 412, -1 }, /* (410) star_func_para ::= expr_or_subquery */ - { 412, -3 }, /* (411) star_func_para ::= table_name NK_DOT NK_STAR */ - { 407, -4 }, /* (412) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - { 407, -5 }, /* (413) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - { 413, -1 }, /* (414) when_then_list ::= when_then_expr */ - { 413, -2 }, /* (415) when_then_list ::= when_then_list when_then_expr */ - { 416, -4 }, /* (416) when_then_expr ::= WHEN common_expression THEN common_expression */ - { 414, 0 }, /* (417) case_when_else_opt ::= */ - { 414, -2 }, /* (418) case_when_else_opt ::= ELSE common_expression */ - { 417, -3 }, /* (419) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - { 417, -5 }, /* (420) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - { 417, -6 }, /* (421) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - { 417, -3 }, /* (422) predicate ::= expr_or_subquery IS NULL */ - { 417, -4 }, /* (423) predicate ::= expr_or_subquery IS NOT NULL */ - { 417, -3 }, /* (424) predicate ::= expr_or_subquery in_op in_predicate_value */ - { 418, -1 }, /* (425) compare_op ::= NK_LT */ - { 418, -1 }, /* (426) compare_op ::= NK_GT */ - { 418, -1 }, /* (427) compare_op ::= NK_LE */ - { 418, -1 }, /* (428) compare_op ::= NK_GE */ - { 418, -1 }, /* (429) compare_op ::= NK_NE */ - { 418, -1 }, /* (430) compare_op ::= NK_EQ */ - { 418, -1 }, /* (431) compare_op ::= LIKE */ - { 418, -2 }, /* (432) compare_op ::= NOT LIKE */ - { 418, -1 }, /* (433) compare_op ::= MATCH */ - { 418, -1 }, /* (434) compare_op ::= NMATCH */ - { 418, -1 }, /* (435) compare_op ::= CONTAINS */ - { 419, -1 }, /* (436) in_op ::= IN */ - { 419, -2 }, /* (437) in_op ::= NOT IN */ - { 420, -3 }, /* (438) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 421, -1 }, /* (439) boolean_value_expression ::= boolean_primary */ - { 421, -2 }, /* (440) boolean_value_expression ::= NOT boolean_primary */ - { 421, -3 }, /* (441) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 421, -3 }, /* (442) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 422, -1 }, /* (443) boolean_primary ::= predicate */ - { 422, -3 }, /* (444) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 415, -1 }, /* (445) common_expression ::= expr_or_subquery */ - { 415, -1 }, /* (446) common_expression ::= boolean_value_expression */ - { 423, 0 }, /* (447) from_clause_opt ::= */ - { 423, -2 }, /* (448) from_clause_opt ::= FROM table_reference_list */ - { 424, -1 }, /* (449) table_reference_list ::= table_reference */ - { 424, -3 }, /* (450) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 425, -1 }, /* (451) table_reference ::= table_primary */ - { 425, -1 }, /* (452) table_reference ::= joined_table */ - { 426, -2 }, /* (453) table_primary ::= table_name alias_opt */ - { 426, -4 }, /* (454) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 426, -2 }, /* (455) table_primary ::= subquery alias_opt */ - { 426, -1 }, /* (456) table_primary ::= parenthesized_joined_table */ - { 428, 0 }, /* (457) alias_opt ::= */ - { 428, -1 }, /* (458) alias_opt ::= table_alias */ - { 428, -2 }, /* (459) alias_opt ::= AS table_alias */ - { 430, -3 }, /* (460) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 430, -3 }, /* (461) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 427, -6 }, /* (462) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 431, 0 }, /* (463) join_type ::= */ - { 431, -1 }, /* (464) join_type ::= INNER */ - { 433, -12 }, /* (465) 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 */ - { 434, 0 }, /* (466) set_quantifier_opt ::= */ - { 434, -1 }, /* (467) set_quantifier_opt ::= DISTINCT */ - { 434, -1 }, /* (468) set_quantifier_opt ::= ALL */ - { 435, -1 }, /* (469) select_list ::= select_item */ - { 435, -3 }, /* (470) select_list ::= select_list NK_COMMA select_item */ - { 443, -1 }, /* (471) select_item ::= NK_STAR */ - { 443, -1 }, /* (472) select_item ::= common_expression */ - { 443, -2 }, /* (473) select_item ::= common_expression column_alias */ - { 443, -3 }, /* (474) select_item ::= common_expression AS column_alias */ - { 443, -3 }, /* (475) select_item ::= table_name NK_DOT NK_STAR */ - { 398, 0 }, /* (476) where_clause_opt ::= */ - { 398, -2 }, /* (477) where_clause_opt ::= WHERE search_condition */ - { 436, 0 }, /* (478) partition_by_clause_opt ::= */ - { 436, -3 }, /* (479) partition_by_clause_opt ::= PARTITION BY partition_list */ - { 444, -1 }, /* (480) partition_list ::= partition_item */ - { 444, -3 }, /* (481) partition_list ::= partition_list NK_COMMA partition_item */ - { 445, -1 }, /* (482) partition_item ::= expr_or_subquery */ - { 445, -2 }, /* (483) partition_item ::= expr_or_subquery column_alias */ - { 445, -3 }, /* (484) partition_item ::= expr_or_subquery AS column_alias */ - { 440, 0 }, /* (485) twindow_clause_opt ::= */ - { 440, -6 }, /* (486) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 440, -4 }, /* (487) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - { 440, -6 }, /* (488) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 440, -8 }, /* (489) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 384, 0 }, /* (490) sliding_opt ::= */ - { 384, -4 }, /* (491) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 439, 0 }, /* (492) fill_opt ::= */ - { 439, -4 }, /* (493) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 439, -6 }, /* (494) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 446, -1 }, /* (495) fill_mode ::= NONE */ - { 446, -1 }, /* (496) fill_mode ::= PREV */ - { 446, -1 }, /* (497) fill_mode ::= NULL */ - { 446, -1 }, /* (498) fill_mode ::= LINEAR */ - { 446, -1 }, /* (499) fill_mode ::= NEXT */ - { 441, 0 }, /* (500) group_by_clause_opt ::= */ - { 441, -3 }, /* (501) group_by_clause_opt ::= GROUP BY group_by_list */ - { 447, -1 }, /* (502) group_by_list ::= expr_or_subquery */ - { 447, -3 }, /* (503) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - { 442, 0 }, /* (504) having_clause_opt ::= */ - { 442, -2 }, /* (505) having_clause_opt ::= HAVING search_condition */ - { 437, 0 }, /* (506) range_opt ::= */ - { 437, -6 }, /* (507) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - { 438, 0 }, /* (508) every_opt ::= */ - { 438, -4 }, /* (509) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 448, -4 }, /* (510) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 449, -1 }, /* (511) query_simple ::= query_specification */ - { 449, -1 }, /* (512) query_simple ::= union_query_expression */ - { 453, -4 }, /* (513) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - { 453, -3 }, /* (514) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - { 454, -1 }, /* (515) query_simple_or_subquery ::= query_simple */ - { 454, -1 }, /* (516) query_simple_or_subquery ::= subquery */ - { 387, -1 }, /* (517) query_or_subquery ::= query_expression */ - { 387, -1 }, /* (518) query_or_subquery ::= subquery */ - { 450, 0 }, /* (519) order_by_clause_opt ::= */ - { 450, -3 }, /* (520) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 451, 0 }, /* (521) slimit_clause_opt ::= */ - { 451, -2 }, /* (522) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 451, -4 }, /* (523) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 451, -4 }, /* (524) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 452, 0 }, /* (525) limit_clause_opt ::= */ - { 452, -2 }, /* (526) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 452, -4 }, /* (527) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 452, -4 }, /* (528) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 429, -3 }, /* (529) subquery ::= NK_LP query_expression NK_RP */ - { 429, -3 }, /* (530) subquery ::= NK_LP subquery NK_RP */ - { 432, -1 }, /* (531) search_condition ::= common_expression */ - { 455, -1 }, /* (532) sort_specification_list ::= sort_specification */ - { 455, -3 }, /* (533) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 456, -3 }, /* (534) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - { 457, 0 }, /* (535) ordering_specification_opt ::= */ - { 457, -1 }, /* (536) ordering_specification_opt ::= ASC */ - { 457, -1 }, /* (537) ordering_specification_opt ::= DESC */ - { 458, 0 }, /* (538) null_ordering_opt ::= */ - { 458, -2 }, /* (539) null_ordering_opt ::= NULLS FIRST */ - { 458, -2 }, /* (540) null_ordering_opt ::= NULLS LAST */ + { 324, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 324, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 325, 0 }, /* (2) account_options ::= */ + { 325, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 325, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 325, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 325, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 325, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 325, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 325, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 325, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 325, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 326, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 326, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 328, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 328, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 328, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 328, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 328, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 328, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 328, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 328, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 328, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 328, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 324, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 324, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 324, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 324, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 324, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 330, 0 }, /* (29) sysinfo_opt ::= */ + { 330, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 324, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 324, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 331, -1 }, /* (33) privileges ::= ALL */ + { 331, -1 }, /* (34) privileges ::= priv_type_list */ + { 331, -1 }, /* (35) privileges ::= SUBSCRIBE */ + { 333, -1 }, /* (36) priv_type_list ::= priv_type */ + { 333, -3 }, /* (37) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 334, -1 }, /* (38) priv_type ::= READ */ + { 334, -1 }, /* (39) priv_type ::= WRITE */ + { 332, -3 }, /* (40) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 332, -3 }, /* (41) priv_level ::= db_name NK_DOT NK_STAR */ + { 332, -1 }, /* (42) priv_level ::= topic_name */ + { 324, -3 }, /* (43) cmd ::= CREATE DNODE dnode_endpoint */ + { 324, -5 }, /* (44) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 324, -4 }, /* (45) cmd ::= DROP DNODE NK_INTEGER force_opt */ + { 324, -4 }, /* (46) cmd ::= DROP DNODE dnode_endpoint force_opt */ + { 324, -4 }, /* (47) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 324, -5 }, /* (48) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 324, -4 }, /* (49) cmd ::= ALTER ALL DNODES NK_STRING */ + { 324, -5 }, /* (50) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 337, -1 }, /* (51) dnode_endpoint ::= NK_STRING */ + { 337, -1 }, /* (52) dnode_endpoint ::= NK_ID */ + { 337, -1 }, /* (53) dnode_endpoint ::= NK_IPTOKEN */ + { 338, 0 }, /* (54) force_opt ::= */ + { 338, -1 }, /* (55) force_opt ::= FORCE */ + { 324, -3 }, /* (56) cmd ::= ALTER LOCAL NK_STRING */ + { 324, -4 }, /* (57) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 324, -5 }, /* (58) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 324, -5 }, /* (59) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 324, -5 }, /* (60) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 324, -5 }, /* (61) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 324, -5 }, /* (62) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 324, -5 }, /* (63) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 324, -5 }, /* (64) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 324, -5 }, /* (65) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 324, -5 }, /* (66) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 324, -4 }, /* (67) cmd ::= DROP DATABASE exists_opt db_name */ + { 324, -2 }, /* (68) cmd ::= USE db_name */ + { 324, -4 }, /* (69) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 324, -3 }, /* (70) cmd ::= FLUSH DATABASE db_name */ + { 324, -4 }, /* (71) cmd ::= TRIM DATABASE db_name speed_opt */ + { 339, -3 }, /* (72) not_exists_opt ::= IF NOT EXISTS */ + { 339, 0 }, /* (73) not_exists_opt ::= */ + { 341, -2 }, /* (74) exists_opt ::= IF EXISTS */ + { 341, 0 }, /* (75) exists_opt ::= */ + { 340, 0 }, /* (76) db_options ::= */ + { 340, -3 }, /* (77) db_options ::= db_options BUFFER NK_INTEGER */ + { 340, -3 }, /* (78) db_options ::= db_options CACHEMODEL NK_STRING */ + { 340, -3 }, /* (79) db_options ::= db_options CACHESIZE NK_INTEGER */ + { 340, -3 }, /* (80) db_options ::= db_options COMP NK_INTEGER */ + { 340, -3 }, /* (81) db_options ::= db_options DURATION NK_INTEGER */ + { 340, -3 }, /* (82) db_options ::= db_options DURATION NK_VARIABLE */ + { 340, -3 }, /* (83) db_options ::= db_options MAXROWS NK_INTEGER */ + { 340, -3 }, /* (84) db_options ::= db_options MINROWS NK_INTEGER */ + { 340, -3 }, /* (85) db_options ::= db_options KEEP integer_list */ + { 340, -3 }, /* (86) db_options ::= db_options KEEP variable_list */ + { 340, -3 }, /* (87) db_options ::= db_options PAGES NK_INTEGER */ + { 340, -3 }, /* (88) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 340, -3 }, /* (89) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + { 340, -3 }, /* (90) db_options ::= db_options PRECISION NK_STRING */ + { 340, -3 }, /* (91) db_options ::= db_options REPLICA NK_INTEGER */ + { 340, -3 }, /* (92) db_options ::= db_options VGROUPS NK_INTEGER */ + { 340, -3 }, /* (93) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 340, -3 }, /* (94) db_options ::= db_options RETENTIONS retention_list */ + { 340, -3 }, /* (95) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 340, -3 }, /* (96) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + { 340, -3 }, /* (97) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + { 340, -3 }, /* (98) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + { 340, -4 }, /* (99) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + { 340, -3 }, /* (100) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + { 340, -4 }, /* (101) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + { 340, -3 }, /* (102) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + { 340, -3 }, /* (103) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + { 340, -3 }, /* (104) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + { 340, -3 }, /* (105) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ + { 340, -3 }, /* (106) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ + { 342, -1 }, /* (107) alter_db_options ::= alter_db_option */ + { 342, -2 }, /* (108) alter_db_options ::= alter_db_options alter_db_option */ + { 347, -2 }, /* (109) alter_db_option ::= BUFFER NK_INTEGER */ + { 347, -2 }, /* (110) alter_db_option ::= CACHEMODEL NK_STRING */ + { 347, -2 }, /* (111) alter_db_option ::= CACHESIZE NK_INTEGER */ + { 347, -2 }, /* (112) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + { 347, -2 }, /* (113) alter_db_option ::= KEEP integer_list */ + { 347, -2 }, /* (114) alter_db_option ::= KEEP variable_list */ + { 347, -2 }, /* (115) alter_db_option ::= PAGES NK_INTEGER */ + { 347, -2 }, /* (116) alter_db_option ::= REPLICA NK_INTEGER */ + { 347, -2 }, /* (117) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + { 347, -2 }, /* (118) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + { 344, -1 }, /* (119) integer_list ::= NK_INTEGER */ + { 344, -3 }, /* (120) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 345, -1 }, /* (121) variable_list ::= NK_VARIABLE */ + { 345, -3 }, /* (122) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 346, -1 }, /* (123) retention_list ::= retention */ + { 346, -3 }, /* (124) retention_list ::= retention_list NK_COMMA retention */ + { 348, -3 }, /* (125) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 343, 0 }, /* (126) speed_opt ::= */ + { 343, -2 }, /* (127) speed_opt ::= MAX_SPEED NK_INTEGER */ + { 324, -9 }, /* (128) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 324, -3 }, /* (129) cmd ::= CREATE TABLE multi_create_clause */ + { 324, -9 }, /* (130) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 324, -3 }, /* (131) cmd ::= DROP TABLE multi_drop_clause */ + { 324, -4 }, /* (132) cmd ::= DROP STABLE exists_opt full_table_name */ + { 324, -3 }, /* (133) cmd ::= ALTER TABLE alter_table_clause */ + { 324, -3 }, /* (134) cmd ::= ALTER STABLE alter_table_clause */ + { 356, -2 }, /* (135) alter_table_clause ::= full_table_name alter_table_options */ + { 356, -5 }, /* (136) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 356, -4 }, /* (137) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 356, -5 }, /* (138) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 356, -5 }, /* (139) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 356, -5 }, /* (140) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 356, -4 }, /* (141) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 356, -5 }, /* (142) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 356, -5 }, /* (143) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 356, -6 }, /* (144) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 353, -1 }, /* (145) multi_create_clause ::= create_subtable_clause */ + { 353, -2 }, /* (146) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 361, -10 }, /* (147) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ + { 355, -1 }, /* (148) multi_drop_clause ::= drop_table_clause */ + { 355, -2 }, /* (149) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 364, -2 }, /* (150) drop_table_clause ::= exists_opt full_table_name */ + { 362, 0 }, /* (151) specific_cols_opt ::= */ + { 362, -3 }, /* (152) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + { 349, -1 }, /* (153) full_table_name ::= table_name */ + { 349, -3 }, /* (154) full_table_name ::= db_name NK_DOT table_name */ + { 350, -1 }, /* (155) column_def_list ::= column_def */ + { 350, -3 }, /* (156) column_def_list ::= column_def_list NK_COMMA column_def */ + { 367, -2 }, /* (157) column_def ::= column_name type_name */ + { 367, -4 }, /* (158) column_def ::= column_name type_name COMMENT NK_STRING */ + { 359, -1 }, /* (159) type_name ::= BOOL */ + { 359, -1 }, /* (160) type_name ::= TINYINT */ + { 359, -1 }, /* (161) type_name ::= SMALLINT */ + { 359, -1 }, /* (162) type_name ::= INT */ + { 359, -1 }, /* (163) type_name ::= INTEGER */ + { 359, -1 }, /* (164) type_name ::= BIGINT */ + { 359, -1 }, /* (165) type_name ::= FLOAT */ + { 359, -1 }, /* (166) type_name ::= DOUBLE */ + { 359, -4 }, /* (167) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 359, -1 }, /* (168) type_name ::= TIMESTAMP */ + { 359, -4 }, /* (169) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 359, -2 }, /* (170) type_name ::= TINYINT UNSIGNED */ + { 359, -2 }, /* (171) type_name ::= SMALLINT UNSIGNED */ + { 359, -2 }, /* (172) type_name ::= INT UNSIGNED */ + { 359, -2 }, /* (173) type_name ::= BIGINT UNSIGNED */ + { 359, -1 }, /* (174) type_name ::= JSON */ + { 359, -4 }, /* (175) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 359, -1 }, /* (176) type_name ::= MEDIUMBLOB */ + { 359, -1 }, /* (177) type_name ::= BLOB */ + { 359, -4 }, /* (178) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 359, -1 }, /* (179) type_name ::= DECIMAL */ + { 359, -4 }, /* (180) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 359, -6 }, /* (181) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 351, 0 }, /* (182) tags_def_opt ::= */ + { 351, -1 }, /* (183) tags_def_opt ::= tags_def */ + { 354, -4 }, /* (184) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 352, 0 }, /* (185) table_options ::= */ + { 352, -3 }, /* (186) table_options ::= table_options COMMENT NK_STRING */ + { 352, -3 }, /* (187) table_options ::= table_options MAX_DELAY duration_list */ + { 352, -3 }, /* (188) table_options ::= table_options WATERMARK duration_list */ + { 352, -5 }, /* (189) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 352, -3 }, /* (190) table_options ::= table_options TTL NK_INTEGER */ + { 352, -5 }, /* (191) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 352, -3 }, /* (192) table_options ::= table_options DELETE_MARK duration_list */ + { 357, -1 }, /* (193) alter_table_options ::= alter_table_option */ + { 357, -2 }, /* (194) alter_table_options ::= alter_table_options alter_table_option */ + { 370, -2 }, /* (195) alter_table_option ::= COMMENT NK_STRING */ + { 370, -2 }, /* (196) alter_table_option ::= TTL NK_INTEGER */ + { 368, -1 }, /* (197) duration_list ::= duration_literal */ + { 368, -3 }, /* (198) duration_list ::= duration_list NK_COMMA duration_literal */ + { 369, -1 }, /* (199) rollup_func_list ::= rollup_func_name */ + { 369, -3 }, /* (200) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 372, -1 }, /* (201) rollup_func_name ::= function_name */ + { 372, -1 }, /* (202) rollup_func_name ::= FIRST */ + { 372, -1 }, /* (203) rollup_func_name ::= LAST */ + { 365, -1 }, /* (204) col_name_list ::= col_name */ + { 365, -3 }, /* (205) col_name_list ::= col_name_list NK_COMMA col_name */ + { 374, -1 }, /* (206) col_name ::= column_name */ + { 324, -2 }, /* (207) cmd ::= SHOW DNODES */ + { 324, -2 }, /* (208) cmd ::= SHOW USERS */ + { 324, -3 }, /* (209) cmd ::= SHOW USER PRIVILEGES */ + { 324, -2 }, /* (210) cmd ::= SHOW DATABASES */ + { 324, -4 }, /* (211) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 324, -4 }, /* (212) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 324, -3 }, /* (213) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 324, -2 }, /* (214) cmd ::= SHOW MNODES */ + { 324, -2 }, /* (215) cmd ::= SHOW QNODES */ + { 324, -2 }, /* (216) cmd ::= SHOW FUNCTIONS */ + { 324, -5 }, /* (217) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 324, -2 }, /* (218) cmd ::= SHOW STREAMS */ + { 324, -2 }, /* (219) cmd ::= SHOW ACCOUNTS */ + { 324, -2 }, /* (220) cmd ::= SHOW APPS */ + { 324, -2 }, /* (221) cmd ::= SHOW CONNECTIONS */ + { 324, -2 }, /* (222) cmd ::= SHOW LICENCES */ + { 324, -2 }, /* (223) cmd ::= SHOW GRANTS */ + { 324, -4 }, /* (224) cmd ::= SHOW CREATE DATABASE db_name */ + { 324, -4 }, /* (225) cmd ::= SHOW CREATE TABLE full_table_name */ + { 324, -4 }, /* (226) cmd ::= SHOW CREATE STABLE full_table_name */ + { 324, -2 }, /* (227) cmd ::= SHOW QUERIES */ + { 324, -2 }, /* (228) cmd ::= SHOW SCORES */ + { 324, -2 }, /* (229) cmd ::= SHOW TOPICS */ + { 324, -2 }, /* (230) cmd ::= SHOW VARIABLES */ + { 324, -3 }, /* (231) cmd ::= SHOW CLUSTER VARIABLES */ + { 324, -3 }, /* (232) cmd ::= SHOW LOCAL VARIABLES */ + { 324, -5 }, /* (233) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + { 324, -2 }, /* (234) cmd ::= SHOW BNODES */ + { 324, -2 }, /* (235) cmd ::= SHOW SNODES */ + { 324, -2 }, /* (236) cmd ::= SHOW CLUSTER */ + { 324, -2 }, /* (237) cmd ::= SHOW TRANSACTIONS */ + { 324, -4 }, /* (238) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 324, -2 }, /* (239) cmd ::= SHOW CONSUMERS */ + { 324, -2 }, /* (240) cmd ::= SHOW SUBSCRIPTIONS */ + { 324, -5 }, /* (241) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 324, -7 }, /* (242) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + { 324, -3 }, /* (243) cmd ::= SHOW VNODES NK_INTEGER */ + { 324, -3 }, /* (244) cmd ::= SHOW VNODES NK_STRING */ + { 375, 0 }, /* (245) db_name_cond_opt ::= */ + { 375, -2 }, /* (246) db_name_cond_opt ::= db_name NK_DOT */ + { 376, 0 }, /* (247) like_pattern_opt ::= */ + { 376, -2 }, /* (248) like_pattern_opt ::= LIKE NK_STRING */ + { 377, -1 }, /* (249) table_name_cond ::= table_name */ + { 378, 0 }, /* (250) from_db_opt ::= */ + { 378, -2 }, /* (251) from_db_opt ::= FROM db_name */ + { 379, 0 }, /* (252) tag_list_opt ::= */ + { 379, -1 }, /* (253) tag_list_opt ::= tag_item */ + { 379, -3 }, /* (254) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + { 380, -1 }, /* (255) tag_item ::= TBNAME */ + { 380, -1 }, /* (256) tag_item ::= QTAGS */ + { 380, -1 }, /* (257) tag_item ::= column_name */ + { 380, -2 }, /* (258) tag_item ::= column_name column_alias */ + { 380, -3 }, /* (259) tag_item ::= column_name AS column_alias */ + { 324, -8 }, /* (260) cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ + { 324, -4 }, /* (261) cmd ::= DROP INDEX exists_opt full_index_name */ + { 382, -1 }, /* (262) full_index_name ::= index_name */ + { 382, -3 }, /* (263) full_index_name ::= db_name NK_DOT index_name */ + { 383, -10 }, /* (264) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 383, -12 }, /* (265) 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 */ + { 385, -1 }, /* (266) func_list ::= func */ + { 385, -3 }, /* (267) func_list ::= func_list NK_COMMA func */ + { 388, -4 }, /* (268) func ::= function_name NK_LP expression_list NK_RP */ + { 387, 0 }, /* (269) sma_stream_opt ::= */ + { 387, -3 }, /* (270) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + { 387, -3 }, /* (271) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + { 387, -3 }, /* (272) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + { 324, -6 }, /* (273) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + { 324, -7 }, /* (274) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 324, -9 }, /* (275) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 324, -7 }, /* (276) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 324, -9 }, /* (277) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 324, -4 }, /* (278) cmd ::= DROP TOPIC exists_opt topic_name */ + { 324, -7 }, /* (279) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 324, -2 }, /* (280) cmd ::= DESC full_table_name */ + { 324, -2 }, /* (281) cmd ::= DESCRIBE full_table_name */ + { 324, -3 }, /* (282) cmd ::= RESET QUERY CACHE */ + { 324, -4 }, /* (283) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + { 391, 0 }, /* (284) analyze_opt ::= */ + { 391, -1 }, /* (285) analyze_opt ::= ANALYZE */ + { 392, 0 }, /* (286) explain_options ::= */ + { 392, -3 }, /* (287) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 392, -3 }, /* (288) explain_options ::= explain_options RATIO NK_FLOAT */ + { 324, -10 }, /* (289) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 324, -4 }, /* (290) cmd ::= DROP FUNCTION exists_opt function_name */ + { 393, 0 }, /* (291) agg_func_opt ::= */ + { 393, -1 }, /* (292) agg_func_opt ::= AGGREGATE */ + { 394, 0 }, /* (293) bufsize_opt ::= */ + { 394, -2 }, /* (294) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 324, -11 }, /* (295) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ + { 324, -4 }, /* (296) cmd ::= DROP STREAM exists_opt stream_name */ + { 396, 0 }, /* (297) stream_options ::= */ + { 396, -3 }, /* (298) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 396, -3 }, /* (299) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 396, -4 }, /* (300) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 396, -3 }, /* (301) stream_options ::= stream_options WATERMARK duration_literal */ + { 396, -4 }, /* (302) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + { 396, -3 }, /* (303) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + { 396, -4 }, /* (304) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + { 397, 0 }, /* (305) subtable_opt ::= */ + { 397, -4 }, /* (306) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + { 324, -3 }, /* (307) cmd ::= KILL CONNECTION NK_INTEGER */ + { 324, -3 }, /* (308) cmd ::= KILL QUERY NK_STRING */ + { 324, -3 }, /* (309) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 324, -2 }, /* (310) cmd ::= BALANCE VGROUP */ + { 324, -4 }, /* (311) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 324, -4 }, /* (312) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 324, -3 }, /* (313) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 399, -2 }, /* (314) dnode_list ::= DNODE NK_INTEGER */ + { 399, -3 }, /* (315) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 324, -4 }, /* (316) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 324, -1 }, /* (317) cmd ::= query_or_subquery */ + { 324, -7 }, /* (318) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + { 324, -4 }, /* (319) cmd ::= INSERT INTO full_table_name query_or_subquery */ + { 327, -1 }, /* (320) literal ::= NK_INTEGER */ + { 327, -1 }, /* (321) literal ::= NK_FLOAT */ + { 327, -1 }, /* (322) literal ::= NK_STRING */ + { 327, -1 }, /* (323) literal ::= NK_BOOL */ + { 327, -2 }, /* (324) literal ::= TIMESTAMP NK_STRING */ + { 327, -1 }, /* (325) literal ::= duration_literal */ + { 327, -1 }, /* (326) literal ::= NULL */ + { 327, -1 }, /* (327) literal ::= NK_QUESTION */ + { 371, -1 }, /* (328) duration_literal ::= NK_VARIABLE */ + { 401, -1 }, /* (329) signed ::= NK_INTEGER */ + { 401, -2 }, /* (330) signed ::= NK_PLUS NK_INTEGER */ + { 401, -2 }, /* (331) signed ::= NK_MINUS NK_INTEGER */ + { 401, -1 }, /* (332) signed ::= NK_FLOAT */ + { 401, -2 }, /* (333) signed ::= NK_PLUS NK_FLOAT */ + { 401, -2 }, /* (334) signed ::= NK_MINUS NK_FLOAT */ + { 360, -1 }, /* (335) signed_literal ::= signed */ + { 360, -1 }, /* (336) signed_literal ::= NK_STRING */ + { 360, -1 }, /* (337) signed_literal ::= NK_BOOL */ + { 360, -2 }, /* (338) signed_literal ::= TIMESTAMP NK_STRING */ + { 360, -1 }, /* (339) signed_literal ::= duration_literal */ + { 360, -1 }, /* (340) signed_literal ::= NULL */ + { 360, -1 }, /* (341) signed_literal ::= literal_func */ + { 360, -1 }, /* (342) signed_literal ::= NK_QUESTION */ + { 403, -1 }, /* (343) literal_list ::= signed_literal */ + { 403, -3 }, /* (344) literal_list ::= literal_list NK_COMMA signed_literal */ + { 335, -1 }, /* (345) db_name ::= NK_ID */ + { 366, -1 }, /* (346) table_name ::= NK_ID */ + { 358, -1 }, /* (347) column_name ::= NK_ID */ + { 373, -1 }, /* (348) function_name ::= NK_ID */ + { 404, -1 }, /* (349) table_alias ::= NK_ID */ + { 381, -1 }, /* (350) column_alias ::= NK_ID */ + { 329, -1 }, /* (351) user_name ::= NK_ID */ + { 336, -1 }, /* (352) topic_name ::= NK_ID */ + { 395, -1 }, /* (353) stream_name ::= NK_ID */ + { 390, -1 }, /* (354) cgroup_name ::= NK_ID */ + { 384, -1 }, /* (355) index_name ::= NK_ID */ + { 405, -1 }, /* (356) expr_or_subquery ::= expression */ + { 398, -1 }, /* (357) expression ::= literal */ + { 398, -1 }, /* (358) expression ::= pseudo_column */ + { 398, -1 }, /* (359) expression ::= column_reference */ + { 398, -1 }, /* (360) expression ::= function_expression */ + { 398, -1 }, /* (361) expression ::= case_when_expression */ + { 398, -3 }, /* (362) expression ::= NK_LP expression NK_RP */ + { 398, -2 }, /* (363) expression ::= NK_PLUS expr_or_subquery */ + { 398, -2 }, /* (364) expression ::= NK_MINUS expr_or_subquery */ + { 398, -3 }, /* (365) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + { 398, -3 }, /* (366) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + { 398, -3 }, /* (367) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + { 398, -3 }, /* (368) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + { 398, -3 }, /* (369) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + { 398, -3 }, /* (370) expression ::= column_reference NK_ARROW NK_STRING */ + { 398, -3 }, /* (371) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + { 398, -3 }, /* (372) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + { 363, -1 }, /* (373) expression_list ::= expr_or_subquery */ + { 363, -3 }, /* (374) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + { 407, -1 }, /* (375) column_reference ::= column_name */ + { 407, -3 }, /* (376) column_reference ::= table_name NK_DOT column_name */ + { 406, -1 }, /* (377) pseudo_column ::= ROWTS */ + { 406, -1 }, /* (378) pseudo_column ::= TBNAME */ + { 406, -3 }, /* (379) pseudo_column ::= table_name NK_DOT TBNAME */ + { 406, -1 }, /* (380) pseudo_column ::= QSTART */ + { 406, -1 }, /* (381) pseudo_column ::= QEND */ + { 406, -1 }, /* (382) pseudo_column ::= QDURATION */ + { 406, -1 }, /* (383) pseudo_column ::= WSTART */ + { 406, -1 }, /* (384) pseudo_column ::= WEND */ + { 406, -1 }, /* (385) pseudo_column ::= WDURATION */ + { 406, -1 }, /* (386) pseudo_column ::= IROWTS */ + { 406, -1 }, /* (387) pseudo_column ::= QTAGS */ + { 408, -4 }, /* (388) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 408, -4 }, /* (389) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 408, -6 }, /* (390) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + { 408, -1 }, /* (391) function_expression ::= literal_func */ + { 402, -3 }, /* (392) literal_func ::= noarg_func NK_LP NK_RP */ + { 402, -1 }, /* (393) literal_func ::= NOW */ + { 412, -1 }, /* (394) noarg_func ::= NOW */ + { 412, -1 }, /* (395) noarg_func ::= TODAY */ + { 412, -1 }, /* (396) noarg_func ::= TIMEZONE */ + { 412, -1 }, /* (397) noarg_func ::= DATABASE */ + { 412, -1 }, /* (398) noarg_func ::= CLIENT_VERSION */ + { 412, -1 }, /* (399) noarg_func ::= SERVER_VERSION */ + { 412, -1 }, /* (400) noarg_func ::= SERVER_STATUS */ + { 412, -1 }, /* (401) noarg_func ::= CURRENT_USER */ + { 412, -1 }, /* (402) noarg_func ::= USER */ + { 410, -1 }, /* (403) star_func ::= COUNT */ + { 410, -1 }, /* (404) star_func ::= FIRST */ + { 410, -1 }, /* (405) star_func ::= LAST */ + { 410, -1 }, /* (406) star_func ::= LAST_ROW */ + { 411, -1 }, /* (407) star_func_para_list ::= NK_STAR */ + { 411, -1 }, /* (408) star_func_para_list ::= other_para_list */ + { 413, -1 }, /* (409) other_para_list ::= star_func_para */ + { 413, -3 }, /* (410) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 414, -1 }, /* (411) star_func_para ::= expr_or_subquery */ + { 414, -3 }, /* (412) star_func_para ::= table_name NK_DOT NK_STAR */ + { 409, -4 }, /* (413) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + { 409, -5 }, /* (414) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + { 415, -1 }, /* (415) when_then_list ::= when_then_expr */ + { 415, -2 }, /* (416) when_then_list ::= when_then_list when_then_expr */ + { 418, -4 }, /* (417) when_then_expr ::= WHEN common_expression THEN common_expression */ + { 416, 0 }, /* (418) case_when_else_opt ::= */ + { 416, -2 }, /* (419) case_when_else_opt ::= ELSE common_expression */ + { 419, -3 }, /* (420) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + { 419, -5 }, /* (421) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + { 419, -6 }, /* (422) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + { 419, -3 }, /* (423) predicate ::= expr_or_subquery IS NULL */ + { 419, -4 }, /* (424) predicate ::= expr_or_subquery IS NOT NULL */ + { 419, -3 }, /* (425) predicate ::= expr_or_subquery in_op in_predicate_value */ + { 420, -1 }, /* (426) compare_op ::= NK_LT */ + { 420, -1 }, /* (427) compare_op ::= NK_GT */ + { 420, -1 }, /* (428) compare_op ::= NK_LE */ + { 420, -1 }, /* (429) compare_op ::= NK_GE */ + { 420, -1 }, /* (430) compare_op ::= NK_NE */ + { 420, -1 }, /* (431) compare_op ::= NK_EQ */ + { 420, -1 }, /* (432) compare_op ::= LIKE */ + { 420, -2 }, /* (433) compare_op ::= NOT LIKE */ + { 420, -1 }, /* (434) compare_op ::= MATCH */ + { 420, -1 }, /* (435) compare_op ::= NMATCH */ + { 420, -1 }, /* (436) compare_op ::= CONTAINS */ + { 421, -1 }, /* (437) in_op ::= IN */ + { 421, -2 }, /* (438) in_op ::= NOT IN */ + { 422, -3 }, /* (439) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 423, -1 }, /* (440) boolean_value_expression ::= boolean_primary */ + { 423, -2 }, /* (441) boolean_value_expression ::= NOT boolean_primary */ + { 423, -3 }, /* (442) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 423, -3 }, /* (443) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 424, -1 }, /* (444) boolean_primary ::= predicate */ + { 424, -3 }, /* (445) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 417, -1 }, /* (446) common_expression ::= expr_or_subquery */ + { 417, -1 }, /* (447) common_expression ::= boolean_value_expression */ + { 425, 0 }, /* (448) from_clause_opt ::= */ + { 425, -2 }, /* (449) from_clause_opt ::= FROM table_reference_list */ + { 426, -1 }, /* (450) table_reference_list ::= table_reference */ + { 426, -3 }, /* (451) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 427, -1 }, /* (452) table_reference ::= table_primary */ + { 427, -1 }, /* (453) table_reference ::= joined_table */ + { 428, -2 }, /* (454) table_primary ::= table_name alias_opt */ + { 428, -4 }, /* (455) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 428, -2 }, /* (456) table_primary ::= subquery alias_opt */ + { 428, -1 }, /* (457) table_primary ::= parenthesized_joined_table */ + { 430, 0 }, /* (458) alias_opt ::= */ + { 430, -1 }, /* (459) alias_opt ::= table_alias */ + { 430, -2 }, /* (460) alias_opt ::= AS table_alias */ + { 432, -3 }, /* (461) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 432, -3 }, /* (462) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 429, -6 }, /* (463) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 433, 0 }, /* (464) join_type ::= */ + { 433, -1 }, /* (465) join_type ::= INNER */ + { 435, -12 }, /* (466) 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 */ + { 436, 0 }, /* (467) set_quantifier_opt ::= */ + { 436, -1 }, /* (468) set_quantifier_opt ::= DISTINCT */ + { 436, -1 }, /* (469) set_quantifier_opt ::= ALL */ + { 437, -1 }, /* (470) select_list ::= select_item */ + { 437, -3 }, /* (471) select_list ::= select_list NK_COMMA select_item */ + { 445, -1 }, /* (472) select_item ::= NK_STAR */ + { 445, -1 }, /* (473) select_item ::= common_expression */ + { 445, -2 }, /* (474) select_item ::= common_expression column_alias */ + { 445, -3 }, /* (475) select_item ::= common_expression AS column_alias */ + { 445, -3 }, /* (476) select_item ::= table_name NK_DOT NK_STAR */ + { 400, 0 }, /* (477) where_clause_opt ::= */ + { 400, -2 }, /* (478) where_clause_opt ::= WHERE search_condition */ + { 438, 0 }, /* (479) partition_by_clause_opt ::= */ + { 438, -3 }, /* (480) partition_by_clause_opt ::= PARTITION BY partition_list */ + { 446, -1 }, /* (481) partition_list ::= partition_item */ + { 446, -3 }, /* (482) partition_list ::= partition_list NK_COMMA partition_item */ + { 447, -1 }, /* (483) partition_item ::= expr_or_subquery */ + { 447, -2 }, /* (484) partition_item ::= expr_or_subquery column_alias */ + { 447, -3 }, /* (485) partition_item ::= expr_or_subquery AS column_alias */ + { 442, 0 }, /* (486) twindow_clause_opt ::= */ + { 442, -6 }, /* (487) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 442, -4 }, /* (488) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + { 442, -6 }, /* (489) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 442, -8 }, /* (490) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 386, 0 }, /* (491) sliding_opt ::= */ + { 386, -4 }, /* (492) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 441, 0 }, /* (493) fill_opt ::= */ + { 441, -4 }, /* (494) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 441, -6 }, /* (495) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 441, -6 }, /* (496) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ + { 448, -1 }, /* (497) fill_mode ::= NONE */ + { 448, -1 }, /* (498) fill_mode ::= PREV */ + { 448, -1 }, /* (499) fill_mode ::= NULL */ + { 448, -1 }, /* (500) fill_mode ::= NULL_F */ + { 448, -1 }, /* (501) fill_mode ::= LINEAR */ + { 448, -1 }, /* (502) fill_mode ::= NEXT */ + { 443, 0 }, /* (503) group_by_clause_opt ::= */ + { 443, -3 }, /* (504) group_by_clause_opt ::= GROUP BY group_by_list */ + { 449, -1 }, /* (505) group_by_list ::= expr_or_subquery */ + { 449, -3 }, /* (506) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + { 444, 0 }, /* (507) having_clause_opt ::= */ + { 444, -2 }, /* (508) having_clause_opt ::= HAVING search_condition */ + { 439, 0 }, /* (509) range_opt ::= */ + { 439, -6 }, /* (510) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + { 440, 0 }, /* (511) every_opt ::= */ + { 440, -4 }, /* (512) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 450, -4 }, /* (513) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 451, -1 }, /* (514) query_simple ::= query_specification */ + { 451, -1 }, /* (515) query_simple ::= union_query_expression */ + { 455, -4 }, /* (516) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + { 455, -3 }, /* (517) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + { 456, -1 }, /* (518) query_simple_or_subquery ::= query_simple */ + { 456, -1 }, /* (519) query_simple_or_subquery ::= subquery */ + { 389, -1 }, /* (520) query_or_subquery ::= query_expression */ + { 389, -1 }, /* (521) query_or_subquery ::= subquery */ + { 452, 0 }, /* (522) order_by_clause_opt ::= */ + { 452, -3 }, /* (523) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 453, 0 }, /* (524) slimit_clause_opt ::= */ + { 453, -2 }, /* (525) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 453, -4 }, /* (526) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 453, -4 }, /* (527) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 454, 0 }, /* (528) limit_clause_opt ::= */ + { 454, -2 }, /* (529) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 454, -4 }, /* (530) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 454, -4 }, /* (531) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 431, -3 }, /* (532) subquery ::= NK_LP query_expression NK_RP */ + { 431, -3 }, /* (533) subquery ::= NK_LP subquery NK_RP */ + { 434, -1 }, /* (534) search_condition ::= common_expression */ + { 457, -1 }, /* (535) sort_specification_list ::= sort_specification */ + { 457, -3 }, /* (536) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 458, -3 }, /* (537) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + { 459, 0 }, /* (538) ordering_specification_opt ::= */ + { 459, -1 }, /* (539) ordering_specification_opt ::= ASC */ + { 459, -1 }, /* (540) ordering_specification_opt ::= DESC */ + { 460, 0 }, /* (541) null_ordering_opt ::= */ + { 460, -2 }, /* (542) null_ordering_opt ::= NULLS FIRST */ + { 460, -2 }, /* (543) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3629,11 +3641,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,323,&yymsp[0].minor); + yy_destructor(yypParser,325,&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,324,&yymsp[0].minor); + yy_destructor(yypParser,326,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3647,20 +3659,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,323,&yymsp[-2].minor); +{ yy_destructor(yypParser,325,&yymsp[-2].minor); { } - yy_destructor(yypParser,325,&yymsp[0].minor); + yy_destructor(yypParser,327,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,326,&yymsp[0].minor); +{ yy_destructor(yypParser,328,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,324,&yymsp[-1].minor); +{ yy_destructor(yypParser,326,&yymsp[-1].minor); { } - yy_destructor(yypParser,326,&yymsp[0].minor); + yy_destructor(yypParser,328,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3674,80 +3686,80 @@ 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,325,&yymsp[0].minor); + yy_destructor(yypParser,327,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy317, &yymsp[-1].minor.yy0, yymsp[0].minor.yy449); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy77, &yymsp[-1].minor.yy0, yymsp[0].minor.yy287); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy317, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy77, 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.yy317, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy77, 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.yy317, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy77, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy77); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy449 = 1; } +{ yymsp[1].minor.yy287 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy449 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy287 = 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.yy531, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy717, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy531, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy717, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy531 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy717 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 36: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==36); -{ yylhsminor.yy531 = yymsp[0].minor.yy531; } - yymsp[0].minor.yy531 = yylhsminor.yy531; +{ yylhsminor.yy717 = yymsp[0].minor.yy717; } + yymsp[0].minor.yy717 = yylhsminor.yy717; break; case 35: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy531 = PRIVILEGE_TYPE_SUBSCRIBE; } +{ yymsp[0].minor.yy717 = PRIVILEGE_TYPE_SUBSCRIBE; } break; case 37: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy531 = yymsp[-2].minor.yy531 | yymsp[0].minor.yy531; } - yymsp[-2].minor.yy531 = yylhsminor.yy531; +{ yylhsminor.yy717 = yymsp[-2].minor.yy717 | yymsp[0].minor.yy717; } + yymsp[-2].minor.yy717 = yylhsminor.yy717; break; case 38: /* priv_type ::= READ */ -{ yymsp[0].minor.yy531 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy717 = PRIVILEGE_TYPE_READ; } break; case 39: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy531 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy717 = PRIVILEGE_TYPE_WRITE; } break; case 40: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy317 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy317 = yylhsminor.yy317; +{ yylhsminor.yy77 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy77 = yylhsminor.yy77; break; case 41: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy317 = yymsp[-2].minor.yy317; } - yymsp[-2].minor.yy317 = yylhsminor.yy317; +{ yylhsminor.yy77 = yymsp[-2].minor.yy77; } + yymsp[-2].minor.yy77 = yylhsminor.yy77; break; case 42: /* priv_level ::= topic_name */ - case 458: /* alias_opt ::= table_alias */ yytestcase(yyruleno==458); -{ yylhsminor.yy317 = yymsp[0].minor.yy317; } - yymsp[0].minor.yy317 = yylhsminor.yy317; + case 459: /* alias_opt ::= table_alias */ yytestcase(yyruleno==459); +{ yylhsminor.yy77 = yymsp[0].minor.yy77; } + yymsp[0].minor.yy77 = yylhsminor.yy77; break; case 43: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy317, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy77, NULL); } break; case 44: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0); } break; case 45: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy335); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy841); } break; case 46: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy317, yymsp[0].minor.yy335); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy77, yymsp[0].minor.yy841); } break; case 47: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3764,46 +3776,46 @@ static YYACTIONTYPE yy_reduce( case 51: /* dnode_endpoint ::= NK_STRING */ case 52: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==52); case 53: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==53); - case 344: /* db_name ::= NK_ID */ yytestcase(yyruleno==344); - case 345: /* table_name ::= NK_ID */ yytestcase(yyruleno==345); - case 346: /* column_name ::= NK_ID */ yytestcase(yyruleno==346); - case 347: /* function_name ::= NK_ID */ yytestcase(yyruleno==347); - case 348: /* table_alias ::= NK_ID */ yytestcase(yyruleno==348); - case 349: /* column_alias ::= NK_ID */ yytestcase(yyruleno==349); - case 350: /* user_name ::= NK_ID */ yytestcase(yyruleno==350); - case 351: /* topic_name ::= NK_ID */ yytestcase(yyruleno==351); - case 352: /* stream_name ::= NK_ID */ yytestcase(yyruleno==352); - case 353: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==353); - case 354: /* index_name ::= NK_ID */ yytestcase(yyruleno==354); - case 393: /* noarg_func ::= NOW */ yytestcase(yyruleno==393); - case 394: /* noarg_func ::= TODAY */ yytestcase(yyruleno==394); - case 395: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==395); - case 396: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==396); - case 397: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==397); - case 398: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==398); - case 399: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==399); - case 400: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==400); - case 401: /* noarg_func ::= USER */ yytestcase(yyruleno==401); - case 402: /* star_func ::= COUNT */ yytestcase(yyruleno==402); - case 403: /* star_func ::= FIRST */ yytestcase(yyruleno==403); - case 404: /* star_func ::= LAST */ yytestcase(yyruleno==404); - case 405: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==405); -{ yylhsminor.yy317 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy317 = yylhsminor.yy317; + case 345: /* db_name ::= NK_ID */ yytestcase(yyruleno==345); + case 346: /* table_name ::= NK_ID */ yytestcase(yyruleno==346); + case 347: /* column_name ::= NK_ID */ yytestcase(yyruleno==347); + case 348: /* function_name ::= NK_ID */ yytestcase(yyruleno==348); + case 349: /* table_alias ::= NK_ID */ yytestcase(yyruleno==349); + case 350: /* column_alias ::= NK_ID */ yytestcase(yyruleno==350); + case 351: /* user_name ::= NK_ID */ yytestcase(yyruleno==351); + case 352: /* topic_name ::= NK_ID */ yytestcase(yyruleno==352); + case 353: /* stream_name ::= NK_ID */ yytestcase(yyruleno==353); + case 354: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==354); + case 355: /* index_name ::= NK_ID */ yytestcase(yyruleno==355); + case 394: /* noarg_func ::= NOW */ yytestcase(yyruleno==394); + case 395: /* noarg_func ::= TODAY */ yytestcase(yyruleno==395); + case 396: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==396); + case 397: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==397); + case 398: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==398); + case 399: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==399); + case 400: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==400); + case 401: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==401); + case 402: /* noarg_func ::= USER */ yytestcase(yyruleno==402); + case 403: /* star_func ::= COUNT */ yytestcase(yyruleno==403); + case 404: /* star_func ::= FIRST */ yytestcase(yyruleno==404); + case 405: /* star_func ::= LAST */ yytestcase(yyruleno==405); + case 406: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==406); +{ yylhsminor.yy77 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy77 = yylhsminor.yy77; break; case 54: /* force_opt ::= */ case 73: /* not_exists_opt ::= */ yytestcase(yyruleno==73); case 75: /* exists_opt ::= */ yytestcase(yyruleno==75); case 284: /* analyze_opt ::= */ yytestcase(yyruleno==284); case 291: /* agg_func_opt ::= */ yytestcase(yyruleno==291); - case 466: /* set_quantifier_opt ::= */ yytestcase(yyruleno==466); -{ yymsp[1].minor.yy335 = false; } + case 467: /* set_quantifier_opt ::= */ yytestcase(yyruleno==467); +{ yymsp[1].minor.yy841 = false; } break; case 55: /* force_opt ::= FORCE */ case 285: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==285); case 292: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==292); - case 467: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==467); -{ yymsp[0].minor.yy335 = true; } + case 468: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==468); +{ yymsp[0].minor.yy841 = true; } break; case 56: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3836,206 +3848,206 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 66: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy335, &yymsp[-1].minor.yy317, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy841, &yymsp[-1].minor.yy77, yymsp[0].minor.yy600); } break; case 67: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy335, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy841, &yymsp[0].minor.yy77); } break; case 68: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy77); } break; case 69: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy317, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy77, yymsp[0].minor.yy600); } break; case 70: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy77); } break; case 71: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy317, yymsp[0].minor.yy856); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy77, yymsp[0].minor.yy248); } break; case 72: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy335 = true; } +{ yymsp[-2].minor.yy841 = true; } break; case 74: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy335 = true; } +{ yymsp[-1].minor.yy841 = true; } break; case 76: /* db_options ::= */ -{ yymsp[1].minor.yy74 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy600 = createDefaultDatabaseOptions(pCxt); } break; case 77: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 78: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 79: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 80: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 81: /* db_options ::= db_options DURATION NK_INTEGER */ case 82: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==82); -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 83: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 84: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 85: /* db_options ::= db_options KEEP integer_list */ case 86: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==86); -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_KEEP, yymsp[0].minor.yy874); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_KEEP, yymsp[0].minor.yy601); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 87: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 88: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 89: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 90: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 91: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 92: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 93: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 94: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_RETENTIONS, yymsp[0].minor.yy874); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_RETENTIONS, yymsp[0].minor.yy601); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 95: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 96: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 97: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 98: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 99: /* db_options ::= db_options WAL_RETENTION_PERIOD 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.yy74 = setDatabaseOption(pCxt, yymsp[-3].minor.yy74, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-3].minor.yy600, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; case 100: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 101: /* db_options ::= db_options WAL_RETENTION_SIZE 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.yy74 = setDatabaseOption(pCxt, yymsp[-3].minor.yy74, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-3].minor.yy600, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; case 102: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 103: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 104: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 105: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 106: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ -{ yylhsminor.yy74 = setDatabaseOption(pCxt, yymsp[-2].minor.yy74, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setDatabaseOption(pCxt, yymsp[-2].minor.yy600, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 107: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy74 = createAlterDatabaseOptions(pCxt); yylhsminor.yy74 = setAlterDatabaseOption(pCxt, yylhsminor.yy74, &yymsp[0].minor.yy767); } - yymsp[0].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterDatabaseOptions(pCxt); yylhsminor.yy600 = setAlterDatabaseOption(pCxt, yylhsminor.yy600, &yymsp[0].minor.yy661); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; case 108: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy74 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy74, &yymsp[0].minor.yy767); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy600, &yymsp[0].minor.yy661); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; case 109: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy767.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy661.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 110: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy767.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy661.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 111: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy767.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy661.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 112: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy767.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy661.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 113: /* alter_db_option ::= KEEP integer_list */ case 114: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==114); -{ yymsp[-1].minor.yy767.type = DB_OPTION_KEEP; yymsp[-1].minor.yy767.pList = yymsp[0].minor.yy874; } +{ yymsp[-1].minor.yy661.type = DB_OPTION_KEEP; yymsp[-1].minor.yy661.pList = yymsp[0].minor.yy601; } break; case 115: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy767.type = DB_OPTION_PAGES; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy661.type = DB_OPTION_PAGES; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 116: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy767.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy661.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 117: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy767.type = DB_OPTION_WAL; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy661.type = DB_OPTION_WAL; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 118: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy767.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy661.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 119: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy874 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy874 = yylhsminor.yy874; +{ yylhsminor.yy601 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy601 = yylhsminor.yy601; break; case 120: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 314: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==314); -{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy874 = yylhsminor.yy874; + case 315: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==315); +{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy601 = yylhsminor.yy601; break; case 121: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy874 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy874 = yylhsminor.yy874; +{ yylhsminor.yy601 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy601 = yylhsminor.yy601; break; case 122: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy874 = yylhsminor.yy874; +{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy601 = yylhsminor.yy601; break; case 123: /* retention_list ::= retention */ case 145: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==145); @@ -4045,14 +4057,14 @@ static YYACTIONTYPE yy_reduce( case 204: /* col_name_list ::= col_name */ yytestcase(yyruleno==204); case 253: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==253); case 266: /* func_list ::= func */ yytestcase(yyruleno==266); - case 342: /* literal_list ::= signed_literal */ yytestcase(yyruleno==342); - case 408: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==408); - case 414: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==414); - case 469: /* select_list ::= select_item */ yytestcase(yyruleno==469); - case 480: /* partition_list ::= partition_item */ yytestcase(yyruleno==480); - case 532: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==532); -{ yylhsminor.yy874 = createNodeList(pCxt, yymsp[0].minor.yy74); } - yymsp[0].minor.yy874 = yylhsminor.yy874; + case 343: /* literal_list ::= signed_literal */ yytestcase(yyruleno==343); + case 409: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==409); + case 415: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==415); + case 470: /* select_list ::= select_item */ yytestcase(yyruleno==470); + case 481: /* partition_list ::= partition_item */ yytestcase(yyruleno==481); + case 535: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==535); +{ yylhsminor.yy601 = createNodeList(pCxt, yymsp[0].minor.yy600); } + yymsp[0].minor.yy601 = yylhsminor.yy601; break; case 124: /* retention_list ::= retention_list NK_COMMA retention */ case 156: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==156); @@ -4060,271 +4072,271 @@ static YYACTIONTYPE yy_reduce( case 205: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==205); case 254: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==254); case 267: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==267); - case 343: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==343); - case 409: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==409); - case 470: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==470); - case 481: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==481); - case 533: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==533); -{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, yymsp[0].minor.yy74); } - yymsp[-2].minor.yy874 = yylhsminor.yy874; + case 344: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==344); + case 410: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==410); + case 471: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==471); + case 482: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==482); + case 536: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==536); +{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, yymsp[0].minor.yy600); } + yymsp[-2].minor.yy601 = yylhsminor.yy601; break; case 125: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy74 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 126: /* speed_opt ::= */ case 293: /* bufsize_opt ::= */ yytestcase(yyruleno==293); -{ yymsp[1].minor.yy856 = 0; } +{ yymsp[1].minor.yy248 = 0; } break; case 127: /* speed_opt ::= MAX_SPEED NK_INTEGER */ case 294: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==294); -{ yymsp[-1].minor.yy856 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy248 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 128: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 130: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==130); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy335, yymsp[-5].minor.yy74, yymsp[-3].minor.yy874, yymsp[-1].minor.yy874, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy841, yymsp[-5].minor.yy600, yymsp[-3].minor.yy601, yymsp[-1].minor.yy601, yymsp[0].minor.yy600); } break; case 129: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy874); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy601); } break; case 131: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy874); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy601); } break; case 132: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy335, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy841, yymsp[0].minor.yy600); } break; case 133: /* cmd ::= ALTER TABLE alter_table_clause */ - case 316: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==316); -{ pCxt->pRootNode = yymsp[0].minor.yy74; } + case 317: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==317); +{ pCxt->pRootNode = yymsp[0].minor.yy600; } break; case 134: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy74); } +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy600); } break; case 135: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy74 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; case 136: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy74 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy317, yymsp[0].minor.yy898); } - yymsp[-4].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy77, yymsp[0].minor.yy888); } + yymsp[-4].minor.yy600 = yylhsminor.yy600; break; case 137: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy74 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy74, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy317); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy600, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy77); } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; case 138: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy74 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy317, yymsp[0].minor.yy898); } - yymsp[-4].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy77, yymsp[0].minor.yy888); } + yymsp[-4].minor.yy600 = yylhsminor.yy600; break; case 139: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy74 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy317, &yymsp[0].minor.yy317); } - yymsp[-4].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy77, &yymsp[0].minor.yy77); } + yymsp[-4].minor.yy600 = yylhsminor.yy600; break; case 140: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy74 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy317, yymsp[0].minor.yy898); } - yymsp[-4].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy77, yymsp[0].minor.yy888); } + yymsp[-4].minor.yy600 = yylhsminor.yy600; break; case 141: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy74 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy74, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy317); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy600, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy77); } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; case 142: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy74 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy317, yymsp[0].minor.yy898); } - yymsp[-4].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy77, yymsp[0].minor.yy888); } + yymsp[-4].minor.yy600 = yylhsminor.yy600; break; case 143: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy74 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy74, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy317, &yymsp[0].minor.yy317); } - yymsp[-4].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy600, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy77, &yymsp[0].minor.yy77); } + yymsp[-4].minor.yy600 = yylhsminor.yy600; break; case 144: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy74 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy74, &yymsp[-2].minor.yy317, yymsp[0].minor.yy74); } - yymsp[-5].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy600, &yymsp[-2].minor.yy77, yymsp[0].minor.yy600); } + yymsp[-5].minor.yy600 = yylhsminor.yy600; break; case 146: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 149: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==149); - case 415: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==415); -{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-1].minor.yy874, yymsp[0].minor.yy74); } - yymsp[-1].minor.yy874 = yylhsminor.yy874; + case 416: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==416); +{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-1].minor.yy601, yymsp[0].minor.yy600); } + yymsp[-1].minor.yy601 = yylhsminor.yy601; break; case 147: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ -{ yylhsminor.yy74 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy335, yymsp[-8].minor.yy74, yymsp[-6].minor.yy74, yymsp[-5].minor.yy874, yymsp[-2].minor.yy874, yymsp[0].minor.yy74); } - yymsp[-9].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy841, yymsp[-8].minor.yy600, yymsp[-6].minor.yy600, yymsp[-5].minor.yy601, yymsp[-2].minor.yy601, yymsp[0].minor.yy600); } + yymsp[-9].minor.yy600 = yylhsminor.yy600; break; case 150: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy74 = createDropTableClause(pCxt, yymsp[-1].minor.yy335, yymsp[0].minor.yy74); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createDropTableClause(pCxt, yymsp[-1].minor.yy841, yymsp[0].minor.yy600); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; case 151: /* specific_cols_opt ::= */ case 182: /* tags_def_opt ::= */ yytestcase(yyruleno==182); case 252: /* tag_list_opt ::= */ yytestcase(yyruleno==252); - case 478: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==478); - case 500: /* group_by_clause_opt ::= */ yytestcase(yyruleno==500); - case 519: /* order_by_clause_opt ::= */ yytestcase(yyruleno==519); -{ yymsp[1].minor.yy874 = NULL; } + case 479: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==479); + case 503: /* group_by_clause_opt ::= */ yytestcase(yyruleno==503); + case 522: /* order_by_clause_opt ::= */ yytestcase(yyruleno==522); +{ yymsp[1].minor.yy601 = NULL; } break; case 152: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy874 = yymsp[-1].minor.yy874; } +{ yymsp[-2].minor.yy601 = yymsp[-1].minor.yy601; } break; case 153: /* full_table_name ::= table_name */ -{ yylhsminor.yy74 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy317, NULL); } - yymsp[0].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy77, NULL); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; case 154: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy74 = createRealTableNode(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317, NULL); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createRealTableNode(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77, NULL); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 157: /* column_def ::= column_name type_name */ -{ yylhsminor.yy74 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy317, yymsp[0].minor.yy898, NULL); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy77, yymsp[0].minor.yy888, NULL); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; case 158: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy74 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy317, yymsp[-2].minor.yy898, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy77, yymsp[-2].minor.yy888, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; case 159: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 160: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 161: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 162: /* type_name ::= INT */ case 163: /* type_name ::= INTEGER */ yytestcase(yyruleno==163); -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_INT); } break; case 164: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 165: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 166: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 167: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy898 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy888 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 168: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 169: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy898 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy888 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 170: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy898 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy888 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 171: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy898 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy888 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 172: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy898 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy888 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 173: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy898 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy888 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 174: /* type_name ::= JSON */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 175: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy898 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy888 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 176: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 177: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 178: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy898 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy888 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 179: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy898 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy888 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 180: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy898 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy888 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 181: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy898 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy888 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 183: /* tags_def_opt ::= tags_def */ - case 407: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==407); -{ yylhsminor.yy874 = yymsp[0].minor.yy874; } - yymsp[0].minor.yy874 = yylhsminor.yy874; + case 408: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==408); +{ yylhsminor.yy601 = yymsp[0].minor.yy601; } + yymsp[0].minor.yy601 = yylhsminor.yy601; break; case 184: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy874 = yymsp[-1].minor.yy874; } +{ yymsp[-3].minor.yy601 = yymsp[-1].minor.yy601; } break; case 185: /* table_options ::= */ -{ yymsp[1].minor.yy74 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy600 = createDefaultTableOptions(pCxt); } break; case 186: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-2].minor.yy74, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-2].minor.yy600, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 187: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-2].minor.yy74, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy874); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-2].minor.yy600, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy601); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 188: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-2].minor.yy74, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy874); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-2].minor.yy600, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy601); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 189: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-4].minor.yy74, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy874); } - yymsp[-4].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-4].minor.yy600, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy601); } + yymsp[-4].minor.yy600 = yylhsminor.yy600; break; case 190: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-2].minor.yy74, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-2].minor.yy600, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 191: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-4].minor.yy74, TABLE_OPTION_SMA, yymsp[-1].minor.yy874); } - yymsp[-4].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-4].minor.yy600, TABLE_OPTION_SMA, yymsp[-1].minor.yy601); } + yymsp[-4].minor.yy600 = yylhsminor.yy600; break; case 192: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-2].minor.yy74, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy874); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-2].minor.yy600, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy601); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 193: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy74 = createAlterTableOptions(pCxt); yylhsminor.yy74 = setTableOption(pCxt, yylhsminor.yy74, yymsp[0].minor.yy767.type, &yymsp[0].minor.yy767.val); } - yymsp[0].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createAlterTableOptions(pCxt); yylhsminor.yy600 = setTableOption(pCxt, yylhsminor.yy600, yymsp[0].minor.yy661.type, &yymsp[0].minor.yy661.val); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; case 194: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy74 = setTableOption(pCxt, yymsp[-1].minor.yy74, yymsp[0].minor.yy767.type, &yymsp[0].minor.yy767.val); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setTableOption(pCxt, yymsp[-1].minor.yy600, yymsp[0].minor.yy661.type, &yymsp[0].minor.yy661.val); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; case 195: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy767.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy661.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 196: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy767.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy767.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy661.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy661.val = yymsp[0].minor.yy0; } break; case 197: /* duration_list ::= duration_literal */ - case 372: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==372); -{ yylhsminor.yy874 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy74)); } - yymsp[0].minor.yy874 = yylhsminor.yy874; + case 373: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==373); +{ yylhsminor.yy601 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } + yymsp[0].minor.yy601 = yylhsminor.yy601; break; case 198: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 373: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==373); -{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, releaseRawExprNode(pCxt, yymsp[0].minor.yy74)); } - yymsp[-2].minor.yy874 = yylhsminor.yy874; + case 374: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==374); +{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } + yymsp[-2].minor.yy601 = yylhsminor.yy601; break; case 201: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy74 = createFunctionNode(pCxt, &yymsp[0].minor.yy317, NULL); } - yymsp[0].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createFunctionNode(pCxt, &yymsp[0].minor.yy77, NULL); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; case 202: /* rollup_func_name ::= FIRST */ case 203: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==203); case 256: /* tag_item ::= QTAGS */ yytestcase(yyruleno==256); -{ yylhsminor.yy74 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; case 206: /* col_name ::= column_name */ case 257: /* tag_item ::= column_name */ yytestcase(yyruleno==257); -{ yylhsminor.yy74 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy317); } - yymsp[0].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy77); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; case 207: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -4339,13 +4351,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; case 211: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy74, yymsp[0].minor.yy74, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy600, yymsp[0].minor.yy600, OP_TYPE_LIKE); } break; case 212: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy74, yymsp[0].minor.yy74, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy600, yymsp[0].minor.yy600, OP_TYPE_LIKE); } break; case 213: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy74, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy600, NULL, OP_TYPE_LIKE); } break; case 214: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -4357,7 +4369,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; case 217: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy74, yymsp[-1].minor.yy74, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy600, yymsp[-1].minor.yy600, OP_TYPE_EQUAL); } break; case 218: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -4376,13 +4388,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; case 224: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy77); } break; case 225: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy600); } break; case 226: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy600); } break; case 227: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -4401,7 +4413,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; case 233: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy600); } break; case 234: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } @@ -4416,7 +4428,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; case 238: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy600); } break; case 239: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } @@ -4425,10 +4437,10 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; case 241: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy74, yymsp[-1].minor.yy74, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy600, yymsp[-1].minor.yy600, OP_TYPE_EQUAL); } break; case 242: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy74, yymsp[0].minor.yy74, yymsp[-3].minor.yy874); } +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy600, yymsp[0].minor.yy600, yymsp[-3].minor.yy601); } break; case 243: /* cmd ::= SHOW VNODES NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } @@ -4438,741 +4450,751 @@ static YYACTIONTYPE yy_reduce( break; case 245: /* db_name_cond_opt ::= */ case 250: /* from_db_opt ::= */ yytestcase(yyruleno==250); -{ yymsp[1].minor.yy74 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy600 = createDefaultDatabaseCondValue(pCxt); } break; case 246: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy74 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy317); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy77); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; case 247: /* like_pattern_opt ::= */ - case 304: /* subtable_opt ::= */ yytestcase(yyruleno==304); - case 417: /* case_when_else_opt ::= */ yytestcase(yyruleno==417); - case 447: /* from_clause_opt ::= */ yytestcase(yyruleno==447); - case 476: /* where_clause_opt ::= */ yytestcase(yyruleno==476); - case 485: /* twindow_clause_opt ::= */ yytestcase(yyruleno==485); - case 490: /* sliding_opt ::= */ yytestcase(yyruleno==490); - case 492: /* fill_opt ::= */ yytestcase(yyruleno==492); - case 504: /* having_clause_opt ::= */ yytestcase(yyruleno==504); - case 506: /* range_opt ::= */ yytestcase(yyruleno==506); - case 508: /* every_opt ::= */ yytestcase(yyruleno==508); - case 521: /* slimit_clause_opt ::= */ yytestcase(yyruleno==521); - case 525: /* limit_clause_opt ::= */ yytestcase(yyruleno==525); -{ yymsp[1].minor.yy74 = NULL; } + case 305: /* subtable_opt ::= */ yytestcase(yyruleno==305); + case 418: /* case_when_else_opt ::= */ yytestcase(yyruleno==418); + case 448: /* from_clause_opt ::= */ yytestcase(yyruleno==448); + case 477: /* where_clause_opt ::= */ yytestcase(yyruleno==477); + case 486: /* twindow_clause_opt ::= */ yytestcase(yyruleno==486); + case 491: /* sliding_opt ::= */ yytestcase(yyruleno==491); + case 493: /* fill_opt ::= */ yytestcase(yyruleno==493); + case 507: /* having_clause_opt ::= */ yytestcase(yyruleno==507); + case 509: /* range_opt ::= */ yytestcase(yyruleno==509); + case 511: /* every_opt ::= */ yytestcase(yyruleno==511); + case 524: /* slimit_clause_opt ::= */ yytestcase(yyruleno==524); + case 528: /* limit_clause_opt ::= */ yytestcase(yyruleno==528); +{ yymsp[1].minor.yy600 = NULL; } break; case 248: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 249: /* table_name_cond ::= table_name */ -{ yylhsminor.yy74 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy317); } - yymsp[0].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy77); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; case 251: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy74 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy317); } +{ yymsp[-1].minor.yy600 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy77); } break; case 255: /* tag_item ::= TBNAME */ -{ yylhsminor.yy74 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; case 258: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy74 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy317), &yymsp[0].minor.yy317); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy77), &yymsp[0].minor.yy77); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; case 259: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy74 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy317), &yymsp[0].minor.yy317); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy77), &yymsp[0].minor.yy77); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 260: /* cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy335, yymsp[-3].minor.yy74, yymsp[-1].minor.yy74, NULL, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy841, yymsp[-3].minor.yy600, yymsp[-1].minor.yy600, NULL, yymsp[0].minor.yy600); } break; case 261: /* cmd ::= DROP INDEX exists_opt full_index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy335, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy841, yymsp[0].minor.yy600); } break; case 262: /* full_index_name ::= index_name */ -{ yylhsminor.yy74 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy317); } - yymsp[0].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy77); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; case 263: /* full_index_name ::= db_name NK_DOT index_name */ -{ yylhsminor.yy74 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 264: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy74 = createIndexOption(pCxt, yymsp[-7].minor.yy874, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), NULL, yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } +{ yymsp[-9].minor.yy600 = createIndexOption(pCxt, yymsp[-7].minor.yy601, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), NULL, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } break; case 265: /* 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.yy74 = createIndexOption(pCxt, yymsp[-9].minor.yy874, releaseRawExprNode(pCxt, yymsp[-5].minor.yy74), releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } +{ yymsp[-11].minor.yy600 = createIndexOption(pCxt, yymsp[-9].minor.yy601, releaseRawExprNode(pCxt, yymsp[-5].minor.yy600), releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } break; case 268: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy74 = createFunctionNode(pCxt, &yymsp[-3].minor.yy317, yymsp[-1].minor.yy874); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = createFunctionNode(pCxt, &yymsp[-3].minor.yy77, yymsp[-1].minor.yy601); } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; case 269: /* sma_stream_opt ::= */ case 297: /* stream_options ::= */ yytestcase(yyruleno==297); -{ yymsp[1].minor.yy74 = createStreamOptions(pCxt); } +{ yymsp[1].minor.yy600 = createStreamOptions(pCxt); } break; case 270: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ case 301: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==301); -{ ((SStreamOptions*)yymsp[-2].minor.yy74)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); yylhsminor.yy74 = yymsp[-2].minor.yy74; } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ ((SStreamOptions*)yymsp[-2].minor.yy600)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = yymsp[-2].minor.yy600; } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 271: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy74)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); yylhsminor.yy74 = yymsp[-2].minor.yy74; } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ ((SStreamOptions*)yymsp[-2].minor.yy600)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = yymsp[-2].minor.yy600; } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 272: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy74)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); yylhsminor.yy74 = yymsp[-2].minor.yy74; } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ ((SStreamOptions*)yymsp[-2].minor.yy600)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = yymsp[-2].minor.yy600; } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 273: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy335, &yymsp[-2].minor.yy317, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy841, &yymsp[-2].minor.yy77, yymsp[0].minor.yy600); } break; case 274: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy335, &yymsp[-3].minor.yy317, &yymsp[0].minor.yy317, false); } +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy841, &yymsp[-3].minor.yy77, &yymsp[0].minor.yy77, false); } break; case 275: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy335, &yymsp[-5].minor.yy317, &yymsp[0].minor.yy317, true); } +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy841, &yymsp[-5].minor.yy77, &yymsp[0].minor.yy77, true); } break; case 276: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy335, &yymsp[-3].minor.yy317, yymsp[0].minor.yy74, false); } +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy841, &yymsp[-3].minor.yy77, yymsp[0].minor.yy600, false); } break; case 277: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy335, &yymsp[-5].minor.yy317, yymsp[0].minor.yy74, true); } +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy841, &yymsp[-5].minor.yy77, yymsp[0].minor.yy600, true); } break; case 278: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy335, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy841, &yymsp[0].minor.yy77); } break; case 279: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy335, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy841, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77); } break; case 280: /* cmd ::= DESC full_table_name */ case 281: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==281); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy600); } break; case 282: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; case 283: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy335, yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy841, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } break; case 286: /* explain_options ::= */ -{ yymsp[1].minor.yy74 = createDefaultExplainOptions(pCxt); } +{ yymsp[1].minor.yy600 = createDefaultExplainOptions(pCxt); } break; case 287: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy74 = setExplainVerbose(pCxt, yymsp[-2].minor.yy74, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setExplainVerbose(pCxt, yymsp[-2].minor.yy600, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 288: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy74 = setExplainRatio(pCxt, yymsp[-2].minor.yy74, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ yylhsminor.yy600 = setExplainRatio(pCxt, yymsp[-2].minor.yy600, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 289: /* 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.yy335, yymsp[-8].minor.yy335, &yymsp[-5].minor.yy317, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy898, yymsp[0].minor.yy856); } +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy841, yymsp[-8].minor.yy841, &yymsp[-5].minor.yy77, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy888, yymsp[0].minor.yy248); } break; case 290: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy335, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy841, &yymsp[0].minor.yy77); } break; case 295: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-8].minor.yy335, &yymsp[-7].minor.yy317, yymsp[-4].minor.yy74, yymsp[-6].minor.yy74, yymsp[-3].minor.yy874, yymsp[-2].minor.yy74, yymsp[0].minor.yy74); } +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-8].minor.yy841, &yymsp[-7].minor.yy77, yymsp[-4].minor.yy600, yymsp[-6].minor.yy600, yymsp[-3].minor.yy601, yymsp[-2].minor.yy600, yymsp[0].minor.yy600); } break; case 296: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy335, &yymsp[0].minor.yy317); } +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy841, &yymsp[0].minor.yy77); } break; case 298: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy74)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy74 = yymsp[-2].minor.yy74; } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ ((SStreamOptions*)yymsp[-2].minor.yy600)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy600 = yymsp[-2].minor.yy600; } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 299: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy74)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy74 = yymsp[-2].minor.yy74; } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ ((SStreamOptions*)yymsp[-2].minor.yy600)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy600 = yymsp[-2].minor.yy600; } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; case 300: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy74)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy74)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); yylhsminor.yy74 = yymsp[-3].minor.yy74; } - yymsp[-3].minor.yy74 = yylhsminor.yy74; +{ ((SStreamOptions*)yymsp[-3].minor.yy600)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy600)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); yylhsminor.yy600 = yymsp[-3].minor.yy600; } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; case 302: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-3].minor.yy74)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy74 = yymsp[-3].minor.yy74; } - yymsp[-3].minor.yy74 = yylhsminor.yy74; +{ ((SStreamOptions*)yymsp[-3].minor.yy600)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy600 = yymsp[-3].minor.yy600; } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; case 303: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-2].minor.yy74)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy74 = yymsp[-2].minor.yy74; } - yymsp[-2].minor.yy74 = yylhsminor.yy74; +{ ((SStreamOptions*)yymsp[-2].minor.yy600)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy600 = yymsp[-2].minor.yy600; } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 305: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 491: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==491); - case 509: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==509); -{ yymsp[-3].minor.yy74 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy74); } + case 304: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-3].minor.yy600)->ignoreUpdate = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy600 = yymsp[-3].minor.yy600; } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 306: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 306: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 492: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==492); + case 512: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==512); +{ yymsp[-3].minor.yy600 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy600); } + break; + case 307: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 307: /* cmd ::= KILL QUERY NK_STRING */ + case 308: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 308: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 309: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 309: /* cmd ::= BALANCE VGROUP */ + case 310: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 310: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 311: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 311: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy874); } + case 312: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy601); } break; - case 312: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 313: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 313: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy874 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 314: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy601 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 315: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } + case 316: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } break; - case 317: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy74, yymsp[-2].minor.yy874, yymsp[0].minor.yy74); } + case 318: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy600, yymsp[-2].minor.yy601, yymsp[0].minor.yy600); } break; - case 318: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy74, NULL, yymsp[0].minor.yy74); } + case 319: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy600, NULL, yymsp[0].minor.yy600); } break; - case 319: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 320: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 320: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 321: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 321: /* literal ::= NK_STRING */ -{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 322: /* literal ::= NK_STRING */ +{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 322: /* literal ::= NK_BOOL */ -{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 323: /* literal ::= NK_BOOL */ +{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 323: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; + case 324: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 324: /* literal ::= duration_literal */ - case 334: /* signed_literal ::= signed */ yytestcase(yyruleno==334); - case 355: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==355); - case 356: /* expression ::= literal */ yytestcase(yyruleno==356); - case 357: /* expression ::= pseudo_column */ yytestcase(yyruleno==357); - case 358: /* expression ::= column_reference */ yytestcase(yyruleno==358); - case 359: /* expression ::= function_expression */ yytestcase(yyruleno==359); - case 360: /* expression ::= case_when_expression */ yytestcase(yyruleno==360); - case 390: /* function_expression ::= literal_func */ yytestcase(yyruleno==390); - case 439: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==439); - case 443: /* boolean_primary ::= predicate */ yytestcase(yyruleno==443); - case 445: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==445); - case 446: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==446); - case 449: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==449); - case 451: /* table_reference ::= table_primary */ yytestcase(yyruleno==451); - case 452: /* table_reference ::= joined_table */ yytestcase(yyruleno==452); - case 456: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==456); - case 511: /* query_simple ::= query_specification */ yytestcase(yyruleno==511); - case 512: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==512); - case 515: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==515); - case 517: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==517); -{ yylhsminor.yy74 = yymsp[0].minor.yy74; } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 325: /* literal ::= duration_literal */ + case 335: /* signed_literal ::= signed */ yytestcase(yyruleno==335); + case 356: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==356); + case 357: /* expression ::= literal */ yytestcase(yyruleno==357); + case 358: /* expression ::= pseudo_column */ yytestcase(yyruleno==358); + case 359: /* expression ::= column_reference */ yytestcase(yyruleno==359); + case 360: /* expression ::= function_expression */ yytestcase(yyruleno==360); + case 361: /* expression ::= case_when_expression */ yytestcase(yyruleno==361); + case 391: /* function_expression ::= literal_func */ yytestcase(yyruleno==391); + case 440: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==440); + case 444: /* boolean_primary ::= predicate */ yytestcase(yyruleno==444); + case 446: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==446); + case 447: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==447); + case 450: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==450); + case 452: /* table_reference ::= table_primary */ yytestcase(yyruleno==452); + case 453: /* table_reference ::= joined_table */ yytestcase(yyruleno==453); + case 457: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==457); + case 514: /* query_simple ::= query_specification */ yytestcase(yyruleno==514); + case 515: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==515); + case 518: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==518); + case 520: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==520); +{ yylhsminor.yy600 = yymsp[0].minor.yy600; } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 325: /* literal ::= NULL */ -{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 326: /* literal ::= NULL */ +{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 326: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 327: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 327: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 328: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 328: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 329: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 329: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + case 330: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; - case 330: /* signed ::= NK_MINUS NK_INTEGER */ + case 331: /* 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.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 331: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 332: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 332: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 333: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 333: /* signed ::= NK_MINUS NK_FLOAT */ + case 334: /* 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.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 335: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 336: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 336: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 337: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 337: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 338: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 338: /* signed_literal ::= duration_literal */ - case 340: /* signed_literal ::= literal_func */ yytestcase(yyruleno==340); - case 410: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==410); - case 472: /* select_item ::= common_expression */ yytestcase(yyruleno==472); - case 482: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==482); - case 516: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==516); - case 518: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==518); - case 531: /* search_condition ::= common_expression */ yytestcase(yyruleno==531); -{ yylhsminor.yy74 = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 339: /* signed_literal ::= duration_literal */ + case 341: /* signed_literal ::= literal_func */ yytestcase(yyruleno==341); + case 411: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==411); + case 473: /* select_item ::= common_expression */ yytestcase(yyruleno==473); + case 483: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==483); + case 519: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==519); + case 521: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==521); + case 534: /* search_condition ::= common_expression */ yytestcase(yyruleno==534); +{ yylhsminor.yy600 = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 339: /* signed_literal ::= NULL */ -{ yylhsminor.yy74 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 340: /* signed_literal ::= NULL */ +{ yylhsminor.yy600 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 341: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy74 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 342: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy600 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 361: /* expression ::= NK_LP expression NK_RP */ - case 444: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==444); - case 530: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==530); -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy74)); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 362: /* expression ::= NK_LP expression NK_RP */ + case 445: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==445); + case 533: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==533); +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 362: /* expression ::= NK_PLUS expr_or_subquery */ + case 363: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy74)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 363: /* expression ::= NK_MINUS expr_or_subquery */ + case 364: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy74), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy600), NULL)); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 364: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 365: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 365: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 366: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 366: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 367: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 367: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 368: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 368: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 369: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 369: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 370: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 370: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 371: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 371: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 372: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 374: /* column_reference ::= column_name */ -{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy317, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy317)); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 375: /* column_reference ::= column_name */ +{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy77, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy77)); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 375: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317, createColumnNode(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy317)); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 376: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77, createColumnNode(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy77)); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 376: /* pseudo_column ::= ROWTS */ - case 377: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==377); - case 379: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==379); - case 380: /* pseudo_column ::= QEND */ yytestcase(yyruleno==380); - case 381: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==381); - case 382: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==382); - case 383: /* pseudo_column ::= WEND */ yytestcase(yyruleno==383); - case 384: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==384); - case 385: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==385); - case 386: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==386); - case 392: /* literal_func ::= NOW */ yytestcase(yyruleno==392); -{ yylhsminor.yy74 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 377: /* pseudo_column ::= ROWTS */ + case 378: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==378); + case 380: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==380); + case 381: /* pseudo_column ::= QEND */ yytestcase(yyruleno==381); + case 382: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==382); + case 383: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==383); + case 384: /* pseudo_column ::= WEND */ yytestcase(yyruleno==384); + case 385: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==385); + case 386: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==386); + case 387: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==387); + case 393: /* literal_func ::= NOW */ yytestcase(yyruleno==393); +{ yylhsminor.yy600 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 378: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy317)))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 379: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy77)))); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 387: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 388: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==388); -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy317, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy317, yymsp[-1].minor.yy874)); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; + case 388: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 389: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==389); +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy77, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy77, yymsp[-1].minor.yy601)); } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 389: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), yymsp[-1].minor.yy898)); } - yymsp[-5].minor.yy74 = yylhsminor.yy74; + case 390: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-1].minor.yy888)); } + yymsp[-5].minor.yy600 = yylhsminor.yy600; break; - case 391: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy317, NULL)); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 392: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy77, NULL)); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 406: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy874 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy874 = yylhsminor.yy874; + case 407: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy601 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy601 = yylhsminor.yy601; break; - case 411: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 475: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==475); -{ yylhsminor.yy74 = createColumnNode(pCxt, &yymsp[-2].minor.yy317, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 412: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 476: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==476); +{ yylhsminor.yy600 = createColumnNode(pCxt, &yymsp[-2].minor.yy77, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 412: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy874, yymsp[-1].minor.yy74)); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; + case 413: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy601, yymsp[-1].minor.yy600)); } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 413: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), yymsp[-2].minor.yy874, yymsp[-1].minor.yy74)); } - yymsp[-4].minor.yy74 = yylhsminor.yy74; + case 414: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-2].minor.yy601, yymsp[-1].minor.yy600)); } + yymsp[-4].minor.yy600 = yylhsminor.yy600; break; - case 416: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy74 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74)); } + case 417: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy600 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600)); } break; - case 418: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy74 = releaseRawExprNode(pCxt, yymsp[0].minor.yy74); } + case 419: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy600 = releaseRawExprNode(pCxt, yymsp[0].minor.yy600); } break; - case 419: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 424: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==424); + case 420: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 425: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==425); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy20, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy666, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 420: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 421: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy74), releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy600), releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-4].minor.yy74 = yylhsminor.yy74; + yymsp[-4].minor.yy600 = yylhsminor.yy600; break; - case 421: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 422: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy74), releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy600), releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-5].minor.yy74 = yylhsminor.yy74; + yymsp[-5].minor.yy600 = yylhsminor.yy600; break; - case 422: /* predicate ::= expr_or_subquery IS NULL */ + case 423: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), NULL)); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 423: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 424: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), NULL)); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 425: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy20 = OP_TYPE_LOWER_THAN; } + case 426: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy666 = OP_TYPE_LOWER_THAN; } break; - case 426: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy20 = OP_TYPE_GREATER_THAN; } + case 427: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy666 = OP_TYPE_GREATER_THAN; } break; - case 427: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy20 = OP_TYPE_LOWER_EQUAL; } + case 428: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy666 = OP_TYPE_LOWER_EQUAL; } break; - case 428: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy20 = OP_TYPE_GREATER_EQUAL; } + case 429: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy666 = OP_TYPE_GREATER_EQUAL; } break; - case 429: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy20 = OP_TYPE_NOT_EQUAL; } + case 430: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy666 = OP_TYPE_NOT_EQUAL; } break; - case 430: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy20 = OP_TYPE_EQUAL; } + case 431: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy666 = OP_TYPE_EQUAL; } break; - case 431: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy20 = OP_TYPE_LIKE; } + case 432: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy666 = OP_TYPE_LIKE; } break; - case 432: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy20 = OP_TYPE_NOT_LIKE; } + case 433: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy666 = OP_TYPE_NOT_LIKE; } break; - case 433: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy20 = OP_TYPE_MATCH; } + case 434: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy666 = OP_TYPE_MATCH; } break; - case 434: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy20 = OP_TYPE_NMATCH; } + case 435: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy666 = OP_TYPE_NMATCH; } break; - case 435: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy20 = OP_TYPE_JSON_CONTAINS; } + case 436: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy666 = OP_TYPE_JSON_CONTAINS; } break; - case 436: /* in_op ::= IN */ -{ yymsp[0].minor.yy20 = OP_TYPE_IN; } + case 437: /* in_op ::= IN */ +{ yymsp[0].minor.yy666 = OP_TYPE_IN; } break; - case 437: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy20 = OP_TYPE_NOT_IN; } + case 438: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy666 = OP_TYPE_NOT_IN; } break; - case 438: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy874)); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 439: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy601)); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 440: /* boolean_value_expression ::= NOT boolean_primary */ + case 441: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy74), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy600), NULL)); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 441: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 442: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 442: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 443: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy74); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy74); - yylhsminor.yy74 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy600); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy600); + yylhsminor.yy600 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 448: /* from_clause_opt ::= FROM table_reference_list */ - case 477: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==477); - case 505: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==505); -{ yymsp[-1].minor.yy74 = yymsp[0].minor.yy74; } + case 449: /* from_clause_opt ::= FROM table_reference_list */ + case 478: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==478); + case 508: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==508); +{ yymsp[-1].minor.yy600 = yymsp[0].minor.yy600; } break; - case 450: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy74 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy74, yymsp[0].minor.yy74, NULL); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 451: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy600 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy600, yymsp[0].minor.yy600, NULL); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 453: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy74 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy317, &yymsp[0].minor.yy317); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; + case 454: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy600 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy77, &yymsp[0].minor.yy77); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 454: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy74 = createRealTableNode(pCxt, &yymsp[-3].minor.yy317, &yymsp[-1].minor.yy317, &yymsp[0].minor.yy317); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; + case 455: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy600 = createRealTableNode(pCxt, &yymsp[-3].minor.yy77, &yymsp[-1].minor.yy77, &yymsp[0].minor.yy77); } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 455: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy74 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy74), &yymsp[0].minor.yy317); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; + case 456: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy600 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600), &yymsp[0].minor.yy77); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 457: /* alias_opt ::= */ -{ yymsp[1].minor.yy317 = nil_token; } + case 458: /* alias_opt ::= */ +{ yymsp[1].minor.yy77 = nil_token; } break; - case 459: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy317 = yymsp[0].minor.yy317; } + case 460: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy77 = yymsp[0].minor.yy77; } break; - case 460: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 461: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==461); -{ yymsp[-2].minor.yy74 = yymsp[-1].minor.yy74; } + case 461: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 462: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==462); +{ yymsp[-2].minor.yy600 = yymsp[-1].minor.yy600; } break; - case 462: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy74 = createJoinTableNode(pCxt, yymsp[-4].minor.yy630, yymsp[-5].minor.yy74, yymsp[-2].minor.yy74, yymsp[0].minor.yy74); } - yymsp[-5].minor.yy74 = yylhsminor.yy74; + case 463: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy600 = createJoinTableNode(pCxt, yymsp[-4].minor.yy560, yymsp[-5].minor.yy600, yymsp[-2].minor.yy600, yymsp[0].minor.yy600); } + yymsp[-5].minor.yy600 = yylhsminor.yy600; break; - case 463: /* join_type ::= */ -{ yymsp[1].minor.yy630 = JOIN_TYPE_INNER; } + case 464: /* join_type ::= */ +{ yymsp[1].minor.yy560 = JOIN_TYPE_INNER; } break; - case 464: /* join_type ::= INNER */ -{ yymsp[0].minor.yy630 = JOIN_TYPE_INNER; } + case 465: /* join_type ::= INNER */ +{ yymsp[0].minor.yy560 = JOIN_TYPE_INNER; } break; - case 465: /* 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 466: /* 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.yy74 = createSelectStmt(pCxt, yymsp[-10].minor.yy335, yymsp[-9].minor.yy874, yymsp[-8].minor.yy74); - yymsp[-11].minor.yy74 = addWhereClause(pCxt, yymsp[-11].minor.yy74, yymsp[-7].minor.yy74); - yymsp[-11].minor.yy74 = addPartitionByClause(pCxt, yymsp[-11].minor.yy74, yymsp[-6].minor.yy874); - yymsp[-11].minor.yy74 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy74, yymsp[-2].minor.yy74); - yymsp[-11].minor.yy74 = addGroupByClause(pCxt, yymsp[-11].minor.yy74, yymsp[-1].minor.yy874); - yymsp[-11].minor.yy74 = addHavingClause(pCxt, yymsp[-11].minor.yy74, yymsp[0].minor.yy74); - yymsp[-11].minor.yy74 = addRangeClause(pCxt, yymsp[-11].minor.yy74, yymsp[-5].minor.yy74); - yymsp[-11].minor.yy74 = addEveryClause(pCxt, yymsp[-11].minor.yy74, yymsp[-4].minor.yy74); - yymsp[-11].minor.yy74 = addFillClause(pCxt, yymsp[-11].minor.yy74, yymsp[-3].minor.yy74); + yymsp[-11].minor.yy600 = createSelectStmt(pCxt, yymsp[-10].minor.yy841, yymsp[-9].minor.yy601, yymsp[-8].minor.yy600); + yymsp[-11].minor.yy600 = addWhereClause(pCxt, yymsp[-11].minor.yy600, yymsp[-7].minor.yy600); + yymsp[-11].minor.yy600 = addPartitionByClause(pCxt, yymsp[-11].minor.yy600, yymsp[-6].minor.yy601); + yymsp[-11].minor.yy600 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy600, yymsp[-2].minor.yy600); + yymsp[-11].minor.yy600 = addGroupByClause(pCxt, yymsp[-11].minor.yy600, yymsp[-1].minor.yy601); + yymsp[-11].minor.yy600 = addHavingClause(pCxt, yymsp[-11].minor.yy600, yymsp[0].minor.yy600); + yymsp[-11].minor.yy600 = addRangeClause(pCxt, yymsp[-11].minor.yy600, yymsp[-5].minor.yy600); + yymsp[-11].minor.yy600 = addEveryClause(pCxt, yymsp[-11].minor.yy600, yymsp[-4].minor.yy600); + yymsp[-11].minor.yy600 = addFillClause(pCxt, yymsp[-11].minor.yy600, yymsp[-3].minor.yy600); } break; - case 468: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy335 = false; } + case 469: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy841 = false; } break; - case 471: /* select_item ::= NK_STAR */ -{ yylhsminor.yy74 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy74 = yylhsminor.yy74; + case 472: /* select_item ::= NK_STAR */ +{ yylhsminor.yy600 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 473: /* select_item ::= common_expression column_alias */ - case 483: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==483); -{ yylhsminor.yy74 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy74), &yymsp[0].minor.yy317); } - yymsp[-1].minor.yy74 = yylhsminor.yy74; + case 474: /* select_item ::= common_expression column_alias */ + case 484: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==484); +{ yylhsminor.yy600 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600), &yymsp[0].minor.yy77); } + yymsp[-1].minor.yy600 = yylhsminor.yy600; break; - case 474: /* select_item ::= common_expression AS column_alias */ - case 484: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==484); -{ yylhsminor.yy74 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), &yymsp[0].minor.yy317); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 475: /* select_item ::= common_expression AS column_alias */ + case 485: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==485); +{ yylhsminor.yy600 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), &yymsp[0].minor.yy77); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 479: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 501: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==501); - case 520: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==520); -{ yymsp[-2].minor.yy874 = yymsp[0].minor.yy874; } + case 480: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 504: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==504); + case 523: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==523); +{ yymsp[-2].minor.yy601 = yymsp[0].minor.yy601; } break; - case 486: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy74 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), releaseRawExprNode(pCxt, yymsp[-1].minor.yy74)); } + case 487: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy600 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } break; - case 487: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy74 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy74)); } + case 488: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy600 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } break; - case 488: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy74 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), NULL, yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } + case 489: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy600 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), NULL, yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } break; - case 489: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy74 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy74), releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), yymsp[-1].minor.yy74, yymsp[0].minor.yy74); } + case 490: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy600 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy600), releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), yymsp[-1].minor.yy600, yymsp[0].minor.yy600); } break; - case 493: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy74 = createFillNode(pCxt, yymsp[-1].minor.yy828, NULL); } + case 494: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy600 = createFillNode(pCxt, yymsp[-1].minor.yy798, NULL); } break; - case 494: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy74 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy874)); } + case 495: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy600 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy601)); } break; - case 495: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy828 = FILL_MODE_NONE; } + case 496: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy600 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy601)); } break; - case 496: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy828 = FILL_MODE_PREV; } + case 497: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy798 = FILL_MODE_NONE; } break; - case 497: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy828 = FILL_MODE_NULL; } + case 498: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy798 = FILL_MODE_PREV; } break; - case 498: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy828 = FILL_MODE_LINEAR; } + case 499: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy798 = FILL_MODE_NULL; } break; - case 499: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy828 = FILL_MODE_NEXT; } + case 500: /* fill_mode ::= NULL_F */ +{ yymsp[0].minor.yy798 = FILL_MODE_NULL_F; } break; - case 502: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy874 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[0].minor.yy874 = yylhsminor.yy874; + case 501: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy798 = FILL_MODE_LINEAR; } break; - case 503: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy874 = addNodeToList(pCxt, yymsp[-2].minor.yy874, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy74))); } - yymsp[-2].minor.yy874 = yylhsminor.yy874; + case 502: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy798 = FILL_MODE_NEXT; } break; - case 507: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy74 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy74), releaseRawExprNode(pCxt, yymsp[-1].minor.yy74)); } + case 505: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy601 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } + yymsp[0].minor.yy601 = yylhsminor.yy601; break; - case 510: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 506: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy601 = addNodeToList(pCxt, yymsp[-2].minor.yy601, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy600))); } + yymsp[-2].minor.yy601 = yylhsminor.yy601; + break; + case 510: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy600 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy600), releaseRawExprNode(pCxt, yymsp[-1].minor.yy600)); } + break; + case 513: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy74 = addOrderByClause(pCxt, yymsp[-3].minor.yy74, yymsp[-2].minor.yy874); - yylhsminor.yy74 = addSlimitClause(pCxt, yylhsminor.yy74, yymsp[-1].minor.yy74); - yylhsminor.yy74 = addLimitClause(pCxt, yylhsminor.yy74, yymsp[0].minor.yy74); + yylhsminor.yy600 = addOrderByClause(pCxt, yymsp[-3].minor.yy600, yymsp[-2].minor.yy601); + yylhsminor.yy600 = addSlimitClause(pCxt, yylhsminor.yy600, yymsp[-1].minor.yy600); + yylhsminor.yy600 = addLimitClause(pCxt, yylhsminor.yy600, yymsp[0].minor.yy600); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 513: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy74 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy74, yymsp[0].minor.yy74); } - yymsp[-3].minor.yy74 = yylhsminor.yy74; + case 516: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy600 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy600, yymsp[0].minor.yy600); } + yymsp[-3].minor.yy600 = yylhsminor.yy600; break; - case 514: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy74 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy74, yymsp[0].minor.yy74); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 517: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy600 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy600, yymsp[0].minor.yy600); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 522: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 526: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==526); -{ yymsp[-1].minor.yy74 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 525: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 529: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==529); +{ yymsp[-1].minor.yy600 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 523: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 527: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==527); -{ yymsp[-3].minor.yy74 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 526: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 530: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==530); +{ yymsp[-3].minor.yy600 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 524: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 528: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==528); -{ yymsp[-3].minor.yy74 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 527: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 531: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==531); +{ yymsp[-3].minor.yy600 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 529: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy74 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy74); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 532: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy600 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy600); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 534: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy74 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy74), yymsp[-1].minor.yy326, yymsp[0].minor.yy109); } - yymsp[-2].minor.yy74 = yylhsminor.yy74; + case 537: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy600 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy600), yymsp[-1].minor.yy32, yymsp[0].minor.yy385); } + yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 535: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy326 = ORDER_ASC; } + case 538: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy32 = ORDER_ASC; } break; - case 536: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy326 = ORDER_ASC; } + case 539: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy32 = ORDER_ASC; } break; - case 537: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy326 = ORDER_DESC; } + case 540: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy32 = ORDER_DESC; } break; - case 538: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy109 = NULL_ORDER_DEFAULT; } + case 541: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy385 = NULL_ORDER_DEFAULT; } break; - case 539: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy109 = NULL_ORDER_FIRST; } + case 542: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy385 = NULL_ORDER_FIRST; } break; - case 540: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy109 = NULL_ORDER_LAST; } + case 543: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy385 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index 17d02c1cce..eb264687f1 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -643,7 +643,8 @@ TEST_F(ParserInitialCTest, createStream) { auto setCreateStreamReq = [&](const char* pStream, const char* pSrcDb, const char* pSql, const char* pDstStb, int8_t igExists = 0, int8_t triggerType = STREAM_TRIGGER_AT_ONCE, int64_t maxDelay = 0, int64_t watermark = 0, int8_t igExpired = STREAM_DEFAULT_IGNORE_EXPIRED, - int8_t fillHistory = STREAM_DEFAULT_FILL_HISTORY) { + int8_t fillHistory = STREAM_DEFAULT_FILL_HISTORY, + int8_t igUpdate = STREAM_DEFAULT_IGNORE_UPDATE) { snprintf(expect.name, sizeof(expect.name), "0.%s", pStream); snprintf(expect.sourceDB, sizeof(expect.sourceDB), "0.%s", pSrcDb); snprintf(expect.targetStbFullName, sizeof(expect.targetStbFullName), "0.test.%s", pDstStb); @@ -654,6 +655,7 @@ TEST_F(ParserInitialCTest, createStream) { expect.watermark = watermark; expect.fillHistory = fillHistory; expect.igExpired = igExpired; + expect.igUpdate = igUpdate; }; auto addTag = [&](const char* pFieldName, uint8_t type, int32_t bytes = 0) { @@ -699,6 +701,7 @@ TEST_F(ParserInitialCTest, createStream) { ASSERT_EQ(pField->flags, pExpectField->flags); } } + ASSERT_EQ(req.igUpdate, expect.igUpdate); tFreeSCMCreateStreamReq(&req); }); @@ -708,12 +711,11 @@ TEST_F(ParserInitialCTest, createStream) { setCreateStreamReq( "s1", "test", - "create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired 0 fill_history 1 into st1 " - "as select count(*) from t1 interval(10s)", - "st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND, 0, 1); - run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED 0 FILL_HISTORY 1 INTO st1 AS " - "SELECT COUNT(*) " - "FROM t1 INTERVAL(10S)"); + "create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired 0 fill_history 1 ignore " + "update 1 into st1 as select count(*) from t1 interval(10s)", + "st1", 1, STREAM_TRIGGER_MAX_DELAY, 20 * MILLISECOND_PER_SECOND, 10 * MILLISECOND_PER_SECOND, 0, 1, 1); + run("CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED 0 FILL_HISTORY 1 IGNORE " + "UPDATE 1 INTO st1 AS SELECT COUNT(*) FROM t1 INTERVAL(10S)"); clearCreateStreamReq(); setCreateStreamReq("s1", "test", diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index bd1823a770..bfde50761a 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -343,6 +343,13 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect pScan->node.groupAction = GROUP_ACTION_NONE; pScan->node.resultDataOrder = DATA_ORDER_LEVEL_IN_BLOCK; + if (pCxt->pPlanCxt->streamQuery) { + pScan->triggerType = pCxt->pPlanCxt->triggerType; + pScan->watermark = pCxt->pPlanCxt->watermark; + pScan->deleteMark = pCxt->pPlanCxt->deleteMark; + pScan->igExpired = pCxt->pPlanCxt->igExpired; + pScan->igCheckUpdate = pCxt->pPlanCxt->igCheckUpdate; + } // set columns to scan if (TSDB_CODE_SUCCESS == code) { @@ -705,6 +712,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm pWindow->watermark = pCxt->pPlanCxt->watermark; pWindow->deleteMark = pCxt->pPlanCxt->deleteMark; pWindow->igExpired = pCxt->pPlanCxt->igExpired; + pWindow->igCheckUpdate = pCxt->pPlanCxt->igCheckUpdate; } pWindow->inputTsOrder = ORDER_ASC; pWindow->outputTsOrder = ORDER_ASC; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index e901297f4d..90a7261074 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -328,10 +328,6 @@ static void scanPathOptSetScanWin(SScanLogicNode* pScan) { pScan->sliding = ((SWindowLogicNode*)pParent)->sliding; pScan->intervalUnit = ((SWindowLogicNode*)pParent)->intervalUnit; pScan->slidingUnit = ((SWindowLogicNode*)pParent)->slidingUnit; - pScan->triggerType = ((SWindowLogicNode*)pParent)->triggerType; - pScan->watermark = ((SWindowLogicNode*)pParent)->watermark; - pScan->deleteMark = ((SWindowLogicNode*)pParent)->deleteMark; - pScan->igExpired = ((SWindowLogicNode*)pParent)->igExpired; } } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index df10fe8ee3..f016ca165b 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -582,6 +582,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp pTableScan->triggerType = pScanLogicNode->triggerType; pTableScan->watermark = pScanLogicNode->watermark; pTableScan->igExpired = pScanLogicNode->igExpired; + pTableScan->igCheckUpdate = pScanLogicNode->igCheckUpdate; pTableScan->assignBlockUid = pCxt->pPlanCxt->rSmaQuery ? true : false; int32_t code = createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode); diff --git a/source/libs/qworker/inc/qwInt.h b/source/libs/qworker/inc/qwInt.h index aa1ce80903..bde05d4116 100644 --- a/source/libs/qworker/inc/qwInt.h +++ b/source/libs/qworker/inc/qwInt.h @@ -194,6 +194,8 @@ typedef struct SQWorker { SMsgCb msgCb; SQWStat stat; int32_t *destroyed; + + int8_t nodeStopped; } SQWorker; typedef struct SQWorkerMgmt { diff --git a/source/libs/qworker/src/qwUtil.c b/source/libs/qworker/src/qwUtil.c index fdd2775daa..7ee7c50c96 100644 --- a/source/libs/qworker/src/qwUtil.c +++ b/source/libs/qworker/src/qwUtil.c @@ -213,9 +213,15 @@ int32_t qwAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) { QW_SET_QTID(id, qId, tId, eId); *ctx = taosHashAcquire(mgmt->ctxHash, id, sizeof(id)); + int8_t nodeStopped = atomic_load_8(&mgmt->nodeStopped); if (NULL == (*ctx)) { - QW_TASK_DLOG_E("task ctx not exist, may be dropped"); - QW_ERR_RET(TSDB_CODE_QRY_TASK_CTX_NOT_EXIST); + if (!nodeStopped) { + QW_TASK_DLOG_E("task ctx not exist, may be dropped"); + QW_ERR_RET(TSDB_CODE_QRY_TASK_CTX_NOT_EXIST); + } else { + QW_TASK_DLOG_E("node stopped"); + QW_ERR_RET(TSDB_CODE_VND_STOPPED); + } } return TSDB_CODE_SUCCESS; @@ -226,9 +232,16 @@ int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx) { QW_SET_QTID(id, qId, tId, eId); *ctx = taosHashGet(mgmt->ctxHash, id, sizeof(id)); + int8_t nodeStopped = atomic_load_8(&mgmt->nodeStopped); + if (NULL == (*ctx)) { - QW_TASK_DLOG_E("task ctx not exist, may be dropped"); - QW_ERR_RET(TSDB_CODE_QRY_TASK_CTX_NOT_EXIST); + if (!nodeStopped) { + QW_TASK_DLOG_E("task ctx not exist, may be dropped"); + QW_ERR_RET(TSDB_CODE_QRY_TASK_CTX_NOT_EXIST); + } else { + QW_TASK_DLOG_E("node stopped"); + QW_ERR_RET(TSDB_CODE_VND_STOPPED); + } } return TSDB_CODE_SUCCESS; diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index e38361d87f..6486b4b684 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -517,7 +517,7 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp } if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { - if (QW_PHASE_POST_FETCH != phase || qwTaskNotInExec(ctx)) { + if (QW_PHASE_POST_FETCH != phase || ((!QW_QUERY_RUNNING(ctx)) && qwTaskNotInExec(ctx))) { QW_ERR_JRET(qwDropTask(QW_FPARAMS())); QW_ERR_JRET(ctx->rspCode); } @@ -1188,6 +1188,9 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) { uint64_t qId, tId, sId; int32_t eId; int64_t rId = 0; + + atomic_store_8(&mgmt->nodeStopped, 1); + void *pIter = taosHashIterate(mgmt->ctxHash, NULL); while (pIter) { SQWTaskCtx *ctx = (SQWTaskCtx *)pIter; diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 6f77769dec..2f991288ff 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -207,6 +207,7 @@ void streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId) { if (ppTask) { SStreamTask* pTask = *ppTask; taosHashRemove(pMeta->pTasks, &taskId, sizeof(int32_t)); + tdbTbDelete(pMeta->pTaskDb, &taskId, sizeof(int32_t), pMeta->txn); /*if (pTask->timer) { * taosTmrStop(pTask->timer);*/ /*pTask->timer = NULL;*/ diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index 6670bf463e..25f5a3091c 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -128,7 +128,7 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int memset(statePath, 0, 1024); tstrncpy(statePath, path, 1024); } - if (tdbOpen(statePath, szPage, pages, &pState->pTdbState->db, 0) < 0) { + if (tdbOpen(statePath, szPage, pages, &pState->pTdbState->db, 1) < 0) { goto _err; } @@ -192,7 +192,7 @@ void streamStateClose(SStreamState* pState) { } int32_t streamStateBegin(SStreamState* pState) { - if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, + if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, NULL, NULL, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { tdbAbort(pState->pTdbState->db, pState->pTdbState->txn); return -1; @@ -208,7 +208,7 @@ int32_t streamStateCommit(SStreamState* pState) { return -1; } - if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, + if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, NULL, NULL, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { return -1; } @@ -220,7 +220,7 @@ int32_t streamStateAbort(SStreamState* pState) { return -1; } - if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, + if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, NULL, NULL, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { return -1; } diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index 5277e7818f..063b4f51f5 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -24,7 +24,7 @@ extern "C" { #define SYNC_SNAPSHOT_SEQ_INVALID -2 #define SYNC_SNAPSHOT_SEQ_FORCE_CLOSE -3 -#define SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT -1 +#define SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT -1 #define SYNC_SNAPSHOT_SEQ_BEGIN 0 #define SYNC_SNAPSHOT_SEQ_END 0x7FFFFFFF diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 948d2f53e7..835e5d248e 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -89,45 +89,6 @@ // /\ UNCHANGED <> // -int32_t syncNodeFollowerCommit(SSyncNode* ths, SyncIndex newCommitIndex) { - ASSERT(false && "deprecated"); - if (ths->state != TAOS_SYNC_STATE_FOLLOWER) { - sNTrace(ths, "can not do follower commit"); - return -1; - } - - // maybe update commit index, leader notice me - if (newCommitIndex > ths->commitIndex) { - // has commit entry in local - if (newCommitIndex <= ths->pLogStore->syncLogLastIndex(ths->pLogStore)) { - // advance commit index to sanpshot first - SSnapshot snapshot; - ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot); - if (snapshot.lastApplyIndex >= 0 && snapshot.lastApplyIndex > ths->commitIndex) { - SyncIndex commitBegin = ths->commitIndex; - SyncIndex commitEnd = snapshot.lastApplyIndex; - ths->commitIndex = snapshot.lastApplyIndex; - sNTrace(ths, "commit by snapshot from index:%" PRId64 " to index:%" PRId64, commitBegin, commitEnd); - } - - SyncIndex beginIndex = ths->commitIndex + 1; - SyncIndex endIndex = newCommitIndex; - - // update commit index - ths->commitIndex = newCommitIndex; - - // call back Wal - int32_t code = ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->commitIndex); - ASSERT(code == 0); - - code = syncNodeDoCommit(ths, beginIndex, endIndex, ths->state); - ASSERT(code == 0); - } - } - - return 0; -} - SSyncRaftEntry* syncBuildRaftEntryFromAppendEntries(const SyncAppendEntries* pMsg) { SSyncRaftEntry* pEntry = taosMemoryMalloc(pMsg->dataLen); if (pEntry == NULL) { @@ -232,256 +193,3 @@ _IGNORE: rpcFreeCont(rpcRsp.pCont); return 0; } - -int32_t syncNodeOnAppendEntriesOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) { - SyncAppendEntries* pMsg = pRpcMsg->pCont; - SRpcMsg rpcRsp = {0}; - - // if already drop replica, do not process - if (!syncNodeInRaftGroup(ths, &(pMsg->srcId))) { - syncLogRecvAppendEntries(ths, pMsg, "not in my config"); - goto _IGNORE; - } - - // prepare response msg - int32_t code = syncBuildAppendEntriesReply(&rpcRsp, ths->vgId); - if (code != 0) { - syncLogRecvAppendEntries(ths, pMsg, "build rsp error"); - goto _IGNORE; - } - - SyncAppendEntriesReply* pReply = rpcRsp.pCont; - pReply->srcId = ths->myRaftId; - pReply->destId = pMsg->srcId; - pReply->term = ths->raftStore.currentTerm; - pReply->success = false; - // pReply->matchIndex = ths->pLogStore->syncLogLastIndex(ths->pLogStore); - pReply->matchIndex = SYNC_INDEX_INVALID; - pReply->lastSendIndex = pMsg->prevLogIndex + 1; - pReply->startTime = ths->startTime; - - if (pMsg->term < ths->raftStore.currentTerm) { - syncLogRecvAppendEntries(ths, pMsg, "reject, small term"); - goto _SEND_RESPONSE; - } - - if (pMsg->term > ths->raftStore.currentTerm) { - pReply->term = pMsg->term; - } - - syncNodeStepDown(ths, pMsg->term); - syncNodeResetElectTimer(ths); - - SyncIndex startIndex = ths->pLogStore->syncLogBeginIndex(ths->pLogStore); - SyncIndex lastIndex = ths->pLogStore->syncLogLastIndex(ths->pLogStore); - - if (pMsg->prevLogIndex > lastIndex) { - syncLogRecvAppendEntries(ths, pMsg, "reject, index not match"); - goto _SEND_RESPONSE; - } - - if (pMsg->prevLogIndex >= startIndex) { - SyncTerm myPreLogTerm = syncNodeGetPreTerm(ths, pMsg->prevLogIndex + 1); - // ASSERT(myPreLogTerm != SYNC_TERM_INVALID); - if (myPreLogTerm == SYNC_TERM_INVALID) { - syncLogRecvAppendEntries(ths, pMsg, "reject, pre-term invalid"); - goto _SEND_RESPONSE; - } - - if (myPreLogTerm != pMsg->prevLogTerm) { - syncLogRecvAppendEntries(ths, pMsg, "reject, pre-term not match"); - goto _SEND_RESPONSE; - } - } - - // accept - pReply->success = true; - bool hasAppendEntries = pMsg->dataLen > 0; - if (hasAppendEntries) { - SSyncRaftEntry* pAppendEntry = syncEntryBuildFromAppendEntries(pMsg); - ASSERT(pAppendEntry != NULL); - - SyncIndex appendIndex = pMsg->prevLogIndex + 1; - - LRUHandle* hLocal = NULL; - LRUHandle* hAppend = NULL; - - int32_t code = 0; - SSyncRaftEntry* pLocalEntry = NULL; - SLRUCache* pCache = ths->pLogStore->pCache; - hLocal = taosLRUCacheLookup(pCache, &appendIndex, sizeof(appendIndex)); - if (hLocal) { - pLocalEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, hLocal); - code = 0; - - ths->pLogStore->cacheHit++; - sNTrace(ths, "hit cache index:%" PRId64 ", bytes:%u, %p", appendIndex, pLocalEntry->bytes, pLocalEntry); - - } else { - ths->pLogStore->cacheMiss++; - sNTrace(ths, "miss cache index:%" PRId64, appendIndex); - - code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, appendIndex, &pLocalEntry); - } - - if (code == 0) { - // get local entry success - - if (pLocalEntry->term == pAppendEntry->term) { - // do nothing - sNTrace(ths, "log match, do nothing, index:%" PRId64, appendIndex); - - } else { - // truncate - code = ths->pLogStore->syncLogTruncate(ths->pLogStore, appendIndex); - if (code != 0) { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "ignore, truncate error, append-index:%" PRId64, appendIndex); - syncLogRecvAppendEntries(ths, pMsg, logBuf); - - if (hLocal) { - taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false); - } else { - syncEntryDestroy(pLocalEntry); - } - - if (hAppend) { - taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false); - } else { - syncEntryDestroy(pAppendEntry); - } - - goto _IGNORE; - } - - ASSERT(pAppendEntry->index == appendIndex); - - // append - code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry, false); - if (code != 0) { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "ignore, append error, append-index:%" PRId64, appendIndex); - syncLogRecvAppendEntries(ths, pMsg, logBuf); - - if (hLocal) { - taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false); - } else { - syncEntryDestroy(pLocalEntry); - } - - if (hAppend) { - taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false); - } else { - syncEntryDestroy(pAppendEntry); - } - - goto _IGNORE; - } - - syncCacheEntry(ths->pLogStore, pAppendEntry, &hAppend); - } - - } else { - if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) { - // log not exist - - // truncate - code = ths->pLogStore->syncLogTruncate(ths->pLogStore, appendIndex); - if (code != 0) { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "ignore, log not exist, truncate error, append-index:%" PRId64, appendIndex); - syncLogRecvAppendEntries(ths, pMsg, logBuf); - - syncEntryDestroy(pLocalEntry); - syncEntryDestroy(pAppendEntry); - goto _IGNORE; - } - - // append - code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry, false); - if (code != 0) { - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "ignore, log not exist, append error, append-index:%" PRId64, appendIndex); - syncLogRecvAppendEntries(ths, pMsg, logBuf); - - if (hLocal) { - taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false); - } else { - syncEntryDestroy(pLocalEntry); - } - - if (hAppend) { - taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false); - } else { - syncEntryDestroy(pAppendEntry); - } - - goto _IGNORE; - } - - syncCacheEntry(ths->pLogStore, pAppendEntry, &hAppend); - - } else { - // get local entry success - char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "ignore, get local entry error, append-index:%" PRId64 " err:%d", appendIndex, - terrno); - syncLogRecvAppendEntries(ths, pMsg, logBuf); - - if (hLocal) { - taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false); - } else { - syncEntryDestroy(pLocalEntry); - } - - if (hAppend) { - taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false); - } else { - syncEntryDestroy(pAppendEntry); - } - - goto _IGNORE; - } - } - - // update match index - pReply->matchIndex = pAppendEntry->index; - - if (hLocal) { - taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false); - } else { - syncEntryDestroy(pLocalEntry); - } - - if (hAppend) { - taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false); - } else { - syncEntryDestroy(pAppendEntry); - } - - } else { - // no append entries, do nothing - // maybe has extra entries, no harm - - // update match index - pReply->matchIndex = pMsg->prevLogIndex; - } - - // maybe update commit index, leader notice me - syncNodeFollowerCommit(ths, pMsg->commitIndex); - - syncLogRecvAppendEntries(ths, pMsg, "accept"); - goto _SEND_RESPONSE; - -_IGNORE: - rpcFreeCont(rpcRsp.pCont); - return 0; - -_SEND_RESPONSE: - // msg event log - syncLogSendAppendEntriesReply(ths, pReply, ""); - - // send response - syncNodeSendMsgById(&pReply->destId, ths, &rpcRsp); - return 0; -} diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 8157a5a14f..44a29da3ea 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -89,63 +89,3 @@ int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) { } return 0; } - -int32_t syncNodeOnAppendEntriesReplyOld(SSyncNode* ths, SyncAppendEntriesReply* pMsg) { - int32_t ret = 0; - - // if already drop replica, do not process - if (!syncNodeInRaftGroup(ths, &(pMsg->srcId))) { - syncLogRecvAppendEntriesReply(ths, pMsg, "not in my config"); - return 0; - } - - // drop stale response - if (pMsg->term < ths->raftStore.currentTerm) { - syncLogRecvAppendEntriesReply(ths, pMsg, "drop stale response"); - return 0; - } - - if (ths->state == TAOS_SYNC_STATE_LEADER) { - if (pMsg->term > ths->raftStore.currentTerm) { - syncLogRecvAppendEntriesReply(ths, pMsg, "error term"); - syncNodeStepDown(ths, pMsg->term); - return -1; - } - - ASSERT(pMsg->term == ths->raftStore.currentTerm); - - if (pMsg->success) { - SyncIndex oldMatchIndex = syncIndexMgrGetIndex(ths->pMatchIndex, &(pMsg->srcId)); - if (pMsg->matchIndex > oldMatchIndex) { - syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), pMsg->matchIndex); - syncMaybeAdvanceCommitIndex(ths); - - // maybe update minMatchIndex - ths->minMatchIndex = syncMinMatchIndex(ths); - } - syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), pMsg->matchIndex + 1); - - } else { - SyncIndex nextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId)); - if (nextIndex > SYNC_INDEX_BEGIN) { - --nextIndex; - } - syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), nextIndex); - } - - // send next append entries - SPeerState* pState = syncNodeGetPeerState(ths, &(pMsg->srcId)); - ASSERT(pState != NULL); - - if (pMsg->lastSendIndex == pState->lastSendIndex) { - int64_t timeNow = taosGetTimestampMs(); - int64_t elapsed = timeNow - pState->lastSendTime; - sNTrace(ths, "sync-append-entries rtt elapsed:%" PRId64 ", index:%" PRId64, elapsed, pState->lastSendIndex); - - syncNodeReplicateOne(ths, &(pMsg->srcId), true); - } - } - - syncLogRecvAppendEntriesReply(ths, pMsg, "process"); - return 0; -} diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 286cf4daf5..6d256a735d 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -43,148 +43,6 @@ // IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex] // /\ UNCHANGED <> // -void syncOneReplicaAdvance(SSyncNode* pSyncNode) { - ASSERT(false && "deprecated"); - if (pSyncNode == NULL) { - sError("pSyncNode is NULL"); - return; - } - - if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { - sNError(pSyncNode, "not leader, can not advance commit index"); - return; - } - - if (pSyncNode->replicaNum != 1) { - sNError(pSyncNode, "not one replica, can not advance commit index"); - return; - } - - // advance commit index to snapshot first - SSnapshot snapshot; - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); - if (snapshot.lastApplyIndex > 0 && snapshot.lastApplyIndex > pSyncNode->commitIndex) { - SyncIndex commitBegin = pSyncNode->commitIndex; - SyncIndex commitEnd = snapshot.lastApplyIndex; - pSyncNode->commitIndex = snapshot.lastApplyIndex; - sNTrace(pSyncNode, "commit by snapshot from index:%" PRId64 " to index:%" PRId64, commitBegin, commitEnd); - } - - // advance commit index as large as possible - SyncIndex lastIndex = syncNodeGetLastIndex(pSyncNode); - if (lastIndex > pSyncNode->commitIndex) { - sNTrace(pSyncNode, "commit by wal from index:%" PRId64 " to index:%" PRId64, pSyncNode->commitIndex + 1, lastIndex); - pSyncNode->commitIndex = lastIndex; - } - - // call back Wal - SyncIndex walCommitVer = logStoreWalCommitVer(pSyncNode->pLogStore); - if (pSyncNode->commitIndex > walCommitVer) { - pSyncNode->pLogStore->syncLogUpdateCommitIndex(pSyncNode->pLogStore, pSyncNode->commitIndex); - } -} - -void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { - ASSERTS(false, "deprecated"); - if (pSyncNode == NULL) { - sError("pSyncNode is NULL"); - return; - } - - if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { - sNError(pSyncNode, "not leader, can not advance commit index"); - return; - } - - // advance commit index to sanpshot first - SSnapshot snapshot; - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); - if (snapshot.lastApplyIndex > 0 && snapshot.lastApplyIndex > pSyncNode->commitIndex) { - SyncIndex commitBegin = pSyncNode->commitIndex; - SyncIndex commitEnd = snapshot.lastApplyIndex; - pSyncNode->commitIndex = snapshot.lastApplyIndex; - sNTrace(pSyncNode, "commit by snapshot from index:%" PRId64 " to index:%" PRId64, commitBegin, commitEnd); - } - - // update commit index - SyncIndex newCommitIndex = pSyncNode->commitIndex; - for (SyncIndex index = syncNodeGetLastIndex(pSyncNode); index > pSyncNode->commitIndex; --index) { - bool agree = syncAgree(pSyncNode, index); - - if (agree) { - // term - SSyncRaftEntry* pEntry = NULL; - SLRUCache* pCache = pSyncNode->pLogStore->pCache; - LRUHandle* h = taosLRUCacheLookup(pCache, &index, sizeof(index)); - if (h) { - pEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, h); - - pSyncNode->pLogStore->cacheHit++; - sNTrace(pSyncNode, "hit cache index:%" PRId64 ", bytes:%u, %p", index, pEntry->bytes, pEntry); - - } else { - pSyncNode->pLogStore->cacheMiss++; - sNTrace(pSyncNode, "miss cache index:%" PRId64, index); - - int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, index, &pEntry); - if (code != 0) { - sNError(pSyncNode, "advance commit index error, read wal index:%" PRId64, index); - return; - } - } - // cannot commit, even if quorum agree. need check term! - if (pEntry->term <= pSyncNode->raftStore.currentTerm) { - // update commit index - newCommitIndex = index; - - if (h) { - taosLRUCacheRelease(pCache, h, false); - } else { - syncEntryDestroy(pEntry); - } - - break; - } else { - sNTrace(pSyncNode, "can not commit due to term not equal, index:%" PRId64 ", term:%" PRIu64, pEntry->index, - pEntry->term); - } - - if (h) { - taosLRUCacheRelease(pCache, h, false); - } else { - syncEntryDestroy(pEntry); - } - } - } - - // advance commit index as large as possible - SyncIndex walCommitVer = logStoreWalCommitVer(pSyncNode->pLogStore); - if (walCommitVer > newCommitIndex) { - newCommitIndex = walCommitVer; - } - - // maybe execute fsm - if (newCommitIndex > pSyncNode->commitIndex) { - SyncIndex beginIndex = pSyncNode->commitIndex + 1; - SyncIndex endIndex = newCommitIndex; - - // update commit index - pSyncNode->commitIndex = newCommitIndex; - - // call back Wal - pSyncNode->pLogStore->syncLogUpdateCommitIndex(pSyncNode->pLogStore, pSyncNode->commitIndex); - - // execute fsm - if (pSyncNode != NULL && pSyncNode->pFsm != NULL) { - int32_t code = syncNodeDoCommit(pSyncNode, beginIndex, endIndex, pSyncNode->state); - if (code != 0) { - sNError(pSyncNode, "advance commit index error, do commit begin:%" PRId64 ", end:%" PRId64, beginIndex, - endIndex); - return; - } - } - } -} bool syncAgreeIndex(SSyncNode* pSyncNode, SRaftId* pRaftId, SyncIndex index) { // I am leader, I agree @@ -210,83 +68,7 @@ static inline int64_t syncNodeAbs64(int64_t a, int64_t b) { return c; } -int32_t syncNodeDynamicQuorum(const SSyncNode* pSyncNode) { - return pSyncNode->quorum; - -#if 0 - int32_t quorum = 1; // self - - int64_t timeNow = taosGetTimestampMs(); - for (int i = 0; i < pSyncNode->peersNum; ++i) { - int64_t peerStartTime = syncIndexMgrGetStartTime(pSyncNode->pNextIndex, &(pSyncNode->peersId)[i]); - int64_t peerRecvTime = syncIndexMgrGetRecvTime(pSyncNode->pNextIndex, &(pSyncNode->peersId)[i]); - SyncIndex peerMatchIndex = syncIndexMgrGetIndex(pSyncNode->pMatchIndex, &(pSyncNode->peersId)[i]); - - int64_t recvTimeDiff = TABS(peerRecvTime - timeNow); - int64_t startTimeDiff = TABS(peerStartTime - pSyncNode->startTime); - int64_t logDiff = TABS(peerMatchIndex - syncNodeGetLastIndex(pSyncNode)); - - /* - int64_t recvTimeDiff = syncNodeAbs64(peerRecvTime, timeNow); - int64_t startTimeDiff = syncNodeAbs64(peerStartTime, pSyncNode->startTime); - int64_t logDiff = syncNodeAbs64(peerMatchIndex, syncNodeGetLastIndex(pSyncNode)); - */ - - int32_t addQuorum = 0; - - if (recvTimeDiff < SYNC_MAX_RECV_TIME_RANGE_MS) { - if (startTimeDiff < SYNC_MAX_START_TIME_RANGE_MS) { - addQuorum = 1; - } else { - if (logDiff < SYNC_ADD_QUORUM_COUNT) { - addQuorum = 1; - } else { - addQuorum = 0; - } - } - } else { - addQuorum = 0; - } - - /* - if (recvTimeDiff < SYNC_MAX_RECV_TIME_RANGE_MS) { - addQuorum = 1; - } else { - addQuorum = 0; - } - - if (startTimeDiff > SYNC_MAX_START_TIME_RANGE_MS) { - addQuorum = 0; - } - */ - - quorum += addQuorum; - } - - ASSERT(quorum <= pSyncNode->replicaNum); - - if (quorum < pSyncNode->quorum) { - quorum = pSyncNode->quorum; - } - - return quorum; -#endif -} - -/* -bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) { - int agreeCount = 0; - for (int i = 0; i < pSyncNode->replicaNum; ++i) { - if (syncAgreeIndex(pSyncNode, &(pSyncNode->replicasId[i]), index)) { - ++agreeCount; - } - if (agreeCount >= syncNodeDynamicQuorum(pSyncNode)) { - return true; - } - } - return false; -} -*/ +int32_t syncNodeDynamicQuorum(const SSyncNode* pSyncNode) { return pSyncNode->quorum; } bool syncNodeAgreedUpon(SSyncNode* pNode, SyncIndex index) { int count = 0; @@ -328,7 +110,7 @@ int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely) { if (indexLikely > ths->commitIndex && syncNodeAgreedUpon(ths, indexLikely)) { SyncIndex commitIndex = indexLikely; syncNodeUpdateCommitIndex(ths, commitIndex); - sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index: %" PRId64 "", ths->vgId, ths->state, + sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index:%" PRId64 "", ths->vgId, ths->state, ths->raftStore.currentTerm, commitIndex); } return ths->commitIndex; diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index cd3ffc33e3..682ace83ec 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -43,7 +43,10 @@ static int32_t syncNodeRequestVotePeers(SSyncNode* pNode) { for (int i = 0; i < pNode->peersNum; ++i) { SRpcMsg rpcMsg = {0}; ret = syncBuildRequestVote(&rpcMsg, pNode->vgId); - ASSERT(ret == 0); + if (ret < 0) { + sError("vgId:%d, failed to build request-vote msg since %s", pNode->vgId, terrstr()); + continue; + } SyncRequestVote* pMsg = rpcMsg.pCont; pMsg->srcId = pNode->myRaftId; @@ -51,13 +54,18 @@ static int32_t syncNodeRequestVotePeers(SSyncNode* pNode) { pMsg->term = pNode->raftStore.currentTerm; ret = syncNodeGetLastIndexTerm(pNode, &pMsg->lastLogIndex, &pMsg->lastLogTerm); - ASSERT(ret == 0); + if (ret < 0) { + sError("vgId:%d, failed to get index and term of last log since %s", pNode->vgId, terrstr()); + continue; + } ret = syncNodeSendMsgById(&pNode->peersId[i], pNode, &rpcMsg); - ASSERT(ret == 0); + if (ret < 0) { + sError("vgId:%d, failed to send msg to peerId:%" PRId64, pNode->vgId, pNode->peersId[i].addr); + continue; + } } - - return ret; + return 0; } int32_t syncNodeElect(SSyncNode* pSyncNode) { diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index eeda612bcd..803df6b662 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -85,7 +85,7 @@ int64_t syncOpen(SSyncInfo* pSyncInfo) { int32_t syncStart(int64_t rid) { SSyncNode* pSyncNode = syncNodeAcquire(rid); if (pSyncNode == NULL) { - sError("failed to acquire rid: %" PRId64 " of tsNodeReftId for pSyncNode", rid); + sError("failed to acquire rid:%" PRId64 " of tsNodeReftId for pSyncNode", rid); return -1; } @@ -292,8 +292,6 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) { goto _DEL_WAL; } else { - lastApplyIndex -= SYNC_VNODE_LOG_RETENTION; - SyncIndex beginIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); SyncIndex endIndex = pSyncNode->pLogStore->syncLogEndIndex(pSyncNode->pLogStore); bool isEmpty = pSyncNode->pLogStore->syncLogIsEmpty(pSyncNode->pLogStore); @@ -308,6 +306,8 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) { if (pSyncNode->replicaNum > 1) { // multi replicas + lastApplyIndex = TMAX(lastApplyIndex - SYNC_VNODE_LOG_RETENTION, beginIndex - 1); + if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { pSyncNode->minMatchIndex = syncMinMatchIndex(pSyncNode); @@ -586,78 +586,6 @@ SSyncState syncGetState(int64_t rid) { return state; } -#if 0 -int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapshot) { - if (index < SYNC_INDEX_BEGIN) { - return -1; - } - - SSyncNode* pSyncNode = syncNodeAcquire(rid); - if (pSyncNode == NULL) { - return -1; - } - ASSERT(rid == pSyncNode->rid); - - SSyncRaftEntry* pEntry = NULL; - int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, index, &pEntry); - if (code != 0) { - if (pEntry != NULL) { - syncEntryDestroy(pEntry); - } - syncNodeRelease(pSyncNode); - return -1; - } - ASSERT(pEntry != NULL); - - pSnapshot->data = NULL; - pSnapshot->lastApplyIndex = index; - pSnapshot->lastApplyTerm = pEntry->term; - pSnapshot->lastConfigIndex = syncNodeGetSnapshotConfigIndex(pSyncNode, index); - - syncEntryDestroy(pEntry); - syncNodeRelease(pSyncNode); - return 0; -} - -int32_t syncGetSnapshotMeta(int64_t rid, struct SSnapshotMeta* sMeta) { - SSyncNode* pSyncNode = syncNodeAcquire(rid); - if (pSyncNode == NULL) { - return -1; - } - ASSERT(rid == pSyncNode->rid); - sMeta->lastConfigIndex = pSyncNode->raftCfg.lastConfigIndex; - - sTrace("vgId:%d, get snapshot meta, lastConfigIndex:%" PRId64, pSyncNode->vgId, pSyncNode->raftCfg.lastConfigIndex); - - syncNodeRelease(pSyncNode); - return 0; -} - -int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct SSnapshotMeta* sMeta) { - SSyncNode* pSyncNode = syncNodeAcquire(rid); - if (pSyncNode == NULL) { - return -1; - } - ASSERT(rid == pSyncNode->rid); - - ASSERT(pSyncNode->raftCfg.configIndexCount >= 1); - SyncIndex lastIndex = (pSyncNode->raftCfg.configIndexArr)[0]; - - for (int32_t i = 0; i < pSyncNode->raftCfg.configIndexCount; ++i) { - if ((pSyncNode->raftCfg.configIndexArr)[i] > lastIndex && - (pSyncNode->raftCfg.configIndexArr)[i] <= snapshotIndex) { - lastIndex = (pSyncNode->raftCfg.configIndexArr)[i]; - } - } - sMeta->lastConfigIndex = lastIndex; - sTrace("vgId:%d, get snapshot meta by index:%" PRId64 " lcindex:%" PRId64, pSyncNode->vgId, snapshotIndex, - sMeta->lastConfigIndex); - - syncNodeRelease(pSyncNode); - return 0; -} -#endif - SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapshotLastApplyIndex) { ASSERT(pSyncNode->raftCfg.configIndexCount >= 1); SyncIndex lastIndex = (pSyncNode->raftCfg.configIndexArr)[0]; @@ -828,7 +756,7 @@ int32_t syncNodeLogStoreRestoreOnNeed(SSyncNode* pNode) { SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore); if (lastVer < commitIndex || firstVer > commitIndex + 1) { if (pNode->pLogStore->syncLogRestoreFromSnapshot(pNode->pLogStore, commitIndex)) { - sError("vgId:%d, failed to restore log store from snapshot since %s. lastVer: %" PRId64 ", snapshotVer: %" PRId64, + sError("vgId:%d, failed to restore log store from snapshot since %s. lastVer:%" PRId64 ", snapshotVer:%" PRId64, pNode->vgId, terrstr(), lastVer, commitIndex); return -1; } @@ -1031,9 +959,12 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { pSyncNode->commitIndex = commitIndex; sInfo("vgId:%d, sync node commitIndex initialized as %" PRId64, pSyncNode->vgId, pSyncNode->commitIndex); + // restore log store on need if (syncNodeLogStoreRestoreOnNeed(pSyncNode) < 0) { + sError("vgId:%d, failed to restore log store since %s.", pSyncNode->vgId, terrstr()); goto _error; } + // timer ms init pSyncNode->pingBaseLine = PING_TIMER_MS; pSyncNode->electBaseLine = tsElectInterval; @@ -1096,10 +1027,16 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { pSyncNode->changing = false; // replication mgr - syncNodeLogReplMgrInit(pSyncNode); + if (syncNodeLogReplMgrInit(pSyncNode) < 0) { + sError("vgId:%d, failed to init repl mgr since %s.", pSyncNode->vgId, terrstr()); + goto _error; + } // peer state - syncNodePeerStateInit(pSyncNode); + if (syncNodePeerStateInit(pSyncNode) < 0) { + sError("vgId:%d, failed to init peer stat since %s.", pSyncNode->vgId, terrstr()); + goto _error; + } // // min match index @@ -1164,7 +1101,7 @@ int32_t syncNodeRestore(SSyncNode* pSyncNode) { SyncIndex endIndex = pSyncNode->pLogBuf->endIndex; if (lastVer != -1 && endIndex != lastVer + 1) { terrno = TSDB_CODE_WAL_LOG_INCOMPLETE; - sError("vgId:%d, failed to restore sync node since %s. expected lastLogIndex: %" PRId64 ", lastVer: %" PRId64 "", + sError("vgId:%d, failed to restore sync node since %s. expected lastLogIndex:%" PRId64 ", lastVer:%" PRId64 "", pSyncNode->vgId, terrstr(), endIndex - 1, lastVer); return -1; } @@ -1194,27 +1131,10 @@ int32_t syncNodeStart(SSyncNode* pSyncNode) { int32_t ret = 0; ret = syncNodeStartPingTimer(pSyncNode); - ASSERT(ret == 0); - return ret; -} - -void syncNodeStartOld(SSyncNode* pSyncNode) { - // start raft - if (pSyncNode->replicaNum == 1) { - raftStoreNextTerm(pSyncNode); - syncNodeBecomeLeader(pSyncNode, "one replica start"); - - // Raft 3.6.2 Committing entries from previous terms - syncNodeAppendNoop(pSyncNode); - syncMaybeAdvanceCommitIndex(pSyncNode); - - } else { - syncNodeBecomeFollower(pSyncNode, "first start"); + if (ret != 0) { + sError("vgId:%d, failed to start ping timer since %s", pSyncNode->vgId, terrstr()); } - - int32_t ret = 0; - ret = syncNodeStartPingTimer(pSyncNode); - ASSERT(ret == 0); + return ret; } int32_t syncNodeStartStandBy(SSyncNode* pSyncNode) { @@ -1225,11 +1145,16 @@ int32_t syncNodeStartStandBy(SSyncNode* pSyncNode) { // reset elect timer, long enough int32_t electMS = TIMER_MAX_MS; int32_t ret = syncNodeRestartElectTimer(pSyncNode, electMS); - ASSERT(ret == 0); + if (ret < 0) { + sError("vgId:%d, failed to restart elect timer since %s", pSyncNode->vgId, terrstr()); + return -1; + } - ret = 0; ret = syncNodeStartPingTimer(pSyncNode); - ASSERT(ret == 0); + if (ret < 0) { + sError("vgId:%d, failed to start ping timer since %s", pSyncNode->vgId, terrstr()); + return -1; + } return ret; } @@ -1818,12 +1743,6 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { pSyncNode->leaderCache = pSyncNode->myRaftId; for (int32_t i = 0; i < pSyncNode->pNextIndex->replicaNum; ++i) { - // maybe overwrite myself, no harm - // just do it! - - // pSyncNode->pNextIndex->index[i] = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) + 1; - - // maybe wal is deleted SyncIndex lastIndex; SyncTerm lastTerm; int32_t code = syncNodeGetLastIndexTerm(pSyncNode, &lastIndex, &lastTerm); @@ -1885,7 +1804,11 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { void syncNodeCandidate2Leader(SSyncNode* pSyncNode) { ASSERT(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE); - ASSERT(voteGrantedMajority(pSyncNode->pVotesGranted)); + bool granted = voteGrantedMajority(pSyncNode->pVotesGranted); + if (!granted) { + sError("vgId:%d, not granted by majority.", pSyncNode->vgId); + return; + } syncNodeBecomeLeader(pSyncNode, "candidate to leader"); sNTrace(pSyncNode, "state change syncNodeCandidate2Leader"); @@ -1897,24 +1820,10 @@ void syncNodeCandidate2Leader(SSyncNode* pSyncNode) { SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); ASSERT(lastIndex >= 0); - sInfo("vgId:%d, become leader. term: %" PRId64 ", commit index: %" PRId64 ", last index: %" PRId64 "", + sInfo("vgId:%d, become leader. term:%" PRId64 ", commit index:%" PRId64 ", last index:%" PRId64 "", pSyncNode->vgId, pSyncNode->raftStore.currentTerm, pSyncNode->commitIndex, lastIndex); } -void syncNodeCandidate2LeaderOld(SSyncNode* pSyncNode) { - ASSERT(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE); - ASSERT(voteGrantedMajority(pSyncNode->pVotesGranted)); - syncNodeBecomeLeader(pSyncNode, "candidate to leader"); - - // Raft 3.6.2 Committing entries from previous terms - syncNodeAppendNoop(pSyncNode); - syncMaybeAdvanceCommitIndex(pSyncNode); - - if (pSyncNode->replicaNum > 1) { - syncNodeReplicate(pSyncNode); - } -} - bool syncNodeIsMnode(SSyncNode* pSyncNode) { return (pSyncNode->vgId == 1); } int32_t syncNodePeerStateInit(SSyncNode* pSyncNode) { @@ -1930,7 +1839,7 @@ void syncNodeFollower2Candidate(SSyncNode* pSyncNode) { ASSERT(pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER); pSyncNode->state = TAOS_SYNC_STATE_CANDIDATE; SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); - sInfo("vgId:%d, become candidate from follower. term: %" PRId64 ", commit index: %" PRId64 ", last index: %" PRId64, + sInfo("vgId:%d, become candidate from follower. term:%" PRId64 ", commit index:%" PRId64 ", last index:%" PRId64, pSyncNode->vgId, pSyncNode->raftStore.currentTerm, pSyncNode->commitIndex, lastIndex); sNTrace(pSyncNode, "follower to candidate"); @@ -1940,7 +1849,7 @@ void syncNodeLeader2Follower(SSyncNode* pSyncNode) { ASSERT(pSyncNode->state == TAOS_SYNC_STATE_LEADER); syncNodeBecomeFollower(pSyncNode, "leader to follower"); SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); - sInfo("vgId:%d, become follower from leader. term: %" PRId64 ", commit index: %" PRId64 ", last index: %" PRId64, + sInfo("vgId:%d, become follower from leader. term:%" PRId64 ", commit index:%" PRId64 ", last index:%" PRId64, pSyncNode->vgId, pSyncNode->raftStore.currentTerm, pSyncNode->commitIndex, lastIndex); sNTrace(pSyncNode, "leader to follower"); @@ -1950,7 +1859,7 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode) { ASSERT(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE); syncNodeBecomeFollower(pSyncNode, "candidate to follower"); SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); - sInfo("vgId:%d, become follower from candidate. term: %" PRId64 ", commit index: %" PRId64 ", last index: %" PRId64, + sInfo("vgId:%d, become follower from candidate. term:%" PRId64 ", commit index:%" PRId64 ", last index:%" PRId64, pSyncNode->vgId, pSyncNode->raftStore.currentTerm, pSyncNode->commitIndex, lastIndex); sNTrace(pSyncNode, "candidate to follower"); @@ -1960,7 +1869,8 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode) { // need assert void syncNodeVoteForTerm(SSyncNode* pSyncNode, SyncTerm term, SRaftId* pRaftId) { ASSERT(term == pSyncNode->raftStore.currentTerm); - ASSERT(!raftStoreHasVoted(pSyncNode)); + bool voted = raftStoreHasVoted(pSyncNode); + ASSERT(!voted); raftStoreVote(pSyncNode, pRaftId); } @@ -2389,7 +2299,7 @@ int32_t syncNodeAppend(SSyncNode* ths, SSyncRaftEntry* pEntry) { // proceed match index, with replicating on needed SyncIndex matchIndex = syncLogBufferProceed(ths->pLogBuf, ths, NULL); - sTrace("vgId:%d, append raft entry. index: %" PRId64 ", term: %" PRId64 " pBuf: [%" PRId64 " %" PRId64 " %" PRId64 + sTrace("vgId:%d, append raft entry. index:%" PRId64 ", term:%" PRId64 " pBuf: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", ths->vgId, pEntry->index, pEntry->term, ths->pLogBuf->startIndex, ths->pLogBuf->commitIndex, ths->pLogBuf->matchIndex, ths->pLogBuf->endIndex); @@ -2562,7 +2472,7 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { sError("vgId:%d, sync enqueue step-down msg error, code:%d", ths->vgId, code); rpcFreeCont(rpcMsgLocalCmd.pCont); } else { - sTrace("vgId:%d, sync enqueue step-down msg, new-term: %" PRId64, ths->vgId, pSyncMsg->currentTerm); + sTrace("vgId:%d, sync enqueue step-down msg, new-term:%" PRId64, ths->vgId, pSyncMsg->currentTerm); } } } @@ -2628,7 +2538,7 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) { (void)syncNodeUpdateCommitIndex(ths, pMsg->commitIndex); } if (syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex) < 0) { - sError("vgId:%d, failed to commit raft log since %s. commit index: %" PRId64 "", ths->vgId, terrstr(), + sError("vgId:%d, failed to commit raft log since %s. commit index:%" PRId64 "", ths->vgId, terrstr(), ths->commitIndex); } } else { @@ -2638,24 +2548,6 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) { return 0; } -int32_t syncNodeOnLocalCmdOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) { - ASSERT(false && "deprecated"); - SyncLocalCmd* pMsg = pRpcMsg->pCont; - syncLogRecvLocalCmd(ths, pMsg, ""); - - if (pMsg->cmd == SYNC_LOCAL_CMD_STEP_DOWN) { - syncNodeStepDown(ths, pMsg->currentTerm); - - } else if (pMsg->cmd == SYNC_LOCAL_CMD_FOLLOWER_CMT) { - syncNodeFollowerCommit(ths, pMsg->commitIndex); - - } else { - sError("error local cmd"); - } - - return 0; -} - // TLA+ Spec // ClientRequest(i, v) == // /\ state[i] = Leader @@ -2700,96 +2592,6 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn } } -int32_t syncNodeOnClientRequestOld(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIndex) { - sNTrace(ths, "on client request"); - - int32_t ret = 0; - int32_t code = 0; - - SyncIndex index = ths->pLogStore->syncLogWriteIndex(ths->pLogStore); - SyncTerm term = ths->raftStore.currentTerm; - SSyncRaftEntry* pEntry; - - if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) { - pEntry = syncEntryBuildFromClientRequest(pMsg->pCont, term, index); - } else { - pEntry = syncEntryBuildFromRpcMsg(pMsg, term, index); - } - - LRUHandle* h = NULL; - - if (ths->state == TAOS_SYNC_STATE_LEADER) { - // append entry - code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pEntry, false); - if (code != 0) { - if (ths->replicaNum == 1) { - if (h) { - taosLRUCacheRelease(ths->pLogStore->pCache, h, false); - } else { - syncEntryDestroy(pEntry); - } - - return -1; - - } else { - // del resp mgr, call FpCommitCb - SFsmCbMeta cbMeta = { - .index = pEntry->index, - .lastConfigIndex = SYNC_INDEX_INVALID, - .isWeak = pEntry->isWeak, - .code = -1, - .state = ths->state, - .seqNum = pEntry->seqNum, - .term = pEntry->term, - .currentTerm = ths->raftStore.currentTerm, - .flag = 0, - }; - ths->pFsm->FpCommitCb(ths->pFsm, pMsg, &cbMeta); - - if (h) { - taosLRUCacheRelease(ths->pLogStore->pCache, h, false); - } else { - syncEntryDestroy(pEntry); - } - - return -1; - } - } - - syncCacheEntry(ths->pLogStore, pEntry, &h); - - // if mulit replica, start replicate right now - if (ths->replicaNum > 1) { - syncNodeReplicate(ths); - } - - // if only myself, maybe commit right now - if (ths->replicaNum == 1) { - if (syncNodeIsMnode(ths)) { - syncMaybeAdvanceCommitIndex(ths); - } else { - syncOneReplicaAdvance(ths); - } - } - } - - if (pRetIndex != NULL) { - if (ret == 0 && pEntry != NULL) { - *pRetIndex = pEntry->index; - } else { - *pRetIndex = SYNC_INDEX_INVALID; - } - } - - if (h) { - taosLRUCacheRelease(ths->pLogStore->pCache, h, false); - } else { - syncEntryDestroy(pEntry); - } - - return ret; -} - const char* syncStr(ESyncState state) { switch (state) { case TAOS_SYNC_STATE_FOLLOWER: @@ -2894,129 +2696,6 @@ bool syncNodeIsOptimizedOneReplica(SSyncNode* ths, SRpcMsg* pMsg) { return (ths->replicaNum == 1 && syncUtilUserCommit(pMsg->msgType) && ths->vgId != 1); } -int32_t syncNodeDoCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, uint64_t flag) { - ASSERT(false); - if (beginIndex > endIndex) { - return 0; - } - - if (ths == NULL) { - return -1; - } - - if (ths->pFsm != NULL && ths->pFsm->FpGetSnapshotInfo != NULL) { - // advance commit index to sanpshot first - SSnapshot snapshot = {0}; - ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot); - if (snapshot.lastApplyIndex >= 0 && snapshot.lastApplyIndex >= beginIndex) { - sNTrace(ths, "commit by snapshot from index:%" PRId64 " to index:%" PRId64, beginIndex, snapshot.lastApplyIndex); - - // update begin index - beginIndex = snapshot.lastApplyIndex + 1; - } - } - - int32_t code = 0; - ESyncState state = flag; - - sNTrace(ths, "commit by wal from index:%" PRId64 " to index:%" PRId64, beginIndex, endIndex); - - // execute fsm - if (ths->pFsm != NULL) { - for (SyncIndex i = beginIndex; i <= endIndex; ++i) { - if (i != SYNC_INDEX_INVALID) { - SSyncRaftEntry* pEntry; - SLRUCache* pCache = ths->pLogStore->pCache; - LRUHandle* h = taosLRUCacheLookup(pCache, &i, sizeof(i)); - if (h) { - pEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, h); - - ths->pLogStore->cacheHit++; - sNTrace(ths, "hit cache index:%" PRId64 ", bytes:%u, %p", i, pEntry->bytes, pEntry); - - } else { - ths->pLogStore->cacheMiss++; - sNTrace(ths, "miss cache index:%" PRId64, i); - - code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, i, &pEntry); - // ASSERT(code == 0); - // ASSERT(pEntry != NULL); - if (code != 0 || pEntry == NULL) { - sNError(ths, "get log entry error"); - sFatal("vgId:%d, get log entry %" PRId64 " error when commit since %s", ths->vgId, i, terrstr()); - continue; - } - } - - SRpcMsg rpcMsg = {0}; - syncEntry2OriginalRpc(pEntry, &rpcMsg); - - sTrace("do commit index:%" PRId64 ", type:%s", i, TMSG_INFO(pEntry->msgType)); - - // user commit - if ((ths->pFsm->FpCommitCb != NULL) && syncUtilUserCommit(pEntry->originalRpcType)) { - bool internalExecute = true; - if ((ths->replicaNum == 1) && ths->restoreFinish && ths->vgId != 1) { - internalExecute = false; - } - - sNTrace(ths, "user commit index:%" PRId64 ", internal:%d, type:%s", i, internalExecute, - TMSG_INFO(pEntry->msgType)); - - // execute fsm in apply thread, or execute outside syncPropose - if (internalExecute) { - SFsmCbMeta cbMeta = { - .index = pEntry->index, - .lastConfigIndex = syncNodeGetSnapshotConfigIndex(ths, pEntry->index), - .isWeak = pEntry->isWeak, - .code = 0, - .state = ths->state, - .seqNum = pEntry->seqNum, - .term = pEntry->term, - .currentTerm = ths->raftStore.currentTerm, - .flag = flag, - }; - - syncRespMgrGetAndDel(ths->pSyncRespMgr, cbMeta.seqNum, &rpcMsg.info); - ths->pFsm->FpCommitCb(ths->pFsm, &rpcMsg, &cbMeta); - } - } - -#if 0 - // execute in pre-commit - // leader transfer - if (pEntry->originalRpcType == TDMT_SYNC_LEADER_TRANSFER) { - code = syncDoLeaderTransfer(ths, &rpcMsg, pEntry); - ASSERT(code == 0); - } -#endif - - // restore finish - // if only snapshot, a noop entry will be append, so syncLogLastIndex is always ok - if (pEntry->index == ths->pLogStore->syncLogLastIndex(ths->pLogStore)) { - if (ths->restoreFinish == false) { - if (ths->pFsm->FpRestoreFinishCb != NULL) { - ths->pFsm->FpRestoreFinishCb(ths->pFsm); - } - ths->restoreFinish = true; - - int64_t restoreDelay = taosGetTimestampMs() - ths->leaderTime; - sNTrace(ths, "restore finish, index:%" PRId64 ", elapsed:%" PRId64 " ms", pEntry->index, restoreDelay); - } - } - - rpcFreeCont(rpcMsg.pCont); - if (h) { - taosLRUCacheRelease(pCache, h, false); - } else { - syncEntryDestroy(pEntry); - } - } - } - } - return 0; -} - bool syncNodeInRaftGroup(SSyncNode* ths, SRaftId* pRaftId) { for (int32_t i = 0; i < ths->replicaNum; ++i) { if (syncUtilSameId(&((ths->replicasId)[i]), pRaftId)) { diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index 1d2b0b57fe..b3eb5684cf 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -132,16 +132,16 @@ SSyncRaftEntry* syncEntryBuildDummy(SyncTerm term, SyncIndex index, int32_t vgId int32_t syncLogValidateAlignmentOfCommit(SSyncNode* pNode, SyncIndex commitIndex) { SyncIndex firstVer = pNode->pLogStore->syncLogBeginIndex(pNode->pLogStore); if (firstVer > commitIndex + 1) { - sError("vgId:%d, firstVer of WAL log greater than tsdb commit version + 1. firstVer: %" PRId64 - ", tsdb commit version: %" PRId64 "", + sError("vgId:%d, firstVer of WAL log greater than tsdb commit version + 1. firstVer:%" PRId64 + ", tsdb commit version:%" PRId64 "", pNode->vgId, firstVer, commitIndex); return -1; } SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore); if (lastVer < commitIndex) { - sError("vgId:%d, lastVer of WAL log less than tsdb commit version. lastVer: %" PRId64 - ", tsdb commit version: %" PRId64 "", + sError("vgId:%d, lastVer of WAL log less than tsdb commit version. lastVer:%" PRId64 + ", tsdb commit version:%" PRId64 "", pNode->vgId, lastVer, commitIndex); return -1; } @@ -293,7 +293,7 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt bool inBuf = true; if (index <= pBuf->commitIndex) { - sTrace("vgId:%d, already committed. index: %" PRId64 ", term: %" PRId64 ". log buffer: [%" PRId64 " %" PRId64 + sTrace("vgId:%d, already committed. index:%" PRId64 ", term:%" PRId64 ". log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, pEntry->index, pEntry->term, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); @@ -306,7 +306,7 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt } if (index - pBuf->startIndex >= pBuf->size) { - sWarn("vgId:%d, out of buffer range. index: %" PRId64 ", term: %" PRId64 ". log buffer: [%" PRId64 " %" PRId64 + sWarn("vgId:%d, out of buffer range. index:%" PRId64 ", term:%" PRId64 ". log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, pEntry->index, pEntry->term, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); @@ -314,8 +314,8 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt } if (index > pBuf->matchIndex && lastMatchTerm != prevTerm) { - sWarn("vgId:%d, not ready to accept. index: %" PRId64 ", term: %" PRId64 ": prevterm: %" PRId64 - " != lastmatch: %" PRId64 ". log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", + sWarn("vgId:%d, not ready to accept. index:%" PRId64 ", term:%" PRId64 ": prevterm:%" PRId64 + " != lastmatch:%" PRId64 ". log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, pEntry->index, pEntry->term, prevTerm, lastMatchTerm, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); goto _out; @@ -328,7 +328,7 @@ int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt if (pEntry->term != pExist->term) { (void)syncLogBufferRollback(pBuf, pNode, index); } else { - sTrace("vgId:%d, duplicate log entry received. index: %" PRId64 ", term: %" PRId64 ". log buffer: [%" PRId64 + sTrace("vgId:%d, duplicate log entry received. index:%" PRId64 ", term:%" PRId64 ". log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, pEntry->index, pEntry->term, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); @@ -434,7 +434,7 @@ int64_t syncLogBufferProceed(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncTerm* p // increase match index pBuf->matchIndex = index; - sTrace("vgId:%d, log buffer proceed. start index: %" PRId64 ", match index: %" PRId64 ", end index: %" PRId64, + sTrace("vgId:%d, log buffer proceed. start index:%" PRId64 ", match index:%" PRId64 ", end index:%" PRId64, pNode->vgId, pBuf->startIndex, pBuf->matchIndex, pBuf->endIndex); // replicate on demand @@ -475,7 +475,7 @@ int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, Syn } if (pEntry->originalRpcType == TDMT_VND_COMMIT) { - sInfo("vgId:%d, fsm execute vnode commit. index: %" PRId64 ", term: %" PRId64 "", pNode->vgId, pEntry->index, + sInfo("vgId:%d, fsm execute vnode commit. index:%" PRId64 ", term:%" PRId64 "", pNode->vgId, pEntry->index, pEntry->term); } @@ -528,7 +528,7 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm goto _out; } - sTrace("vgId:%d, commit. log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 "), role: %d, term: %" PRId64, + sTrace("vgId:%d, commit. log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 "), role:%d, term:%" PRId64, pNode->vgId, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex, role, term); // execute in fsm @@ -541,19 +541,19 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm // execute it if (!syncUtilUserCommit(pEntry->originalRpcType)) { - sInfo("vgId:%d, commit sync barrier. index: %" PRId64 ", term:%" PRId64 ", type: %s", vgId, pEntry->index, + sInfo("vgId:%d, commit sync barrier. index:%" PRId64 ", term:%" PRId64 ", type:%s", vgId, pEntry->index, pEntry->term, TMSG_INFO(pEntry->originalRpcType)); } if (syncLogFsmExecute(pNode, pFsm, role, term, pEntry, 0) != 0) { sError("vgId:%d, failed to execute sync log entry. index:%" PRId64 ", term:%" PRId64 - ", role: %d, current term: %" PRId64, + ", role:%d, current term:%" PRId64, vgId, pEntry->index, pEntry->term, role, term); goto _out; } pBuf->commitIndex = index; - sTrace("vgId:%d, committed index: %" PRId64 ", term: %" PRId64 ", role: %d, current term: %" PRId64 "", pNode->vgId, + sTrace("vgId:%d, committed index:%" PRId64 ", term:%" PRId64 ", role:%d, current term:%" PRId64 "", pNode->vgId, pEntry->index, pEntry->term, role, term); if (!inBuf) { @@ -614,7 +614,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { SRaftId* pDestId = &pNode->replicasId[pMgr->peerId]; if (pMgr->retryBackoff == SYNC_MAX_RETRY_BACKOFF) { syncLogReplMgrReset(pMgr); - sWarn("vgId:%d, reset sync log repl mgr since retry backoff exceeding limit. peer: %" PRIx64, pNode->vgId, + sWarn("vgId:%d, reset sync log repl mgr since retry backoff exceeding limit. peer:%" PRIx64, pNode->vgId, pDestId->addr); return -1; } @@ -639,7 +639,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { if (pMgr->states[pos].acked) { if (pMgr->matchIndex < index && pMgr->states[pos].timeMs + (syncGetRetryMaxWaitMs() << 3) < nowMs) { syncLogReplMgrReset(pMgr); - sWarn("vgId:%d, reset sync log repl mgr since stagnation. index: %" PRId64 ", peer: %" PRIx64, pNode->vgId, + sWarn("vgId:%d, reset sync log repl mgr since stagnation. index:%" PRId64 ", peer:%" PRIx64, pNode->vgId, index, pDestId->addr); goto _out; } @@ -648,7 +648,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { bool barrier = false; if (syncLogReplMgrReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) { - sError("vgId:%d, failed to replicate sync log entry since %s. index: %" PRId64 ", dest: %" PRIx64 "", pNode->vgId, + sError("vgId:%d, failed to replicate sync log entry since %s. index:%" PRId64 ", dest:%" PRIx64 "", pNode->vgId, terrstr(), index, pDestId->addr); goto _out; } @@ -670,8 +670,8 @@ _out: if (retried) { pMgr->retryBackoff = syncLogGetNextRetryBackoff(pMgr); SSyncLogBuffer* pBuf = pNode->pLogBuf; - sInfo("vgId:%d, resend %d sync log entries. dest: %" PRIx64 ", indexes: %" PRId64 " ..., terms: ... %" PRId64 - ", retryWaitMs: %" PRId64 ", mgr: [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 + sInfo("vgId:%d, resend %d sync log entries. dest:%" PRIx64 ", indexes:%" PRId64 " ..., terms: ... %" PRId64 + ", retryWaitMs:%" PRId64 ", mgr: [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, count, pDestId->addr, firstIndex, term, retryWaitMs, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); @@ -714,7 +714,7 @@ int32_t syncLogReplMgrProcessReplyAsRecovery(SSyncLogReplMgr* pMgr, SSyncNode* p } if (pMsg->success == false && pMsg->matchIndex >= pMsg->lastSendIndex) { - sWarn("vgId:%d, failed to rollback match index. peer: dnode:%d, match index: %" PRId64 ", last sent: %" PRId64, + sWarn("vgId:%d, failed to rollback match index. peer: dnode:%d, match index:%" PRId64 ", last sent:%" PRId64, pNode->vgId, DID(&destId), pMsg->matchIndex, pMsg->lastSendIndex); if (syncNodeStartSnapshot(pNode, &destId) < 0) { sError("vgId:%d, failed to start snapshot for peer dnode:%d", pNode->vgId, DID(&destId)); @@ -761,7 +761,7 @@ int32_t syncLogReplMgrProcessHeartbeatReply(SSyncLogReplMgr* pMgr, SSyncNode* pN SSyncLogBuffer* pBuf = pNode->pLogBuf; taosThreadMutexLock(&pBuf->mutex); if (pMsg->startTime != 0 && pMsg->startTime != pMgr->peerStartTime) { - sInfo("vgId:%d, reset sync log repl mgr in heartbeat. peer: %" PRIx64 ", start time:%" PRId64 ", old:%" PRId64 "", + sInfo("vgId:%d, reset sync log repl mgr in heartbeat. peer:%" PRIx64 ", start time:%" PRId64 ", old:%" PRId64 "", pNode->vgId, pMsg->srcId.addr, pMsg->startTime, pMgr->peerStartTime); syncLogReplMgrReset(pMgr); pMgr->peerStartTime = pMsg->startTime; @@ -774,7 +774,7 @@ int32_t syncLogReplMgrProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sync SSyncLogBuffer* pBuf = pNode->pLogBuf; taosThreadMutexLock(&pBuf->mutex); if (pMsg->startTime != pMgr->peerStartTime) { - sInfo("vgId:%d, reset sync log repl mgr in appendlog reply. peer: %" PRIx64 ", start time:%" PRId64 + sInfo("vgId:%d, reset sync log repl mgr in appendlog reply. peer:%" PRIx64 ", start time:%" PRId64 ", old:%" PRId64, pNode->vgId, pMsg->srcId.addr, pMsg->startTime, pMgr->peerStartTime); syncLogReplMgrReset(pMgr); @@ -815,7 +815,7 @@ int32_t syncLogReplMgrReplicateProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy bool barrier = false; SyncTerm term = -1; if (syncLogReplMgrReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) { - sError("vgId:%d, failed to replicate log entry since %s. index: %" PRId64 ", dest: 0x%016" PRIx64 "", pNode->vgId, + sError("vgId:%d, failed to replicate log entry since %s. index:%" PRId64 ", dest: 0x%016" PRIx64 "", pNode->vgId, terrstr(), index, pDestId->addr); return -1; } @@ -830,7 +830,7 @@ int32_t syncLogReplMgrReplicateProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy pMgr->endIndex = index + 1; SSyncLogBuffer* pBuf = pNode->pLogBuf; - sInfo("vgId:%d, probe peer:%" PRIx64 " with msg of index:%" PRId64 " term: %" PRId64 ". mgr (rs:%d): [%" PRId64 + sTrace("vgId:%d, probe peer:%" PRIx64 " with msg of index:%" PRId64 " term:%" PRId64 ". mgr (rs:%d): [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, pDestId->addr, index, term, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); @@ -860,7 +860,7 @@ int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) bool barrier = false; SyncTerm term = -1; if (syncLogReplMgrReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) { - sError("vgId:%d, failed to replicate log entry since %s. index: %" PRId64 ", dest: 0x%016" PRIx64 "", pNode->vgId, + sError("vgId:%d, failed to replicate log entry since %s. index:%" PRId64 ", dest: 0x%016" PRIx64 "", pNode->vgId, terrstr(), index, pDestId->addr); return -1; } @@ -874,7 +874,7 @@ int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) pMgr->endIndex = index + 1; if (barrier) { - sInfo("vgId:%d, replicated sync barrier to dest: %" PRIx64 ". index: %" PRId64 ", term: %" PRId64 + sInfo("vgId:%d, replicated sync barrier to dest:%" PRIx64 ". index:%" PRId64 ", term:%" PRId64 ", repl mgr: rs(%d) [%" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, pDestId->addr, index, term, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex); @@ -885,7 +885,7 @@ int32_t syncLogReplMgrReplicateAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) syncLogReplMgrRetryOnNeed(pMgr, pNode); SSyncLogBuffer* pBuf = pNode->pLogBuf; - sTrace("vgId:%d, replicated %d msgs to peer: %" PRIx64 ". indexes: %" PRId64 "..., terms: ...%" PRId64 + sTrace("vgId:%d, replicated %d msgs to peer:%" PRIx64 ". indexes:%" PRId64 "..., terms: ...%" PRId64 ", mgr: (rs:%d) [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, count, pDestId->addr, firstIndex, term, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, @@ -945,8 +945,11 @@ int32_t syncNodeLogReplMgrInit(SSyncNode* pNode) { for (int i = 0; i < TSDB_MAX_REPLICA; i++) { ASSERT(pNode->logReplMgrs[i] == NULL); pNode->logReplMgrs[i] = syncLogReplMgrCreate(); + if (pNode->logReplMgrs[i] == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } pNode->logReplMgrs[i]->peerId = i; - ASSERTS(pNode->logReplMgrs[i] != NULL, "Out of memory."); } return 0; } @@ -1025,7 +1028,7 @@ int32_t syncLogBufferRollback(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex return 0; } - sInfo("vgId:%d, rollback sync log buffer. toindex: %" PRId64 ", buffer: [%" PRId64 " %" PRId64 " %" PRId64 + sInfo("vgId:%d, rollback sync log buffer. toindex:%" PRId64 ", buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, toIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); @@ -1116,11 +1119,11 @@ int32_t syncLogReplMgrReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy pEntry = syncLogBufferGetOneEntry(pBuf, pNode, index, &inBuf); if (pEntry == NULL) { - sError("vgId:%d, failed to get raft entry for index: %" PRId64 "", pNode->vgId, index); + sError("vgId:%d, failed to get raft entry for index:%" PRId64 "", pNode->vgId, index); if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) { SSyncLogReplMgr* pMgr = syncNodeGetLogReplMgr(pNode, pDestId); if (pMgr) { - sInfo("vgId:%d, reset sync log repl mgr of peer: %" PRIx64 " since %s. index: %" PRId64, pNode->vgId, + sInfo("vgId:%d, reset sync log repl mgr of peer:%" PRIx64 " since %s. index:%" PRId64, pNode->vgId, pDestId->addr, terrstr(), index); (void)syncLogReplMgrReset(pMgr); } @@ -1131,7 +1134,7 @@ int32_t syncLogReplMgrReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy prevLogTerm = syncLogReplMgrGetPrevLogTerm(pMgr, pNode, index); if (prevLogTerm < 0) { - sError("vgId:%d, failed to get prev log term since %s. index: %" PRId64 "", pNode->vgId, terrstr(), index); + sError("vgId:%d, failed to get prev log term since %s. index:%" PRId64 "", pNode->vgId, terrstr(), index); goto _err; } if (pTerm) *pTerm = pEntry->term; @@ -1144,7 +1147,7 @@ int32_t syncLogReplMgrReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sy (void)syncNodeSendAppendEntries(pNode, pDestId, &msgOut); - sTrace("vgId:%d, replicate one msg index: %" PRId64 " term: %" PRId64 " prevterm: %" PRId64 " to dest: 0x%016" PRIx64, + sTrace("vgId:%d, replicate one msg index:%" PRId64 " term:%" PRId64 " prevterm:%" PRId64 " to dest: 0x%016" PRIx64, pNode->vgId, pEntry->index, pEntry->term, prevLogTerm, pDestId->addr); if (!inBuf) { diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index 988a86cc67..623f1b77a4 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -91,7 +91,7 @@ SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index, int32_t vgId) void syncEntryDestroy(SSyncRaftEntry* pEntry) { if (pEntry != NULL) { - sTrace("free entry: %p", pEntry); + sTrace("free entry:%p", pEntry); taosMemoryFree(pEntry); } } diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index e6569d9974..9299651999 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -249,6 +249,7 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR int64_t ts2 = taosGetTimestampNs(); code = walReadVer(pWalHandle, index); + walReadReset(pWalHandle); int64_t ts3 = taosGetTimestampNs(); // code = walReadVerCached(pWalHandle, index); diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 1aa476e84e..3df203221b 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -48,92 +48,6 @@ int32_t syncNodeMaybeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg); -int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapshot) { - ASSERT(false && "deprecated"); - // next index - SyncIndex nextIndex = syncIndexMgrGetIndex(pSyncNode->pNextIndex, pDestId); - - if (snapshot) { - // maybe start snapshot - SyncIndex logStartIndex = pSyncNode->pLogStore->syncLogBeginIndex(pSyncNode->pLogStore); - SyncIndex logEndIndex = pSyncNode->pLogStore->syncLogEndIndex(pSyncNode->pLogStore); - if (nextIndex < logStartIndex || nextIndex - 1 > logEndIndex) { - sNTrace(pSyncNode, "maybe start snapshot for next-index:%" PRId64 ", start:%" PRId64 ", end:%" PRId64, nextIndex, - logStartIndex, logEndIndex); - // start snapshot - int32_t code = syncNodeStartSnapshot(pSyncNode, pDestId); - } - } - - // pre index, pre term - SyncIndex preLogIndex = syncNodeGetPreIndex(pSyncNode, nextIndex); - SyncTerm preLogTerm = syncNodeGetPreTerm(pSyncNode, nextIndex); - - // prepare entry - SRpcMsg rpcMsg = {0}; - SyncAppendEntries* pMsg = NULL; - - SSyncRaftEntry* pEntry = NULL; - SLRUCache* pCache = pSyncNode->pLogStore->pCache; - LRUHandle* h = taosLRUCacheLookup(pCache, &nextIndex, sizeof(nextIndex)); - int32_t code = 0; - if (h) { - pEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, h); - code = 0; - - pSyncNode->pLogStore->cacheHit++; - sNTrace(pSyncNode, "hit cache index:%" PRId64 ", bytes:%u, %p", nextIndex, pEntry->bytes, pEntry); - - } else { - pSyncNode->pLogStore->cacheMiss++; - sNTrace(pSyncNode, "miss cache index:%" PRId64, nextIndex); - - code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, nextIndex, &pEntry); - } - - if (code == 0) { - ASSERT(pEntry != NULL); - - code = syncBuildAppendEntries(&rpcMsg, (int32_t)(pEntry->bytes), pSyncNode->vgId); - ASSERT(code == 0); - - pMsg = rpcMsg.pCont; - memcpy(pMsg->data, pEntry, pEntry->bytes); - } else { - if (terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) { - // no entry in log - code = syncBuildAppendEntries(&rpcMsg, 0, pSyncNode->vgId); - ASSERT(code == 0); - - pMsg = rpcMsg.pCont; - } else { - sNError(pSyncNode, "replicate to dnode:%d error, next-index:%" PRId64, DID(pDestId), nextIndex); - return -1; - } - } - - if (h) { - taosLRUCacheRelease(pCache, h, false); - } else { - syncEntryDestroy(pEntry); - } - - // prepare msg - ASSERT(pMsg != NULL); - pMsg->srcId = pSyncNode->myRaftId; - pMsg->destId = *pDestId; - pMsg->term = pSyncNode->raftStore.currentTerm; - pMsg->prevLogIndex = preLogIndex; - pMsg->prevLogTerm = preLogTerm; - pMsg->commitIndex = pSyncNode->commitIndex; - pMsg->privateTerm = 0; - // pMsg->privateTerm = syncIndexMgrGetTerm(pSyncNode->pNextIndex, pDestId); - - // send msg - syncNodeMaybeSendAppendEntries(pSyncNode, pDestId, &rpcMsg); - return 0; -} - int32_t syncNodeReplicate(SSyncNode* pNode) { SSyncLogBuffer* pBuf = pNode->pLogBuf; taosThreadMutexLock(&pBuf->mutex); @@ -156,25 +70,6 @@ int32_t syncNodeReplicateWithoutLock(SSyncNode* pNode) { return 0; } -int32_t syncNodeReplicateOld(SSyncNode* pSyncNode) { - if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { - return -1; - } - - sNTrace(pSyncNode, "do replicate"); - - int32_t ret = 0; - for (int i = 0; i < pSyncNode->peersNum; ++i) { - SRaftId* pDestId = &(pSyncNode->peersId[i]); - ret = syncNodeReplicateOne(pSyncNode, pDestId, true); - if (ret != 0) { - sError("vgId:%d, do append entries error for dnode:%d", pSyncNode->vgId, DID(pDestId)); - } - } - - return 0; -} - int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) { SyncAppendEntries* pMsg = pRpcMsg->pCont; pMsg->destId = *destRaftId; @@ -182,39 +77,6 @@ int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftI return 0; } -int32_t syncNodeSendAppendEntriesOld(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) { - int32_t ret = 0; - SyncAppendEntries* pMsg = pRpcMsg->pCont; - if (pMsg == NULL) { - sError("vgId:%d, sync-append-entries msg is NULL", pSyncNode->vgId); - return 0; - } - - SPeerState* pState = syncNodeGetPeerState(pSyncNode, destRaftId); - if (pState == NULL) { - sError("vgId:%d, replica maybe dropped", pSyncNode->vgId); - return 0; - } - - // save index, otherwise pMsg will be free by rpc - SyncIndex saveLastSendIndex = pState->lastSendIndex; - bool update = false; - if (pMsg->dataLen > 0) { - saveLastSendIndex = pMsg->prevLogIndex + 1; - update = true; - } - - syncLogSendAppendEntries(pSyncNode, pMsg, ""); - syncNodeSendMsgById(destRaftId, pSyncNode, pRpcMsg); - - if (update) { - pState->lastSendIndex = saveLastSendIndex; - pState->lastSendTime = taosGetTimestampMs(); - } - - return ret; -} - int32_t syncNodeMaybeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) { int32_t ret = 0; SyncAppendEntries* pMsg = pRpcMsg->pCont; diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 880c76e4dd..18f263cc95 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -112,7 +112,7 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex; pMsg->lastConfig = pSender->lastConfig; pMsg->startTime = pSender->startTime; - pMsg->seq = SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT; + pMsg->seq = SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT; // event log syncLogSendSyncSnapshotSend(pSender->pSyncNode, pMsg, "snapshot sender start"); @@ -379,7 +379,7 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *p } pReceiver->start = true; - pReceiver->ack = SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT; + pReceiver->ack = SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT; pReceiver->term = pReceiver->pSyncNode->raftStore.currentTerm; pReceiver->fromId = pPreMsg->srcId; pReceiver->startTime = pPreMsg->startTime; @@ -510,16 +510,8 @@ SyncIndex syncNodeGetSnapBeginIndex(SSyncNode *ths) { SSyncLogStoreData *pData = ths->pLogStore->data; SWal *pWal = pData->pWal; - bool isEmpty = ths->pLogStore->syncLogIsEmpty(ths->pLogStore); int64_t walCommitVer = walGetCommittedVer(pWal); - - if (!isEmpty && ths->commitIndex != walCommitVer) { - sNError(ths, "commit not same, wal-commit:%" PRId64 ", commit:%" PRId64 ", ignore", walCommitVer, - ths->commitIndex); - snapStart = walCommitVer + 1; - } else { - snapStart = ths->commitIndex + 1; - } + snapStart = TMAX(ths->commitIndex, walCommitVer) + 1; sNInfo(ths, "snapshot begin index is %" PRId64, snapStart); } @@ -527,7 +519,7 @@ SyncIndex syncNodeGetSnapBeginIndex(SSyncNode *ths) { return snapStart; } -static int32_t syncNodeOnSnapshotPre(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { +static int32_t syncNodeOnSnapshotPrep(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; int64_t timeNow = taosGetTimestampMs(); int32_t code = 0; @@ -565,7 +557,7 @@ _START_RECEIVER: } else { // waiting for clock match while (timeNow < pMsg->startTime) { - sRInfo(pReceiver, "snapshot receiver pre waitting for true time, now:%" PRId64 ", stime:%" PRId64, timeNow, + sRInfo(pReceiver, "snapshot receiver pre waitting for true time, now:%" PRId64 ", startTime:%" PRId64, timeNow, pMsg->startTime); taosMsleep(10); timeNow = taosGetTimestampMs(); @@ -765,7 +757,7 @@ static int32_t syncNodeOnSnapshotEnd(SSyncNode *pSyncNode, SyncSnapshotSend *pMs // receiver on message // -// condition 1, recv SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT +// condition 1, recv SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT // if receiver already start // if sender.start-time > receiver.start-time, restart receiver(reply snapshot start) // if sender.start-time = receiver.start-time, maybe duplicate msg @@ -809,9 +801,9 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { int32_t code = 0; if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) { if (pMsg->term == pSyncNode->raftStore.currentTerm) { - if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT) { + if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT) { syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq pre-snapshot"); - code = syncNodeOnSnapshotPre(pSyncNode, pMsg); + code = syncNodeOnSnapshotPrep(pSyncNode, pMsg); } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_BEGIN) { syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq begin"); code = syncNodeOnSnapshotBegin(pSyncNode, pMsg); @@ -848,7 +840,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { return code; } -static int32_t syncNodeOnSnapshotPreRsp(SSyncNode *pSyncNode, SSyncSnapshotSender *pSender, SyncSnapshotRsp *pMsg) { +static int32_t syncNodeOnSnapshotPrepRsp(SSyncNode *pSyncNode, SSyncSnapshotSender *pSender, SyncSnapshotRsp *pMsg) { SSnapshot snapshot = {0}; pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); @@ -945,8 +937,8 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { if (pMsg->startTime != pSender->startTime) { syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "snapshot sender and receiver time not match"); - sSError(pSender, "sender:%" PRId64 " receiver:%" PRId64 " time not match, code:0x%x", pMsg->startTime, - pSender->startTime, pMsg->code); + sSError(pSender, "sender:%" PRId64 " receiver:%" PRId64 " time not match, error:%s 0x%x", pMsg->startTime, + pSender->startTime, tstrerror(pMsg->code), pMsg->code); terrno = TSDB_CODE_SYN_INTERNAL_ERROR; goto _ERROR; } @@ -961,15 +953,15 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { if (pMsg->code != 0) { syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "receive error code"); - sSError(pSender, "snapshot sender receive error code:0x%x and stop sender", pMsg->code); + sSError(pSender, "snapshot sender receive error:%s 0x%x and stop sender", tstrerror(pMsg->code), pMsg->code); terrno = pMsg->code; goto _ERROR; } // prepare , send begin msg - if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT) { + if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT) { syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq pre-snapshot"); - return syncNodeOnSnapshotPreRsp(pSyncNode, pSender, pMsg); + return syncNodeOnSnapshotPrepRsp(pSyncNode, pSender, pMsg); } if (pSender->pReader == NULL || pSender->finish) { diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index b246d9a79d..97641b8f41 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -43,7 +43,7 @@ void syncUtilNodeInfo2EpSet(const SNodeInfo* pInfo, SEpSet* pEpSet) { bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* raftId) { uint32_t ipv4 = taosGetIpv4FromFqdn(pInfo->nodeFqdn); if (ipv4 == 0xFFFFFFFF || ipv4 == 1) { - sError("failed to resolve ipv4 addr, fqdn: %s", pInfo->nodeFqdn); + sError("failed to resolve ipv4 addr, fqdn:%s", pInfo->nodeFqdn); terrno = TSDB_CODE_TSC_INVALID_FQDN; return false; } @@ -141,20 +141,15 @@ static void syncLogReplMgrStates2Str(SSyncNode* pSyncNode, char* buf, int32_t bu } static void syncPeerState2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) { - int32_t len = 1; - + int32_t len = 0; + len += snprintf(buf + len, bufLen - len, "%s", "{"); for (int32_t i = 0; i < pSyncNode->replicaNum; ++i) { SPeerState* pState = syncNodeGetPeerState(pSyncNode, &(pSyncNode->replicasId[i])); if (pState == NULL) break; - - if (i < pSyncNode->replicaNum - 1) { - len += snprintf(buf + len, bufLen - len, "%d:%" PRId64 " %" PRId64 ", ", i, pState->lastSendIndex, - pState->lastSendTime); - } else { - len += snprintf(buf + len, bufLen - len, "%d:%" PRId64 " %" PRId64 "}", i, pState->lastSendIndex, - pState->lastSendTime); - } + len += snprintf(buf + len, bufLen - len, "%d:%" PRId64 " %" PRId64 "%s", i, pState->lastSendIndex, + pState->lastSendTime, (i < pSyncNode->replicaNum - 1) ? ", " : ""); } + len += snprintf(buf + len, bufLen - len, "%s", "}"); } void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNode* pNode, const char* format, ...) { @@ -245,7 +240,7 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla char cfgStr[1024] = ""; syncCfg2SimpleStr(&pNode->raftCfg.cfg, cfgStr, sizeof(cfgStr)); - char peerStr[1024] = "{"; + char peerStr[1024] = ""; syncPeerState2Str(pNode, peerStr, sizeof(peerStr)); char eventLog[512]; // {0}; @@ -255,20 +250,21 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla va_end(argpointer); taosPrintLog(flags, level, dflag, - "vgId:%d, %s, sync:%s, {%p s-param:%" PRId64 " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 - " lcindex:%" PRId64 - " seq:%d ack:%d finish:%d replica-index:%d dnode:%d}" - ", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64 - ", snap-tm:%" PRIu64 ", sby:%d, stgy:%d, bch:%d, r-num:%d, lcfg:%" PRId64 - ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s", + "vgId:%d, %s, sync:%s, snap-sender:{%p start:%" PRId64 " end:%" PRId64 " last-index:%" PRId64 + " last-term:%" PRIu64 " last-cfg:%" PRId64 + ", seq:%d ack:%d finish:%d, as:%d dnode:%d}" + ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64 + ", min-match:%" PRId64 ", snap:{last-index:%" PRId64 ", term:%" PRIu64 + "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64 + ", chging:%d, restore:%d, quorum:%d, lc-timer:{elect:%" PRId64 ", hb:%" PRId64 "}, peer:%s, cfg:%s", pNode->vgId, eventLog, syncStr(pNode->state), pSender, pSender->snapshotParam.start, pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, pSender->finish, pSender->replicaIndex, DID(&pNode->replicasId[pSender->replicaIndex]), pNode->raftStore.currentTerm, pNode->commitIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, - pNode->raftCfg.isStandBy, pNode->raftCfg.snapshotStrategy, pNode->raftCfg.batchSize, pNode->replicaNum, - pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode), - pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr); + pNode->raftCfg.isStandBy, pNode->raftCfg.batchSize, pNode->replicaNum, pNode->raftCfg.lastConfigIndex, + pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, + pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr); } void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotReceiver* pReceiver, @@ -291,7 +287,7 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df char cfgStr[1024] = ""; syncCfg2SimpleStr(&pNode->raftCfg.cfg, cfgStr, sizeof(cfgStr)); - char peerStr[1024] = "{"; + char peerStr[1024] = ""; syncPeerState2Str(pNode, peerStr, sizeof(peerStr)); char eventLog[512]; // {0}; @@ -300,22 +296,22 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df int32_t writeLen = vsnprintf(eventLog, sizeof(eventLog), format, argpointer); va_end(argpointer); - taosPrintLog(flags, level, dflag, - "vgId:%d, %s, sync:%s," - " {%p start:%d ack:%d term:%" PRIu64 " start-time:%" PRId64 " from dnode:%d s-param:%" PRId64 - " e-param:%" PRId64 " laindex:%" PRId64 " laterm:%" PRIu64 " lcindex:%" PRId64 - "}" - ", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64 - ", snap-tm:%" PRIu64 ", sby:%d, stgy:%d, bch:%d, r-num:%d, lcfg:%" PRId64 - ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s", - pNode->vgId, eventLog, syncStr(pNode->state), pReceiver, pReceiver->start, pReceiver->ack, - pReceiver->term, pReceiver->startTime, DID(&pReceiver->fromId), pReceiver->snapshotParam.start, - pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm, - pReceiver->snapshot.lastConfigIndex, pNode->raftStore.currentTerm, pNode->commitIndex, logBeginIndex, - logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, - pNode->raftCfg.isStandBy, pNode->raftCfg.snapshotStrategy, pNode->raftCfg.batchSize, pNode->replicaNum, - pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode), - pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr); + taosPrintLog( + flags, level, dflag, + "vgId:%d, %s, sync:%s," + " snap-receiver:{%p started:%d acked:%d term:%" PRIu64 " start-time:%" PRId64 " from-dnode:%d, start:%" PRId64 + " end:%" PRId64 " last-index:%" PRId64 " last-term:%" PRIu64 " last-cfg:%" PRId64 + "}" + ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64 ", min-match:%" PRId64 + ", snap:{last-index:%" PRId64 ", last-term:%" PRIu64 "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64 + ", chging:%d, restore:%d, quorum:%d, lc-timers:{elect:%" PRId64 ", hb:%" PRId64 "}, peer:%s, cfg:%s", + pNode->vgId, eventLog, syncStr(pNode->state), pReceiver, pReceiver->start, pReceiver->ack, pReceiver->term, + pReceiver->startTime, DID(&pReceiver->fromId), pReceiver->snapshotParam.start, pReceiver->snapshotParam.end, + pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm, pReceiver->snapshot.lastConfigIndex, + pNode->raftStore.currentTerm, pNode->commitIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex, + snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->raftCfg.isStandBy, pNode->raftCfg.batchSize, + pNode->replicaNum, pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, + syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr); } void syncLogRecvTimer(SSyncNode* pSyncNode, const SyncTimeout* pMsg, const char* s) { @@ -351,13 +347,13 @@ void syncLogSendHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, bool int64_t execTime) { if (printX) { sNTrace(pSyncNode, - "send sync-heartbeat to dnode:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 - "}, x", + "send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64 + ", ts:%" PRId64 "}, x", DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp); } else { sNTrace(pSyncNode, - "send sync-heartbeat to dnode:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 - "}, timer-elapsed:%" PRId64 ", next-exec:%" PRId64, + "send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64 + ", ts:%" PRId64 "}, timer-elapsed:%" PRId64 ", next-exec:%" PRId64, DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, timerElapsed, execTime); } @@ -368,14 +364,14 @@ void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, int64 pSyncNode->hbSlowNum++; sNInfo(pSyncNode, - "recv sync-heartbeat from dnode:%d slow {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 + "recv sync-heartbeat from dnode:%d slow {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64, DID(&pMsg->srcId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, s, timeDiff); } sNTrace(pSyncNode, - "recv sync-heartbeat from dnode:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 - "}, %s, net elapsed:%" PRId64, + "recv sync-heartbeat from dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64 + ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64, DID(&pMsg->srcId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, s, timeDiff); } @@ -400,67 +396,64 @@ void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* p void syncLogSendSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) { sNDebug(pSyncNode, - "send sync-snapshot-send to dnode:%d, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", end:%" PRId64 - ", lterm:%" PRId64 ", stime:%" PRId64, + "send sync-snapshot-send to dnode:%d, %s, seq:%d, term:%" PRId64 ", begin-index:%" PRId64 + ", last-index:%" PRId64 ", last-term:%" PRId64 ", start-time:%" PRId64, DID(&pMsg->destId), s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime); } void syncLogRecvSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* pMsg, const char* s) { sNDebug(pSyncNode, - "recv sync-snapshot-send from dnode:%d, %s, seq:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 - ", lterm:%" PRId64 ", stime:%" PRId64 ", len:%u", + "recv sync-snapshot-send from dnode:%d, %s, seq:%d, term:%" PRId64 ", begin-index:%" PRId64 + ", last-index:%" PRId64 ", last-term:%" PRId64 ", start-time:%" PRId64 ", data-len:%u", DID(&pMsg->srcId), s, pMsg->seq, pMsg->term, pMsg->beginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime, pMsg->dataLen); } void syncLogSendSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) { sNDebug(pSyncNode, - "send sync-snapshot-rsp to dnode:%d, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 - ", lterm:%" PRId64 ", stime:%" PRId64, + "send sync-snapshot-rsp to dnode:%d, %s, acked:%d, term:%" PRId64 ", begin-index:%" PRId64 + ", last-index:%" PRId64 ", last-term:%" PRId64 ", start-time:%" PRId64, DID(&pMsg->destId), s, pMsg->ack, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime); } void syncLogRecvSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMsg, const char* s) { sNDebug(pSyncNode, - "recv sync-snapshot-rsp from dnode:%d, %s, ack:%d, term:%" PRId64 ", begin:%" PRId64 ", lst:%" PRId64 - ", lterm:%" PRId64 ", stime:%" PRId64, + "recv sync-snapshot-rsp from dnode:%d, %s, ack:%d, term:%" PRId64 ", begin-index:%" PRId64 + ", last-index:%" PRId64 ", last-term:%" PRId64 ", start-time:%" PRId64, DID(&pMsg->srcId), s, pMsg->ack, pMsg->term, pMsg->snapBeginIndex, pMsg->lastIndex, pMsg->lastTerm, pMsg->startTime); } void syncLogRecvAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) { sNTrace(pSyncNode, - "recv sync-append-entries from dnode:%d {term:%" PRId64 ", pre-index:%" PRId64 ", pre-term:%" PRId64 - ", cmt:%" PRId64 ", pterm:%" PRId64 ", datalen:%d}, %s", - DID(&pMsg->srcId), pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->commitIndex, pMsg->privateTerm, - pMsg->dataLen, s); + "recv sync-append-entries from dnode:%d {term:%" PRId64 ", prev-log:{index:%" PRId64 ", term:%" PRId64 + "}, commit-index:%" PRId64 ", datalen:%d}, %s", + DID(&pMsg->srcId), pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->commitIndex, pMsg->dataLen, s); } void syncLogSendAppendEntries(SSyncNode* pSyncNode, const SyncAppendEntries* pMsg, const char* s) { sNTrace(pSyncNode, - "send sync-append-entries to dnode:%d, {term:%" PRId64 ", pre-index:%" PRId64 ", pre-term:%" PRId64 - ", lsend-index:%" PRId64 ", cmt:%" PRId64 ", datalen:%d}, %s", + "send sync-append-entries to dnode:%d, {term:%" PRId64 ", prev-log:{index:%" PRId64 ", term:%" PRId64 + "}, index:%" PRId64 ", commit-index:%" PRId64 ", datalen:%d}, %s", DID(&pMsg->destId), pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, (pMsg->prevLogIndex + 1), pMsg->commitIndex, pMsg->dataLen, s); } -void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, int32_t voteGranted, const char* s) { - if (voteGranted == -1) { - sNInfo(pSyncNode, - "recv sync-request-vote from dnode:%d, {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 "}, %s", - DID(&pMsg->srcId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, s); - } else { - sNInfo(pSyncNode, - "recv sync-request-vote from dnode:%d, {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 - "}, granted:%d", - DID(&pMsg->srcId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, voteGranted); - } +void syncLogRecvRequestVote(SSyncNode* pSyncNode, const SyncRequestVote* pMsg, int32_t voteGranted, + const char* errmsg) { + char statusMsg[64]; + snprintf(statusMsg, sizeof(statusMsg), "granted:%d", voteGranted); + sNInfo(pSyncNode, + "recv sync-request-vote from dnode:%d, {term:%" PRId64 ", last-index:%" PRId64 ", last-term:%" PRId64 "}, %s", + DID(&pMsg->srcId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, + (voteGranted != -1) ? statusMsg : errmsg); } void syncLogSendRequestVote(SSyncNode* pNode, const SyncRequestVote* pMsg, const char* s) { - sNInfo(pNode, "send sync-request-vote to dnode:%d {term:%" PRId64 ", lindex:%" PRId64 ", lterm:%" PRId64 "}, %s", + sNInfo(pNode, + "send sync-request-vote to dnode:%d {term:%" PRId64 ", last-index:%" PRId64 ", last-term:%" PRId64 "}, %s", DID(&pMsg->destId), pMsg->term, pMsg->lastLogIndex, pMsg->lastLogTerm, s); } diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index 50dc8e0a65..dc448c986e 100644 --- a/source/libs/tdb/src/db/tdbPage.c +++ b/source/libs/tdb/src/db/tdbPage.c @@ -404,62 +404,50 @@ static int tdbPageFree(SPage *pPage, int idx, SCell *pCell, int szCell) { return 0; } -static int tdbPageDefragment(SPage *pPage) { - int nFree; - int nCells; - SCell *pCell; - SCell *pNextCell; - SCell *pTCell; - int szCell; - int idx; - int iCell; - - nFree = TDB_PAGE_NFREE(pPage); - nCells = TDB_PAGE_NCELLS(pPage); - - ASSERT(pPage->pFreeEnd - pPage->pFreeStart < nFree); - - // Loop to compact the page content - // Here we use an O(n^2) algorithm to do the job since - // this is a low frequency job. - pNextCell = (u8 *)pPage->pPageFtr; - pCell = NULL; - for (iCell = 0;; iCell++) { - // compact over - if (iCell == nCells) { - pPage->pFreeEnd = pNextCell; - break; - } - - for (int i = 0; i < nCells; i++) { - if (TDB_PAGE_CELL_OFFSET_AT(pPage, i) < pNextCell - pPage->pData) { - pTCell = TDB_PAGE_CELL_AT(pPage, i); - if (pCell == NULL || pCell < pTCell) { - pCell = pTCell; - idx = i; - } - } else { - continue; - } - } - - ASSERT(pCell != NULL); - - szCell = (*pPage->xCellSize)(pPage, pCell, 0, NULL, NULL); - - ASSERT(pCell + szCell <= pNextCell); - if (pCell + szCell < pNextCell) { - memmove(pNextCell - szCell, pCell, szCell); - } - - pCell = NULL; - pNextCell = pNextCell - szCell; - TDB_PAGE_CELL_OFFSET_AT_SET(pPage, idx, pNextCell - pPage->pData); +typedef struct { + int32_t iCell; + int32_t offset; +} SCellIdx; +static int32_t tCellIdxCmprFn(const void *p1, const void *p2) { + if (((SCellIdx *)p1)->offset < ((SCellIdx *)p2)->offset) { + return -1; + } else if (((SCellIdx *)p1)->offset > ((SCellIdx *)p2)->offset) { + return 1; + } else { + return 0; } +} +static int tdbPageDefragment(SPage *pPage) { + int32_t nFree = TDB_PAGE_NFREE(pPage); + int32_t nCell = TDB_PAGE_NCELLS(pPage); - ASSERT(pPage->pFreeEnd - pPage->pFreeStart == nFree); + SCellIdx *aCellIdx = (SCellIdx *)tdbOsMalloc(sizeof(SCellIdx) * nCell); + if (aCellIdx == NULL) return -1; + for (int32_t iCell = 0; iCell < nCell; iCell++) { + aCellIdx[iCell].iCell = iCell; + aCellIdx[iCell].offset = TDB_PAGE_CELL_OFFSET_AT(pPage, iCell); + } + taosSort(aCellIdx, nCell, sizeof(SCellIdx), tCellIdxCmprFn); + + SCell *pNextCell = (u8 *)pPage->pPageFtr; + for (int32_t iCell = nCell - 1; iCell >= 0; iCell--) { + SCell *pCell = TDB_PAGE_CELL_AT(pPage, aCellIdx[iCell].iCell); + int32_t szCell = pPage->xCellSize(pPage, pCell, 0, NULL, NULL); + + ASSERT(pNextCell - szCell >= pCell); + + pNextCell -= szCell; + if (pNextCell > pCell) { + memmove(pNextCell, pCell, szCell); + TDB_PAGE_CELL_OFFSET_AT_SET(pPage, aCellIdx[iCell].iCell, pNextCell - pPage->pData); + } + } + pPage->pFreeEnd = pNextCell; TDB_PAGE_CCELLS_SET(pPage, pPage->pFreeEnd - pPage->pData); TDB_PAGE_FCELL_SET(pPage, 0); + tdbOsFree(aCellIdx); + + ASSERT(pPage->pFreeEnd - pPage->pFreeStart == nFree); return 0; } diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 62d82edeb1..63e88b0a12 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -457,6 +457,11 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { SPgno journalSize = 0; int ret; + if (pTxn->jfd == 0) { + // txn is commited + return 0; + } + // sync the journal file ret = tdbOsFSync(pTxn->jfd); if (ret < 0) { diff --git a/source/libs/tdb/test/CMakeLists.txt b/source/libs/tdb/test/CMakeLists.txt index 2621e02b02..fd4d7c101d 100644 --- a/source/libs/tdb/test/CMakeLists.txt +++ b/source/libs/tdb/test/CMakeLists.txt @@ -6,7 +6,11 @@ target_link_libraries(tdbTest tdb gtest gtest_main) add_executable(tdbUtilTest "tdbUtilTest.cpp") target_link_libraries(tdbUtilTest tdb gtest gtest_main) -# tdbUtilTest +# overflow pages testing add_executable(tdbExOVFLTest "tdbExOVFLTest.cpp") target_link_libraries(tdbExOVFLTest tdb gtest gtest_main) +# page defragment testing +add_executable(tdbPageDefragmentTest "tdbPageDefragmentTest.cpp") +target_link_libraries(tdbPageDefragmentTest tdb gtest gtest_main) + diff --git a/source/libs/tdb/test/tdbPageDefragmentTest.cpp b/source/libs/tdb/test/tdbPageDefragmentTest.cpp new file mode 100644 index 0000000000..7aeef94d14 --- /dev/null +++ b/source/libs/tdb/test/tdbPageDefragmentTest.cpp @@ -0,0 +1,722 @@ +#include + +#define ALLOW_FORBID_FUNC +#include "os.h" +#include "tdb.h" + +#include +#include +#include +#include +#include "tlog.h" + +typedef struct SPoolMem { + int64_t size; + struct SPoolMem *prev; + struct SPoolMem *next; +} SPoolMem; + +static SPoolMem *openPool() { + SPoolMem *pPool = (SPoolMem *)taosMemoryMalloc(sizeof(*pPool)); + + pPool->prev = pPool->next = pPool; + pPool->size = 0; + + return pPool; +} + +static void clearPool(SPoolMem *pPool) { + SPoolMem *pMem; + + do { + pMem = pPool->next; + + if (pMem == pPool) break; + + pMem->next->prev = pMem->prev; + pMem->prev->next = pMem->next; + pPool->size -= pMem->size; + + taosMemoryFree(pMem); + } while (1); + + assert(pPool->size == 0); +} + +static void closePool(SPoolMem *pPool) { + clearPool(pPool); + taosMemoryFree(pPool); +} + +static void *poolMalloc(void *arg, size_t size) { + void *ptr = NULL; + SPoolMem *pPool = (SPoolMem *)arg; + SPoolMem *pMem; + + pMem = (SPoolMem *)taosMemoryMalloc(sizeof(*pMem) + size); + if (pMem == NULL) { + assert(0); + } + + pMem->size = sizeof(*pMem) + size; + pMem->next = pPool->next; + pMem->prev = pPool; + + pPool->next->prev = pMem; + pPool->next = pMem; + pPool->size += pMem->size; + + ptr = (void *)(&pMem[1]); + return ptr; +} + +static void poolFree(void *arg, void *ptr) { + SPoolMem *pPool = (SPoolMem *)arg; + SPoolMem *pMem; + + pMem = &(((SPoolMem *)ptr)[-1]); + + pMem->next->prev = pMem->prev; + pMem->prev->next = pMem->next; + pPool->size -= pMem->size; + + taosMemoryFree(pMem); +} + +static int tKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2) { + int k1, k2; + + std::string s1((char *)pKey1 + 3, kLen1 - 3); + std::string s2((char *)pKey2 + 3, kLen2 - 3); + k1 = stoi(s1); + k2 = stoi(s2); + + if (k1 < k2) { + return -1; + } else if (k1 > k2) { + return 1; + } else { + return 0; + } +} + +static int tDefaultKeyCmpr(const void *pKey1, int keyLen1, const void *pKey2, int keyLen2) { + int mlen; + int cret; + + ASSERT(keyLen1 > 0 && keyLen2 > 0 && pKey1 != NULL && pKey2 != NULL); + + mlen = keyLen1 < keyLen2 ? keyLen1 : keyLen2; + cret = memcmp(pKey1, pKey2, mlen); + if (cret == 0) { + if (keyLen1 < keyLen2) { + cret = -1; + } else if (keyLen1 > keyLen2) { + cret = 1; + } else { + cret = 0; + } + } + return cret; +} + +// TEST(TdbPageDefragmentTest, DISABLED_TbUpsertTest) { +// TEST(TdbPageDefragmentTest, TbUpsertTest) { +//} + +// TEST(TdbPageDefragmentTest, DISABLED_TbPGetTest) { +// TEST(TdbPageDefragmentTest, TbPGetTest) { +//} + +static void generateBigVal(char *val, int valLen) { + for (int i = 0; i < valLen; ++i) { + char c = char(i & 0xff); + if (c == 0) { + c = 1; + } + val[i] = c; + } +} + +static TDB *openEnv(char const *envName, int const pageSize, int const pageNum) { + TDB *pEnv = NULL; + + int ret = tdbOpen(envName, pageSize, pageNum, &pEnv, 0); + if (ret) { + pEnv = NULL; + } + + return pEnv; +} + +static void insertOfp(void) { + int ret = 0; + + taosRemoveDir("tdb"); + + // open Env + int const pageSize = 4096; + int const pageNum = 64; + TDB *pEnv = openEnv("tdb", pageSize, pageNum); + GTEST_ASSERT_NE(pEnv, nullptr); + + // open db + TTB *pDb = NULL; + tdb_cmpr_fn_t compFunc = tKeyCmpr; + // ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb, 0); + ret = tdbTbOpen("ofp_insert.db", 12, -1, compFunc, pEnv, &pDb, 0); + GTEST_ASSERT_EQ(ret, 0); + + // open the pool + SPoolMem *pPool = openPool(); + + // start a transaction + TXN *txn = NULL; + + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + + // generate value payload + // char val[((4083 - 4 - 3 - 2) + 1) * 100]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + char val[32605]; + int valLen = sizeof(val) / sizeof(val[0]); + generateBigVal(val, valLen); + + // insert the generated big data + // char const *key = "key1"; + char const *key = "key123456789"; + ret = tdbTbInsert(pDb, key, strlen(key), val, valLen, txn); + GTEST_ASSERT_EQ(ret, 0); + + // commit current transaction + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); +} + +TEST(TdbPageDefragmentTest, DISABLED_TbInsertTest) { + // TEST(TdbPageDefragmentTest, TbInsertTest) { + // ofp inserting + insertOfp(); +} + +TEST(TdbPageDefragmentTest, DISABLED_TbGetTest) { + // TEST(TdbPageDefragmentTest, TbGetTest) { + insertOfp(); + + // open Env + int const pageSize = 4096; + int const pageNum = 64; + TDB *pEnv = openEnv("tdb", pageSize, pageNum); + GTEST_ASSERT_NE(pEnv, nullptr); + + // open db + TTB *pDb = NULL; + tdb_cmpr_fn_t compFunc = tKeyCmpr; + // int ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb, 0); + int ret = tdbTbOpen("ofp_insert.db", 12, -1, compFunc, pEnv, &pDb, 0); + GTEST_ASSERT_EQ(ret, 0); + + // generate value payload + // char val[((4083 - 4 - 3 - 2) + 1) * 100]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + char val[32605]; + int valLen = sizeof(val) / sizeof(val[0]); + generateBigVal(val, valLen); + + { // Query the data + void *pVal = NULL; + int vLen; + + // char const *key = "key1"; + char const *key = "key123456789"; + ret = tdbTbGet(pDb, key, strlen(key), &pVal, &vLen); + ASSERT(ret == 0); + GTEST_ASSERT_EQ(ret, 0); + + GTEST_ASSERT_EQ(vLen, valLen); + GTEST_ASSERT_EQ(memcmp(val, pVal, vLen), 0); + + tdbFree(pVal); + } +} + +TEST(TdbPageDefragmentTest, DISABLED_TbDeleteTest) { + // TEST(TdbPageDefragmentTest, TbDeleteTest) { + int ret = 0; + + taosRemoveDir("tdb"); + + // open Env + int const pageSize = 4096; + int const pageNum = 64; + TDB *pEnv = openEnv("tdb", pageSize, pageNum); + GTEST_ASSERT_NE(pEnv, nullptr); + + // open db + TTB *pDb = NULL; + tdb_cmpr_fn_t compFunc = tKeyCmpr; + ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb, 0); + GTEST_ASSERT_EQ(ret, 0); + + // open the pool + SPoolMem *pPool = openPool(); + + // start a transaction + TXN *txn; + + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + + // generate value payload + // char val[((4083 - 4 - 3 - 2) + 1) * 100]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + char val[((4083 - 4 - 3 - 2) + 1) * 2]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + int valLen = sizeof(val) / sizeof(val[0]); + generateBigVal(val, valLen); + + { // insert the generated big data + ret = tdbTbInsert(pDb, "key1", strlen("key1"), val, valLen, txn); + GTEST_ASSERT_EQ(ret, 0); + } + + { // query the data + void *pVal = NULL; + int vLen; + + ret = tdbTbGet(pDb, "key1", strlen("key1"), &pVal, &vLen); + ASSERT(ret == 0); + GTEST_ASSERT_EQ(ret, 0); + + GTEST_ASSERT_EQ(vLen, valLen); + GTEST_ASSERT_EQ(memcmp(val, pVal, vLen), 0); + + tdbFree(pVal); + } + /* open to debug committed file +tdbCommit(pEnv, &txn); +tdbTxnClose(&txn); + +++txnid; +tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); +tdbBegin(pEnv, &txn); + */ + { // upsert the data + ret = tdbTbUpsert(pDb, "key1", strlen("key1"), "value1", strlen("value1"), txn); + GTEST_ASSERT_EQ(ret, 0); + } + + { // query the upserted data + void *pVal = NULL; + int vLen; + + ret = tdbTbGet(pDb, "key1", strlen("key1"), &pVal, &vLen); + ASSERT(ret == 0); + GTEST_ASSERT_EQ(ret, 0); + + GTEST_ASSERT_EQ(vLen, strlen("value1")); + GTEST_ASSERT_EQ(memcmp("value1", pVal, vLen), 0); + + tdbFree(pVal); + } + + { // delete the data + ret = tdbTbDelete(pDb, "key1", strlen("key1"), txn); + GTEST_ASSERT_EQ(ret, 0); + } + + { // query the deleted data + void *pVal = NULL; + int vLen = -1; + + ret = tdbTbGet(pDb, "key1", strlen("key1"), &pVal, &vLen); + ASSERT(ret == -1); + GTEST_ASSERT_EQ(ret, -1); + + GTEST_ASSERT_EQ(vLen, -1); + GTEST_ASSERT_EQ(pVal, nullptr); + + tdbFree(pVal); + } + + // commit current transaction + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); +} + +TEST(TdbPageDefragmentTest, DISABLED_simple_insert1) { + // TEST(TdbPageDefragmentTest, simple_insert1) { + int ret; + TDB *pEnv; + TTB *pDb; + tdb_cmpr_fn_t compFunc; + int nData = 1; + TXN *txn; + int const pageSize = 4096; + + taosRemoveDir("tdb"); + + // Open Env + ret = tdbOpen("tdb", pageSize, 64, &pEnv, 0); + GTEST_ASSERT_EQ(ret, 0); + + // Create a database + compFunc = tKeyCmpr; + ret = tdbTbOpen("db.db", -1, -1, compFunc, pEnv, &pDb, 0); + GTEST_ASSERT_EQ(ret, 0); + + { + char key[64]; + // char val[(4083 - 4 - 3 - 2)]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + char val[(4083 - 4 - 3 - 2) + 1]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + int64_t poolLimit = 4096; // 1M pool limit + SPoolMem *pPool; + + // open the pool + pPool = openPool(); + + // start a transaction + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + + for (int iData = 1; iData <= nData; iData++) { + sprintf(key, "key0"); + sprintf(val, "value%d", iData); + + // ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), &txn); + // GTEST_ASSERT_EQ(ret, 0); + + // generate value payload + int valLen = sizeof(val) / sizeof(val[0]); + for (int i = 6; i < valLen; ++i) { + char c = char(i & 0xff); + if (c == 0) { + c = 1; + } + val[i] = c; + } + + ret = tdbTbInsert(pDb, "key1", strlen("key1"), val, valLen, txn); + GTEST_ASSERT_EQ(ret, 0); + + // if pool is full, commit the transaction and start a new one + if (pPool->size >= poolLimit) { + // commit current transaction + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); + + // start a new transaction + clearPool(pPool); + + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + } + } + + // commit the transaction + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); + + { // Query the data + void *pVal = NULL; + int vLen; + + for (int i = 1; i <= nData; i++) { + sprintf(key, "key%d", i); + // sprintf(val, "value%d", i); + + ret = tdbTbGet(pDb, key, strlen(key), &pVal, &vLen); + ASSERT(ret == 0); + GTEST_ASSERT_EQ(ret, 0); + + GTEST_ASSERT_EQ(vLen, sizeof(val) / sizeof(val[0])); + GTEST_ASSERT_EQ(memcmp(val, pVal, vLen), 0); + } + + tdbFree(pVal); + } + + { // Iterate to query the DB data + TBC *pDBC; + void *pKey = NULL; + void *pVal = NULL; + int vLen, kLen; + int count = 0; + + ret = tdbTbcOpen(pDb, &pDBC, NULL); + GTEST_ASSERT_EQ(ret, 0); + + tdbTbcMoveToFirst(pDBC); + + for (;;) { + ret = tdbTbcNext(pDBC, &pKey, &kLen, &pVal, &vLen); + if (ret < 0) break; + + // std::cout.write((char *)pKey, kLen) /* << " " << kLen */ << " "; + // std::cout.write((char *)pVal, vLen) /* << " " << vLen */; + // std::cout << std::endl; + + count++; + } + + GTEST_ASSERT_EQ(count, nData); + + tdbTbcClose(pDBC); + + tdbFree(pKey); + tdbFree(pVal); + } + } + + ret = tdbTbDrop(pDb); + GTEST_ASSERT_EQ(ret, 0); + + // Close a database + tdbTbClose(pDb); + + // Close Env + ret = tdbClose(pEnv); + GTEST_ASSERT_EQ(ret, 0); +} + +// TEST(TdbPageDefragmentTest, DISABLED_seq_insert) { +TEST(TdbPageDefragmentTest, seq_insert) { + int ret = 0; + TDB *pEnv = NULL; + TTB *pDb = NULL; + tdb_cmpr_fn_t compFunc; + int nData = 64 * 1024; + TXN *txn = NULL; + int const pageSize = 1 * 1024 * 1024; + + taosRemoveDir("tdb"); + + // Open Env + ret = tdbOpen("tdb", pageSize, 64, &pEnv, 0); + GTEST_ASSERT_EQ(ret, 0); + + // Create a database + compFunc = tKeyCmpr; + ret = tdbTbOpen("db.db", -1, -1, compFunc, pEnv, &pDb, 0); + GTEST_ASSERT_EQ(ret, 0); + + // 1, insert nData kv + { + char key[64]; + // char val[(4083 - 4 - 3 - 2)]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + char val[(4083 - 4 - 3 - 2) + 1]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + int64_t poolLimit = 4096; // 1M pool limit + SPoolMem *pPool; + + // open the pool + pPool = openPool(); + + // start a transaction + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + + for (int iData = 0; iData < nData; ++iData) { + sprintf(key, "key%d", iData); + sprintf(val, "value%d", iData); + + ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), txn); + GTEST_ASSERT_EQ(ret, 0); + /* + // generate value payload + int valLen = sizeof(val) / sizeof(val[0]); + for (int i = 6; i < valLen; ++i) { + char c = char(i & 0xff); + if (c == 0) { + c = 1; + } + val[i] = c; + } + + ret = tdbTbInsert(pDb, key, strlen(key), val, valLen, txn); + GTEST_ASSERT_EQ(ret, 0); + */ + // if pool is full, commit the transaction and start a new one + if (pPool->size >= poolLimit) { + // commit current transaction + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); + + // start a new transaction + clearPool(pPool); + + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + } + } + + // commit the transaction + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); + + // 2, delete nData/2 records + } + + // Close a database + tdbTbClose(pDb); + + // Close Env + ret = tdbClose(pEnv); + GTEST_ASSERT_EQ(ret, 0); +} + +// TEST(TdbPageDefragmentTest, DISABLED_seq_delete) { +TEST(TdbPageDefragmentTest, seq_delete) { + int ret = 0; + TDB *pEnv = NULL; + TTB *pDb = NULL; + tdb_cmpr_fn_t compFunc; + int nData = 64 * 1024; + TXN *txn = NULL; + int const pageSize = 1 * 1024 * 1024; + + // Open Env + ret = tdbOpen("tdb", pageSize, 64, &pEnv, 0); + GTEST_ASSERT_EQ(ret, 0); + + // Create a database + compFunc = tKeyCmpr; + ret = tdbTbOpen("db.db", -1, -1, compFunc, pEnv, &pDb, 0); + GTEST_ASSERT_EQ(ret, 0); + + // 2, delete nData/2 records + { + char key[64]; + // char val[(4083 - 4 - 3 - 2)]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + char val[(4083 - 4 - 3 - 2) + 1]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + int64_t poolLimit = 4096; // 1M pool limit + SPoolMem *pPool; + + // open the pool + pPool = openPool(); + + // start a transaction + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + + for (int iData = 1; iData <= nData; iData++) { + if (iData % 2 == 0) continue; + + sprintf(key, "key%d", iData); + sprintf(val, "value%d", iData); + + { // delete the data + ret = tdbTbDelete(pDb, key, strlen(key), txn); + GTEST_ASSERT_EQ(ret, 0); + } + + /* + // generate value payload + int valLen = sizeof(val) / sizeof(val[0]); + for (int i = 6; i < valLen; ++i) { + char c = char(i & 0xff); + if (c == 0) { + c = 1; + } + val[i] = c; + } + + ret = tdbTbInsert(pDb, key, strlen(key), val, valLen, txn); + GTEST_ASSERT_EQ(ret, 0); + */ + // if pool is full, commit the transaction and start a new one + if (pPool->size >= poolLimit) { + // commit current transaction + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); + + // start a new transaction + clearPool(pPool); + + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + } + } + + // commit the transaction + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); + } + + // Close a database + tdbTbClose(pDb); + + // Close Env + ret = tdbClose(pEnv); + GTEST_ASSERT_EQ(ret, 0); +} + +// TEST(TdbPageDefragmentTest, DISABLED_defragment_insert) { +TEST(TdbPageDefragmentTest, defragment_insert) { + int ret = 0; + TDB *pEnv = NULL; + TTB *pDb = NULL; + tdb_cmpr_fn_t compFunc; + int nData = 64 * 1024; + TXN *txn = NULL; + int const pageSize = 1 * 1024 * 1024; + + // Open Env + ret = tdbOpen("tdb", pageSize, 64, &pEnv, 0); + GTEST_ASSERT_EQ(ret, 0); + + // Create a database + compFunc = tKeyCmpr; + ret = tdbTbOpen("db.db", -1, -1, compFunc, pEnv, &pDb, 0); + GTEST_ASSERT_EQ(ret, 0); + + // 3, insert 32k records + { + char key[64]; + // char val[(4083 - 4 - 3 - 2)]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + char val[(4083 - 4 - 3 - 2) + 1]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4) + int64_t poolLimit = 4096; // 1M pool limit + SPoolMem *pPool; + + // open the pool + pPool = openPool(); + + // start a transaction + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + + for (int iData = nData + 1; iData <= nData * 2; iData++) { + // if (iData % 2 == 0) continue; + sprintf(key, "key%d", iData); + sprintf(val, "value%d", iData); + + ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), txn); + GTEST_ASSERT_EQ(ret, 0); + /* + // generate value payload + int valLen = sizeof(val) / sizeof(val[0]); + for (int i = 6; i < valLen; ++i) { + char c = char(i & 0xff); + if (c == 0) { + c = 1; + } + val[i] = c; + } + + ret = tdbTbInsert(pDb, key, strlen(key), val, valLen, txn); + GTEST_ASSERT_EQ(ret, 0); + */ + // if pool is full, commit the transaction and start a new one + if (pPool->size >= poolLimit) { + // commit current transaction + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); + + // start a new transaction + clearPool(pPool); + + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + } + } + + // commit the transaction + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); + + // 2, delete nData/2 records + } + + // Close a database + tdbTbClose(pDb); + + // Close Env + ret = tdbClose(pEnv); + GTEST_ASSERT_EQ(ret, 0); +} diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 1a99db5f99..111742a6f4 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -671,7 +671,7 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) { conn->stream = (uv_stream_t*)taosMemoryMalloc(sizeof(uv_tcp_t)); uv_tcp_init(pThrd->loop, (uv_tcp_t*)(conn->stream)); conn->stream->data = conn; - transSetConnOption((uv_tcp_t*)conn->stream); + // transSetConnOption((uv_tcp_t*)conn->stream); uv_timer_t* timer = taosArrayGetSize(pThrd->timerList) > 0 ? *(uv_timer_t**)taosArrayPop(pThrd->timerList) : NULL; if (timer == NULL) { @@ -778,7 +778,7 @@ static void cliSendCb(uv_write_t* req, int status) { SCliMsg* pMsg = !transQueueEmpty(&pConn->cliMsgs) ? transQueueGet(&pConn->cliMsgs, 0) : NULL; if (pMsg != NULL) { int64_t cost = taosGetTimestampUs() - pMsg->st; - if (cost > 1000) { + if (cost > 1000 * 20) { tWarn("%s conn %p send cost:%dus, send exception", CONN_GET_INST_LABEL(pConn), pConn, (int)cost); } } @@ -800,9 +800,12 @@ static void cliSendCb(uv_write_t* req, int status) { } void cliSend(SCliConn* pConn) { - bool empty = transQueueEmpty(&pConn->cliMsgs); - ASSERTS(empty == false, "trans-cli get invalid msg"); - if (empty == true) { + SCliThrd* pThrd = pConn->hostThrd; + STrans* pTransInst = pThrd->pTransInst; + + if (transQueueEmpty(&pConn->cliMsgs)) { + tError("%s conn %p not msg to send", pTransInst->label, pConn); + cliHandleExcept(pConn); return; } @@ -812,9 +815,6 @@ void cliSend(SCliConn* pConn) { STransConnCtx* pCtx = pCliMsg->ctx; - SCliThrd* pThrd = pConn->hostThrd; - STrans* pTransInst = pThrd->pTransInst; - STransMsg* pMsg = (STransMsg*)(&pCliMsg->msg); if (pMsg->pCont == 0) { pMsg->pCont = (void*)rpcMallocCont(0); @@ -1045,6 +1045,12 @@ static FORCE_INLINE uint32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn) uint32_t* v = taosHashGet(cache, fqdn, strlen(fqdn)); if (v == NULL) { addr = taosGetIpv4FromFqdn(fqdn); + if (addr == 0xffffffff) { + terrno = TAOS_SYSTEM_ERROR(errno); + tError("failed to get ip from fqdn:%s since %s", fqdn, terrstr()); + return addr; + } + taosHashPut(cache, fqdn, strlen(fqdn), &addr, sizeof(addr)); } else { addr = *v; @@ -1061,9 +1067,10 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { STransConnCtx* pCtx = pMsg->ctx; cliMayCvtFqdnToIp(&pCtx->epSet, &pThrd->cvtAddr); + STraceId* trace = &pMsg->msg.info.traceId; if (!EPSET_IS_VALID(&pCtx->epSet)) { - tError("invalid epset"); + tGError("%s, msg %s sent with invalid epset", pTransInst->label, TMSG_INFO(pMsg->msg.msgType)); destroyCmsg(pMsg); return; } @@ -1116,15 +1123,45 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { conn->ip = strdup(EPSET_GET_INUSE_IP(&pCtx->epSet)); conn->port = EPSET_GET_INUSE_PORT(&pCtx->epSet); + uint32_t ipaddr = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, conn->ip); + if (ipaddr == 0xffffffff) { + uv_timer_stop(conn->timer); + conn->timer->data = NULL; + taosArrayPush(pThrd->timerList, &conn->timer); + conn->timer = NULL; + + cliHandleExcept(conn); + return; + } + struct sockaddr_in addr; addr.sin_family = AF_INET; - addr.sin_addr.s_addr = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, conn->ip); + addr.sin_addr.s_addr = ipaddr; addr.sin_port = (uint16_t)htons((uint16_t)conn->port); - STraceId* trace = &(pMsg->msg.info.traceId); tGTrace("%s conn %p try to connect to %s:%d", pTransInst->label, conn, conn->ip, conn->port); + int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 4); + if (fd == -1) { + tGError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn, + tstrerror(TAOS_SYSTEM_ERROR(errno))); + cliHandleExcept(conn); + errno = 0; + return; + } + int ret = uv_tcp_open((uv_tcp_t*)conn->stream, fd); + if (ret != 0) { + tGError("%s conn %p failed to set stream, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret)); + cliHandleExcept(conn); + return; + } + ret = transSetConnOption((uv_tcp_t*)conn->stream); + if (ret != 0) { + tGError("%s conn %p failed to set socket opt, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret)); + cliHandleExcept(conn); + return; + } - int ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb); + ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb); if (ret != 0) { tGError("%s conn %p failed to connect to %s:%d, reason:%s", pTransInst->label, conn, conn->ip, conn->port, uv_err_name(ret)); @@ -1139,7 +1176,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { } uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0); } - STraceId* trace = &pMsg->msg.info.traceId; tGTrace("%s conn %p ready", pTransInst->label, conn); } static void cliAsyncCb(uv_async_t* handle) { @@ -1275,7 +1311,11 @@ void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, for (int i = 0; i < cli->numOfThreads; i++) { SCliThrd* pThrd = createThrdObj(shandle); - int err = taosThreadCreate(&pThrd->thread, NULL, cliWorkThread, (void*)(pThrd)); + if (pThrd == NULL) { + return NULL; + } + + int err = taosThreadCreate(&pThrd->thread, NULL, cliWorkThread, (void*)(pThrd)); if (err == 0) { tDebug("success to create tranport-cli thread:%d", i); } @@ -1332,9 +1372,23 @@ static SCliThrd* createThrdObj(void* trans) { taosThreadMutexInit(&pThrd->msgMtx, NULL); pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); - uv_loop_init(pThrd->loop); - + int err = uv_loop_init(pThrd->loop); + if (err != 0) { + tError("failed to init uv_loop, reason:%s", uv_err_name(err)); + taosMemoryFree(pThrd->loop); + taosThreadMutexDestroy(&pThrd->msgMtx); + taosMemoryFree(pThrd); + return NULL; + } pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 8, pThrd, cliAsyncCb); + if (pThrd->asyncPool == NULL) { + tError("failed to init async pool"); + uv_loop_close(pThrd->loop); + taosMemoryFree(pThrd->loop); + taosThreadMutexDestroy(&pThrd->msgMtx); + taosMemoryFree(pThrd); + return NULL; + } pThrd->prepare = taosMemoryCalloc(1, sizeof(uv_prepare_t)); uv_prepare_init(pThrd->loop, pThrd->prepare); diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 1161ed7c00..4c107a88f1 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -205,6 +205,10 @@ bool transReadComplete(SConnBuffer* connBuf) { } int transSetConnOption(uv_tcp_t* stream) { +#if defined(WINDOWS) || defined(DARWIN) +#else + uv_tcp_keepalive(stream, 1, 20); +#endif return uv_tcp_nodelay(stream, 1); // int ret = uv_tcp_keepalive(stream, 5, 60); } @@ -214,24 +218,37 @@ SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb) pool->nAsync = sz; pool->asyncs = taosMemoryCalloc(1, sizeof(uv_async_t) * pool->nAsync); - for (int i = 0; i < pool->nAsync; i++) { + int i = 0, err = 0; + for (i = 0; i < pool->nAsync; i++) { + uv_async_t* async = &(pool->asyncs[i]); + SAsyncItem* item = taosMemoryCalloc(1, sizeof(SAsyncItem)); item->pThrd = arg; QUEUE_INIT(&item->qmsg); taosThreadMutexInit(&item->mtx, NULL); - uv_async_t* async = &(pool->asyncs[i]); - uv_async_init(loop, async, cb); async->data = item; + err = uv_async_init(loop, async, cb); + if (err != 0) { + tError("failed to init async, reason:%s", uv_err_name(err)); + break; + } } + + if (i != pool->nAsync) { + transAsyncPoolDestroy(pool); + pool = NULL; + } + return pool; } void transAsyncPoolDestroy(SAsyncPool* pool) { for (int i = 0; i < pool->nAsync; i++) { uv_async_t* async = &(pool->asyncs[i]); - SAsyncItem* item = async->data; + if (item == NULL) continue; + taosThreadMutexDestroy(&item->mtx); taosMemoryFree(item); } diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 44e88a4dcc..a547378967 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -325,6 +325,35 @@ bool walLogEntriesComplete(const SWal* pWal) { return complete; } +int walTrimIdxFile(SWal* pWal, int32_t fileIdx) { + SWalFileInfo* pFileInfo = taosArrayGet(pWal->fileInfoSet, fileIdx); + ASSERT(pFileInfo != NULL); + char fnameStr[WAL_FILE_LEN]; + walBuildIdxName(pWal, pFileInfo->firstVer, fnameStr); + + int64_t fileSize = 0; + taosStatFile(fnameStr, &fileSize, NULL); + int64_t records = TMAX(0, pFileInfo->lastVer - pFileInfo->firstVer + 1); + int64_t lastEndOffset = records * sizeof(SWalIdxEntry); + + if (fileSize <= lastEndOffset) { + return 0; + } + + TdFilePtr pFile = taosOpenFile(fnameStr, TD_FILE_READ | TD_FILE_WRITE); + if (pFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + wInfo("vgId:%d, trim idx file. file: %s, size: %" PRId64 ", offset: %" PRId64, pWal->cfg.vgId, fnameStr, fileSize, + lastEndOffset); + + taosFtruncateFile(pFile, lastEndOffset); + taosCloseFile(&pFile); + return 0; +} + int walCheckAndRepairMeta(SWal* pWal) { // load log files, get first/snapshot/last version info const char* logPattern = "^[0-9]+.log$"; @@ -402,6 +431,8 @@ int walCheckAndRepairMeta(SWal* pWal) { } updateMeta = true; + (void)walTrimIdxFile(pWal, fileIdx); + int64_t lastVer = walScanLogGetLastVer(pWal, fileIdx); if (lastVer < 0) { if (terrno != TSDB_CODE_WAL_LOG_NOT_EXIST) { @@ -567,6 +598,7 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) { goto _err; } + int64_t count = 0; while (idxEntry.ver < pFileInfo->lastVer) { ASSERT(idxEntry.ver == ckHead.head.version); @@ -578,11 +610,11 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) { idxEntry.offset, fLogNameStr); goto _err; } - wWarn("vgId:%d, wal idx append new entry %" PRId64 " %" PRId64, pWal->cfg.vgId, idxEntry.ver, idxEntry.offset); if (taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)) < 0) { wError("vgId:%d, failed to append file since %s. file:%s", pWal->cfg.vgId, terrstr(), fnameStr); goto _err; } + count++; } if (taosFsyncFile(pIdxFile) < 0) { @@ -590,6 +622,11 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) { goto _err; } + if (count > 0) { + wInfo("vgId:%d, rebuilt %" PRId64 " wal idx entries until lastVer: %" PRId64, pWal->cfg.vgId, count, + pFileInfo->lastVer); + } + (void)taosCloseFile(&pLogFile); (void)taosCloseFile(&pIdxFile); return 0; diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 07228bddd8..0f8f140bd8 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -594,3 +594,12 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { return 0; } + +void walReadReset(SWalReader *pReader) { + taosThreadMutexLock(&pReader->mutex); + taosCloseFile(&pReader->pIdxFile); + taosCloseFile(&pReader->pLogFile); + pReader->curInvalid = 1; + pReader->curFileFirstVer = -1; + taosThreadMutexUnlock(&pReader->mutex); +} diff --git a/source/libs/wal/src/walRef.c b/source/libs/wal/src/walRef.c index e86111109c..43470f4c82 100644 --- a/source/libs/wal/src/walRef.c +++ b/source/libs/wal/src/walRef.c @@ -77,14 +77,41 @@ void walUnrefVer(SWalRef *pRef) { } #endif -SWalRef *walRefCommittedVer(SWal *pWal) { - SWalRef *pRef = walOpenRef(pWal); +SWalRef *walRefFirstVer(SWal *pWal, SWalRef *pRef) { if (pRef == NULL) { - return NULL; + pRef = walOpenRef(pWal); + if (pRef == NULL) { + return NULL; + } } taosThreadMutexLock(&pWal->mutex); - int64_t ver = walGetCommittedVer(pWal); + int64_t ver = walGetFirstVer(pWal); + + wDebug("vgId:%d, wal ref version %" PRId64 " for first", pWal->cfg.vgId, ver); + + pRef->refVer = ver; + // bsearch in fileSet + SWalFileInfo tmpInfo; + tmpInfo.firstVer = ver; + SWalFileInfo *pRet = taosArraySearch(pWal->fileInfoSet, &tmpInfo, compareWalFileInfo, TD_LE); + ASSERT(pRet != NULL); + pRef->refFile = pRet->firstVer; + + taosThreadMutexUnlock(&pWal->mutex); + return pRef; +} + +SWalRef *walRefCommittedVer(SWal *pWal) { + SWalRef *pRef = walOpenRef(pWal); + if (pRef == NULL) { + return NULL; + } + taosThreadMutexLock(&pWal->mutex); + + int64_t ver = walGetCommittedVer(pWal); + + wDebug("vgId:%d, wal ref version %" PRId64 " for committed", pWal->cfg.vgId, ver); pRef->refVer = ver; // bsearch in fileSet diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index 3aac5e9775..bc554c48a3 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -37,7 +37,9 @@ if(CHECK_STR2INT_ERROR) add_definitions(-DTD_CHECK_STR_TO_INT_ERROR) endif() target_link_libraries( - os PUBLIC pthread + os + PUBLIC pthread + PUBLIC zlibstatic ) if(TD_WINDOWS) target_link_libraries( @@ -63,4 +65,4 @@ ENDIF () if(${BUILD_TEST}) add_subdirectory(test) -endif(${BUILD_TEST}) \ No newline at end of file +endif(${BUILD_TEST}) diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index 3f527e9130..4cdf4cbdbc 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -15,6 +15,7 @@ #define ALLOW_FORBID_FUNC #include "os.h" #include "osSemaphore.h" +#include "zlib.h" #ifdef WINDOWS #include @@ -830,3 +831,48 @@ bool taosCheckAccessFile(const char *pathname, int32_t tdFileAccessOptions) { } bool taosCheckExistFile(const char *pathname) { return taosCheckAccessFile(pathname, TD_FILE_ACCESS_EXIST_OK); }; + +int32_t taosCompressFile(char *srcFileName, char *destFileName) { + int32_t compressSize = 163840; + int32_t ret = 0; + int32_t len = 0; + char *data = taosMemoryMalloc(compressSize); + gzFile dstFp = NULL; + + TdFilePtr pSrcFile = taosOpenFile(srcFileName, TD_FILE_READ | TD_FILE_STREAM); + if (pSrcFile == NULL) { + ret = -1; + goto cmp_end; + } + + TdFilePtr pFile = taosOpenFile(destFileName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); + if (pFile == NULL) { + ret = -2; + goto cmp_end; + } + + dstFp = gzdopen(pFile->fd, "wb6f"); + if (dstFp == NULL) { + ret = -3; + taosCloseFile(&pFile); + goto cmp_end; + } + + while (!feof(pSrcFile->fp)) { + len = (int32_t)fread(data, 1, compressSize, pSrcFile->fp); + (void)gzwrite(dstFp, data, len); + } + +cmp_end: + if (pSrcFile) { + taosCloseFile(&pSrcFile); + } + + if (dstFp) { + gzclose(dstFp); + } + + taosMemoryFree(data); + + return ret; +} diff --git a/source/os/src/osMath.c b/source/os/src/osMath.c index dddadd5ff6..41c8c9257a 100644 --- a/source/os/src/osMath.c +++ b/source/os/src/osMath.c @@ -32,7 +32,18 @@ void swapStr(char* j, char* J, int width) { } #endif -// todo refactor: 1) move away; 2) use merge sort instead; 3) qsort is not a stable sort actually. -void taosSort(void* arr, int64_t sz, int64_t width, __compar_fn_t compar) { - qsort(arr, sz, width, compar); +int qsortHelper(const void* p1, const void* p2, const void* param) { + __compar_fn_t comparFn = param; + return comparFn(p1, p2); } + +// todo refactor: 1) move away; 2) use merge sort instead; 3) qsort is not a stable sort actually. +void taosSort(void* base, int64_t sz, int64_t width, __compar_fn_t compar) { +#ifdef _ALPINE + void* param = compar; + taosqsort(base, width, sz, param, qsortHelper); +#else + qsort(base, sz, width, compar); +#endif +} + diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index 6611a937f2..6b0bfb3a02 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -55,7 +55,7 @@ typedef struct TdSocket { #endif int refId; SocketFd fd; -} * TdSocketPtr, TdSocket; +} *TdSocketPtr, TdSocket; typedef struct TdSocketServer { #if SOCKET_WITH_LOCK @@ -63,7 +63,7 @@ typedef struct TdSocketServer { #endif int refId; SocketFd fd; -} * TdSocketServerPtr, TdSocketServer; +} *TdSocketServerPtr, TdSocketServer; typedef struct TdEpoll { #if SOCKET_WITH_LOCK @@ -71,7 +71,7 @@ typedef struct TdEpoll { #endif int refId; EpollFd fd; -} * TdEpollPtr, TdEpoll; +} *TdEpollPtr, TdEpoll; #if 0 int32_t taosSendto(TdSocketPtr pSocket, void *buf, int len, unsigned int flags, const struct sockaddr *dest_addr, @@ -944,7 +944,7 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) { iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); if (iResult != 0) { // printf("WSAStartup failed: %d\n", iResult); - return 1; + return 0xFFFFFFFF; } #endif struct addrinfo hints = {0}; @@ -1005,7 +1005,7 @@ int32_t taosGetFqdn(char *fqdn) { // immediately // hints.ai_family = AF_INET; strcpy(fqdn, hostname); - strcpy(fqdn+strlen(hostname), ".local"); + strcpy(fqdn + strlen(hostname), ".local"); #else // __APPLE__ struct addrinfo hints = {0}; struct addrinfo *result = NULL; @@ -1060,7 +1060,7 @@ int32_t taosCreateSocketWithTimeout(uint32_t timeout) { #if defined(WINDOWS) SOCKET fd; #else - int fd; + int fd; #endif if ((fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { return -1; @@ -1071,11 +1071,12 @@ int32_t taosCreateSocketWithTimeout(uint32_t timeout) { return -1; } #elif defined(_TD_DARWIN_64) - uint32_t conn_timeout_ms = timeout * 1000; - if (0 != setsockopt(fd, IPPROTO_TCP, TCP_CONNECTIONTIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) { - taosCloseSocketNoCheck1(fd); - return -1; - } + // invalid config + // uint32_t conn_timeout_ms = timeout * 1000; + // if (0 != setsockopt(fd, IPPROTO_TCP, TCP_CONNECTIONTIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) { + // taosCloseSocketNoCheck1(fd); + // return -1; + //} #else // Linux like systems uint32_t conn_timeout_ms = timeout * 1000; if (0 != setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) { diff --git a/source/os/src/osTime.c b/source/os/src/osTime.c index cd4324a592..685693a709 100644 --- a/source/os/src/osTime.c +++ b/source/os/src/osTime.c @@ -33,6 +33,11 @@ #include //#define TM_YEAR_BASE 1970 //origin #define TM_YEAR_BASE 1900 // slguan + +// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) +// until 00:00:00 January 1, 1970 +static const uint64_t TIMEEPOCH = ((uint64_t)116444736000000000ULL); + /* * We do not implement alternate representations. However, we always * check whether a given modifier is allowed for a certain conversion. @@ -341,15 +346,17 @@ char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm) { int32_t taosGetTimeOfDay(struct timeval *tv) { #ifdef WINDOWS - time_t t; - t = taosGetTimestampSec(); - SYSTEMTIME st; - GetLocalTime(&st); + LARGE_INTEGER t; + FILETIME f; - tv->tv_sec = (long)t; - tv->tv_usec = st.wMilliseconds * 1000; + GetSystemTimeAsFileTime(&f); + t.QuadPart = f.dwHighDateTime; + t.QuadPart <<= 32; + t.QuadPart |= f.dwLowDateTime; - return 0; + t.QuadPart -= TIMEEPOCH; + tv->tv_sec = t.QuadPart / 10000000; + tv->tv_usec = (t.QuadPart % 10000000) / 10; #else return gettimeofday(tv, NULL); #endif @@ -550,37 +557,13 @@ int32_t taosClockGetTime(int clock_id, struct timespec *pTS) { #ifdef WINDOWS LARGE_INTEGER t; FILETIME f; - static FILETIME ff; - static SYSTEMTIME ss; - static LARGE_INTEGER offset; - - static int8_t offsetInit = 0; - static volatile bool offsetInitFinished = false; - int8_t old = atomic_val_compare_exchange_8(&offsetInit, 0, 1); - if (0 == old) { - ss.wYear = 1970; - ss.wMonth = 1; - ss.wDay = 1; - ss.wHour = 0; - ss.wMinute = 0; - ss.wSecond = 0; - ss.wMilliseconds = 0; - SystemTimeToFileTime(&ss, &ff); - offset.QuadPart = ff.dwHighDateTime; - offset.QuadPart <<= 32; - offset.QuadPart |= ff.dwLowDateTime; - offsetInitFinished = true; - } else { - while (!offsetInitFinished) - ; // Ensure initialization is completed. - } GetSystemTimeAsFileTime(&f); t.QuadPart = f.dwHighDateTime; t.QuadPart <<= 32; t.QuadPart |= f.dwLowDateTime; - t.QuadPart -= offset.QuadPart; + t.QuadPart -= TIMEEPOCH; pTS->tv_sec = t.QuadPart / 10000000; pTS->tv_nsec = (t.QuadPart % 10000000) * 100; return (0); diff --git a/source/util/src/talgo.c b/source/util/src/talgo.c index d9319485b7..e373850b3c 100644 --- a/source/util/src/talgo.c +++ b/source/util/src/talgo.c @@ -28,32 +28,26 @@ static void median(void *src, int64_t size, int64_t s, int64_t e, const void *pa void *buf) { int32_t mid = ((int32_t)(e - s) >> 1u) + (int32_t)s; - if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) == 1) { + if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) > 0) { doswap(elePtrAt(src, size, mid), elePtrAt(src, size, s), size, buf); } - if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, e), param) == 1) { + if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, e), param) > 0) { doswap(elePtrAt(src, size, mid), elePtrAt(src, size, s), size, buf); doswap(elePtrAt(src, size, mid), elePtrAt(src, size, e), size, buf); - } else if (comparFn(elePtrAt(src, size, s), elePtrAt(src, size, e), param) == 1) { + } else if (comparFn(elePtrAt(src, size, s), elePtrAt(src, size, e), param) > 0) { doswap(elePtrAt(src, size, s), elePtrAt(src, size, e), size, buf); } ASSERT(comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) <= 0 && comparFn(elePtrAt(src, size, s), elePtrAt(src, size, e), param) <= 0); - -#ifdef _DEBUG_VIEW -// tTagsPrints(src[s], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx); -// tTagsPrints(src[mid], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx); -// tTagsPrints(src[e], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx); -#endif } static void tInsertSort(void *src, int64_t size, int32_t s, int32_t e, const void *param, __ext_compar_fn_t comparFn, void *buf) { for (int32_t i = s + 1; i <= e; ++i) { for (int32_t j = i; j > s; --j) { - if (comparFn(elePtrAt(src, size, j), elePtrAt(src, size, j - 1), param) == -1) { + if (comparFn(elePtrAt(src, size, j), elePtrAt(src, size, j - 1), param) < 0) { doswap(elePtrAt(src, size, j), elePtrAt(src, size, j - 1), size, buf); } else { break; @@ -278,14 +272,4 @@ void taosheapsort(void *base, int32_t size, int32_t len, const void *parcompar, } taosMemoryFree(buf); - /* - char *buf = taosMemoryCalloc(1, size); - - for (i = len - 1; i > 0; i--) { - doswap(elePtrAt(base, size, 0), elePtrAt(base, size, i)); - taosheapadjust(base, size, 0, i - 1, parcompar, compar, parswap, swap, maxroot); - } - - taosMemoryFreeClear(buf); - */ } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 14c3df38a7..d610d26f97 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -287,6 +287,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_STREAM_NOT_EXIST, "Stream not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_STREAM_OPTION, "Invalid stream option") TAOS_DEFINE_ERROR(TSDB_CODE_MND_STREAM_MUST_BE_DELETED, "Stream must be dropped first") TAOS_DEFINE_ERROR(TSDB_CODE_MND_MULTI_REPLICA_SOURCE_DB, "Stream temporarily does not support source db having replica > 1") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_STREAMS, "Too many streams") // mnode-sma TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_ALREADY_EXIST, "SMA already exists") diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 62f074db5b..89dd51a892 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -115,7 +115,6 @@ static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t m static SLogBuff *taosLogBuffNew(int32_t bufSize); static void taosCloseLogByFd(TdFilePtr pFile); static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum); -static int32_t taosCompressFile(char *srcFileName, char *destFileName); static FORCE_INLINE void taosUpdateDaylight() { struct tm Tm, *ptm; @@ -748,50 +747,6 @@ static void *taosAsyncOutputLog(void *param) { return NULL; } -int32_t taosCompressFile(char *srcFileName, char *destFileName) { - int32_t compressSize = 163840; - int32_t ret = 0; - int32_t len = 0; - char *data = taosMemoryMalloc(compressSize); - // gzFile dstFp = NULL; - - // srcFp = fopen(srcFileName, "r"); - TdFilePtr pSrcFile = taosOpenFile(srcFileName, TD_FILE_READ); - if (pSrcFile == NULL) { - ret = -1; - goto cmp_end; - } - - TdFilePtr pFile = taosOpenFile(destFileName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); - if (pFile == NULL) { - ret = -2; - goto cmp_end; - } - - // dstFp = gzdopen(fd, "wb6f"); - // if (dstFp == NULL) { - // ret = -3; - // close(fd); - // goto cmp_end; - // } - // - // while (!feof(srcFp)) { - // len = (int32_t)fread(data, 1, compressSize, srcFp); - // (void)gzwrite(dstFp, data, len); - // } - -cmp_end: - if (pSrcFile) { - taosCloseFile(&pSrcFile); - } - // if (dstFp) { - // gzclose(dstFp); - // } - taosMemoryFree(data); - - return ret; -} - bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...) { if (condition) return false; diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index 7c60862c56..3cecfdff9c 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -5,11 +5,11 @@ #include "thash.h" #include "tlog.h" -#define GET_PAYLOAD_DATA(_p) ((char*)(_p)->pData + POINTER_BYTES) -#define BUF_PAGE_IN_MEM(_p) ((_p)->pData != NULL) +#define GET_PAYLOAD_DATA(_p) ((char*)(_p)->pData + POINTER_BYTES) +#define BUF_PAGE_IN_MEM(_p) ((_p)->pData != NULL) #define CLEAR_BUF_PAGE_IN_MEM_FLAG(_p) ((_p)->pData = NULL) -#define HAS_DATA_IN_DISK(_p) ((_p)->offset >= 0) -#define NO_IN_MEM_AVAILABLE_PAGES(_b) (listNEles((_b)->lruList) >= (_b)->inMemPages) +#define HAS_DATA_IN_DISK(_p) ((_p)->offset >= 0) +#define NO_IN_MEM_AVAILABLE_PAGES(_b) (listNEles((_b)->lruList) >= (_b)->inMemPages) typedef struct SPageDiskInfo { int64_t offset; @@ -17,7 +17,7 @@ typedef struct SPageDiskInfo { } SPageDiskInfo, SFreeListItem; struct SPageInfo { - SListNode* pn; // point to list node struct. it is NULL when the page is evicted from the in-memory buffer + SListNode* pn; // point to list node struct. it is NULL when the page is evicted from the in-memory buffer void* pData; int64_t offset; int32_t pageId; @@ -52,10 +52,13 @@ struct SDiskbasedBuf { }; static int32_t createDiskFile(SDiskbasedBuf* pBuf) { - if (pBuf->path == NULL) { // prepare the file name when needed it + if (pBuf->path == NULL) { // prepare the file name when needed it char path[PATH_MAX] = {0}; taosGetTmpfilePath(pBuf->prefix, "paged-buf", path); pBuf->path = taosMemoryStrDup(path); + if (pBuf->path == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } } pBuf->pFile = @@ -126,6 +129,30 @@ static uint64_t allocateNewPositionInFile(SDiskbasedBuf* pBuf, size_t size) { static FORCE_INLINE size_t getAllocPageSize(int32_t pageSize) { return pageSize + POINTER_BYTES + sizeof(SFilePage); } +static int32_t doFlushBufPageImpl(SDiskbasedBuf* pBuf, int64_t offset, const char* pData, int32_t size) { + int32_t ret = taosLSeekFile(pBuf->pFile, offset, SEEK_SET); + if (ret == -1) { + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } + + ret = (int32_t)taosWriteFile(pBuf->pFile, pData, size); + if (ret != size) { + terrno = TAOS_SYSTEM_ERROR(errno); + return terrno; + } + + // extend the file + if (pBuf->fileSize < offset + size) { + pBuf->fileSize = offset + size; + } + + pBuf->statis.flushBytes += size; + pBuf->statis.flushPages += 1; + + return TSDB_CODE_SUCCESS; +} + static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) { if (pg->pData == NULL || pg->used) { uError("invalid params in paged buffer process when flushing buf to disk, %s", pBuf->id); @@ -134,12 +161,15 @@ static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) { } int32_t size = pBuf->pageSize; - char* t = NULL; + int64_t offset = pg->offset; + + char* t = NULL; if ((!HAS_DATA_IN_DISK(pg)) || pg->dirty) { void* payload = GET_PAYLOAD_DATA(pg); t = doCompressData(payload, pBuf->pageSize, &size, pBuf); if (size < 0) { uError("failed to compress data when flushing data to disk, %s", pBuf->id); + terrno = TSDB_CODE_INVALID_PARA; return NULL; } } @@ -147,59 +177,29 @@ static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) { // this page is flushed to disk for the first time if (pg->dirty) { if (!HAS_DATA_IN_DISK(pg)) { - pg->offset = allocateNewPositionInFile(pBuf, size); + offset = allocateNewPositionInFile(pBuf, size); pBuf->nextPos += size; - int32_t ret = taosLSeekFile(pBuf->pFile, pg->offset, SEEK_SET); - if (ret == -1) { - terrno = TAOS_SYSTEM_ERROR(errno); + int32_t code = doFlushBufPageImpl(pBuf, offset, t, size); + if (code != TSDB_CODE_SUCCESS) { return NULL; } - - ret = (int32_t)taosWriteFile(pBuf->pFile, t, size); - if (ret != size) { - terrno = TAOS_SYSTEM_ERROR(errno); - return NULL; - } - - // extend the file size - if (pBuf->fileSize < pg->offset + size) { - pBuf->fileSize = pg->offset + size; - } - - pBuf->statis.flushBytes += size; - pBuf->statis.flushPages += 1; } else { // length becomes greater, current space is not enough, allocate new place, otherwise, do nothing if (pg->length < size) { // 1. add current space to free list - SPageDiskInfo dinfo = {.length = pg->length, .offset = pg->offset}; + SPageDiskInfo dinfo = {.length = pg->length, .offset = offset}; taosArrayPush(pBuf->pFree, &dinfo); // 2. allocate new position, and update the info - pg->offset = allocateNewPositionInFile(pBuf, size); + offset = allocateNewPositionInFile(pBuf, size); pBuf->nextPos += size; } - // 3. write to disk. - int32_t ret = taosLSeekFile(pBuf->pFile, pg->offset, SEEK_SET); - if (ret == -1) { - terrno = TAOS_SYSTEM_ERROR(errno); + int32_t code = doFlushBufPageImpl(pBuf, offset, t, size); + if (code != TSDB_CODE_SUCCESS) { return NULL; } - - ret = (int32_t)taosWriteFile(pBuf->pFile, t, size); - if (ret != size) { - terrno = TAOS_SYSTEM_ERROR(errno); - return NULL; - } - - if (pBuf->fileSize < pg->offset + size) { - pBuf->fileSize = pg->offset + size; - } - - pBuf->statis.flushBytes += size; - pBuf->statis.flushPages += 1; } } else { // NOTE: the size may be -1, the this recycle page has not been flushed to disk yet. size = pg->length; @@ -209,9 +209,10 @@ static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) { memset(pDataBuf, 0, getAllocPageSize(pBuf->pageSize)); #ifdef BUF_PAGE_DEBUG - uDebug("page_flush %p, pageId:%d, offset:%d", pDataBuf, pg->pageId, pg->offset); + uDebug("page_flush %p, pageId:%d, offset:%d", pDataBuf, pg->pageId, offset); #endif + pg->offset = offset; pg->length = size; // on disk size return pDataBuf; } @@ -236,7 +237,7 @@ static char* flushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) { // load file block data in disk static int32_t loadPageFromDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) { if (pg->offset < 0 || pg->length <= 0) { - uError("failed to load buf page from disk, offset:%"PRId64", length:%d, %s", pg->offset, pg->length, pBuf->id); + uError("failed to load buf page from disk, offset:%" PRId64 ", length:%d, %s", pg->offset, pg->length, pBuf->id); return TSDB_CODE_INVALID_PARA; } @@ -303,6 +304,7 @@ static SListNode* getEldestUnrefedPage(SDiskbasedBuf* pBuf) { static char* evictBufPage(SDiskbasedBuf* pBuf) { SListNode* pn = getEldestUnrefedPage(pBuf); if (pn == NULL) { // no available buffer pages now, return. + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } @@ -382,14 +384,14 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem goto _error; } - pPBuf->prefix = (char*) dir; + pPBuf->prefix = (char*)dir; pPBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t)); // qDebug("QInfo:0x%"PRIx64" create resBuf for output, page size:%d, inmem buf pages:%d, file:%s", qId, // pPBuf->pageSize, pPBuf->inMemPages, pPBuf->path); return TSDB_CODE_SUCCESS; - _error: +_error: destroyDiskbasedBuf(pPBuf); return TSDB_CODE_OUT_OF_MEMORY; } @@ -399,11 +401,12 @@ static char* doExtractPage(SDiskbasedBuf* pBuf) { if (NO_IN_MEM_AVAILABLE_PAGES(pBuf)) { availablePage = evictBufPage(pBuf); if (availablePage == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - uWarn("no available buf pages, current:%d, max:%d", listNEles(pBuf->lruList), pBuf->inMemPages) + uWarn("no available buf pages, current:%d, max:%d, reason: %s, %s", listNEles(pBuf->lruList), pBuf->inMemPages, + terrstr(), pBuf->id) } } else { - availablePage = taosMemoryCalloc(1, getAllocPageSize(pBuf->pageSize)); // add extract bytes in case of zipped buffer increased. + availablePage = + taosMemoryCalloc(1, getAllocPageSize(pBuf->pageSize)); // add extract bytes in case of zipped buffer increased. if (availablePage == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; } @@ -551,9 +554,7 @@ void releaseBufPageInfo(SDiskbasedBuf* pBuf, SPageInfo* pi) { size_t getTotalBufSize(const SDiskbasedBuf* pBuf) { return (size_t)pBuf->totalBufSize; } -SArray* getDataBufPagesIdList(SDiskbasedBuf* pBuf) { - return pBuf->pIdList; -} +SArray* getDataBufPagesIdList(SDiskbasedBuf* pBuf) { return pBuf->pIdList; } void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) { if (pBuf == NULL) { @@ -567,7 +568,7 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) { needRemoveFile = true; uDebug( "Paged buffer closed, total:%.2f Kb (%d Pages), inmem size:%.2f Kb (%d Pages), file size:%.2f Kb, page " - "size:%.2f Kb, %s\n", + "size:%.2f Kb, %s", pBuf->totalBufSize / 1024.0, pBuf->numOfPages, listNEles(pBuf->lruList) * pBuf->pageSize / 1024.0, listNEles(pBuf->lruList), pBuf->fileSize / 1024.0, pBuf->pageSize / 1024.0f, pBuf->id); @@ -584,8 +585,7 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) { ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages); } else { uDebug( - "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f " - "Kb", + "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPgSize:%.2f Kb", ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages)); } @@ -628,9 +628,7 @@ SPageInfo* getLastPageInfo(SArray* pList) { return pPgInfo; } -int32_t getPageId(const SPageInfo* pPgInfo) { - return pPgInfo->pageId; -} +int32_t getPageId(const SPageInfo* pPgInfo) { return pPgInfo->pageId; } int32_t getBufPageSize(const SDiskbasedBuf* pBuf) { return pBuf->pageSize; } @@ -686,7 +684,7 @@ void dBufPrintStatis(const SDiskbasedBuf* pBuf) { ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages)); } else { - //printf("no page loaded\n"); + // printf("no page loaded\n"); } } diff --git a/tests/ci/Dockerfile b/tests/ci/Dockerfile new file mode 100644 index 0000000000..594bcc902d --- /dev/null +++ b/tests/ci/Dockerfile @@ -0,0 +1,48 @@ +FROM python:3.8 +RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple +RUN pip3 install pandas psutil fabric2 requests faker simplejson toml pexpect tzlocal distro +RUN apt-get update +RUN apt-get install -y psmisc sudo tree libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config build-essential valgrind \ + vim libjemalloc-dev openssh-server screen sshpass net-tools dirmngr gnupg apt-transport-https ca-certificates software-properties-common r-base iputils-ping +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 +RUN add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/' +RUN apt install -y r-base +ADD go1.17.6.linux-amd64.tar.gz /usr/local/ +ADD jdk-8u144-linux-x64.tar.gz /usr/local/ +ADD apache-maven-3.8.4-bin.tar.gz /usr/local/ +RUN apt-get install wget -y \ + && wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \ + && dpkg -i packages-microsoft-prod.deb \ + && rm packages-microsoft-prod.deb \ + && apt-get update && apt-get install -y dotnet-sdk-5.0 && apt-get install -y dotnet-sdk-6.0 +ADD node-v12.20.0-linux-x64.tar.gz /usr/local/ +RUN sh -c "rm -f /etc/localtime;ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime;echo \"Asia/Shanghai\" >/etc/timezone" +COPY id_rsa /root/.ssh/id_rsa +COPY .m2 /root/.m2 +COPY .nuget /root/.nuget +COPY .dotnet /root/.dotnet +COPY .cargo /root/.cargo +COPY go /root/go +ADD cmake-3.21.5-linux-x86_64.tar.gz /usr/local/ +RUN echo " export RUSTUP_DIST_SERVER=\"https://rsproxy.cn\" " >> /root/.bashrc +RUN echo " export RUSTUP_UPDATE_ROOT=\"https://rsproxy.cn/rustup\" " >> /root/.bashrc +RUN curl https://sh.rustup.rs -o /tmp/rustup-init.sh +RUN sh /tmp/rustup-init.sh -y +ENV PATH /usr/local/go/bin:/usr/local/node-v12.20.0-linux-x64/bin:/usr/local/apache-maven-3.8.4/bin:/usr/local/jdk1.8.0_144/bin:/usr/local/cmake-3.21.5-linux-x86_64/bin:/root/.cargo/bin:$PATH +ENV JAVA_HOME /usr/local/jdk1.8.0_144 +RUN go env -w GOPROXY=https://goproxy.cn +RUN echo "StrictHostKeyChecking no" >>/etc/ssh/ssh_config +RUN npm config -g set unsafe-perm +RUN npm config -g set registry https://registry.npm.taobao.org +COPY .npm /root/.npm +RUN R CMD javareconf JAVA_HOME=${JAVA_HOME} JAVA=${JAVA_HOME}/bin/java JAVAC=${JAVA_HOME}/bin/javac JAVAH=${JAVA_HOME}/bin/javah JAR=${JAVA_HOME}/bin/jar +RUN echo "install.packages(\"RJDBC\", repos=\"http://cran.us.r-project.org\")"|R --no-save +COPY .gitconfig /root/.gitconfig +RUN mkdir -p /run/sshd +COPY id_rsa.pub /root/.ssh/id_rsa.pub +COPY id_rsa.pub /root/.ssh/authorized_keys +RUN pip3 uninstall -y taostest +COPY repository/TDinternal /home/TDinternal +COPY repository/taos-connector-python /home/taos-connector-python +RUN sh -c "cd /home/taos-connector-python; pip3 install ." +COPY setup.sh /home/setup.sh \ No newline at end of file diff --git a/tests/ci/build_image.sh b/tests/ci/build_image.sh new file mode 100755 index 0000000000..1864df35db --- /dev/null +++ b/tests/ci/build_image.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build --no-cache -t taos_test:v1.0 . + diff --git a/tests/ci/daily_build_image.sh b/tests/ci/daily_build_image.sh new file mode 100755 index 0000000000..01148a3aae --- /dev/null +++ b/tests/ci/daily_build_image.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -x + +script_dir=`dirname $0` +cd $script_dir +script_dir=`pwd` +cd $script_dir/repository/taos-connector-python +git pull + +cd $script_dir/repository/TDinternal +git clean -fxd +git pull + +cd $script_dir/repository/TDinternal/community +git clean -fxd +git checkout main +git pull origin main +git submodule update --init --recursive + +cd $script_dir +cp $script_dir/repository/TDinternal/community/tests/ci/build_image.sh . +cp $script_dir/repository/TDinternal/community/tests/ci/daily_build_image.sh . + +./build_image.sh || exit 1 +docker image prune -f +ips="\ +192.168.1.47 \ +192.168.1.48 \ +192.168.1.49 \ +192.168.1.52 \ +192.168.0.215 \ +192.168.0.217 \ +192.168.0.219 \ +" + +image=taos_image.tar + +docker save taos_test:v1.0 -o $image + +for ip in $ips; do + echo "scp $image root@$ip:/home/ &" + scp $image root@$ip:/home/ & +done +wait + +for ip in $ips; do + echo "ssh root@$ip docker load -i /home/$image &" + ssh root@$ip docker load -i /home/$image & +done +wait + +for ip in $ips; do + echo "ssh root@$ip rm -f /home/$image &" + ssh root@$ip rm -f /home/$image & +done +wait + +rm -rf taos_image.tar + diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py b/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py index 2c6d09b0f5..1b65e38d72 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py +++ b/tests/develop-test/5-taos-tools/taosbenchmark/sml_json_alltypes.py @@ -19,32 +19,38 @@ from util.dnodes import * class TDTestCase: def caseDescription(self): - ''' + """ [TD-11510] taosBenchmark test cases - ''' - return + """ def init(self, conn, logSql, replicaVar=1): - self.replicaVar = int(replicaVar) tdLog.debug("start to execute %s" % __file__) + self.replicaVar = int(replicaVar) tdSql.init(conn.cursor(), logSql) def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] + if "community" in selfPath: + projPath = selfPath[: selfPath.find("community")] + elif "src" in selfPath: + projPath = selfPath[: selfPath.find("src")] + elif "/tools/" in selfPath: + projPath = selfPath[: selfPath.find("/tools/")] + elif "/tests/" in selfPath: + projPath = selfPath[: selfPath.find("/tests/")] else: - projPath = selfPath[:selfPath.find("tests")] + tdLog.info("cannot found %s in path: %s, use system's" % (tool, selfPath)) + projPath = "/usr/local/taos/bin/" paths = [] - for root, dirs, files in os.walk(projPath): - if ((tool) in files): + for root, dummy, files in os.walk(projPath): + if (tool) in files: rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): + if "packaging" not in rootRealPath: paths.append(os.path.join(root, tool)) break - if (len(paths) == 0): + if len(paths) == 0: tdLog.exit("taosBenchmark not found!") return else: @@ -52,31 +58,45 @@ class TDTestCase: return paths[0] def run(self): + tdSql.query("select client_version()") + client_ver = "".join(tdSql.queryResult[0]) + major_ver = client_ver.split(".")[0] + binPath = self.getPath() - cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_json_alltypes.json" %binPath + cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_json_alltypes.json" % binPath tdLog.info("%s" % cmd) os.system("%s" % cmd) tdSql.execute("reset query cache") tdSql.query("describe db.stb1") tdSql.checkData(1, 1, "BOOL") tdSql.query("describe db.stb2") - tdSql.checkData(1, 1, "TINYINT") + tdSql.checkData(1, 1, "DOUBLE") tdSql.query("describe db.stb3") - tdSql.checkData(1, 1, "SMALLINT") + tdSql.checkData(1, 1, "DOUBLE") tdSql.query("describe db.stb4") - tdSql.checkData(1, 1, "INT") + tdSql.checkData(1, 1, "DOUBLE") tdSql.query("describe db.stb5") - tdSql.checkData(1, 1, "BIGINT") + tdSql.checkData(1, 1, "DOUBLE") tdSql.query("describe db.stb6") - tdSql.checkData(1, 1, "FLOAT") + tdSql.checkData(1, 1, "DOUBLE") tdSql.query("describe db.stb7") tdSql.checkData(1, 1, "DOUBLE") tdSql.query("describe db.stb8") - tdSql.checkData(1, 1, "VARCHAR") - tdSql.checkData(1, 2, 16) + if major_ver == "3": + tdSql.checkData(1, 1, "NCHAR") + tdSql.checkData(1, 2, 16) + else: + tdSql.checkData(1, 1, "NCHAR") + tdSql.checkData(1, 2, 8) + tdSql.query("describe db.stb9") - tdSql.checkData(1, 1, "NCHAR") - tdSql.checkData(1, 2, 16) + if major_ver == "3": + tdSql.checkData(1, 1, "NCHAR") + tdSql.checkData(1, 2, 16) + else: + tdSql.checkData(1, 1, "NCHAR") + tdSql.checkData(1, 2, 8) + tdSql.query("select count(*) from db.stb1") tdSql.checkData(0, 0, 160) tdSql.query("select count(*) from db.stb2") diff --git a/tests/docs-examples-test/python.sh b/tests/docs-examples-test/python.sh index 140d05395b..ccb391b752 100644 --- a/tests/docs-examples-test/python.sh +++ b/tests/docs-examples-test/python.sh @@ -23,7 +23,7 @@ python3 bind_param_example.py # 4 taos -s "drop database power" -python3 multi_bind_example.py +python3 multi_bind_example.py # 5 python3 query_example.py @@ -44,4 +44,43 @@ taos -s "drop database test" python3 json_protocol_example.py # 10 -# python3 subscribe_demo.py +pip install SQLAlchemy +pip install pandas +taosBenchmark -y -d power -t 10 -n 10 +python3 conn_native_pandas.py +python3 conn_rest_pandas.py +taos -s "drop database if exists power" + +# 11 +taos -s "create database if not exists test" +python3 connect_native_reference.py + +# 12 +python3 connect_rest_examples.py + +# 13 +python3 handle_exception.py + +# 14 +taosBenchmark -y -d power -t 2 -n 10 +python3 rest_client_example.py +taos -s "drop database if exists power" + +# 15 +python3 result_set_examples.py + +# 16 +python3 tmq_example.py + +# 17 +python3 sql_writer.py + +# 18 +python3 mockdatasource.py + +# 19 +python3 fast_write_example.py + +# 20 +pip3 install kafka-python +python3 kafka_example.py diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index df4cc5f468..33f22896be 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -178,6 +178,7 @@ ,,y,script,./test.sh -f tsim/query/udf_with_const.sim ,,y,script,./test.sh -f tsim/query/sys_tbname.sim ,,y,script,./test.sh -f tsim/query/groupby.sim +,,y,script,./test.sh -f tsim/query/forceFill.sim ,,y,script,./test.sh -f tsim/qnode/basic1.sim ,,y,script,./test.sh -f tsim/snode/basic1.sim ,,y,script,./test.sh -f tsim/mnode/basic1.sim @@ -405,7 +406,7 @@ ,,y,script,./test.sh -f tmp/monitor.sim #system test - +,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/balance_vgroups_r1.py -N 6 ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShell.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellError.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellNetChk.py @@ -1046,6 +1047,11 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -R +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-20582.py diff --git a/tests/parallel_test/container_build.sh b/tests/parallel_test/container_build.sh index 221e549056..ff854449bb 100755 --- a/tests/parallel_test/container_build.sh +++ b/tests/parallel_test/container_build.sh @@ -55,7 +55,7 @@ fi date 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_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true;make -j || exit 1" + --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 -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=true;make -j || exit 1" if [[ -d ${WORKDIR}/debugNoSan ]] ;then echo "delete ${WORKDIR}/debugNoSan" @@ -70,7 +70,7 @@ mv ${REP_REAL_PATH}/debug ${WORKDIR}/debugNoSan date 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_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DTOOLS_BUILD_TYPE=Debug;make -j || exit 1 " + --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 -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=true;make -j || exit 1 " mv ${REP_REAL_PATH}/debug ${WORKDIR}/debugSan diff --git a/tests/script/tsim/compute/block_dist.sim b/tests/script/tsim/compute/block_dist.sim index 2d0a4e8902..4fdcf63e34 100644 --- a/tests/script/tsim/compute/block_dist.sim +++ b/tests/script/tsim/compute/block_dist.sim @@ -91,6 +91,10 @@ print ============== TD-5998 sql_error select _block_dist() from (select * from $nt) sql_error select _block_dist() from (select * from $mt) +print ============== TD-22140 & TD-22165 +sql_error show table distributed information_schema.ins_databases +sql_error show table distributed performance_schema.perf_apps + print =============== clear sql drop database $db sql select * from information_schema.ins_databases diff --git a/tests/script/tsim/db/alter_replica_13.sim b/tests/script/tsim/db/alter_replica_13.sim index d75acb50ad..a9dc1741a1 100644 --- a/tests/script/tsim/db/alter_replica_13.sim +++ b/tests/script/tsim/db/alter_replica_13.sim @@ -79,6 +79,7 @@ sql insert into db.ctb6 values(now, 6, "6") sql insert into db.ctb7 values(now, 7, "7") sql insert into db.ctb8 values(now, 8, "8") sql insert into db.ctb9 values(now, 9, "9") +sql flush database db; print =============== step3: create dnodes sql create dnode $hostname port 7300 diff --git a/tests/script/tsim/parser/interp.sim b/tests/script/tsim/parser/interp.sim index 1b7878178c..e6512a22d7 100644 --- a/tests/script/tsim/parser/interp.sim +++ b/tests/script/tsim/parser/interp.sim @@ -72,4 +72,33 @@ sql_error select interp(*) from nt5931 where ts=now sql_error select interp(*) from st5931 where ts=now sql_error select interp(*) from ct5931 where ts=now +sql create stable sta (ts timestamp, f1 double, f2 binary(200)) tags(t1 int); +sql create table tba1 using sta tags(1); +sql insert into tba1 values ('2022-04-26 15:15:01', -3.0, "a"); +sql insert into tba1 values ('2022-04-26 15:15:05', 3.0, "b"); +sql select a from (select interp(f1) as a from tba1 where ts >= '2022-04-26 15:15:01' and ts <= '2022-04-26 15:15:05' range('2022-04-26 15:15:01','2022-04-26 15:15:05') every(1s) fill(linear)) where a > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 1.500000000 then + return -1 +endi +if $data10 != 3.000000000 then + return -1 +endi + +sql select a from (select interp(f1+1) as a from tba1 where ts >= '2022-04-26 15:15:01' and ts <= '2022-04-26 15:15:05' range('2022-04-26 15:15:01','2022-04-26 15:15:05') every(1s) fill(linear)) where a > 0; +if $rows != 3 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data10 != 2.500000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/regressiontest.sim b/tests/script/tsim/parser/regressiontest.sim index 1b127155cb..6f350b439f 100644 --- a/tests/script/tsim/parser/regressiontest.sim +++ b/tests/script/tsim/parser/regressiontest.sim @@ -15,7 +15,7 @@ $db = $dbPrefix . $i sql drop database if exists $db -x step1 step1: -sql create database $db vgroups 1; +sql create database $db vgroups 1 cachemodel 'last_row' sql use $db sql create table $tb (ts timestamp, c1 int) @@ -31,13 +31,8 @@ sql insert into $tb values ( $ts , $x ) $x = $x + 1 endw -print ================== restart server to commit data into disk -system sh/exec.sh -n dnode1 -s stop -x SIGINT -system sh/exec.sh -n dnode1 -s start -print ================== server restart completed -sql connect +sql flush database $db -sql use $db sql delete from $tb where ts=1537146000000 sql delete from $tb where ts=1537146409500 @@ -63,4 +58,132 @@ if $rows != 8198 then return -1 endi +sql drop database if exists $db -x step1 +sql create database $db vgroups 1; + +sql use $db +sql create stable st1 (ts timestamp, c int) tags(a int); +sql create table t1 using st1 tags(1); +sql create table t2 using st1 tags(2); + +$i = 0 +$ts = 1674977959000 +$rowNum = 200 + +$x = 0 +while $x < $rowNum +$xs = $x * $delta +$ts = $ts0 + $xs +sql insert into t1 values ( $ts , $x ) +sql insert into t2 values ( $ts + 1000a, $x ) +$x = $x + 1 +$ts = $ts + 1000 +endw + +sql flush database $db + +print ===========================> TD-22077 && TD-21877 + +sql insert into t1 values('2018-09-17 09:00:26', 26); +sql insert into t2 values('2018-09-17 09:00:25', 25); + +sql insert into t2 values('2018-09-17 09:00:30', 30); +sql flush database reg_db0; + +sql delete from st1 where ts<='2018-9-17 09:00:26'; +sql select * from st1; + +sql drop table t1 +sql drop table t2 + +print =========================================>TD-22196 +sql create table t1 using st1 tags(1); + +$i = 0 +$ts = 1674977959000 +$rowNum = 200 + +$x = 0 +while $x < $rowNum +$xs = $x * $delta +$ts = $ts0 + $xs +sql insert into t1 values ( $ts , $x ) +$x = $x + 1 +$ts = $ts + 1000 +endw + +sql flush database $db +sql select min(c),max(c) from t1 +if $data00 != 0 then + return -1 +endi + +if $data01 != 199 then + return -1 +endi + +sql drop table t1 + +$rowNum = 8200 +$ts0 = 1537146000000 +sql create table t1 (ts timestamp, c1 int) + +$i = 0 +$ts = $ts0 + +$x = 0 +while $x < $rowNum +$xs = $x * $delta +$ts = $ts0 + $xs +sql insert into t1 values ( $ts , $x ) +$x = $x + 1 +endw + +sql delete from t1 where ts<=1537146409500 + +sql flush database $db + +print =====================================>TD-22007 +sql select count(*) from t1 interval(10a) + +sql drop table t1 + +sql create table st1 (ts timestamp, k int) tags(a int); +sql insert into t1 using st1 tags(1) values('2020-1-1 10:10:10', 0); +sql insert into t2 using st1 tags(1) values('2020-1-1 10:10:11', 1); +sql insert into t3 using st1 tags(1) values('2020-1-1 10:10:12', 2); +sql insert into t4 using st1 tags(1) values('2020-1-1 10:10:13', 3); +sql insert into t5 using st1 tags(1) values('2020-1-1 10:10:14', 4); +sql insert into t6 using st1 tags(2) values('2020-1-1 10:10:15', 5); +sql insert into t7 using st1 tags(2) values('2020-1-1 10:10:16', 6); +sql insert into t8 using st1 tags(2) values('2020-1-1 10:10:17', 7); +sql insert into t9 using st1 tags(2) values('2020-1-1 10:10:18', 8); +sql insert into t10 using st1 tags(2) values('2020-1-1 10:10:19', 9); + +sql select count(*) from st1 +if $data00 != 10 then + return -1 +endi + +sql select last_row(*) from st1 group by a +if $rows != 2 then + return -1 +endi + +if $data00 != @20-01-01 10:10:19.000@ then + return -1 +endi + +if $data01 != 9 then + return -1 +endi + +if $data10 != @20-01-01 10:10:14.000@ then + return -1 +endi + +if $data11 != 4 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/forceFill.sim b/tests/script/tsim/query/forceFill.sim new file mode 100644 index 0000000000..37eb85baaa --- /dev/null +++ b/tests/script/tsim/query/forceFill.sim @@ -0,0 +1,367 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql drop database if exists db1; +sql create database db1 vgroups 10; +sql use db1; +sql create stable sta (ts timestamp, f1 double, f2 binary(200)) tags(t1 int); +sql create table tba1 using sta tags(1); +sql insert into tba1 values ('2022-04-26 15:15:01', 1.0, "a"); +sql insert into tba1 values ('2022-04-26 15:15:02', 2.0, "b"); +sql insert into tba1 values ('2022-04-26 15:15:04', 4.0, "b"); +sql insert into tba1 values ('2022-04-26 15:15:05', 5.0, "b"); + +sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:00' and ts <= '2022-04-26 15:15:06' interval(1s) fill(value_f, 8.8); +if $rows != 7 then + return -1 +endi +if $data00 != 8.800000000 then + return -1 +endi +if $data10 != 1.000000000 then + return -1 +endi +if $data20 != 2.000000000 then + return -1 +endi +if $data30 != 8.800000000 then + return -1 +endi +if $data40 != 4.000000000 then + return -1 +endi +if $data50 != 5.000000000 then + return -1 +endi +if $data60 != 8.800000000 then + return -1 +endi +sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:00' and ts <= '2022-04-26 15:15:06' interval(1s) fill(value, 8.8); +if $rows != 7 then + return -1 +endi +if $data00 != 8.800000000 then + return -1 +endi +if $data10 != 1.000000000 then + return -1 +endi +if $data20 != 2.000000000 then + return -1 +endi +if $data30 != 8.800000000 then + return -1 +endi +if $data40 != 4.000000000 then + return -1 +endi +if $data50 != 5.000000000 then + return -1 +endi +if $data60 != 8.800000000 then + return -1 +endi +sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:00' and ts <= '2022-04-26 15:15:06' interval(1s) fill(null); +if $rows != 7 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != 1.000000000 then + return -1 +endi +if $data20 != 2.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.000000000 then + return -1 +endi +if $data50 != 5.000000000 then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:00' and ts <= '2022-04-26 15:15:06' interval(1s) fill(null_f); +if $rows != 7 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != 1.000000000 then + return -1 +endi +if $data20 != 2.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.000000000 then + return -1 +endi +if $data50 != 5.000000000 then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:06' and ts <= '2022-04-26 15:15:10' interval(1s) fill(value, 8.8); +if $rows != 0 then + return -1 +endi +sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:06' and ts <= '2022-04-26 15:15:10' interval(1s) fill(value_f, 8.8); +if $rows != 5 then + return -1 +endi +if $data00 != 8.800000000 then + return -1 +endi +if $data10 != 8.800000000 then + return -1 +endi +if $data20 != 8.800000000 then + return -1 +endi +if $data30 != 8.800000000 then + return -1 +endi +if $data40 != 8.800000000 then + return -1 +endi +sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:06' and ts <= '2022-04-26 15:15:10' interval(1s) fill(null); +if $rows != 0 then + return -1 +endi +sql select avg(f1) from tba1 where ts >= '2022-04-26 15:15:06' and ts <= '2022-04-26 15:15:10' interval(1s) fill(null_f); +if $rows != 5 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != NULL then + return -1 +endi +sql select avg(f1) from tba1 where ts >= '2022-04-26 15:16:00' and ts <= '2022-04-26 19:15:59' interval(1s) fill(value_f, 8.8); +if $rows != 14400 then + return -1 +endi +if $data00 != 8.800000000 then + return -1 +endi +sql select avg(f1) from tba1 where ts >= '2022-04-26 15:16:00' and ts <= '2022-04-26 19:15:59' interval(1s) fill(null_f); +if $rows != 14400 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +sql select interp(f1) from tba1 range('2022-04-26 15:15:00','2022-04-26 15:15:06') every(1s) fill(value_f, 8.8); +if $rows != 7 then + return -1 +endi +if $data00 != 8.800000000 then + return -1 +endi +if $data10 != 1.000000000 then + return -1 +endi +if $data20 != 2.000000000 then + return -1 +endi +if $data30 != 8.800000000 then + return -1 +endi +if $data40 != 4.000000000 then + return -1 +endi +if $data50 != 5.000000000 then + return -1 +endi +if $data60 != 8.800000000 then + return -1 +endi +sql select interp(f1) from tba1 range('2022-04-26 15:15:00','2022-04-26 15:15:06') every(1s) fill(value, 8.8); +if $rows != 7 then + return -1 +endi +if $data00 != 8.800000000 then + return -1 +endi +if $data10 != 1.000000000 then + return -1 +endi +if $data20 != 2.000000000 then + return -1 +endi +if $data30 != 8.800000000 then + return -1 +endi +if $data40 != 4.000000000 then + return -1 +endi +if $data50 != 5.000000000 then + return -1 +endi +if $data60 != 8.800000000 then + return -1 +endi +sql select interp(f1) from tba1 range('2022-04-26 15:15:00','2022-04-26 15:15:06') every(1s) fill(null); +if $rows != 7 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != 1.000000000 then + return -1 +endi +if $data20 != 2.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.000000000 then + return -1 +endi +if $data50 != 5.000000000 then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select interp(f1) from tba1 range('2022-04-26 15:15:00','2022-04-26 15:15:06') every(1s) fill(null_f); +if $rows != 7 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != 1.000000000 then + return -1 +endi +if $data20 != 2.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.000000000 then + return -1 +endi +if $data50 != 5.000000000 then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select interp(f1) from tba1 range('2022-04-26 15:15:06','2022-04-26 15:15:10') every(1s) fill(value, 8.8); +if $rows != 5 then + return -1 +endi +if $data00 != 8.800000000 then + return -1 +endi +if $data10 != 8.800000000 then + return -1 +endi +if $data20 != 8.800000000 then + return -1 +endi +if $data30 != 8.800000000 then + return -1 +endi +if $data40 != 8.800000000 then + return -1 +endi +sql select interp(f1) from tba1 range('2022-04-26 15:15:06','2022-04-26 15:15:10') every(1s) fill(value_f, 8.8); +if $rows != 5 then + return -1 +endi +if $data00 != 8.800000000 then + return -1 +endi +if $data10 != 8.800000000 then + return -1 +endi +if $data20 != 8.800000000 then + return -1 +endi +if $data30 != 8.800000000 then + return -1 +endi +if $data40 != 8.800000000 then + return -1 +endi +sql select interp(f1) from tba1 range('2022-04-26 15:15:06','2022-04-26 15:15:10') every(1s) fill(null); +if $rows != 5 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != NULL then + return -1 +endi +sql select interp(f1) from tba1 range('2022-04-26 15:15:06','2022-04-26 15:15:10') every(1s) fill(null_f); +if $rows != 5 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != NULL then + return -1 +endi +sql select interp(f1) from tba1 range('2022-04-26 15:16:00','2022-04-26 19:15:59') every(1s) fill(value_f, 8.8); +if $rows != 14400 then + return -1 +endi +if $data00 != 8.800000000 then + return -1 +endi +sql select interp(f1) from tba1 range('2022-04-26 15:16:00','2022-04-26 19:15:59') every(1s) fill(null_f); +if $rows != 14400 then + return -1 +endi +if $data00 != NULL then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/basic1.sim b/tests/script/tsim/stream/basic1.sim index 7bf10df637..c61c7667f8 100644 --- a/tests/script/tsim/stream/basic1.sim +++ b/tests/script/tsim/stream/basic1.sim @@ -834,4 +834,57 @@ endi print ====== test _wstart end +print insert into ts1 values(-1648791211000,1,2,3) + +sql create database test7 vgroups 1; +sql use test7; +sql create stable st(ts timestamp, a int, b int , c int) tags(ta int,tb int,tc int); +sql create table ts1 using st tags(1,1,1); +sql create stream streams7 trigger at_once into streamt7 as select _wstart, count(*) from ts1 interval(10s) ; + +sql insert into ts1 values(1648791211000,1,2,3); +sql_error insert into ts1 values(-1648791211000,1,2,3); + +loop18: + +sleep 200 +sql select * from streamt7; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 1 then + print =====rows=$rows + goto loop18 +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop18 +endi + +sql_error insert into ts1 values(-1648791211001,1,2,3) (1648791211001,1,2,3); + +sql select _wstart, count(*) from ts1 interval(10s) ; + +print $data00 $data01 +print $data10 $data11 + +loop19: + +sleep 200 +sql select * from streamt7; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 1 then + print =====rows=$rows + goto loop19 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/basic3.sim b/tests/script/tsim/stream/basic3.sim index e598919e34..2df33541b4 100644 --- a/tests/script/tsim/stream/basic3.sim +++ b/tests/script/tsim/stream/basic3.sim @@ -81,6 +81,15 @@ if $rows == 0 then return -1 endi +sleep 3000 + +sql drop stream if exists streamd1; +sql drop stream if exists streamd2; +sql drop stream if exists streamd3; +sql drop stream if exists streamd4; +sql drop stream if exists streamd5; +sql drop stream if exists streamd6; + sql create stream streamd10 into streamd10 as select _wstart, _wend, count(*), first(ca), last(cb) as c2 from t1 interval(10s); sql desc streamd10; @@ -100,15 +109,6 @@ if $rows == 0 then return -1 endi -sleep 3000 - -sql drop stream if exists streamd1; -sql drop stream if exists streamd2; -sql drop stream if exists streamd3; -sql drop stream if exists streamd4; -sql drop stream if exists streamd5; -sql drop stream if exists streamd6; - _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/drop_stream.sim b/tests/script/tsim/stream/drop_stream.sim index 1a474bd9ae..7ff9632a3e 100644 --- a/tests/script/tsim/stream/drop_stream.sim +++ b/tests/script/tsim/stream/drop_stream.sim @@ -55,62 +55,62 @@ sql create stream stb_asin_stream trigger at_once into output_asin_stb as select sql create stream ctb_asin_stream trigger at_once into output_asin_ctb as select ts, asin(c1), asin(c2), c3 from scalar_ct1; sql create stream tb_asin_stream trigger at_once into output_asin_tb as select ts, asin(c1), asin(c2), c3 from scalar_tb; sql create stream stb_atan_stream trigger at_once into output_atan_stb as select ts, atan(c1), atan(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_atan_stream trigger at_once into output_atan_ctb as select ts, atan(c1), atan(c2), c3 from scalar_ct1; -sql create stream tb_atan_stream trigger at_once into output_atan_tb as select ts, atan(c1), atan(c2), c3 from scalar_tb; -sql create stream stb_ceil_stream trigger at_once into output_ceil_stb as select ts, ceil(c1), ceil(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_ceil_stream trigger at_once into output_ceil_ctb as select ts, ceil(c1), ceil(c2), c3 from scalar_ct1; -sql create stream tb_ceil_stream trigger at_once into output_ceil_tb as select ts, ceil(c1), ceil(c2), c3 from scalar_tb; -sql create stream stb_cos_stream trigger at_once into output_cos_stb as select ts, cos(c1), cos(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_cos_stream trigger at_once into output_cos_ctb as select ts, cos(c1), cos(c2), c3 from scalar_ct1; -sql create stream tb_cos_stream trigger at_once into output_cos_tb as select ts, cos(c1), cos(c2), c3 from scalar_tb; -sql create stream stb_floor_stream trigger at_once into output_floor_stb as select ts, floor(c1), floor(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_floor_stream trigger at_once into output_floor_ctb as select ts, floor(c1), floor(c2), c3 from scalar_ct1; -sql create stream tb_floor_stream trigger at_once into output_floor_tb as select ts, floor(c1), floor(c2), c3 from scalar_tb; -sql create stream stb_log_stream trigger at_once into output_log_stb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_stb partition by tbname; -sql create stream ctb_log_stream trigger at_once into output_log_ctb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_ct1; -sql create stream tb_log_stream trigger at_once into output_log_tb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_tb; -sql create stream stb_pow_stream trigger at_once into output_pow_stb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_stb partition by tbname; -sql create stream ctb_pow_stream trigger at_once into output_pow_ctb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_ct1; -sql create stream tb_pow_stream trigger at_once into output_pow_tb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_tb; -sql create stream stb_round_stream trigger at_once into output_round_stb as select ts, round(c1), round(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_round_stream trigger at_once into output_round_ctb as select ts, round(c1), round(c2), c3 from scalar_ct1; -sql create stream tb_round_stream trigger at_once into output_round_tb as select ts, round(c1), round(c2), c3 from scalar_tb; -sql create stream stb_sin_stream trigger at_once into output_sin_stb as select ts, sin(c1), sin(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_sin_stream trigger at_once into output_sin_ctb as select ts, sin(c1), sin(c2), c3 from scalar_ct1; -sql create stream tb_sin_stream trigger at_once into output_sin_tb as select ts, sin(c1), sin(c2), c3 from scalar_tb; -sql create stream stb_sqrt_stream trigger at_once into output_sqrt_stb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_sqrt_stream trigger at_once into output_sqrt_ctb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_ct1; -sql create stream tb_sqrt_stream trigger at_once into output_sqrt_tb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_tb; -sql create stream stb_tan_stream trigger at_once into output_tan_stb as select ts, tan(c1), tan(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_tan_stream trigger at_once into output_tan_ctb as select ts, tan(c1), tan(c2), c3 from scalar_ct1; -sql create stream tb_tan_stream trigger at_once into output_tan_tb as select ts, tan(c1), tan(c2), c3 from scalar_tb; -sql create stream stb_char_length_stream into output_char_length_stb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_stb partition by tbname; -sql create stream ctb_char_length_stream into output_char_length_ctb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_ct1; -sql create stream tb_char_length_stream into output_char_length_tb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_tb; -sql create stream stb_concat_stream into output_concat_stb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_stb partition by tbname; -sql create stream ctb_concat_stream into output_concat_ctb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_ct1; -sql create stream tb_concat_stream into output_concat_tb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_tb; -sql create stream stb_concat_ws_stream into output_concat_ws_stb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_stb partition by tbname; -sql create stream ctb_concat_ws_stream into output_concat_ws_ctb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_ct1; -sql create stream tb_concat_ws_stream into output_concat_ws_tb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_tb; -sql create stream stb_length_stream into output_length_stb as select ts, length(c3), length(c4), length(c5) from scalar_stb partition by tbname; -sql create stream ctb_length_stream into output_length_ctb as select ts, length(c3), length(c4), length(c5) from scalar_ct1; -sql create stream tb_length_stream into output_length_tb as select ts, length(c3), length(c4), length(c5) from scalar_tb; -sql create stream stb_lower_stream into output_lower_stb as select ts, lower(c3), lower(c4), lower(c5) from scalar_stb partition by tbname; -sql create stream ctb_lower_stream into output_lower_ctb as select ts, lower(c3), lower(c4), lower(c5) from scalar_ct1; -sql create stream tb_lower_stream into output_lower_tb as select ts, lower(c3), lower(c4), lower(c5) from scalar_tb; -sql create stream stb_ltrim_stream into output_ltrim_stb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_stb partition by tbname; -sql create stream ctb_ltrim_stream into output_ltrim_ctb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_ct1; -sql create stream tb_ltrim_stream into output_ltrim_tb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_tb; -sql create stream stb_rtrim_stream into output_rtrim_stb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_stb partition by tbname; -sql create stream ctb_rtrim_stream into output_rtrim_ctb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_ct1; -sql create stream tb_rtrim_stream into output_rtrim_tb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_tb; -sql create stream stb_substr_stream into output_substr_stb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_stb partition by tbname; -sql create stream ctb_substr_stream into output_substr_ctb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_ct1; -sql create stream tb_substr_stream into output_substr_tb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_tb; -sql create stream stb_upper_stream into output_upper_stb as select ts, upper(c3), upper(c4), upper(c5) from scalar_stb partition by tbname; -sql create stream ctb_upper_stream into output_upper_ctb as select ts, upper(c3), upper(c4), upper(c5) from scalar_ct1; -sql create stream tb_upper_stream into output_upper_tb as select ts, upper(c3), upper(c4), upper(c5) from scalar_tb; +# sql create stream ctb_atan_stream trigger at_once into output_atan_ctb as select ts, atan(c1), atan(c2), c3 from scalar_ct1; +# sql create stream tb_atan_stream trigger at_once into output_atan_tb as select ts, atan(c1), atan(c2), c3 from scalar_tb; +# sql create stream stb_ceil_stream trigger at_once into output_ceil_stb as select ts, ceil(c1), ceil(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_ceil_stream trigger at_once into output_ceil_ctb as select ts, ceil(c1), ceil(c2), c3 from scalar_ct1; +# sql create stream tb_ceil_stream trigger at_once into output_ceil_tb as select ts, ceil(c1), ceil(c2), c3 from scalar_tb; +# sql create stream stb_cos_stream trigger at_once into output_cos_stb as select ts, cos(c1), cos(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_cos_stream trigger at_once into output_cos_ctb as select ts, cos(c1), cos(c2), c3 from scalar_ct1; +# sql create stream tb_cos_stream trigger at_once into output_cos_tb as select ts, cos(c1), cos(c2), c3 from scalar_tb; +# sql create stream stb_floor_stream trigger at_once into output_floor_stb as select ts, floor(c1), floor(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_floor_stream trigger at_once into output_floor_ctb as select ts, floor(c1), floor(c2), c3 from scalar_ct1; +# sql create stream tb_floor_stream trigger at_once into output_floor_tb as select ts, floor(c1), floor(c2), c3 from scalar_tb; +# sql create stream stb_log_stream trigger at_once into output_log_stb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_log_stream trigger at_once into output_log_ctb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_ct1; +# sql create stream tb_log_stream trigger at_once into output_log_tb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_tb; +# sql create stream stb_pow_stream trigger at_once into output_pow_stb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_pow_stream trigger at_once into output_pow_ctb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_ct1; +# sql create stream tb_pow_stream trigger at_once into output_pow_tb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_tb; +# sql create stream stb_round_stream trigger at_once into output_round_stb as select ts, round(c1), round(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_round_stream trigger at_once into output_round_ctb as select ts, round(c1), round(c2), c3 from scalar_ct1; +# sql create stream tb_round_stream trigger at_once into output_round_tb as select ts, round(c1), round(c2), c3 from scalar_tb; +# sql create stream stb_sin_stream trigger at_once into output_sin_stb as select ts, sin(c1), sin(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_sin_stream trigger at_once into output_sin_ctb as select ts, sin(c1), sin(c2), c3 from scalar_ct1; +# sql create stream tb_sin_stream trigger at_once into output_sin_tb as select ts, sin(c1), sin(c2), c3 from scalar_tb; +# sql create stream stb_sqrt_stream trigger at_once into output_sqrt_stb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_sqrt_stream trigger at_once into output_sqrt_ctb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_ct1; +# sql create stream tb_sqrt_stream trigger at_once into output_sqrt_tb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_tb; +# sql create stream stb_tan_stream trigger at_once into output_tan_stb as select ts, tan(c1), tan(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_tan_stream trigger at_once into output_tan_ctb as select ts, tan(c1), tan(c2), c3 from scalar_ct1; +# sql create stream tb_tan_stream trigger at_once into output_tan_tb as select ts, tan(c1), tan(c2), c3 from scalar_tb; +# sql create stream stb_char_length_stream into output_char_length_stb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_stb partition by tbname; +# sql create stream ctb_char_length_stream into output_char_length_ctb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_ct1; +# sql create stream tb_char_length_stream into output_char_length_tb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_tb; +# sql create stream stb_concat_stream into output_concat_stb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_stb partition by tbname; +# sql create stream ctb_concat_stream into output_concat_ctb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_ct1; +# sql create stream tb_concat_stream into output_concat_tb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_tb; +# sql create stream stb_concat_ws_stream into output_concat_ws_stb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_stb partition by tbname; +# sql create stream ctb_concat_ws_stream into output_concat_ws_ctb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_ct1; +# sql create stream tb_concat_ws_stream into output_concat_ws_tb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_tb; +# sql create stream stb_length_stream into output_length_stb as select ts, length(c3), length(c4), length(c5) from scalar_stb partition by tbname; +# sql create stream ctb_length_stream into output_length_ctb as select ts, length(c3), length(c4), length(c5) from scalar_ct1; +# sql create stream tb_length_stream into output_length_tb as select ts, length(c3), length(c4), length(c5) from scalar_tb; +# sql create stream stb_lower_stream into output_lower_stb as select ts, lower(c3), lower(c4), lower(c5) from scalar_stb partition by tbname; +# sql create stream ctb_lower_stream into output_lower_ctb as select ts, lower(c3), lower(c4), lower(c5) from scalar_ct1; +# sql create stream tb_lower_stream into output_lower_tb as select ts, lower(c3), lower(c4), lower(c5) from scalar_tb; +# sql create stream stb_ltrim_stream into output_ltrim_stb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_stb partition by tbname; +# sql create stream ctb_ltrim_stream into output_ltrim_ctb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_ct1; +# sql create stream tb_ltrim_stream into output_ltrim_tb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_tb; +# sql create stream stb_rtrim_stream into output_rtrim_stb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_stb partition by tbname; +# sql create stream ctb_rtrim_stream into output_rtrim_ctb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_ct1; +# sql create stream tb_rtrim_stream into output_rtrim_tb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_tb; +# sql create stream stb_substr_stream into output_substr_stb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_stb partition by tbname; +# sql create stream ctb_substr_stream into output_substr_ctb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_ct1; +# sql create stream tb_substr_stream into output_substr_tb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_tb; +# sql create stream stb_upper_stream into output_upper_stb as select ts, upper(c3), upper(c4), upper(c5) from scalar_stb partition by tbname; +# sql create stream ctb_upper_stream into output_upper_ctb as select ts, upper(c3), upper(c4), upper(c5) from scalar_ct1; +# sql create stream tb_upper_stream into output_upper_tb as select ts, upper(c3), upper(c4), upper(c5) from scalar_tb; sql insert into scalar_ct1 values (1656668180503, 100, 100.1, "beijing", "taos", "Taos"); sql insert into scalar_ct1 values (1656668180503+1s, -50, -50.1, "tianjin", "taosdata", "Taosdata"); sql insert into scalar_ct1 values (1656668180503+2s, 0, Null, "hebei", "TDengine", Null); @@ -146,62 +146,62 @@ sql create stream stb_asin_stream trigger at_once into output_asin_stb as select sql create stream ctb_asin_stream trigger at_once into output_asin_ctb as select ts, asin(c1), asin(c2), c3 from scalar_ct1; sql create stream tb_asin_stream trigger at_once into output_asin_tb as select ts, asin(c1), asin(c2), c3 from scalar_tb; sql create stream stb_atan_stream trigger at_once into output_atan_stb as select ts, atan(c1), atan(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_atan_stream trigger at_once into output_atan_ctb as select ts, atan(c1), atan(c2), c3 from scalar_ct1; -sql create stream tb_atan_stream trigger at_once into output_atan_tb as select ts, atan(c1), atan(c2), c3 from scalar_tb; -sql create stream stb_ceil_stream trigger at_once into output_ceil_stb as select ts, ceil(c1), ceil(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_ceil_stream trigger at_once into output_ceil_ctb as select ts, ceil(c1), ceil(c2), c3 from scalar_ct1; -sql create stream tb_ceil_stream trigger at_once into output_ceil_tb as select ts, ceil(c1), ceil(c2), c3 from scalar_tb; -sql create stream stb_cos_stream trigger at_once into output_cos_stb as select ts, cos(c1), cos(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_cos_stream trigger at_once into output_cos_ctb as select ts, cos(c1), cos(c2), c3 from scalar_ct1; -sql create stream tb_cos_stream trigger at_once into output_cos_tb as select ts, cos(c1), cos(c2), c3 from scalar_tb; -sql create stream stb_floor_stream trigger at_once into output_floor_stb as select ts, floor(c1), floor(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_floor_stream trigger at_once into output_floor_ctb as select ts, floor(c1), floor(c2), c3 from scalar_ct1; -sql create stream tb_floor_stream trigger at_once into output_floor_tb as select ts, floor(c1), floor(c2), c3 from scalar_tb; -sql create stream stb_log_stream trigger at_once into output_log_stb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_stb partition by tbname; -sql create stream ctb_log_stream trigger at_once into output_log_ctb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_ct1; -sql create stream tb_log_stream trigger at_once into output_log_tb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_tb; -sql create stream stb_pow_stream trigger at_once into output_pow_stb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_stb partition by tbname; -sql create stream ctb_pow_stream trigger at_once into output_pow_ctb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_ct1; -sql create stream tb_pow_stream trigger at_once into output_pow_tb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_tb; -sql create stream stb_round_stream trigger at_once into output_round_stb as select ts, round(c1), round(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_round_stream trigger at_once into output_round_ctb as select ts, round(c1), round(c2), c3 from scalar_ct1; -sql create stream tb_round_stream trigger at_once into output_round_tb as select ts, round(c1), round(c2), c3 from scalar_tb; -sql create stream stb_sin_stream trigger at_once into output_sin_stb as select ts, sin(c1), sin(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_sin_stream trigger at_once into output_sin_ctb as select ts, sin(c1), sin(c2), c3 from scalar_ct1; -sql create stream tb_sin_stream trigger at_once into output_sin_tb as select ts, sin(c1), sin(c2), c3 from scalar_tb; -sql create stream stb_sqrt_stream trigger at_once into output_sqrt_stb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_sqrt_stream trigger at_once into output_sqrt_ctb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_ct1; -sql create stream tb_sqrt_stream trigger at_once into output_sqrt_tb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_tb; -sql create stream stb_tan_stream trigger at_once into output_tan_stb as select ts, tan(c1), tan(c2), c3 from scalar_stb partition by tbname; -sql create stream ctb_tan_stream trigger at_once into output_tan_ctb as select ts, tan(c1), tan(c2), c3 from scalar_ct1; -sql create stream tb_tan_stream trigger at_once into output_tan_tb as select ts, tan(c1), tan(c2), c3 from scalar_tb; -sql create stream stb_char_length_stream into output_char_length_stb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_stb partition by tbname; -sql create stream ctb_char_length_stream into output_char_length_ctb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_ct1; -sql create stream tb_char_length_stream into output_char_length_tb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_tb; -sql create stream stb_concat_stream into output_concat_stb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_stb partition by tbname; -sql create stream ctb_concat_stream into output_concat_ctb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_ct1; -sql create stream tb_concat_stream into output_concat_tb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_tb; -sql create stream stb_concat_ws_stream into output_concat_ws_stb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_stb partition by tbname; -sql create stream ctb_concat_ws_stream into output_concat_ws_ctb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_ct1; -sql create stream tb_concat_ws_stream into output_concat_ws_tb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_tb; -sql create stream stb_length_stream into output_length_stb as select ts, length(c3), length(c4), length(c5) from scalar_stb partition by tbname; -sql create stream ctb_length_stream into output_length_ctb as select ts, length(c3), length(c4), length(c5) from scalar_ct1; -sql create stream tb_length_stream into output_length_tb as select ts, length(c3), length(c4), length(c5) from scalar_tb; -sql create stream stb_lower_stream into output_lower_stb as select ts, lower(c3), lower(c4), lower(c5) from scalar_stb partition by tbname; -sql create stream ctb_lower_stream into output_lower_ctb as select ts, lower(c3), lower(c4), lower(c5) from scalar_ct1; -sql create stream tb_lower_stream into output_lower_tb as select ts, lower(c3), lower(c4), lower(c5) from scalar_tb; -sql create stream stb_ltrim_stream into output_ltrim_stb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_stb partition by tbname; -sql create stream ctb_ltrim_stream into output_ltrim_ctb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_ct1; -sql create stream tb_ltrim_stream into output_ltrim_tb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_tb; -sql create stream stb_rtrim_stream into output_rtrim_stb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_stb partition by tbname; -sql create stream ctb_rtrim_stream into output_rtrim_ctb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_ct1; -sql create stream tb_rtrim_stream into output_rtrim_tb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_tb; -sql create stream stb_substr_stream into output_substr_stb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_stb partition by tbname; -sql create stream ctb_substr_stream into output_substr_ctb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_ct1; -sql create stream tb_substr_stream into output_substr_tb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_tb; -sql create stream stb_upper_stream into output_upper_stb as select ts, upper(c3), upper(c4), upper(c5) from scalar_stb partition by tbname; -sql create stream ctb_upper_stream into output_upper_ctb as select ts, upper(c3), upper(c4), upper(c5) from scalar_ct1; -sql create stream tb_upper_stream into output_upper_tb as select ts, upper(c3), upper(c4), upper(c5) from scalar_tb; +# sql create stream ctb_atan_stream trigger at_once into output_atan_ctb as select ts, atan(c1), atan(c2), c3 from scalar_ct1; +# sql create stream tb_atan_stream trigger at_once into output_atan_tb as select ts, atan(c1), atan(c2), c3 from scalar_tb; +# sql create stream stb_ceil_stream trigger at_once into output_ceil_stb as select ts, ceil(c1), ceil(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_ceil_stream trigger at_once into output_ceil_ctb as select ts, ceil(c1), ceil(c2), c3 from scalar_ct1; +# sql create stream tb_ceil_stream trigger at_once into output_ceil_tb as select ts, ceil(c1), ceil(c2), c3 from scalar_tb; +# sql create stream stb_cos_stream trigger at_once into output_cos_stb as select ts, cos(c1), cos(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_cos_stream trigger at_once into output_cos_ctb as select ts, cos(c1), cos(c2), c3 from scalar_ct1; +# sql create stream tb_cos_stream trigger at_once into output_cos_tb as select ts, cos(c1), cos(c2), c3 from scalar_tb; +# sql create stream stb_floor_stream trigger at_once into output_floor_stb as select ts, floor(c1), floor(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_floor_stream trigger at_once into output_floor_ctb as select ts, floor(c1), floor(c2), c3 from scalar_ct1; +# sql create stream tb_floor_stream trigger at_once into output_floor_tb as select ts, floor(c1), floor(c2), c3 from scalar_tb; +# sql create stream stb_log_stream trigger at_once into output_log_stb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_log_stream trigger at_once into output_log_ctb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_ct1; +# sql create stream tb_log_stream trigger at_once into output_log_tb as select ts, log(c1, 2), log(c2, 2), c3 from scalar_tb; +# sql create stream stb_pow_stream trigger at_once into output_pow_stb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_pow_stream trigger at_once into output_pow_ctb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_ct1; +# sql create stream tb_pow_stream trigger at_once into output_pow_tb as select ts, pow(c1, 2), pow(c2, 2), c3 from scalar_tb; +# sql create stream stb_round_stream trigger at_once into output_round_stb as select ts, round(c1), round(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_round_stream trigger at_once into output_round_ctb as select ts, round(c1), round(c2), c3 from scalar_ct1; +# sql create stream tb_round_stream trigger at_once into output_round_tb as select ts, round(c1), round(c2), c3 from scalar_tb; +# sql create stream stb_sin_stream trigger at_once into output_sin_stb as select ts, sin(c1), sin(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_sin_stream trigger at_once into output_sin_ctb as select ts, sin(c1), sin(c2), c3 from scalar_ct1; +# sql create stream tb_sin_stream trigger at_once into output_sin_tb as select ts, sin(c1), sin(c2), c3 from scalar_tb; +# sql create stream stb_sqrt_stream trigger at_once into output_sqrt_stb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_sqrt_stream trigger at_once into output_sqrt_ctb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_ct1; +# sql create stream tb_sqrt_stream trigger at_once into output_sqrt_tb as select ts, sqrt(c1), sqrt(c2), c3 from scalar_tb; +# sql create stream stb_tan_stream trigger at_once into output_tan_stb as select ts, tan(c1), tan(c2), c3 from scalar_stb partition by tbname; +# sql create stream ctb_tan_stream trigger at_once into output_tan_ctb as select ts, tan(c1), tan(c2), c3 from scalar_ct1; +# sql create stream tb_tan_stream trigger at_once into output_tan_tb as select ts, tan(c1), tan(c2), c3 from scalar_tb; +# sql create stream stb_char_length_stream into output_char_length_stb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_stb partition by tbname; +# sql create stream ctb_char_length_stream into output_char_length_ctb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_ct1; +# sql create stream tb_char_length_stream into output_char_length_tb as select ts, char_length(c3), char_length(c4), char_length(c5) from scalar_tb; +# sql create stream stb_concat_stream into output_concat_stb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_stb partition by tbname; +# sql create stream ctb_concat_stream into output_concat_ctb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_ct1; +# sql create stream tb_concat_stream into output_concat_tb as select ts, concat(c3, c4), concat(c3, c5), concat(c4, c5), concat(c3, c4, c5) from scalar_tb; +# sql create stream stb_concat_ws_stream into output_concat_ws_stb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_stb partition by tbname; +# sql create stream ctb_concat_ws_stream into output_concat_ws_ctb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_ct1; +# sql create stream tb_concat_ws_stream into output_concat_ws_tb as select ts, concat_ws("aND", c3, c4), concat_ws("and", c3, c5), concat_ws("And", c4, c5), concat_ws("AND", c3, c4, c5) from scalar_tb; +# sql create stream stb_length_stream into output_length_stb as select ts, length(c3), length(c4), length(c5) from scalar_stb partition by tbname; +# sql create stream ctb_length_stream into output_length_ctb as select ts, length(c3), length(c4), length(c5) from scalar_ct1; +# sql create stream tb_length_stream into output_length_tb as select ts, length(c3), length(c4), length(c5) from scalar_tb; +# sql create stream stb_lower_stream into output_lower_stb as select ts, lower(c3), lower(c4), lower(c5) from scalar_stb partition by tbname; +# sql create stream ctb_lower_stream into output_lower_ctb as select ts, lower(c3), lower(c4), lower(c5) from scalar_ct1; +# sql create stream tb_lower_stream into output_lower_tb as select ts, lower(c3), lower(c4), lower(c5) from scalar_tb; +# sql create stream stb_ltrim_stream into output_ltrim_stb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_stb partition by tbname; +# sql create stream ctb_ltrim_stream into output_ltrim_ctb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_ct1; +# sql create stream tb_ltrim_stream into output_ltrim_tb as select ts, ltrim(c3), ltrim(c4), ltrim(c5) from scalar_tb; +# sql create stream stb_rtrim_stream into output_rtrim_stb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_stb partition by tbname; +# sql create stream ctb_rtrim_stream into output_rtrim_ctb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_ct1; +# sql create stream tb_rtrim_stream into output_rtrim_tb as select ts, rtrim(c3), rtrim(c4), rtrim(c5) from scalar_tb; +# sql create stream stb_substr_stream into output_substr_stb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_stb partition by tbname; +# sql create stream ctb_substr_stream into output_substr_ctb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_ct1; +# sql create stream tb_substr_stream into output_substr_tb as select ts, substr(c3, 2), substr(c3, 2, 2), substr(c4, 5, 1), substr(c5, 3, 4) from scalar_tb; +# sql create stream stb_upper_stream into output_upper_stb as select ts, upper(c3), upper(c4), upper(c5) from scalar_stb partition by tbname; +# sql create stream ctb_upper_stream into output_upper_ctb as select ts, upper(c3), upper(c4), upper(c5) from scalar_ct1; +# sql create stream tb_upper_stream into output_upper_tb as select ts, upper(c3), upper(c4), upper(c5) from scalar_tb; sql insert into scalar_ct1 values (1656668180503, 100, 100.1, "beijing", "taos", "Taos"); sql insert into scalar_ct1 values (1656668180503+1s, -50, -50.1, "tianjin", "taosdata", "Taosdata"); sql insert into scalar_ct1 values (1656668180503+2s, 0, Null, "hebei", "TDengine", Null); @@ -273,4 +273,4 @@ print ========== step7 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 \ No newline at end of file +system sh/exec.sh -n dnode4 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/fillIntervalValue.sim b/tests/script/tsim/stream/fillIntervalValue.sim index fe4ec759eb..2cd419397f 100644 --- a/tests/script/tsim/stream/fillIntervalValue.sim +++ b/tests/script/tsim/stream/fillIntervalValue.sim @@ -14,6 +14,7 @@ sql use test; sql create table t1(ts timestamp, a int, b int , c int, d double, s varchar(20));; sql create stream streams1 trigger at_once into streamt as select _wstart ts, count(*) c1 from t1 where ts > 1648791210000 and ts < 1648791413000 interval(10s) fill(value, 100); +sql create stream streams1a trigger at_once into streamta as select _wstart ts, count(*) c1 from t1 where ts > 1648791210000 and ts < 1648791413000 interval(10s) fill(value_f, 100); sql insert into t1 values(1648791213000,1,2,3,1.0,'aaa'); sleep 100 sql insert into t1 values(1648791233000,1,2,3,1.0,'aaa'); @@ -77,6 +78,69 @@ if $data71 != 1 then goto loop0 endi + +print "force fill vaule" + +$loop_count = 0 + +loop0a: +sleep 200 +sql select * from streamta order by ts; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 8 then + print =====rows=$rows + goto loop0a +endi + +if $data01 != 1 then + print =====data01=$data01 + goto loop0a +endi + +if $data11 != 1 then + print =====data11=$data11 + goto loop0a +endi + +if $data21 != 1 then + print =====data21=$data21 + goto loop0a +endi + +if $data31 != 100 then + print =====data31=$data31 + goto loop0a +endi + +if $data41 != 1 then + print =====data41=$data41 + goto loop0a +endi + +if $data51 != 100 then + print =====data01=$data01 + goto loop0a +endi + +if $data61 != 100 then + print =====data61=$data61 + goto loop0a +endi + +if $data71 != 1 then + print =====data71=$data71 + goto loop0a +endi + + + + + sql drop stream if exists streams2; sql drop database if exists test2; sql create database test2 vgroups 1; @@ -408,6 +472,7 @@ sql create table t1 using st tags(1,1,1); sql create table t2 using st tags(2,2,2); sql create stream streams4 trigger at_once into streamt4 as select _wstart ts, count(*) c1, concat(tbname, 'aaa') as pname, timezone() from st where ts > 1648791000000 and ts < 1648793000000 partition by tbname interval(10s) fill(NULL); +sql create stream streams4a trigger at_once into streamt4a as select _wstart ts, count(*) c1, concat(tbname, 'aaa') as pname, timezone() from st where ts > 1648791000000 and ts < 1648793000000 partition by tbname interval(10s) fill(NULL_F); sql insert into t1 values(1648791213000,1,2,3,1.0,'aaa'); sql insert into t1 values(1648791233000,1,2,3,1.0,'aaa'); sql insert into t1 values(1648791273000,1,2,3,1.0,'aaa'); @@ -512,32 +577,104 @@ if $data[12][3] == NULL then goto loop4 endi +print "force fill null" +$loop_count = 0 +loop4a: +sleep 200 +sql select * from streamt4a order by pname, ts; +print ===> $data[0][0] , $data[0][1] , $data[0][2] , $data[0][3] +print ===> $data[1][0] , $data[1][1] , $data[1][2] , $data[1][3] +print ===> $data[2][0] , $data[2][1] , $data[2][2] , $data[2][3] +print ===> $data[3][0] , $data[3][1] , $data[3][2] , $data[3][3] +print ===> $data[4][0] , $data[4][1] , $data[4][2] , $data[4][3] +print ===> $data[5][0] , $data[5][1] , $data[5][2] , $data[5][3] +print ===> $data[6][0] , $data[6][1] , $data[6][2] , $data[6][3] +print ===> $data[7][0] , $data[7][1] , $data[7][2] , $data[7][3] +print ===> $data[8][0] , $data[8][1] , $data[8][2] , $data[8][3] +print ===> $data[9][0] , $data[9][1] , $data[9][2] , $data[9][3] +print ===> $data[10][0] , $data[10][1] , $data[10][2] , $data[10][3] +print ===> $data[11][0] , $data[11][1] , $data[11][2] , $data[11][3] +print ===> $data[12][0] , $data[12][1] , $data[12][2] , $data[12][3] +print ===> $data[13][0] , $data[13][1] , $data[13][2] , $data[13][3] +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi +if $rows != 14 then + print =====rows=$rows + goto loop4a +endi +if $data11 != NULL then + print =====data11=$data11 + goto loop4a +endi +if $data12 != t1aaa then + print =====data12=$data12 + goto loop4a +endi +if $data13 == NULL then + print =====data13=$data13 + goto loop4a +endi +if $data32 != t1aaa then + print =====data32=$data32 + goto loop4a +endi +if $data42 != t1aaa then + print =====data42=$data42 + goto loop4a +endi +if $data52 != t1aaa then + print =====data52=$data52 + goto loop4a +endi +if $data81 != NULL then + print =====data81=$data81 + goto loop4a +endi +if $data82 != t2aaa then + print =====data82=$data82 + goto loop4a +endi +if $data83 == NULL then + print =====data83=$data83 + goto loop4a +endi +if $data[10][2] != t2aaa then + print =====data[10][2]=$data[10][2] + goto loop4a +endi +if $data[11][2] != t2aaa then + print =====data[11][2]=$data[11][2] + goto loop4a +endi +if $data[12][2] != t2aaa then + print =====data[12][2]=$data[12][2] + goto loop4a +endi - - - - - - - +if $data[12][3] == NULL then + print =====data[12][3]=$data[12][3] + goto loop4a +endi @@ -584,4 +721,4 @@ print ============loop_all=$loop_all system sh/stop_dnodes.sh -#goto looptest \ No newline at end of file +#goto looptest diff --git a/tests/script/tsim/stream/ignoreCheckUpdate.sim b/tests/script/tsim/stream/ignoreCheckUpdate.sim new file mode 100644 index 0000000000..7f99c534c8 --- /dev/null +++ b/tests/script/tsim/stream/ignoreCheckUpdate.sim @@ -0,0 +1,285 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step 1 start + +sql drop stream if exists streams0; +sql drop database if exists test; +sql create database test vgroups 1; +sql use test; +sql create table t1(ts timestamp, a int, b int , c int); + +print create stream streams0 trigger at_once ignore update 1 into streamt as select _wstart c1, count(*) c2, max(b) c3 from t1 interval(10s); + +sql create stream streams0 trigger at_once ignore update 1 into streamt as select _wstart c1, count(*) c2, max(b) c3 from t1 interval(10s); + +sql insert into t1 values(1648791213000,1,1,1); +sql insert into t1 values(1648791213000,2,2,2); + +$loop_count = 0 + +loop0: +sleep 300 +sql select * from streamt order by 1,2,3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop0 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop0 +endi + + +sql insert into t1 values(1648791213000,3,3,3); + +$loop_count = 0 + +loop1: +sleep 300 +sql select * from streamt order by 1,2,3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 3 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 3 then + print =====data02=$data02 + goto loop1 +endi + +print step 1 end + +print step 2 start + +sql drop stream if exists streams1; +sql drop database if exists test1; +sql create database test1 vgroups 1; +sql use test1; +sql create table t1(ts timestamp, a int, b int , c int); + +print create stream streams1 trigger at_once ignore update 1 into streamt1 as select _wstart c1, count(*) c2, max(b) c3 from t1 session(ts, 10s); + +sql create stream streams1 trigger at_once ignore update 1 into streamt1 as select _wstart c1, count(*) c2, max(b) c3 from t1 session(ts, 10s); + +sql insert into t1 values(1648791213000,1,1,1); +sql insert into t1 values(1648791213000,2,2,2); + +$loop_count = 0 + +loop2: +sleep 300 +sql select * from streamt1 order by 1,2,3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop2 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop2 +endi + + +sql insert into t1 values(1648791213000,3,3,3); + +$loop_count = 0 + +loop3: + +sleep 300 +sql select * from streamt1 order by 1,2,3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 3 then + print =====data01=$data01 + goto loop3 +endi + +if $data02 != 3 then + print =====data02=$data02 + goto loop3 +endi + +print step 2 end + +print step 3 start + +sql drop stream if exists streams2; +sql drop database if exists test2; +sql create database test2 vgroups 1; +sql use test2; +sql create table t1(ts timestamp, a int, b int , c int); + +print create stream streams2 trigger at_once ignore update 1 into streamt2 as select _wstart c1, count(*) c2, max(b) c3 from t1 state_window(c); + +sql create stream streams2 trigger at_once ignore update 1 into streamt2 as select _wstart c1, count(*) c2, max(b) c3 from t1 state_window(c); + +sql insert into t1 values(1648791213000,1,1,1); +sql insert into t1 values(1648791213000,2,2,1); + +$loop_count = 0 + +loop2: +sleep 300 +sql select * from streamt2 order by 1,2,3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 2 then + print =====data01=$data01 + goto loop2 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop2 +endi + + +sql insert into t1 values(1648791213000,3,3,1); + +$loop_count = 0 + +loop3: + +sleep 300 +sql select * from streamt2 order by 1,2,3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 3 then + print =====data01=$data01 + goto loop3 +endi + +if $data02 != 3 then + print =====data02=$data02 + goto loop3 +endi + +print step 3 end + +print step 4 start + +sql drop stream if exists streams3; +sql drop database if exists test3; +sql create database test3 vgroups 4; +sql use test3; +sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); + +print create stream streams3 trigger at_once ignore update 1 into streamt3 as select _wstart c1, count(*) c2, max(b) c3 from st interval(10s); + +sql create stream streams3 trigger at_once ignore update 1 into streamt3 as select _wstart c1, count(*) c2, max(b) c3 from st interval(10s); + +sql insert into t1 values(1648791213000,1,1,1); +sql insert into t1 values(1648791213000,2,2,2); + +sql insert into t2 values(1648791213000,1,1,1); +sql insert into t2 values(1648791213000,2,2,2); + +$loop_count = 0 + +loop0: +sleep 300 +sql select * from streamt3 order by 1,2,3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 4 then + print =====data01=$data01 + goto loop0 +endi + +if $data02 != 2 then + print =====data02=$data02 + goto loop0 +endi + + +sql insert into t1 values(1648791213000,3,3,3); + +$loop_count = 0 + +loop1: +sleep 300 +sql select * from streamt3 order by 1,2,3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 5 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 3 then + print =====data02=$data02 + goto loop1 +endi + +sql insert into t2 values(1648791213000,4,4,4); + +$loop_count = 0 + +loop1: +sleep 300 +sql select * from streamt3 order by 1,2,3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $data01 != 6 then + print =====data01=$data01 + goto loop1 +endi + +if $data02 != 4 then + print =====data02=$data02 + goto loop1 +endi + +print step 4 end + +system sh/stop_dnodes.sh diff --git a/tests/script/tsim/stream/ignoreExpiredData.sim b/tests/script/tsim/stream/ignoreExpiredData.sim index 03f574bc52..b143b7977f 100644 --- a/tests/script/tsim/stream/ignoreExpiredData.sim +++ b/tests/script/tsim/stream/ignoreExpiredData.sim @@ -52,6 +52,7 @@ sql insert into t1 values(1648791213000,1,2,3,1.0); sql insert into t1 values(1648791223001,1,2,3,1.1); sql insert into t1 values(1648791233002,2,2,3,2.1); sql insert into t1 values(1648791243003,2,2,3,3.1); +sleep 300 sql insert into t1 values(1648791200000,4,2,3,4.1); $loop_count = 0 @@ -115,6 +116,7 @@ sql create stream stream_t1 trigger at_once IGNORE EXPIRED 1 into streamtST1 as sql create stream stream_t2 trigger at_once IGNORE EXPIRED 1 into streamtST2 as select _wstart, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st session(ts, 10s) ; sql insert into ts1 values(1648791211000,1,2,3); sql insert into ts1 values(1648791222001,2,2,3); +sleep 300 sql insert into ts2 values(1648791211000,1,2,3); sql insert into ts2 values(1648791222001,2,2,3); diff --git a/tests/script/tsim/stream/state0.sim b/tests/script/tsim/stream/state0.sim index 7c922658c9..07abdc0040 100644 --- a/tests/script/tsim/stream/state0.sim +++ b/tests/script/tsim/stream/state0.sim @@ -16,6 +16,9 @@ print $data00 $data01 $data02 sql use test; sql create table t1(ts timestamp, a int, b int , c int, d double, id int); + +print create stream streams1 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); + sql create stream streams1 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); sql insert into t1 values(1648791213000,1,2,3,1.0,1); @@ -79,86 +82,88 @@ endi if $data03 != 1 then print ======$data03 - return -1 + goto loop1 endi if $data04 != 1 then print ======$data04 - return -1 + goto loop1 endi if $data05 != 3 then print ======$data05 - return -1 + goto loop1 endi if $data06 != 5 then print ======$data06 - return -1 + goto loop1 endi # row 1 if $data11 != 1 then print ======$data11 - return -1 + goto loop1 endi if $data12 != 1 then print ======$data12 - return -1 + goto loop1 endi if $data13 != 2 then print ======$data13 - return -1 + goto loop1 endi if $data14 != 2 then print ======$data14 - return -1 + goto loop1 endi if $data15 != 3 then print ======$data15 - return -1 + goto loop1 endi if $data16 != 4 then print ======$data16 - return -1 + goto loop1 endi # row 2 if $data21 != 1 then print ======$data21 - return -1 + goto loop1 endi if $data22 != 1 then print ======$data22 - return -1 + goto loop1 endi if $data23 != 1 then print ======$data23 - return -1 + goto loop1 endi if $data24 != 1 then print ======$data24 - return -1 + goto loop1 endi if $data25 != 3 then print ======$data25 - return -1 + goto loop1 endi if $data26 != 6 then print ======$data26 - return -1 + goto loop1 endi +print loop1 end + sql insert into t1 values(1648791213011,1,2,3,1.0,7); $loop_count = 0 @@ -174,33 +179,31 @@ endi if $data21 != 2 then print =====data21=$data21 goto loop2 - return -1 endi if $data22 != 2 then print =====data22=$data22 goto loop2 - return -1 endi if $data23 != 2 then print ======$data23 - return -1 + goto loop2 endi if $data24 != 1 then print ======$data24 - return -1 + goto loop2 endi if $data25 != 3 then print ======$data25 - return -1 + goto loop2 endi if $data26 != 7 then print ======$data26 - return -1 + goto loop2 endi sql insert into t1 values(1648791213011,1,2,3,1.0,8); @@ -238,99 +241,93 @@ endi if $data21 != 1 then print =====data21=$data21 goto loop3 - return -1 endi if $data22 != 1 then print =====data22=$data22 goto loop3 - return -1 endi if $data23 != 10 then print ======$data23 - return -1 + goto loop3 endi if $data24 != 10 then print ======$data24 - return -1 + goto loop3 endi if $data25 != 10 then print ======$data25 - return -1 + goto loop3 endi if $data26 != 12 then print ======$data26 - return -1 + goto loop3 endi # row 3 if $data31 != 1 then print =====data31=$data31 goto loop3 - return -1 endi if $data32 != 1 then print =====data32=$data32 goto loop3 - return -1 endi if $data33 != 3 then print ======$data33 - return -1 + goto loop3 endi if $data34 != 3 then print ======$data34 - return -1 + goto loop3 endi if $data35 != 3 then print ======$data35 - return -1 + goto loop3 endi if $data36 != 10 then print ======$data36 - return -1 + goto loop3 endi # row 4 if $data41 != 1 then print =====data41=$data41 goto loop3 - return -1 endi if $data42 != 1 then print =====data42=$data42 goto loop3 - return -1 endi if $data43 != 1 then print ======$data43 - return -1 + goto loop3 endi if $data44 != 1 then print ======$data44 - return -1 + goto loop3 endi if $data45 != 3 then print ======$data45 - return -1 + goto loop3 endi if $data46 != 11 then print ======$data46 - return -1 + goto loop3 endi sql insert into t1 values(1648791213030,3,12,12,12.0,13); @@ -360,95 +357,93 @@ endi if $data02 != 2 then print ======$data02 - return -1 + goto loop4 endi if $data03 != 6 then print ======$data03 - return -1 + goto loop4 endi if $data04 != 3 then print ======$data04 - return -1 + goto loop4 endi if $data05 != 3 then print ======$data05 - return -1 + goto loop4 endi if $data06 != 15 then print ======$data06 - return -1 + goto loop4 endi # row 1 if $data11 != 1 then print =====data11=$data11 goto loop4 - return -1 endi if $data12 != 1 then print =====data12=$data12 goto loop4 - return -1 endi if $data13 != 15 then print ======$data13 - return -1 + goto loop4 endi if $data14 != 15 then print ======$data14 - return -1 + goto loop4 endi if $data15 != 15 then print ======$data15 - return -1 + goto loop4 endi if $data16 != 16 then print ======$data16 - return -1 + goto loop4 endi # row 2 if $data21 != 1 then print =====data21=$data21 goto loop4 - return -1 endi if $data22 != 1 then print =====data22=$data22 goto loop4 - return -1 endi if $data23 != 1 then print ======$data23 - return -1 + goto loop4 endi if $data24 != 1 then print ======$data24 - return -1 + goto loop4 endi if $data25 != 13 then print ======$data25 - return -1 + goto loop4 endi if $data26 != 14 then print ======$data26 - return -1 + goto loop4 endi +print loop4 end + sql create database test1 vgroups 1; sql select * from information_schema.ins_databases; @@ -457,6 +452,9 @@ print $data00 $data01 $data02 sql use test1; sql create table t1(ts timestamp, a int, b int , c int, d double, id int); + +print create stream streams2 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); + sql create stream streams2 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); sql insert into t1 values(1648791212000,2,2,3,1.0,1); @@ -502,6 +500,9 @@ sql create database test3 vgroups 1; sql use test3; sql create table t1(ts timestamp, a int, b int , c int, d double, id int); + +print create stream streams3 trigger at_once into streamt3 as select _wstart, count(*) c1, sum(b) c3 from t1 state_window(a); + sql create stream streams3 trigger at_once into streamt3 as select _wstart, count(*) c1, sum(b) c3 from t1 state_window(a); sql insert into t1 values(1648791212000,1,2,3,1.0,1); sql insert into t1 values(1648791213000,2,2,3,1.0,1); @@ -543,7 +544,6 @@ if $rows != 10 then goto loop6 endi - sql drop stream if exists streams4; sql drop database if exists test4; sql drop stable if exists streamt4; @@ -552,7 +552,10 @@ sql use test4; sql create table st (ts timestamp, c1 tinyint, c2 smallint) tags (t1 tinyint) ; sql create table t1 using st tags (-81) ; sql create table t2 using st tags (-81) ; -sql create stream if not exists streams4 trigger window_close into streamt4 as select _wstart AS start, min(c1),count(c1) from t1 state_window(c1); + +print create stream if not exists streams4 trigger window_close into streamt4 as select _wstart AS startts, min(c1),count(c1) from t1 state_window(c1); + +sql create stream if not exists streams4 trigger window_close into streamt4 as select _wstart AS startts, min(c1),count(c1) from t1 state_window(c1); sql insert into t1 (ts, c1) values (1668073288209, 11); sql insert into t1 (ts, c1) values (1668073288210, 11); @@ -567,7 +570,7 @@ loop7: sleep 200 -sql select * from streamt4 order by start; +sql select * from streamt4 order by startts; $loop_count = $loop_count + 1 if $loop_count == 20 then @@ -606,7 +609,7 @@ loop8: sleep 200 -sql select * from streamt4 order by start; +sql select * from streamt4 order by startts; $loop_count = $loop_count + 1 if $loop_count == 20 then @@ -636,11 +639,11 @@ sql insert into t1 (ts, c1) values (1668073288225, 65); sql insert into t1 (ts, c1) values (1668073288226, 65); $loop_count = 0 -loop8: +loop81: sleep 200 -sql select * from streamt4 order by start; +sql select * from streamt4 order by startts; $loop_count = $loop_count + 1 if $loop_count == 20 then @@ -649,27 +652,27 @@ endi if $rows != 2 then print =====rows=$rows - goto loop8 + goto loop81 endi if $data01 != 11 then print =====data01=$data01 - goto loop8 + goto loop81 endi if $data02 != 5 then print =====data02=$data02 - goto loop8 + goto loop81 endi if $data11 != 29 then print =====data11=$data11 - goto loop8 + goto loop81 endi if $data12 != 1 then print =====data12=$data12 - goto loop8 + goto loop81 endi sql insert into t1 (ts, c1) values (1668073288224, 64); @@ -679,7 +682,7 @@ loop9: sleep 200 -sql select * from streamt4 order by start; +sql select * from streamt4 order by startts; $loop_count = $loop_count + 1 if $loop_count == 20 then @@ -738,6 +741,9 @@ sql use test5; sql create table tb (ts timestamp, a int); sql insert into tb values (now + 1m , 1 ); sql create table b (c timestamp, d int, e int , f int, g double); + +print create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3 from tb state_window(a); + sql create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3 from tb state_window(a); sql insert into b values(1648791213000,NULL,NULL,NULL,NULL); sql select * from streamt order by c1, c2, c3; @@ -792,4 +798,6 @@ if $data00 != 2 then goto loop10 endi +print state0 end + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/triggerInterval0.sim b/tests/script/tsim/stream/triggerInterval0.sim index 7353f026bb..b522dcf035 100644 --- a/tests/script/tsim/stream/triggerInterval0.sim +++ b/tests/script/tsim/stream/triggerInterval0.sim @@ -29,69 +29,119 @@ sql insert into t1 values(1648791223001,2,2,3,1.1); sql insert into t1 values(1648791223002,2,2,3,1.1); sql insert into t1 values(1648791223003,2,2,3,1.1); sql insert into t1 values(1648791223001,2,2,3,1.1); + +print step 0 + +$loop_count = 0 + +loop0: sleep 300 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + sql select * from streamt; + if $rows != 1 then print ======$rows - return -1 + goto loop0 endi if $data01 != 1 then print ======$data01 - return -1 + goto loop0 endi sql insert into t1 values(1648791233001,2,2,3,1.1); + +print step 1 + +$loop_count = 0 + +loop1: sleep 300 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + sql select * from streamt; if $rows != 2 then print ======$rows - return -1 + goto loop1 endi if $data01 != 1 then print ======$data01 - return -1 + goto loop1 endi if $data11 != 3 then print ======$data11 - return -1 + goto loop1 endi sql insert into t1 values(1648791223004,2,2,3,1.1); sql insert into t1 values(1648791223004,2,2,3,1.1); sql insert into t1 values(1648791223005,2,2,3,1.1); + +print step 2 + +$loop_count = 0 + +loop2: sleep 300 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + sql select * from streamt; if $rows != 2 then print ======$rows - return -1 + goto loop2 endi + if $data01 != 1 then print ======$data01 - return -1 + goto loop2 endi if $data11 != 5 then print ======$data11 - return -1 + goto loop2 endi sql insert into t1 values(1648791233002,3,2,3,2.1); sql insert into t1 values(1648791213002,4,2,3,3.1) sql insert into t1 values(1648791213002,4,2,3,4.1); + +print step 3 + +$loop_count = 0 + +loop3: sleep 300 -sql select * from streamt; -if $rows != 2 then - print ======$rows - return -1 -endi -if $data01 != 2 then - print ======$data01 - return -1 -endi -if $data11 != 5 then - print ======$data11 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then return -1 endi +sql select * from streamt; +if $rows != 2 then + print ======$rows + goto loop3 +endi +if $data01 != 2 then + print ======$data01 + goto loop3 +endi +if $data11 != 5 then + print ======$data11 + goto loop3 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/system-test/0-others/balance_vgroups_r1.py b/tests/system-test/0-others/balance_vgroups_r1.py new file mode 100644 index 0000000000..ae504cbab1 --- /dev/null +++ b/tests/system-test/0-others/balance_vgroups_r1.py @@ -0,0 +1,99 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + + +from util import constant +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +from util.sqlset import * +from util.cluster import * +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.dnode_num=len(cluster.dnodes) + self.dbname = 'db_test' + self.setsql = TDSetSql() + self.stbname = f'{self.dbname}.stb' + self.rowNum = 5 + self.tbnum = 10 + self.ts = 1537146000000 + self.binary_str = 'taosdata' + self.nchar_str = '涛思数据' + 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': 'binary(20)', + 'col13': 'nchar(20)' + } + self.replica = [1,3] + + def insert_data(self,column_dict,tbname,row_num): + insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str) + for i in range(row_num): + insert_list = [] + self.setsql.insert_values(column_dict,i,insert_sql,insert_list,self.ts) + def prepare_data(self,dbname,stbname,column_dict,tbnum,rowNum,replica): + tag_dict = { + 't0':'int' + } + tag_values = [ + f'1' + ] + tdSql.execute(f"create database if not exists {dbname} vgroups 1 replica {replica} ") + tdSql.execute(f'use {dbname}') + tdSql.execute(self.setsql.set_create_stable_sql(stbname,column_dict,tag_dict)) + for i in range(tbnum): + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags({tag_values[0]})") + self.insert_data(self.column_dict,f'{stbname}_{i}',rowNum) + def redistribute_vgroups(self,replica,stbname,tbnum,rownum): + tdSql.query('show vgroups') + vnode_id = tdSql.queryResult[0][0] + if replica == 1: + for dnode_id in range(1,self.dnode_num+1) : + tdSql.execute(f'redistribute vgroup {vnode_id} dnode {dnode_id}') + tdSql.query(f'select count(*) from {stbname}') + tdSql.checkEqual(tdSql.queryResult[0][0],tbnum*rownum) + elif replica == 3: + for dnode_id in range(1,self.dnode_num-1): + tdSql.execute(f'redistribute vgroup {vnode_id} dnode {dnode_id} dnode {dnode_id+1} dnode {dnode_id+2}') + tdSql.query(f'select count(*) from {stbname}') + tdSql.checkEqual(tdSql.queryResult[0][0],tbnum*rownum) + + def run(self): + for replica in self.replica: + self.prepare_data(self.dbname,self.stbname,self.column_dict,self.tbnum,self.rowNum,replica) + self.redistribute_vgroups(replica,self.stbname,self.tbnum,self.rowNum) + tdSql.execute(f'drop database {self.dbname}') + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/1-insert/insert_drop.py b/tests/system-test/1-insert/insert_drop.py index 029d013d5b..930c65d90e 100644 --- a/tests/system-test/1-insert/insert_drop.py +++ b/tests/system-test/1-insert/insert_drop.py @@ -31,6 +31,10 @@ class TDTestCase: tdSql.execute('create database if not exists test;') tdSql.execute('create table test.stb (ts timestamp, c11 int, c12 float ) TAGS(t11 int, t12 int );') tdSql.execute('create table test.tb using test.stb TAGS (1, 1);') + + # double comma insert check error + tdSql.error("insert into test.tb(ts, c11) values(now,,100)") + sql_list = list() for i in range(5): sql = f'insert into test.tb values (now-{i}m, {i}, {i});' diff --git a/tests/system-test/2-query/case_when.py b/tests/system-test/2-query/case_when.py index cfe0399553..eebbcc3fa3 100755 --- a/tests/system-test/2-query/case_when.py +++ b/tests/system-test/2-query/case_when.py @@ -111,6 +111,17 @@ class TDTestCase: sql2 = "select (case when sum(q_smallint)=0 then null else sum(q_smallint) end) from %s.stable_1_1 limit 100;" %database self.constant_check(database,sql1,sql2,0) + #TD-20257 + sql1 = "select tbname,first(ts),q_int,q_smallint,q_bigint,case when q_int <0 then 1 else 0 end from %s.stable_1 where tbname = 'stable_1_1' and ts < now partition by tbname state_window(case when q_int <0 then 1 else 0 end);" %database + sql2 = "select tbname,first(ts),q_int,q_smallint,q_bigint,case when q_int <0 then 1 else 0 end from %s.stable_1_1 where ts < now partition by tbname state_window(case when q_int <0 then 1 else 0 end);" %database + self.constant_check(database,sql1,sql2,0) + self.constant_check(database,sql1,sql2,1) + self.constant_check(database,sql1,sql2,2) + self.constant_check(database,sql1,sql2,3) + self.constant_check(database,sql1,sql2,4) + self.constant_check(database,sql1,sql2,5) + + #TD-20260 sql1 = "select _wstart,avg(q_int),min(q_smallint) from %s.stable_1 where tbname = 'stable_1_1' and ts < now state_window(case when q_smallint <0 then 1 else 0 end);" %database sql2 = "select _wstart,avg(q_int),min(q_smallint) from %s.stable_1_1 where ts < now state_window(case when q_smallint <0 then 1 else 0 end);" %database self.constant_check(database,sql1,sql2,0) diff --git a/tests/system-test/2-query/max_min_data.py b/tests/system-test/2-query/max_min_data.py new file mode 100755 index 0000000000..e3dff5da78 --- /dev/null +++ b/tests/system-test/2-query/max_min_data.py @@ -0,0 +1,159 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import random +import os +import time +import taos +import subprocess +from faker import Faker +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +from util.dnodes import tdDnodes +from util.dnodes import * + +class TDTestCase: + updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 131 ,"querySmaOptimize":1} + + def init(self, conn, logSql, replicaVar): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.testcasePath = os.path.split(__file__)[0] + self.testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + self.db = "max_min" + + def dropandcreateDB_random(self,database,n): + ts = 1630000000000 + num_random = 5 + fake = Faker('zh_CN') + tdSql.execute('''drop database if exists %s ;''' %database) + tdSql.execute('''create database %s keep 36500 ;'''%(database)) + tdSql.execute('''use %s;'''%database) + + tdSql.execute('''create stable %s.stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ + tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);'''%database) + + for i in range(num_random): + tdSql.execute('''create table %s.stable_1_%d using %s.stable_1 tags('stable_1_%d', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(database,i,database,i,fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + + # insert data + for i in range(num_random): + for j in range(n): + tdSql.execute('''insert into %s.stable_1_%d (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts)\ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d) ;''' + % (database,i,ts + i*1000 + j, fake.random_int(min=-2147483647, max=2147483647, step=1), + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i)) + + tdSql.query("select count(*) from %s.stable_1;" %database) + tdSql.checkData(0,0,num_random*n) + tdSql.query("select count(*) from %s.stable_1_1;"%database) + tdSql.checkData(0,0,n) + + + def TD_22219_max(self,database): + + sql3 = "select count(*) from (select max(q_int) from %s.stable_1 group by tbname); ;" %database + tdSql.query(sql3) + sql_value = tdSql.getData(0,0) + self.value_check(sql_value,5) + + sql1 = "select max(q_int) from %s.stable_1_1 ;" %database + sql2 = "select max(q_int) from %s.stable_1 where tbname = 'stable_1_1' ;" %database + self.constant_check(database,sql1,sql2,0) + + sql3 = "select count(*) from (select max(q_int) from %s.stable_1 group by tbname); ;" %database + tdSql.query(sql3) + sql_value = tdSql.getData(0,0) + self.value_check(sql_value,5) + + def TD_22219_min(self,database): + + sql3 = "select count(*) from (select min(q_int) from %s.stable_1 group by tbname); ;" %database + tdSql.query(sql3) + sql_value = tdSql.getData(0,0) + self.value_check(sql_value,5) + + sql1 = "select min(q_int) from %s.stable_1_1 ;" %database + sql2 = "select min(q_int) from %s.stable_1 where tbname = 'stable_1_1' ;" %database + self.constant_check(database,sql1,sql2,0) + + sql3 = "select count(*) from (select min(q_int) from %s.stable_1 group by tbname); ;" %database + tdSql.query(sql3) + sql_value = tdSql.getData(0,0) + self.value_check(sql_value,5) + + def constant_check(self,database,sql1,sql2,column): + #column =0 代表0列, column = n代表n-1列 + tdLog.info("\n=============sql1:(%s)___sql2:(%s) ====================\n" %(sql1,sql2)) + + tdSql.query(sql1) + sql1_value = tdSql.getData(0,column) + tdSql.query(sql2) + sql2_value = tdSql.getData(0,column) + self.value_check(sql1_value,sql2_value) + + tdSql.execute(" flush database %s;" %database) + + time.sleep(3) + + tdSql.query(sql1) + sql1_flush_value = tdSql.getData(0,column) + tdSql.query(sql2) + sql2_flush_value = tdSql.getData(0,column) + self.value_check(sql1_flush_value,sql2_flush_value) + + self.value_check(sql1_value,sql1_flush_value) + self.value_check(sql2_value,sql2_flush_value) + + def value_check(self,base_value,check_value): + if base_value==check_value: + tdLog.info(f"checkEqual success, base_value={base_value},check_value={check_value}") + else : + tdLog.exit(f"checkEqual error, base_value=={base_value},check_value={check_value}") + + def run(self): + + startTime = time.time() + + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + self.dropandcreateDB_random("%s" %self.db, 2000) + + self.TD_22219_max("%s" %self.db) + + self.dropandcreateDB_random("%s" %self.db, 2000) + + self.TD_22219_min("%s" %self.db) + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmqUpdate-1ctb.py b/tests/system-test/7-tmq/tmqUpdate-1ctb.py index b974e4a41a..db2ec3285d 100644 --- a/tests/system-test/7-tmq/tmqUpdate-1ctb.py +++ b/tests/system-test/7-tmq/tmqUpdate-1ctb.py @@ -206,7 +206,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 1 if self.snapshot == 0: - expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2)) + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1/2)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1)) diff --git a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py index d5df88cf43..daffff44c1 100644 --- a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py +++ b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py @@ -213,9 +213,9 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 1 if self.snapshot == 0: - expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2*2 + 1/2*1/2)) + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1/2) * (1/2*3)) elif self.snapshot == 1: - expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (2 + 1/2*1/2)) + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/2)) topicList = topicFromStb1 ifcheckdata = 1 diff --git a/tools/shell/src/shellWebsocket.c b/tools/shell/src/shellWebsocket.c index add3ccc51f..b93cc02964 100644 --- a/tools/shell/src/shellWebsocket.c +++ b/tools/shell/src/shellWebsocket.c @@ -218,8 +218,13 @@ void shellRunSingleCommandWebsocketImp(char *command) { res = ws_query_timeout(shell.ws_conn, command, shell.args.timeout); int code = ws_errno(res); if (code != 0 && !shell.stop_query) { - et = taosGetTimestampUs(); - fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6); + // websocket interface masked off first bit from standard error number. + if (TSDB_CODE_PAR_SYNTAX_ERROR == (code|0x80000000)) { + et = taosGetTimestampUs(); + fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6); + ws_free_result(res); + return; + } if (code == TSDB_CODE_WS_SEND_TIMEOUT || code == TSDB_CODE_WS_RECV_TIMEOUT) { fprintf(stderr, "Hint: use -t to increase the timeout in seconds\n"); } else if (code == TSDB_CODE_WS_INTERNAL_ERRO || code == TSDB_CODE_WS_CLOSED) {